I'm trying to use the gitflow-helper-maven-plugin
extension for my maven builds.
Therefore I'd like to configure my project in order to run some extra steps when building a release version and skipping them while compiling a SNAPSHOT one, but I cannot find a way to enable a profile if ${project.version}
contains -SNAPSHOT
.
Any suggestion?
Below a possible approach which is how you could always simulate an
if
statement in a Maven build:buid-helper-maven-plugin
and itsregex-property
goal to parse the default${project.version}
property and create a new${only.when.is.snapshot.used}
property with valuetrue
or${project.version}
in case ofSNAPSHOT
suffix found.maven-source-plugin
to execute itsjar
goal with a special configuration using itsskipSource
option and passing to it the new (dynamic)${only.when.is.snapshot.used}
property: in case of snapshot it will have valuetrue
hence skip the execution, otherwise will have value${project.version}
which will be used asfalse
and hence not skip this executionmaven-javadoc-plugin
using itsskip
optionA sample of the approach above would be:
That is, no need for profiles, this configuration will only be enabled when a non SNAPSHOT version will be used, dynamically and without any further configuration (command line options or whatsoever).
As a side reminder, you could also look at the
maven-release-plugin
, which will effectively invoke the source and javadoc plugin only when performing a release without the added (minor) complexity of the approach above.Otherwise, you could simple use the default profile coming from the Maven Super POM which would actually invoke the same, source and javadoc plugin, and can be activated via the property
performRelease
set to valuetrue
. That is, on any Maven project could you invoke the following:or
And you will automatically benefit from the default super profile and have sources and javadoc jars generated, although this approach should be used as last option since the profile could be dropped from the super pom in future releases.