我有一个maven多模块项目结构。我想使用maven-antrun-plugin在父项目的pom中声明它来构建子项目的jar。
这是我的父母-pom:
<groupId>com.package.abc</groupId>
<artifactId>parent-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>concat-build-classpath</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<jar destfile="${project.build.directory}/${project.build.finalName}.jar"
basedir="src/main">
<manifest>
<attribute name="Main-Class" value="com.package.abc.Application" />
</manifest>
</jar>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>default-jar</id>
<phase>never</phase>
<configuration>
<finalName>unwanted</finalName>
<classifier>unwanted</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build></project>下面是我的子项目的pom:
<modelVersion>4.0.0</modelVersion>
<artifactId>sample-project</artifactId>
<parent>
<groupId>com.package.abc</groupId>
<artifactId>parent-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<build>
<finalName>sample-project</finalName>
</build></project>当我构建子项目时,它显示了如下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-install) on project sample-project: The packaging for this project did not assign a file to the build artifact -> [Help 1]发布于 2020-08-18 02:22:50
您可以在<plugin>元素中将<inherited>设置为false:
...
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.5</version>
<inherited>false</inherited>
...更多信息请访问:
https://stackoverflow.com/questions/48688501
复制相似问题