mvn release:prepare
mvn释放:准备
It constantly asks me to resolve snapshot dependencies. Is there a way to do this in batch mode so that maven automatically uses the associated release. i.e. if a dependency is 1.0.0-SNAPSHOT it will automatically update this dependency to the 1.0.0 release?
它经常要求我解析快照依赖性。是否有一种方法可以在批处理模式下进行此操作,以便maven自动使用相关的发布。例如,如果一个依赖项是1.0快照,它会自动将这个依赖项更新到1.0.0版本吗?
[INFO] Checking dependencies and plugins for snapshots ...
There are still some remaining snapshot dependencies.: Do you want to resolve them now? (yes/no) no: : yes
Dependency type to resolve,: specify the selection number ( 0:All 1:Project Dependencies 2:Plugins 3:Reports 4:Extensions ): (0/1/2/3) 1: : 1
Resolve Project Dependency Snapshots.: 'com.my.project' set to release? (yes/no) yes: : yes
What is the next development version? (0.0.2-SNAPSHOT) 0.0.2-SNAPSHOT: : 0.0.2-SNAPSHOT
3 个解决方案
#1
5
You can do update of the SNAPSHOT's via the versions-maven-plugin before the release.
您可以通过版本-maven-plugin来更新快照。
#2
8
Note that you can configure Maven ignore SNAPSHOT dependencies checking by using allowTimestampedSnapshots, according to maven-release-plugin documentation:
注意,根据Maven -release-plugin文档,您可以使用allowtimestampedsnapshot配置Maven忽略快照依赖项检查:
allowTimestampedSnapshots:
allowTimestampedSnapshots:
Whether to allow timestamped SNAPSHOT dependencies. Default is to fail when finding any SNAPSHOT.
是否允许时间戳快照依赖项。默认是在查找任何快照时失败。
- Type: boolean
- 类型:布尔
- Since: 2.0-beta-7
- 自:2.0 -beta-7
- Required: No
- 要求:不
- Expression: ${ignoreSnapshots}
- 表情:$ { ignoreSnapshots }
- Default: false
- 默认值:假
Or simply run the command below:
或者简单地运行以下命令:
mvn release:prepare -DignoreSnapshots=true
mvn释放:准备-DignoreSnapshots = true
However, it is still recommended to resolve all SNAPSHOT dependencies before doing the final release, as it is the convention used by most people. You should always consider to do it manually at developing phase rather than automatically batching at release phase, as change/upgrade project's dependencies (either your own or third party jar) may sometimes introduce bug or incompatibility and break your project, which usually need developer's attention and fix them before doing final release.
但是,仍然建议在执行最终版本之前解决所有快照依赖关系,因为这是大多数人使用的约定。你应该考虑去做手工在发展阶段而不是自动配料在释放阶段,改变/升级项目的依赖关系(自己或第三方jar)有时可能会引入缺陷或不相容,打破你的项目,通常需要开发人员的关注,在最终版本之前修复它们。
In another word, dependency resolution is not a task which should be done at release phase, moreover, it is not a task which should be done automatically without developer's attention.
换句话说,依赖项解析不是一项应该在发布阶段完成的任务,而且它也不是一项应该在没有开发人员注意的情况下自动完成的任务。
#3
3
If your dependency is a program of you own and its lifecycle is closely linked to the one you try to release, you may think about using a multimodule project : http://maven.apache.org/guides/mini/guide-multiple-modules.html. Maven release plugin would update version for all of you dependencies modules.
如果您的依赖项是一个您自己的程序,并且它的生命周期与您尝试释放的一个程序密切相关,您可能会考虑使用一个多模块项目:http://maven.apache.org/guides/mini/guide-multimodules.html。Maven发布插件将更新所有依赖模块的版本。
If not, you are probably doing something you should not. Just changing 1.0.0-SNAPSHOT to 1.0.0 does not ensure you app will continue to work. So does not consider that Maven should !
如果没有,你可能正在做一些你不应该做的事情。仅仅将1.0 - snapshot更改为1.0.0并不保证您的应用程序能够继续工作。所以不要认为Maven应该这样做!
Further considerations
进一步的考虑
Maven release plugin checks if you are using a snapshot dependency, because Snapshot, by definition, are unstable vesions. It may change along the time. That means what was working today may not work tomorrow.
Maven发布插件检查是否使用快照依赖项,因为根据定义,快照是不稳定的vesions。它可能会随时间而改变。这意味着今天工作的东西明天可能不会工作。
Releasing means that your version is stable, and the build can be reproduce anytime without any change. Using Snapshot version, this assertion become false.
发布意味着您的版本是稳定的,并且构建可以在任何时候复制而不需要任何更改。使用快照版本,此断言变为false。
So,
所以,
#1
5
You can do update of the SNAPSHOT's via the versions-maven-plugin before the release.
您可以通过版本-maven-plugin来更新快照。
#2
8
Note that you can configure Maven ignore SNAPSHOT dependencies checking by using allowTimestampedSnapshots, according to maven-release-plugin documentation:
注意,根据Maven -release-plugin文档,您可以使用allowtimestampedsnapshot配置Maven忽略快照依赖项检查:
allowTimestampedSnapshots:
allowTimestampedSnapshots:
Whether to allow timestamped SNAPSHOT dependencies. Default is to fail when finding any SNAPSHOT.
是否允许时间戳快照依赖项。默认是在查找任何快照时失败。
- Type: boolean
- 类型:布尔
- Since: 2.0-beta-7
- 自:2.0 -beta-7
- Required: No
- 要求:不
- Expression: ${ignoreSnapshots}
- 表情:$ { ignoreSnapshots }
- Default: false
- 默认值:假
Or simply run the command below:
或者简单地运行以下命令:
mvn release:prepare -DignoreSnapshots=true
mvn释放:准备-DignoreSnapshots = true
However, it is still recommended to resolve all SNAPSHOT dependencies before doing the final release, as it is the convention used by most people. You should always consider to do it manually at developing phase rather than automatically batching at release phase, as change/upgrade project's dependencies (either your own or third party jar) may sometimes introduce bug or incompatibility and break your project, which usually need developer's attention and fix them before doing final release.
但是,仍然建议在执行最终版本之前解决所有快照依赖关系,因为这是大多数人使用的约定。你应该考虑去做手工在发展阶段而不是自动配料在释放阶段,改变/升级项目的依赖关系(自己或第三方jar)有时可能会引入缺陷或不相容,打破你的项目,通常需要开发人员的关注,在最终版本之前修复它们。
In another word, dependency resolution is not a task which should be done at release phase, moreover, it is not a task which should be done automatically without developer's attention.
换句话说,依赖项解析不是一项应该在发布阶段完成的任务,而且它也不是一项应该在没有开发人员注意的情况下自动完成的任务。
#3
3
If your dependency is a program of you own and its lifecycle is closely linked to the one you try to release, you may think about using a multimodule project : http://maven.apache.org/guides/mini/guide-multiple-modules.html. Maven release plugin would update version for all of you dependencies modules.
如果您的依赖项是一个您自己的程序,并且它的生命周期与您尝试释放的一个程序密切相关,您可能会考虑使用一个多模块项目:http://maven.apache.org/guides/mini/guide-multimodules.html。Maven发布插件将更新所有依赖模块的版本。
If not, you are probably doing something you should not. Just changing 1.0.0-SNAPSHOT to 1.0.0 does not ensure you app will continue to work. So does not consider that Maven should !
如果没有,你可能正在做一些你不应该做的事情。仅仅将1.0 - snapshot更改为1.0.0并不保证您的应用程序能够继续工作。所以不要认为Maven应该这样做!
Further considerations
进一步的考虑
Maven release plugin checks if you are using a snapshot dependency, because Snapshot, by definition, are unstable vesions. It may change along the time. That means what was working today may not work tomorrow.
Maven发布插件检查是否使用快照依赖项,因为根据定义,快照是不稳定的vesions。它可能会随时间而改变。这意味着今天工作的东西明天可能不会工作。
Releasing means that your version is stable, and the build can be reproduce anytime without any change. Using Snapshot version, this assertion become false.
发布意味着您的版本是稳定的,并且构建可以在任何时候复制而不需要任何更改。使用快照版本,此断言变为false。
So,
所以,