Maven Release: Non-Interactive

I am trying to release a project with Maven.

My POM project contains -SNAPSHOT dependencies, so for automatic release I want to use the following maven command based on the "maven-release-plugin" goals: mvn release:prepare-with-pom in order to prepare the pom.xml project for automatic release and resolving dependency versions of -SNAPSHOT without manually editing them.

Unfortunately, I found that this only works interactively from the command line. The idea is that I wonder if this can be done without any manual interaction. I use Bamboo as a CI Server, and I want to include this in the plan and execute this project automatically. --non-interactive or -B does not work, in fact, if I use -B or --non-interactive maven target fails.

This is the output for mvn release:prepare-with-pom :

 H:\APPS\dev\cmtest\test-dependency\trunk>mvn release:prepare-with-pom -DdryRun=t rue [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building test-dependency 0.0.4-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-release-plugin:2.0:prepare-with-pom (default-cli) @ test-depend ency --- [INFO] Resuming release from phase 'check-dependency-snapshots' [INFO] Checking dependencies and plugins for snapshots ... There are still some remaining snapshot dependencies.: Do you want to resolve th em now? (yes/no) no: : yes Dependency type to resolve,: specify the selection number ( 0:All 1:Project Depe ndencies 2:Plugins 3:Reports 4:Extensions ): (0/1/2/3) 1: : 1 Resolve Project Dependency Snapshots.: '${artifactGroup}:${artifactId}' set to releas e? (yes/no) yes: : yes What is the next development version? (0.1.3-SNAPSHOT) 0.1.3-SNAPSHOT: : '${artifactGroup}:${artifactId1}_1' set to release? (yes/no) yes: : yes What is the next development version? (0.0.2-SNAPSHOT) 0.0.2-SNAPSHOT: : '${artifactGroup}:parent-pom' set to release? (yes/no) yes: : yes What is the next development version? (0.0.3-SNAPSHOT) 0.0.3-SNAPSHOT: : What is the release version for "test-dependency"? (${artifactGroup}:${artifactId1}_2) 0.0.4: : What is SCM release tag or label for "test-dependency"? (${artifactGroup}:${artifactId1}_2) test-dependency-0.0.4: : What is the new development version for "test-dependency"? (${artifactGroup}:${artifactId1}_2) 0.0.5-SNAPSHOT: : [INFO] Transforming '${artifactId1}_2'... [INFO] Updating ${artifactId1}_1 to 0.0.1 [INFO] Updating ${artifactId1} to 0.1.2 [INFO] Generating release POMs... [INFO] Generating release POM for 'test-dependency'... [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ 

So, could you please help me find the trick to execute this maven command in silent mode? thank you very much

+4
source share
1 answer

While your pom is referencing snapshot releases, I don't find it non-interactive (maybe a fantastic “expect” script, but it might be a bit).

Releasing a library that relies on snapshots is very dangerous because libraries can change from under your feet. Anyone who uses your library will assume that every time they use them, they get the same banks with the same SHAs, but in reality this is not so. That is why maven makes it almost impossible to do this.

I would recommend focusing on porting your dependencies to released versions or, if this is not an option, saving your library as a snapshot. Keeping your library as a snapshot means that your customers at least know that the libraries they use can change without their knowledge.

+1
source

Source: https://habr.com/ru/post/1385577/


All Articles