简体   繁体   English

是否有必要在pom中指定maven插件的版本?

[英]Is it necessary to specify version of a maven plugin in pom?

I am using NetBeans for development and it has built-in menu feature that allows us to add maven-checkstyle-plugin in the pom for code formatting . 我正在使用NetBeans进行开发,它具有内置菜单功能,允许我们在pom中添加maven-checkstyle-plugin以进行代码格式化。 However, when you click on that menu it add the following piece of code in the pom automatically but without the <version> information. 但是,当您单击该菜单时,它会自动在pom中添加以下代码,但不包含<version>信息。 Now my IDE keeps on complaining with a small hint message in the margin saying that the 'version' tag is missing. 现在我的IDE继续抱怨边缘的一条小提示消息,说“版本”标签丢失了。 My question is: Does all plugins added has to have a <version> tag in the pom? 我的问题是:添加的所有插件是否都必须在pom中有<version>标签?

pom.xml 的pom.xml

 <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <configuration>
                    <configLocation>config/sun_checks.xml</configLocation>
                </configuration>
            </plugin>
        </plugins>
    </reporting>

It is not necessary, but highly recommended to use the version tag. 没有必要,但强烈建议使用版本标签。

When a plugin was invoked without an explicit version given in the POM or on the command line, Maven 2.x used to pick the latest version available where the latest version could either be a release or a snapshot. 当在没有POM或命令行中给出的显式版本的情况下调用插件时,Maven 2.x用于选择最新版本可用的最新版本,其中最新版本可以是版本或快照。 For the sake of stability, Maven 3.x prefers the latest release version over the latest snapshot version. 为了稳定起见,Maven 3.x更喜欢最新版本的最新版本。

Given the threat of non-reproducible builds imposed by automatic plugin version resolution, this feature is scheduled for removal as far as plugin declarations in the POM are concerned. 鉴于自动插件版本解析所施加的不可重现构建的威胁,就POM中的插件声明而言,此功能计划被删除。 Users of Maven 3.x will find it output a warning when missing plugin versions are detected to encourage the addition of plugin versions to the POM or one of its parent POMs. 当检测到缺少插件版本时,Maven 3.x的用户会发现它会输出警告,以鼓励向POM或其父POM添加插件版本。 The Enforcer rule requirePluginVersions can be used additionally check for missing plugin versions in the POM. 可以使用Enforcer规则requirePluginVersions来检查POM中缺少的插件版本。

https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Maven pom.xml中指定Eclipse插件的版本? - How to specify version of an Eclipse plugin in Maven pom.xml? 是否需要在pom.xml中指定Maven Surefire Plugin? - Is it required to specify Maven Surefire Plugin in pom.xml? 是否可以在POM中指定特定的JDK来运行给定的maven-plugin? - Is it possible to specify in a POM a specific JDK to run a given maven-plugin? Maven发布插件:指定java编译器版本 - Maven release plugin: specify java compiler version Maven surefire-plugin 执行时的版本与 pom 中的版本不同 - Maven surefire-plugin different version at execution than in pom 将父 pom 中使用的 Maven 插件的版本覆盖到主 pom 中的新版本 - Override version of Maven plugin used in parent pom to new version in main pom 自定义Maven插件:保存pom无效的pom - Custom maven plugin: saving pom NOT effective pom Gradle的Maven Publish插件不会将POM或适当的版本发布到Maven Local - Gradle's Maven Publish plugin not publishing POM or proper version to Maven Local 使用gwt maven插件时如何在单个Pom中指定多个runTarget - how can I specify multiple runTargets in a single Pom when using gwt maven plugin 使用versions-maven-plugin在我的父pom.xml中获取最新版本的插件 - getting the latest version of plugin's in my parent pom.xml using versions-maven-plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM