到现在为止,我正在使用该命令mvn clean compile hibernate3:hbm2java
启动我的程序.有没有办法将这三个目标合并为一个,例如mvn run
或mvn myapp:run
?
我正在编写一个Maven插件(Mojo),它需要在运行之前执行一组标准的其他插件执行.
有没有一种机制可以在我的插件中声明所有目标,所以我不必依赖用户在POM中定义所有目标?
在我目前的项目中,我们使用其他插件参数所需的一些插件,如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)
是否有一种干净的方法(没有脚本)?
注意:这个线程是关于编写自定义Mojo,而不是使用插件.
我为Maven 维护了一个测试插件.不幸的是,差不多一年了,我已经让这个特殊的未知世界挥之不去,我真的想知道如何处理它,以便其用户可以更简单的配置.
假设我们的插件中有两个目标:
prepare
(阶段:生成源)do
(阶段:编译)我想配置do
Mojo以要求prepare
在构建的早期阶段执行.但是,描述符文档中没有任何内容表明我可以.
用户可能不关心或理解prepare
目标点,因此我不想强迫他们在POM中指定它.当然,我可以直接执行Mojo do
,但之后prepare
目标将在比预期更晚的阶段运行.
(我查看了自定义生命周期,但这似乎使得每个已经prepare
在POM中具有目标的人都会在运行时执行两次do
.)
我在寻找一种方式,运行MVN原型后执行其他命令(例如Perl脚本):产生于我自定义原型自动.
这可能吗?
我正在编写一个原型,它创建了OSGi包,我希望将它作为模块集成到父项目中.生成捆绑包后,我希望将其组织到父目录结构中,然后自动操作poms和其他配置文件.
这已经在1之前的maven论坛上被问过,但没有给出答案.