Maven Antrun插件继承

时间:2018-02-08 15:01:36

标签: maven maven-antrun-plugin

我有一个maven多模块项目结构。 我想使用maven-antrun-plugin通过在父项目的pom中声明它来构建子项目的jar。

这是我的父母:

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

1 个答案:

答案 0 :(得分:0)