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 profile for Development builds.
Use: -Dtarget_environment=development
-->
<profile>
<id>tokenization_development</id>
<activation>
<property>
<name>!target_environment</name>
</property>
</activation>
<properties>
<target_environment>development</target_environment>
<tokens.environment>${token.dir}/environments/${target_environment}.properties</tokens.environment>
</properties>
</profile>
<!--
Tokenization profile for Test builds.
Use: -Dtarget_environment=test
-->
<profile>
<id>tokenization_test</id>
<activation>
<property>
<name>target_environment</name>
<value>test</value>
</property>
</activation>
<properties>
<target_environment>test</target_environment>
<tokens.environment>${token.dir}/environments/${target_environment}.properties</tokens.environment>
</properties>
</profile>
2015-09-26 22:46 GMT+02:00 Karl Heinz Marbaise <[email protected]>:
> 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<Artifact> resolveTransitively(
> final Set<Artifact> dependencyArtifacts,
> final List<ArtifactRepository> 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:
>>
>> ...
>> <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...
>>
>> 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 ?
>>
>> Kind regards
>> Karl Heinz Marbaise
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
--
--
+==============================+
| Bästa hälsningar,
| [sw. "Best regards"]
|
| Lennart Jörelid
| EAI Architect & Integrator
|
| jGuru Europe AB
| Mölnlycke - Kista
|
| Email: [email protected]
| URL: www.jguru.se
| Phone
| (skype): jgurueurope
| (intl): +46 708 507 603
| (domestic): 0708 - 507 603
+==============================+