Sun*_*Wei 39 directory maven-2
我正在使用maven-exec-plugin来生成Thrift的java源代码.它调用外部Thrift编译器并使用-o指定输出目录"target/generated-sources/thrift".
问题既不是maven-exec-plugin也不是Thrift编译器自动创建输出目录,我必须手动创建它.是否有适当/可移植的方式使用在需要时创建丢失的目录?我不想在pom.xml中定义mkdir命令,因为我的项目需要与系统无关.
dog*_*ane 30
而不是exec插件,使用antrun
插件首先创建目录,然后调用thrift编译器.
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<tasks>
<mkdir dir="target/generated-sources/thrift"/>
<exec executable="${thrift.executable}">
<arg value="--gen"/>
<arg value="java:beans"/>
<arg value="-o"/>
<arg value="target/generated-sources/thrift"/>
<arg value="src/main/resources/MyThriftMessages.thrift"/>
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
您可能还想看看maven-thrift-plugin.
Den*_*hev 18
您可以定义一个ant任务来完成这项工作.将plugin
声明放入项目的pom.xml中.这将使您的项目系统无关:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>createThriftDir</id>
<phase>process-resources</phase>
<configuration>
<tasks>
<delete dir="${thrift.dir}"/>
<mkdir dir="${thrift.dir}"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
小智 8
如果您想在项目中的某处准备这样的文件夹结构,然后复制到您想要的位置,请使用 maven-resource 插件来做到这一点:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-folder</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<resources>
<resource>
<filtering>false</filtering>
<directory>${project.basedir}/src/main/resources/folders</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
45555 次 |
最近记录: |