Maven: Release Plugin Does Not Commit Updated Versions - java

I am using the Maven release plugin. When I run
mvn release:prepare
I am prompted with the usual about the versions
What is the release version for "FOO"? (foo:bar) 1.10.99999:
What is the new development version for "FOO"? (foo:bar) 1.10.100000-SNAPSHOT:
The process completes normally. A tag is created and pushed to the correct repository as specified in the SCM tag:
<scm>
<connection>scm:git:git#top.secret.repo:foo/bar.git</connection>
<tag>HEAD</tag>
</scm>
But the updates to the versions numbers are not committed, and thus the SNAPSHOT, in the case the 1.10.99999-SNAPSHOT is deployed on mvn deploy. It appears others have had this issue as well but no real answer has been found
What is happening here and how do I fix it?
This is on Mac OSX. My Maven version is as follows:
$ brew info maven
maven: stable 3.2.5
http://maven.apache.org/
/usr/local/Cellar/maven/3.2.3 (76 files, 8.0M) *
Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/maven.rb
$ mvn --version
Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T13:58:10-07:00)
Maven home: /usr/local/Cellar/maven/3.2.3/libexec
Java version: 1.7.0_67, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.1", arch: "x86_64", family: "mac"

In general: when facing issues with a specific maven-plugin, verify if you are using the latest version and try to upgrade first.

Updating the version from 2.3.2 to 2.5.3 solves the issue for me. Definitely, something isn't right with the 2.3.2 version of the maven-release-plugin

Related

How to know which java version the Maven is using when build the project

I would like to know if it's possible check which Java version my Maven is using to build the project.
The JAVA_HOME was set to JDK 1.8.
In pom.xml I have this properties configured:
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
I try figured out a way to check it in mvn logs, but I can't find whitch version was used.
How to know the Java version throught some kind of mvn logs.
I appretiate any support.
In your command line if you run mvn -v it shows something like
Maven home: C:\maven\apache-maven-3.6.3\bin\..
Java version: 15.0.1, vendor: Oracle Corporation, runtime: C:\java\jdk-15.0.1
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Depending on where you build the project, in command line it would use the JAVA_HOME setting, in IDE it would use IDE settings for the project, e.g. in IDEA, go to Project Settings page (File -> Project Structure), you can check the Project SDK & Project language level settings on "Project" & "Modules" page, that shows which SDK & language level the current project used.

Maven is using wrong java version

I am trying to build a maven project on centOS 8. I want maven to use Java version 15. When I run mvn package I get the following error:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile
(default-compile) on project systembrett-backend: Fatal error compiling: invalid target release: 15 -> [Help 1]
So I suspect that maven is using the wrong Java version, because when i do mvn package -X for debug logs it start with:
Apache Maven 3.5.4 (Red Hat 3.5.4-5)
Maven home: /usr/share/maven
Java version: 1.8.0_275, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-240.1.1.el8_3.x86_64", arch: "amd64", family: "unix"
so it looks like, maven is using Java version 1.8.
But mvn -version says:
Apache Maven 3.5.4 (Red Hat 3.5.4-5)
Maven home: /usr/share/maven
Java version: 15.0.2, vendor: AdoptOpenJDK, runtime: /opt/jdk-15.0.2+7
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-240.1.1.el8_3.x86_64", arch: "amd64", family: "unix"
JAVA_HOME is /opt/jdk-15.0.2+7 and PATH is /opt/jdk-15.0.2+7/bin:/home/username/.local/bin:/home/username/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin.
I thought maven is choosing the java version by checking JAVA_HOME, but apparently it is using an other version for the build. Does anyone know how to tell maven the correct version?
Thanks!
Following is a list of steps I use to troubleshoot this kind of issues:
Linux usually works with alternatives to ensure proper default Java environment is used. Similar to:
$ alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
+ 1 java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.191-2.6.15.4.el7_5.x86_64/jre/bin/java)
* 2 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/jre/bin/java)
Try also for javac as it may not be configured the same way:
$ alternatives --config javac
For your maven instance, JAVA_HOME should be enough.
Your output of mvn -version testifies that you have configured it correctly. Remove your Java from your PATH to ensure JAVA_HOME and mvn will find the correct one.
The pom.xml can also configure the required compiler, similar to:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Another thing may be that you're not using the same ENV (different terminals may not have the same environment variables exported - I presume you being on CentOS, you already encountered this). You have to exit the terminal and get back in to allow the default variables to take effect.
You encounter this usually when different JRE vs JDK are used ( more: maven installation has runtime as JRE instead of JDK )
I had the same issue on RHEL 9.1. The solution was to look at /etc/java/maven.conf and set the correct JAVA_HOME here in this file.

Which version of confluence do which versions of Atlassian plugin SDK support?

I've been trying to find out which versions of Confluence will my plugin support.
Here's the output of my atlas-version command:
ATLAS Version: 8.0.16
ATLAS Home: /usr/share/atlassian-plugin-sdk-8.0.16
ATLAS Scripts: /usr/share/atlassian-plugin-sdk-8.0.16/bin
ATLAS Maven Home: /usr/share/atlassian-plugin-sdk-8.0.16/apache-maven-3.5.4
AMPS Version: 8.0.2
--------
[INFO] Project POM found
Executing: /usr/share/atlassian-plugin-sdk-8.0.16/apache-maven-3.5.4/bin/mvn --version -gs /usr/share/atlassian-plugin-sdk-8.0.16/apache-maven-3.5.4/conf/settings.xml
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T00:03:14+05:30)
Maven home: /usr/share/atlassian-plugin-sdk-8.0.16/apache-maven-3.5.4
Java version: 1.8.0_181, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-66-generic", arch: "amd64", family: "unix"
Here's a part of my plugin's pom.xml file:
<properties>
<confluence.version>6.14.0</confluence.version>
<confluence.data.version>6.14.0</confluence.data.version>
<amps.version>8.0.2</amps.version>
<plugin.testrunner.version>2.0.1</plugin.testrunner.version>
<atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>
<!-- This property ensures consistency between the key in atlassian-plugin.xml and the OSGi bundle's key. -->
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
I am using Confluence Server 7.2.0 and my plugin can be uploaded and run just fine.
But I can't seem to find any documentation that explains which versions of confluence will my plugin run on.
Looking at these links, however
https://marketplace.atlassian.com/apps/1210950/atlassian-plugin-sdk-windows/version-history
https://marketplace.atlassian.com/apps/1210991/atlassian-plugin-sdk-rpm/version-history
There seem to be different confluence versions supported for SDK version 8.0.16 for windows and the rpm versions of the SDK.
Also, it does not seem to mention the right SDK for building plugins for Confluence 6.7 to 6.13.
Is this the right page for such information? What am I missing?
When the atlas-sdk generates the plugin artifacts, it fills inside the pom file an enterprise version of Confluence as a starting point.
And in order to verify the plugin is working on other version, you will need to change the version in the pom file and restart the server and test your plugin manually to verify all its features are working properly.
Also to answer your inquiry for ATLAS-SDK compatibility with different Atlassian application versions. Each atlassian SDK version is backward compatible with its predecessor versions, which means if you have the latest Atlas-SDK then you may run any Confluence version you'd desire.
Hope this helps

How to upgrade maven's version from 3.1.x to 3.3.9 under Mac OX?

I maven version 3.1.1 of this machine is that when I upgraded to version 3.3.9, when I execute no matter what kind of maven command will get the following error message:
Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable and mvn script match.
like this:
Environmental Information
Java version: 1.8.0_40
OS name: "mac os x", version: "10.11.1", arch: "x86_64"
Apache Maven 3.3.9
I am here to find the answer.
that follow:
In ~/.bashrc /~/.zshrc(
If you are using zsh) add a line insideexport MAVEN_OPTS="-Dmaven.multiModuleProjectDirectory=$M2_HOME"
After completion of the addition result like this:
export MAVEN_OPTS="-Dmaven.multiModuleProjectDirectory=$M2_HOME" M2_HOME=/Users/liuxinyu/software/maven/apache-maven-3.3.9
export M2_HOME
export PATH=$PATH:${M2_HOME}/bin:${GRADLE_HOME}/bin:${GROOVY_HOME}/bin

Why isn't maven replacing the environment variable for the maven-release-plugin release version?

I am trying to use the maven-release-plugin with some environment variables, but I get an issue when I use an environment variable for the release version.
I am executing:
mvn release:clean --batch-mode -Dtag=${env.tag} -Dproject.rel.com.mycompany.project:project-root=${env.project.rel.com.mycompany.project:project-root} -Dproject.dev.com.mycompany.project:project-root=${env.project.dev.com.mycompany.project:project-root} release:prepare
I am getting:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-release-plugin:2.4:prepare
(default-cli) on project project-root: Error parsing version,
cannot determine next version: Unable to parse the version string:
"${env.project.rel.com.mycompany.project:project-root}" -> [Help 1]
If I change the ${env.project.rel.com.mycompany.project:project-root} to a specific version, the command will pass.
But as you can see I am using:
${env.tag}
${env.project.dev.com.mycompany.project:project-root}
with no issues. Is this a bug? Or am I doing something wrong?
Additional notes:
Environment variables:
tag=2.55
project.rel.com.mycompany.project:project-root=2.55
project.dev.com.mycompany.project:project-root=2.56-SNAPSHOT
My Maven version is:
C:\>mvn -version
C:\>set MAVEN_OPTS=-Xmx1024m -XX:MaxPermSize=512m
Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: C:\Users\John\Documents\apache-maven-3.0.4-bin
Java version: 1.6.0_25, vendor: Sun Microsystems Inc.
Java home: C:\JDK\jdk1.6.0_25\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
you will have to use the arguments attribute: http://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html#arguments
So in your context your cmd line will look like this (Note the double quotes as well):
mvn release:clean --batch-mode release:prepare "-Darguments=-Dtag=${env.tag} -Dproject.rel.com.mycompany.project:project-root=${env.project.rel.com.mycompany.project:project-root} -Dproject.dev.com.mycompany.project:project-root=${env.project.dev.com.mycompany.project:project-root}"
Furthermore, if i remember right the uses of the tokens ${env.X} requires the usage of the property name in upper case (to be verified)
It's not working because the release plugin clears the environment[1]. I doubt it's documented[2], I found out by looking at the source. Farid's answer is a good workaround - it passes the environment value via java properties which are not cleared.
I would have simply commented on Farid's answer but SO doesn't think I'm shiny enough.
Why??
Classic maven.

Categories

Resources