noi*_*rre 8 maven-2 maven-plugin
在我目前的项目中,我们使用其他插件参数所需的一些插件,如properties-maven-plugin或buildnumber-plugin.
<?xml version="1.0"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>mygroup</groupId>
<artifactId>myartifact</artifactId>
<packaging>pom</packaging>
<version>v0</version>
<name>myProject</name>
<properties>
<env>dev</env>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<configuration>
<files>
<file>${basedir}/configurations/${env}.properties</file>
</files>
</configuration>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.wakaleo.schemaspy</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>1.0</version>
<configuration>
<databaseType>mysql</databaseType>
<database>${database.schema}</database>
<host>${database.host}</host>
<user>${database.user}</user>
<password>${database.pwd}</password>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
问题在于,当您直接执行插件目标时,不会执行初始化阶段(或验证)上绑定的目标.因此要生成模式间谍,我们需要输入:
$> mvn org.codehaus.mojo:properties-maven-plugin:read-project-properties schemaspy:schemaspy
Run Code Online (Sandbox Code Playgroud)
我们想告诉你需要为每个maven命令执行属性插件和buildNumber插件,这样我们就可以输入:
$> mvn schemaspy:schemaspy
Run Code Online (Sandbox Code Playgroud)
是否有一种干净的方法(没有脚本)?
最简单的方法是将schemaspy
目标绑定到生命周期阶段(特别是因为你已经为其他两个插件做了这个),所以你可以简单地运行类似mvn包的东西,并在适当的阶段执行所有三个插件.
如果你想让schmespy插件只在某些情况下执行,把它放在一个配置文件中,然后运行mvn package -P schemaspy来激活它.实现此目的的配置如下所示:
<profiles>
<profile>
<id>schemaspy</id>
<plugin>
<groupId>com.wakaleo.schemaspy</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>schemaspy</goal>
</goals>
</execution>
</executions>
<configuration>
<databaseType>mysql</databaseType>
<database>${database.schema}</database>
<host>${database.host}</host>
<user>${database.user}</user>
<password>${database.pwd}</password>
</configuration>
</plugin>
</profile>
</profile>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3179 次 |
最近记录: |