Edw*_*edy 5 java maven-plugin maven
我目前正在开发一个项目,该项目使用一个工具,该工具采用以下示例IDL文件并从中生成大约5个Java类.
struct Example {
int x;
int y;
};
有没有办法让Maven使用我们用来在构建时自动创建这些Java类的命令行工具?
以下是使用Exec Maven插件的示例.
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<!-- this execution happens just after compiling the java classes, and builds the native code. -->
<id>build-native</id>
<phase>process-classes</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>src/main/c/Makefile</executable>
<workingDirectory>src/main/c</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
您可以使用maven-antrun-plugin
插件运行任意Ant 任务甚至任何命令行程序:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<target>
<exec executable="ls">
<arg value="-l"/>
<arg value="-a"/>
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
通过此配置,您的命令行程序将在编译之前执行,因此生成的 Java 源代码将可供其余代码使用。
归档时间: |
|
查看次数: |
804 次 |
最近记录: |