本文介绍了为什么Maven跳过我的自定义生成源执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我添加了执行 .thrift - > .java
作为generate-sources阶段的一部分,使用 maven-antrun-plugin
。但是当我输入 mvn generate-sources
时,Maven会跳过这个执行。
I added executions for .thrift -> .java
as part of the generate-sources phase, using maven-antrun-plugin
. But when I enter mvn generate-sources
, Maven skips right over this execution.
这个?
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<tasks>
<exec executable="${thrift.executable}">
<arg value="--gen" />
<arg value="java:beans" />
<arg value="-o" />
<arg value="src/main/java/com/... " />
<arg value="src/main/thrift/... .thrift" />
</exec>
</tasks>
</configuration>
</execution>
<execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
<tasks>
<delete>
<fileset dir="src/main/java/com/... " includes="... .java" />
</delete>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
推荐答案
正确的代码段是:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<tasks>
<exec executable="${thrift.executable}">
<arg value="--gen" />
<arg value="java:beans" />
<arg value="-o" />
<arg value="src/main/java/com/... " />
<arg value="src/main/thrift/... .thrift" />
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
<tasks>
<delete>
<fileset dir="src/main/java/com/... " includes="... .java" />
</delete>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
这篇关于为什么Maven跳过我的自定义生成源执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!