无法获得校验和maven插件以自动执行

时间:2015-08-13 17:01:27

标签: maven pom.xml parent-pom

我正在使用Maven Checksum Plugin,并且在战争构建完成后我遇到问题。以下是我在superpom中的配置:

<build>
    ...
    <pluginManagement>
        <plugins>
            <plugin>
                ...
            </plugin>
            <plugin>
                <groupId>net.ju-n.maven.plugins</groupId>
                <artifactId>checksum-maven-plugin</artifactId>
                <version>1.3-SNAPSHOT</version>
                <executions>
                    <execution>
                        <id>generate-artifact-checksum</id>
                        <phase>package</phase>
                        <goals>
                            <goal>files</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <fileSets>
                        <fileSet>
                            <directory>${project.build.directory}/artifacts</directory>
                        </fileSet>
                    </fileSets>
                </configuration>
            </plugin>
            <plugin>
                ...
            </plugin>
        </plugins>
    </pluginManagement>
</build>

当我运行mvn package时,插件未被执行。不是那里有错误,但是没有执行。在构建过程中没有打印出任何内容。处理战争,构建声明成功,插件不会执行。

我已尝试删除<phase>个实体并运行mvn verify因为根据插件上的文档,checksum:files目标会自动绑定到verify相。仍然没有执行。

但是,如果我运行,该插件可以正常工作:

$ mvn checksum:files

我的配置中缺少什么?

1 个答案:

答案 0 :(得分:1)

插件未执行,因为它是在pluginManagement的{​​{1}}部分下声明的。

您应该将pom的配置移到checksum-maven-plugin之外,如下所示:

pluginManagement

有关<build> <plugins> <plugin> ... </plugin> <plugin> <groupId>net.ju-n.maven.plugins</groupId> <artifactId>checksum-maven-plugin</artifactId> <version>1.3-SNAPSHOT</version> <executions> <execution> <id>generate-artifact-checksum</id> <phase>package</phase> <goals> <goal>files</goal> </goals> </execution> </executions> <configuration> <fileSets> <fileSet> <directory>${project.build.directory}/artifacts</directory> </fileSet> </fileSets> </configuration> </plugin> <plugin> ... </plugin> </plugins> </build> 部分的说明,请参阅this question