在我当前的项目中,我们使用其他插件参数所需的一些插件,例如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>
问题是,当您直接执行插件目标时,绑定在初始化阶段(或验证)的目标不会被执行。因此,要生成模式间谍,我们需要输入:
$> mvn org.codehaus.mojo:properties-maven-plugin:read-project-properties schemaspy:schemaspy
我们想要告诉每个 Maven 命令都需要执行 properties 插件和 buildNumber 插件,这样我们就可以输入:
$> mvn schemaspy:schemaspy
有没有一种干净的方法来做到这一点(无需脚本)?
最简单的方法是绑定schemaspy
目标是生命周期阶段(特别是当您已经为其他两个插件完成此操作时),因此您可以简单地运行类似的东西MVN包并使所有三个插件在适当的阶段执行。
如果您希望 schmespy 插件仅在某些情况下执行,请将其放入配置文件中,然后运行mvn 包 -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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)