Re: Using ${revision} as a version
I have painfully noted that the currently only [properly] working way is to use profiles to switch between values given on the command line and some type of default value (given in another profile). Typically, it takes on the pattern/form as shown below - and it would be really nice not to have to resort to these kinds of things. Instead, it would be cleaner if these types of profile workaround patterns would not be needed, instead simply overriding a property from the CLI. Question, though: Would overriding properties from the CLI in some way be contradictory to the requirement of a repeatable build? tokenization_development !target_environment development ${token.dir}/environments/${target_environment}.properties tokenization_test target_environment test test ${token.dir}/environments/${target_environment}.properties 2015-09-26 22:46 GMT+02:00 Karl Heinz Marbaise : > Hi, > > so after diving into this problem... ( > https://issues.apache.org/jira/browse/MNG-5895)... > > I have found the culprit (in my opinion) at Maven-assembly-plugin located > in this class DefaultDependencyResolver: > > at the following method: > > > private Set resolveTransitively( > final Set dependencyArtifacts, > final List repos, > final ResolutionManagementInfo info, > final AssemblerConfigurationSource configSource ) > throws DependencyResolutionException > { > final MavenProject project = configSource.getProject(); > > final ArtifactFilter filter = info.getScopeFilter(); > > ArtifactResolutionRequest req = new ArtifactResolutionRequest(); > req.setLocalRepository( configSource.getLocalRepository() ); > req.setResolveRoot( false ); > req.setRemoteRepositories( repos ); > req.setResolveTransitively( true ); > req.setArtifact( project.getArtifact() ); > req.setArtifactDependencies( dependencyArtifacts ); > req.setManagedVersionMap( project.getManagedVersionMap() ); > req.setCollectionFilter( filter ); > req.setOffline( configSource.getMavenSession().isOffline() ); > req.setForceUpdate( > configSource.getMavenSession().getRequest().isUpdateSnapshots() ); > req.setServers( > configSource.getMavenSession().getRequest().getServers() ); > req.setMirrors( > configSource.getMavenSession().getRequest().getMirrors() ); > req.setProxies( > configSource.getMavenSession().getRequest().getProxies() ); > > ArtifactResolutionResult result; > > result = resolver.resolve( req ); > if ( result.hasExceptions() ) > { > throw new DependencyResolutionException( "Failed to resolve > dependencies for assembly: ", > > result.getExceptions().get( 0 ) ); > } > > FilterUtils.reportFilteringStatistics( Collections.singleton( > filter ), getLogger() ); > > return result.getArtifacts(); > } > > > > And the identified line is: > > result = resolver.resolve( req ); > > which fails to find the appropriate dependencies...or better the wrong > version of the dependencies > > > So I'm not sure at the moment if this is based on Maven 2 compatibility of > maven-assembly-plugin or if there is an other issue in there or I'm just > simply wrong... > > WDYT ? > > > Kind regards > Karl Heinz Marbaise > > > > On 8/23/15 5:16 PM, Karl Heinz Marbaise wrote: > >> Hi, >> >> I have test project where i defined the pom like this: >> >> ... >>4.0.0 >> >>com.soebes.examples.j2ee >>parent >>${revision} >>pom >> >> If i define the revision on command line like this. >> >> mvn -Drevision=1.0-SNAPSHOT clean package >> >> everything fine... >> >> But now i want to make the usage a bit more convenient so i added the >> following to my pom: >> >> >> >> UTF-8 >> 1.0-SNAPSHOT >> >> >> 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
Re: Using ${revision} as a version
Hi, so after diving into this problem... (https://issues.apache.org/jira/browse/MNG-5895)... I have found the culprit (in my opinion) at Maven-assembly-plugin located in this class DefaultDependencyResolver: at the following method: private Set resolveTransitively( final Set dependencyArtifacts, final List repos, final ResolutionManagementInfo info, final AssemblerConfigurationSource configSource ) throws DependencyResolutionException { final MavenProject project = configSource.getProject(); final ArtifactFilter filter = info.getScopeFilter(); ArtifactResolutionRequest req = new ArtifactResolutionRequest(); req.setLocalRepository( configSource.getLocalRepository() ); req.setResolveRoot( false ); req.setRemoteRepositories( repos ); req.setResolveTransitively( true ); req.setArtifact( project.getArtifact() ); req.setArtifactDependencies( dependencyArtifacts ); req.setManagedVersionMap( project.getManagedVersionMap() ); req.setCollectionFilter( filter ); req.setOffline( configSource.getMavenSession().isOffline() ); req.setForceUpdate( configSource.getMavenSession().getRequest().isUpdateSnapshots() ); req.setServers( configSource.getMavenSession().getRequest().getServers() ); req.setMirrors( configSource.getMavenSession().getRequest().getMirrors() ); req.setProxies( configSource.getMavenSession().getRequest().getProxies() ); ArtifactResolutionResult result; result = resolver.resolve( req ); if ( result.hasExceptions() ) { throw new DependencyResolutionException( "Failed to resolve dependencies for assembly: ", result.getExceptions().get( 0 ) ); } FilterUtils.reportFilteringStatistics( Collections.singleton( filter ), getLogger() ); return result.getArtifacts(); } And the identified line is: result = resolver.resolve( req ); which fails to find the appropriate dependencies...or better the wrong version of the dependencies So I'm not sure at the moment if this is based on Maven 2 compatibility of maven-assembly-plugin or if there is an other issue in there or I'm just simply wrong... WDYT ? Kind regards Karl Heinz Marbaise On 8/23/15 5:16 PM, Karl Heinz Marbaise wrote: Hi, I have test project where i defined the pom like this: ... 4.0.0 com.soebes.examples.j2ee parent ${revision} pom If i define the revision on command line like this. mvn -Drevision=1.0-SNAPSHOT clean package everything fine... But now i want to make the usage a bit more convenient so i added the following to my pom: UTF-8 1.0-SNAPSHOT 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 ? Kind regards Karl Heinz Marbaise - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org
RE: Using ${revision} as a version
> Date: Sun, 23 Aug 2015 17:16:07 +0200 > From: khmarba...@gmx.de > To: dev@maven.apache.org > Subject: Using ${revision} as a version > > Hi, > > I have test project where i defined the pom like this: > > ... >4.0.0 > >com.soebes.examples.j2ee >parent >${revision} >pom > > 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: > > > > UTF-8 > 1.0-SNAPSHOT > > > 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 PluginParameterExpressionEvaluatorimplements 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: dev-unsubscr...@maven.apache.org > For additional commands, e-mail: dev-h...@maven.apache.org >