scm connection vs developerConnection - maven

Can anyone tell me the difference between scm connection and developerConnection in maven?
I am trying to build using mvn release:prepare and it requires either one of them.
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare
(default-cli) on project was-topology-legacy-dsl: Missing required
setting: scm connection or developerConnection must be specified. ->
[Help 1]

As mentioned in POM Reference: SCM The connection requires read access for Maven to be able to find the source code (for example, an update), developerConnection requires a connection that will give write access. It is an information for our project where the other, including with another maven plugin to re-use this information further. In this case the Maven Release Plugin.
The Maven Release Plugin: Prepare a Release also provides us the behind the scenes what it does for us during the release:prepare. There are some significant steps which requires the access to the scm as the following: -
Transform the SCM information in the POM to include the final destination of the tag
Tag the code in the SCM with a version name (this will be prompted for)
Commit the modified POMs
This means we should provide the scm information when using the maven release plugin. Especially the developerConnection. If we don't provide, the plugin is not able to execute.
Another useful information is Maven Release Plugin: Perform a Release and Maven Release Plugin: Rollback a Release.

Related

How to fix not finding a plugin artifact?

I am getting this error: [ERROR] Plugin org.apache.maven.plugins:maven-surefire-plugin:2.12.4 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-surefire-plugin:jar:2.12.4 in nexus-xyz-plugin
I tried to run maven with dependecy:tree, but I can't see surefire, and I dont know why it is looking for this specific version 2.12.4 which is not specified in my pom!
Even the surefire plugin is not defined in my pom, but I have the assembly plugin not sure if assembely is dependent on surefire
Note that I only get the error when running mvn package, however when running mvn compile the build succeeds
Version 2.12.4 of the maven-surefire-plugin is always added to the pom by maven version 3.x unless you depend on a specific other version.
Maven has a so called super pom that you get for free, but that doesn't list surefire: https://maven.apache.org/ref/3.8.5/maven-model-builder/super-pom.html
However it is added to the pom, i've checked this with maven 3.3.9. You can verify this by running mvn help:effective-pom.
Reference with the same problem: No surefire plugin in my pom - How does it show surefire output?
These plugin versions are part of the default bindings for lifecycle executions, in this case of the test phase. So these plugins are always included if not specified.
See for reference:
https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
https://maven.apache.org/ref/3.8.5/maven-core/default-bindings.html
Maven default life-cycle and plugins section
Normally this plugin should be available in maven central, check if you have a <pluginRepository> in your (effective) pom that references https://repo1.maven.org/maven2/
Some other things you can check:
Open the file .m2\repository\org\apache\maven\plugins\maven-surefire-plugin\2.12.4\maven-surefire-plugin-2.12.4.jar.lastUpdated and check the error message for each repository. Check why it can't reach maven central; is it missing from the list or giving an error? This might be a company firewall/policy issue perhaps? Or is it giving an error on HTTPS/TLS protocol level?
Check if you can add maven central to your repositories list if it's missing somehow (should be included by default). Check if it's HTTP or HTTPS, only secure is supported now.
Run your maven command with -X for debug mode to investigate further
An alternative is to add the latest version of surefire to your project that is available in your plugin-repository, and perhaps disable it if you're not executing unit tests.
See Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.

maven release without scm/vcs

I want to build a release version of my spring application with maven without the use of scm or ANY OTHER version control system - All I want is to build an application ready to be served via tomcat. While this sounds simple, it seems impossible for me to achieve.
I already tried options like suppressCommitBeforeTag / remoteTagging / pushChanges / dryRun directly via the command line
mvn -DremoteTagging=false -DsuppressCommitBeforeTag=true -DpushChanges=false release:prepare or by setting inside the pom.xml in the corresponding plugin configuration.
No matter what I do, I always get
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-release-plugin:3.0.0-M1:prepare
(default-cli) on project eStore: Missing required setting: scm
connection or developerConnection must be specified.
How can I completely deactivate version control / remote tagging when releasing?

how to automatically set scm connection in maven pom?

We are trying to run release:prepare but this produces error like below.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:
prepare (default-cli) on project test-module:
Missing required setting:
scm connection or developerConnection must be specified. -> [Help 1]
We want to avoid setting the scm.connection manually.
How to set scm.connection automatically to the current URL? - For SVN and git.
The information must be somewhere within the (metadata of the) module, since svn info displays the value under URL.
In principle, you should be able to set the developerConnection by using a parameter, but (thanks to khmarbaise for telling me) there is a bug (https://issues.apache.org/jira/browse/MRELEASE-1017) so that this does not work at the moment.
I currently work around this with my own Maven plugin. It compares the connection and developerConnection entries of the pom with the url provided by the build server (the build server knows the url because it checked out the code) and adjusts the urls if necessary (followed by scm:checkin).

Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy - Cannot deploy artifacts when Maven is in offline mode

I run project deploy in Maven project and get the problem as below:
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project iris: Cannot deploy artifacts when Maven is in offline mode -> [Help 1]
Could you help me figure out this problem?
Maven is configured in offline mode, that means Maven will not try to connect to any remote repository. Therefore, the maven-deploy-plugin cannot upload your jar.
Offline mode can be configured in two different ways :
launching Maven with the -o flag. Maven is offline only for this execution.
setting the offline attribute to true in the settings.xml file. Maven is offline for all executions.
One of those two options must be enabled in your configuration and you must remove it for maven-deploy-plugin to work.

Maven release without tagging

The main idea of the question is: is that a way to specify that maven release should skip tagging when performing a release?
I have the following context: we have a TFS (Team Fundation Server) as a system that version our software. We also use a svn bridge that "talks" with the TFS and developers and CI tools use it. When performing a mvn release:clean release:prepare release:perform maven complains that it cannot find or create a tag (somehow translating the tag command of the svn into a similiar command in tfs crashes). Any suggestions are appreciated.
The error looks like this:
28-May-2013 15:51:04 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.1:branch (default-cli) on project spring-hibernate-mysql: The scm url is invalid.
28-May-2013 15:51:04 [ERROR] - scm:svn:https://${TFS_SERVER}:${PORT}/${PATH_TO_APP}/tags/dbDiagnostic-1.0.0-RELEASE url isn't a valid svn URL.
28-May-2013 15:51:04 [ERROR] -> [Help 1]
I mention that the url is ok, because the step before this, in a CI plan is a "checkout sources" step with the same url.
The maven release plugin depends on the svn tag as it checks out the tagged version during the release process. So the answer is: No, there is no way to release without a tag.
The svn URL above is not valid, you should consider fixing it by resolving the variable substitutions.
To your question:
You can disable remote tagging by setting the remoteTagging property to false as described in: http://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html#remoteTagging
Note that in only works with SVN.
However, the reason for this error is most likely because maven failed to create the tag in the previous step, due to e.g. authentication failure or incorrect URL configuration ( see "tag base" attribute & etc ).

Resources