【问题标题】:Why is Maven skipping over my custom generate-sources executions?为什么 Maven 跳过我的自定义生成源执行?
【发布时间】:2013-09-14 07:49:56
【问题描述】:

我使用maven-antrun-plugin 添加了.thrift -> .java 的执行作为生成源阶段的一部分。但是当我输入mvn generate-sources 时,Maven 会直接跳过这个执行。

知道为什么会这样做吗?

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>

【问题讨论】:

  • 你们pom有什么样的包装?

标签: maven compilation


【解决方案1】:

啊,我错过了目标。正确的 sn-p 是:

<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>

【讨论】:

    猜你喜欢
    • 2013-03-14
    • 1970-01-01
    • 2014-04-06
    • 2013-02-26
    • 2019-06-05
    • 1970-01-01
    • 2022-01-17
    • 2018-10-07
    • 2011-01-10
    相关资源
    最近更新 更多