Maven release:prepare fails with "scm connection or developerConnection must be specified" - maven

I'm trying to prepare a release of my maven project with mvn release:prepare but it fails with the following error:
Caused by: org.apache.maven.plugin.MojoFailureException: Missing required setting: scm connection or developerConnection must be specified.
After reading about these settings on maven.apache.org, I see that there are SVN (Version Control) settings.
But I'm not using version control. How should I make a maven release in this case?
I'm using maven 3.0.3.

If you only would like to change the version, the Versions Maven Plugin may help.
The versions:set may be the good one for using.
Please take a big note, since you're not using the SCM, please make a full backup before using the following command.
mvn versions:set -DnewVersion=1.0
mvn clean install
mvn versions:set -DnewVersion=1.1-SNAPSHOT
mvn clean install
Anyhow I highly recommend and encourage you to use the SCM and perform the release by following the Maven good practice instead.
I hope this may help.

May your pom.xml not having the entry
<scm>
<connection>scm:svn:https://host:port/abc/xyz/trunk</connection>
<developerConnection>scm:svn:https://host:port/abc/xyz/trunk</developerConnection>
</scm>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<tagBase>https://host:port/abc/xyz/tag</tagBase>
<releaseProfiles>release</releaseProfiles>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

You need to add your SCM configuration. In the example below I added my git repository to the master branch
<scm>
<developerConnection>
scm:git:git#github.com:tufac2/sfg-pet-clinic.git
</developerConnection>
</scm>

In Springboot the answer depends of plugin that you are using
docker-maven-plugin:
mvn docker:build
dockerfile-maven-plugin:
mvn dockerfile:build
I hope this help you
Regards

Related

Specify Jacoco Version from Command Line when Running Maven Release

I have a need to specify jacoco dependency/plugin version from the command line when running the following command:
mvn release:prepare release:perform ...options... [JACOCO VERSION]
Basically, I want all projects to be built using the same jacoco version despite whatever version is present in their pom.
Is there a way to do this through the cli? I have seen examples doing this when specifying jacoco prepare agent, but I want to specify the actual jacoco-maven-plugin plugin version.
You can define the version inside the properties and set value from the command line.
For eg,
<properties>
<jacoco-maven-plugin.version>0.7.9</jacoco-maven-plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
</plugin>
</plugins>
</build>
While from the command line, specify the new property value.
mvn -Djacoco-maven-plugin.version=0.8.5
You can also verify the effective pom by running
mvn -Djacoco-maven-plugin.version=0.8.5 help:effective-pom

How to publish the artifacts at the end using maven-release plugin

I have a multi-module maven project. I'm using maven-release plugin to publish the artifact to maven repository. I'm using following command to do the above task.
mvn -B clean release:clean release:prepare release:perform -DautoVersionSubmodules=true '-DscmCommentPrefix=[maven-release-plugin]'
In one of the sub-module, i have a Unit test failure, but still i see the remaining modules are published to maven repo, except failed module.
Is there a way to publish all sub-modules only when the Unit tests for all modules pass?
Following is the maven pom configuration i have in Parent pom.xml.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<tagNameFormat>v#{project.version}</tagNameFormat>
<localCheckout>true</localCheckout>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<localCheckout>true</localCheckout>
<pushChanges>true</pushChanges>
<mavenExecutorId>forked-path</mavenExecutorId>
<preparationGoals>clean deploy -U -B</preparationGoals>
<goals>clean install</goals>
<arguments>-Prelease</arguments>
</configuration>
</plugin>
The maven-deploy-plugin has a command line option "-DdeployAtEnd=true" that will accomplish this. But because maven-release-plugin runs the deploy command in its own instance of Maven, you have to pass it into this instance using the maven-release-plugin -Darguments option.
Overall, your command will look like this.
mvn -B clean release:clean release:prepare -Darguments=\"-DdeployAtEnd=true\" release:perform -DautoVersionSubmodules=true '-DscmCommentPrefix=[maven-release-plugin]

SonarQube and maven

when I build my project I usually call mvn clean install.
Now I tried to integrate sonarqube analysis. Therefore I created a new Run Configuration in Eclipse where I execute the goal mvn sonar:sonar with some parameters.
Is there a way to run sonar:sonar within the mvn clean install automatially?
This should be documented in "Analyzing with SonarQube Scanner for Maven".
It will be triggered in the build phase.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.3.0.603</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Then see "Running sonar analysis with mvn sonar:sonar ignores sonar-project.properties".
To associate it with an existing lifecycle phase seems problematic.

maven versions plugin does not fetch releases with build number

I have a library with version 1.0.0-19 (19 is the Jenkins build number), on next jenkins build the version 1.0.0-20 will be assigend to the library and the artifact will be deployed to a maven repository. Another artifact which is referencing the library in the pom dependency section does not get the last version if I execute versions:use-latest-versions, the dependency version is still 1.0.0-19 instead of 1.0.0-20. Maybe it has to do with the allow* system parameters, there is no property for the build number part.
Any ideas how it could be achieved to get always the last build (1.0.0-19 -> 1.0.0-20)?
Within your pom make sure you are using -
<dependencies>
<dependency>
<groupId>some.artifactory.group</groupId>
<artifactId>artifact-name</artifactId>
<version>1.0.0-19</version>
</dependency>
</dependencies>
<!-- please use the appropriate artifact and groupId -->
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</build>
and you are executing the command -
mvn versions:use-latest-releases
Source - http://www.mojohaus.org/versions-maven-plugin/use-latest-releases-mojo.html
Note - Just in case this also involves SNAPSHOTS, do take care of allowSnapshots and use the command as -
mvn versions:use-latest-releases -DallowSnapshots=true

How to skip unittests when using mvn scm:bootstrap

I'm trying to use the mvn scm plugin to check out the daily tag, and create an assembly from that version of the code. I configured the scm plugin and everythhing is working well, except that I can not seem to tell it to not run the unittests.
I tried:
Passing the -Dmaven.test.skip=true command line parameter
Creating a profile where the surefire plugin skips test, and list that profile in the scm configuration "profiles" section
setting the "maven.test.skip=true" as an environment variable
In all cases, when the scm plugin starts running the goals I told it to run in the configuration (see below), it also runs the unittests.
Below is the example I used to skip tests by using a profile:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.0</version>
<configuration>
<goals>install,assembly:assembly</goals>
<profiles>skiptest</profiles>
</configuration>
</plugin>
And this is the profile (I defined this in the pom.xml of the project):
<profiles>
<profile>
<id>skiptest</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
The command I use to do the checkout and bootstrap is:
mvn scm:bootstrap -DscmVersion=daily-20110427-421 -DscmVersionType=tag
I'm running mvn 2.2.1 on a Linux machine, and doing a checkout from a CVS repository. It's an existing project, I have continuous integration and tagging all up and running, I just want to check out a daily tag and create an assembly from that.
Any tips are much appreciated.
Edit: Got it to work with the answer below, but only after I upgraded to maven-scm-plugin version 1.1. Apparently, 1.0 did not propagate profiles.
Try this in the profile:
<profiles>
<profile>
<id>skiptest</id>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
</profiles>

Resources