> Date: Sun, 23 Aug 2015 17:16:07 +0200
> From: [email protected]
> To: [email protected]
> Subject: Using ${revision} as a version
>
> Hi,
>
> I have test project where i defined the pom like this:
>
> ...
> <modelVersion>4.0.0</modelVersion>
>
> <groupId>com.soebes.examples.j2ee</groupId>
> <artifactId>parent</artifactId>
> <version>${revision}</version>
> <packaging>pom</packaging>
>
> If i define the revision on command line like this.
>
> mvn -Drevision=1.0-SNAPSHOT clean package
>
> everything fine...
MG>so launcher ingests revision property from System.getProperties()
MG> package org.codehaus.plexus.classworlds.launcher;
public class Configurator implements ConfigurationHandler
{
public void configure( InputStream is )
throws IOException, ConfigurationException, DuplicateRealmException,
NoSuchRealmException
{
if ( world == null )
{
world = new ClassWorld();
}
curRealm = null;
foreignClassLoader = null;
if ( this.launcher != null )
{
foreignClassLoader = this.launcher.getSystemClassLoader();
}
ConfigurationParser parser = new ConfigurationParser( this,
System.getProperties() );
MG>CLI seems to be obtaining properties properly..so far so good... but look
below:
> But now i want to make the usage a bit more convenient so i added the
> following to my pom:
>
>
> <properties>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> <revision>1.0-SNAPSHOT</revision>
> </properties>
>
> to have a default for revision which works fine now...
>
> But if i would like to overwrite the property from command line like this:
>
> mvn -Drevision=1.0 clean package
>
> the build failes in the following location:
>
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single (assemblies)
> on project assembly: Failed to create assembly: Unable to resolve
> dependencies for assembly 'archive': Failed to resolve dependencies for
> assembly: Unable to get dependency information for
> com.soebes.examples.j2ee:service-client:jar:1.0-SNAPSHOT: Failed to
> process POM for
> com.soebes.examples.j2ee:service-client:jar:1.0-SNAPSHOT: Non-resolvable
> parent POM for
> com.soebes.examples.j2ee:service-client:[unknown-version]: Failure to
> find com.soebes.examples.j2ee:parent:pom:${revision} in
> http://localhost:8081/nexus/content/groups/public was cached in the
> local repository, resolution will not be reattempted until the update
> interval of nexus has elapsed or updates are forced
> [ERROR] com.soebes.examples.j2ee:service-client:jar:1.0-SNAPSHOT
>
> The project is available on github
> (https://github.com/khmarbaise/javaee/tree/mvn321)....
>
> So the question which is coming up...is this based on Maven core or is
> this based on maven-assembly-plugin ?
MG>but in Maven-core :
MG>org.apache.maven.plugin
MG>public class PluginParameterExpressionEvaluator implements
TypeAwareExpressionEvaluator
MG>@Override
MG>public Object evaluate( String expr, Class<?> type ) throws
ExpressionEvaluationException
MG>....
MG>if ( value == null )
{
// The CLI should win for defining properties
if ( properties != null )
{
// We will attempt to get nab a system property as a way to
specify a
// parameter to a plugins. My particular case here is allowing
the surefire
// plugin to run a single test so I want to specify that class
on the cli
// as a parameter.
value = properties.getProperty( expression );
}
if ( ( value == null ) && ( ( project != null ) && (
project.getProperties() != null ) ) )
{
value = project.getProperties().getProperty( expression );
}
}
MG>so it appears CLI is supposed to win over any properties defined within
project pom.xml
MG>but CLI implementation becomes inconsistent when project properties has
version already defined in project pom.xml
MG>behaviour resulting from object graph produced by the reactor from CLI
properties appears to be undefined and ultimately causes Exception
MG>I think you found a Bug Karl
>
> Kind regards
> Karl Heinz Marbaise
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>