Java 无法执行目标 org.apache.maven.plugins:maven-antrun-plugin

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32964143/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 14:05:24  来源:igfitidea点击:

Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin

javaeclipsemaven

提问by user3616287

While setting the development environment for Adhar(UIDAI) which is documented here

在为此处记录的 Adhar(UIDAI) 设置开发环境时

I am getting following error

我收到以下错误

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:
run (generate-sources) on project uidai-auth-proto-model: An Ant BuildException

As per the documentation after the navigating to the source code downloaded from here herewe need to run mvn eclipse:eclipsein command line. After successful build we can import those projects into eclipse.

按照上述导航从这里下载源代码后的文件在这里,我们需要运行mvn eclipse:eclipse在命令行。成功构建后,我们可以将这些项目导入到 eclipse 中。

Success Build message enter image description here

成功构建消息 在此处输入图片说明

But I was unable to build due to some reason enter image description here

但由于某种原因我无法构建 在此处输入图片说明

My maven,ant and java config enter image description here

我的 maven、ant 和 java 配置 在此处输入图片说明

UID Protobuf Model files

UID Protobuf 模型文件

Git Repository of UID-Protobuf is here

UID-Protobuf 的 Git 存储库在这里

回答by pingw33n

You need to have protoc(Protobuf compiler) in the PATHor in the project root dir. Make sure you use the same protocversion as the protobuf-javaartifact declared in POM.

您需要在项目根目录或项目根目录中有protoc(Protobuf 编译器)PATH。确保您使用与POM 中声明protocprotobuf-java工件相同的版本。

回答by kumarrahul9292

The problem is maven-antrun-plugin is not getting build(executed). In uidai-auth-proto-model/pom.xml include plugins between pluginManagement tag as follows:

问题是 maven-antrun-plugin 没有得到构建(执行)。在 uidai-auth-proto-model/pom.xml 中包含 pluginManagement 标签之间的插件如下:

<pluginManagement>
  <plugins>
    <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <version>1.3</version>
      <executions>
        <execution>
          <id>generate-sources</id>
          <phase>generate-sources</phase>
          <goals>
            <goal>run</goal>
          </goals>
          <configuration>
            <tasks>
              <exec executable="protoc">
                <arg value="--java_out=src/main/java" />
                <arg value="--proto_path=src/main/proto/auth/" />
                <arg value="src/main/proto/auth/auth.proto" />
              </exec>
              <exec executable="protoc">
                <arg value="--java_out=src/main/java" />
                <arg value="--proto_path=src/main/proto/bfd/" />
                <arg value="src/main/proto/bfd/bfd.proto" />
              </exec>
            </tasks>
            <sourceRoot>src/main/java</sourceRoot>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <version>2.2-beta-5</version>
    </plugin>
    <plugin>
      <artifactId>maven-dependency-plugin</artifactId>
      <version>2.8</version>
    </plugin>
    <plugin>
      <artifactId>maven-release-plugin</artifactId>
      <version>2.3.2</version>
    </plugin>
    <plugin>
      <artifactId>maven-jar-plugin</artifactId>
      <version>2.2</version>
      <configuration>
        <archive>
          <manifest>
            <addClasspath>true</addClasspath>
          </manifest>
        </archive>
        <includes>
          <include>packaged/**/*</include>
          <include>in/**/*</include>
        </includes>
      </configuration>
    </plugin>
    <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.0.2</version>
      <configuration>
        <source>1.6</source>
        <target>1.6</target>
      </configuration>
    </plugin>
  </plugins>
</pluginManagement>

回答by kumarrahul9292

Also, do same in uidai-auth-xsd-model/pom.xml as follow:

此外,在 uidai-auth-xsd-model/pom.xml 中执行相同操作,如下所示:

<pluginManagement>
  <plugins>
    <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <version>1.3</version>
    </plugin>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <version>2.2-beta-5</version>
    </plugin>
    <plugin>
      <artifactId>maven-dependency-plugin</artifactId>
      <version>2.8</version>
    </plugin>
    <plugin>
      <artifactId>maven-release-plugin</artifactId>
      <version>2.3.2</version>
    </plugin>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>jaxb2-maven-plugin</artifactId>
      <executions>
        <execution>
          <goals>
            <goal>xjc</goal>
          </goals>
          <configuration>
            <outputDirectory>C:\Users\[email protected]\Downloads\uidai-auth-client-1.6-src\uidai-auth-xsd-model/src/main/java</outputDirectory>
            <extension>true</extension>
          </configuration>
        </execution>
      </executions>
      <configuration>
        <outputDirectory>C:\Users\[email protected]\Downloads\uidai-auth-client-1.6-src\uidai-auth-xsd-model/src/main/java</outputDirectory>
        <extension>true</extension>
      </configuration>
    </plugin>
    <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
        <source>1.6</source>
        <target>1.6</target>
      </configuration>
    </plugin>
  </plugins>
</pluginManagement>