Wil*_*ill 113 maven-2 maven-plugin
我想让Maven目标触发java类的执行.我正试图通过以下方式迁移Makefile
:
neotest:
mvn exec:java -Dexec.mainClass="org.dhappy.test.NeoTraverse"
Run Code Online (Sandbox Code Playgroud)
我想mvn neotest
生产make neotest
目前的产品.
无论是Exec插件的文件,也不是Maven的Ant任务的网页有任何形式的简单例子.
目前,我在:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions><execution>
<goals><goal>java</goal></goals>
</execution></executions>
<configuration>
<mainClass>org.dhappy.test.NeoTraverse</mainClass>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
不过,我不知道如何从命令行触发插件.
Pas*_*ent 139
使用为exec-maven-plugin定义的全局配置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<mainClass>org.dhappy.test.NeoTraverse</mainClass>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
调用mvn exec:java
命令行上将调用其被配置成执行所述类插件org.dhappy.test.NeoTraverse
.
因此,要从命令行触发插件,只需运行:
mvn exec:java
Run Code Online (Sandbox Code Playgroud)
现在,如果你想要执行exec:java
目标作为标准构建的一部分,你需要的目标绑定到特定阶段的的默认的生命周期.要执行此操作,请声明phase
要在execution
元素中绑定目标的目标:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>my-execution</id>
<phase>package</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.dhappy.test.NeoTraverse</mainClass>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
在这个例子中,您的类将在该package
阶段执行.这只是一个例子,根据您的需求进行调整.也适用于插件版本1.1.
Wil*_*ill 24
为了执行多个程序,我还需要一个profiles
部分:
<profiles>
<profile>
<id>traverse</id>
<activation>
<property>
<name>traverse</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<argument>org.dhappy.test.NeoTraverse</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
然后,这可执行为:
mvn exec:exec -Dtraverse
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
148326 次 |
最近记录: |