这几年做那个网站致富,网站内容的设计与实现,无锡企业推广,sem分析是什么1.为什么要统一管理#xff1f;
maven父子工程多模块#xff0c;每个模块还都可以独立存在#xff0c;子模块往往通常希望和父工程保持一样的版本#xff0c;如果每个工程单独定义版本号#xff0c;后期变更打包也非常麻烦#xff0c;如何维护一个全局的版本号呢#x…1.为什么要统一管理
maven父子工程多模块每个模块还都可以独立存在子模块往往通常希望和父工程保持一样的版本如果每个工程单独定义版本号后期变更打包也非常麻烦如何维护一个全局的版本号呢
2.如何解决呢
Maven官方文档说自 Maven 3.5.0-beta-1 开始可以使用 ${revision}, ${sha1} and/or ${changelist} 这样的变量作为版本占位符。
即在maven多模块项目中可配合插件flatten-maven-plugin及${revision}属性来实现全局版本统一管理。
父工程
?xml version1.0 encodingUTF-8?
project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-parent/artifactIdversion2.7.18/version/parentgroupIdcom.xxx.project/groupIdartifactIdxxx-parent/artifactIdpackagingpom/packagingversion${revision}/versionmodulesmodulemodule1/modulemodulemodule2/modulemodulemodule3/module/modulesproperties!-- globe version,if you can update the version for all project --revision1.1.1/revisionmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.target/propertiesbuildplugins!-- 添加flatten-maven-plugin插件 --plugingroupIdorg.codehaus.mojo/groupIdartifactIdflatten-maven-plugin/artifactIdversion1.3.0/versioninheritedtrue/inheritedexecutionsexecutionidflatten/idphaseprocess-resources/phasegoalsgoalflatten/goal/goalsconfigurationupdatePomFiletrue/updatePomFileflattenModeresolveCiFriendliesOnly/flattenModepomElementsparentexpand/parentdistributionManagementremove/distributionManagementrepositoriesremove/repositories/pomElements/configuration/executionexecutionidflatten.clean/idphaseclean/phasegoalsgoalclean/goal/goals/execution/executions/plugin/plugins/build
/project
子模块
?xml version1.0 encodingUTF-8?
project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdparentartifactIdxxx-parent/artifactIdgroupIdcom.xxx.project/groupIdversion${revision}/version/parentmodelVersion4.0.0/modelVersionartifactIdmodule3/artifactIdpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.target/propertiesdependenciesdependencygroupIdcom.xxx.project/groupIdartifactIdmodule1/artifactIdversion${revision}/version/dependency/dependencies/project
编译
mvn clean package基于以上操作每次版本号变更只需要修改父模块POM文件中的revision即可
3.引用
Maven – Maven CI Friendly Versions