Skip to content

Instantly share code, notes, and snippets.

@gwsu2008
Last active March 12, 2018 16:33
Show Gist options
  • Save gwsu2008/f190fd6135324d1f55bb109efd38f1d6 to your computer and use it in GitHub Desktop.
Save gwsu2008/f190fd6135324d1f55bb109efd38f1d6 to your computer and use it in GitHub Desktop.
maven-tips.sh
# Getting project version from pom.xml and save the version to a file
mvn com.smartcodeltd:release-candidate-maven-plugin:LATEST:version \
-DoutputTemplate="PROJECT_VERSION={{ version }}" \
-DoutputUri="file://\${project.basedir}/version.properties"
#Print project version
mvn -q -N org.codehaus.mojo:exec-maven-plugin:1.3.1:exec \
-Dexec.executable='echo' \
-Dexec.args='${project.version}'
mvn -q -N org.codehaus.mojo:build-helper-maven-plugin:3.0.0:parse-version \
org.codehaus.mojo:exec-maven-plugin:1.3.1:exec \
-Dexec.executable='echo' \
-Dexec.args='${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}'
# 3rd method
MAVEN_OPTS="\
-Dorg.slf4j.simpleLogger.defaultLogLevel=INFO \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.plugins.help=INFO" \
mvn -q help:evaluate -o -Dexpression=project.version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment