[
https://issues.apache.org/jira/browse/MNG-5895?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15360499#comment-15360499
]
Karl Heinz Marbaise commented on MNG-5895:
------------------------------------------
The {{DefaultModelBuilder}} contains a private method:
{code:java}
private Model interpolateModel( Model model, ModelBuildingRequest request,
ModelProblemCollector problems )
{
// save profile activations before interpolation, since they are
evaluated with limited scope
Map<String, Activation> originalActivations = getProfileActivations(
model, true );
Model result = modelInterpolator.interpolateModel( model,
model.getProjectDirectory(), request, problems );
..
}
which interpolates the usual part of the model but leaves the parent entry
untouched. A short PoC hack showed me that If i do something like this (HACK
for testing purposes only):
{code:java}
private Model interpolateModel( Model model, ModelBuildingRequest request,
ModelProblemCollector problems )
{
// save profile activations before interpolation, since they are
evaluated with limited scope
Map<String, Activation> originalActivations = getProfileActivations(
model, true );
Model result = modelInterpolator.interpolateModel( model,
model.getProjectDirectory(), request, problems );
if (result.getParent() != null) {
String version = result.getParent().getVersion();
if (version != null) {
//FIXME: Hack First (WILL NOT WORK in all cases!!!!)
if (version.contains( "${revision}" )) {
String property = request.getUserProperties().getProperty(
"revision");
result.getParent().setVersion( property );
}
if (version.contains( "${changelist}" )) {
String property = request.getUserProperties().getProperty(
"changelist");
result.getParent().setVersion( property );
}
if (version.contains( "${sha1}" )) {
String property = request.getUserProperties().getProperty(
"sha1");
result.getParent().setVersion( property );
}
}
}
result.setPomFile( model.getPomFile() );
// restore profiles with file activation to their value before full
interpolation
injectProfileActivations( model, originalActivations );
return result;
}
{code}
This shows that the ordering problem in the reactor is solved with this HACK
(limited use case).
The above also fixes the problem using the command line to override the
{{revision}} property from command line and fixes the
issue related to maven-assembly-plugin to produce the correct versioned
artifacts. So now i need to find a more elegant way to do that same...
> Problem with CI friendly usage of ${..} which is already defined via property
> in pom file.
> ------------------------------------------------------------------------------------------
>
> Key: MNG-5895
> URL: https://issues.apache.org/jira/browse/MNG-5895
> Project: Maven
> Issue Type: Bug
> Affects Versions: 3.2.1, 3.2.2, 3.2.5, 3.3.1, 3.3.3
> Reporter: Karl Heinz Marbaise
> Attachments: x.diff
>
>
> I have test project where i defined the pom like this:
> {code:xml}
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.soebes.examples.j2ee</groupId>
> <artifactId>parent</artifactId>
> <version>${revision}</version>
> <packaging>pom</packaging>
> {code}
> 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:
> {code:xml}
> <properties>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> <revision>1.0-SNAPSHOT</revision>
> </properties>
> {code}
> 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:
> {noformat}
> [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
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)