From: Joakim Erdfelt Date: Tue, 11 Mar 2008 03:59:04 +0000 (+0000) Subject: MRM-731 - variable in url pom are not replaced. X-Git-Tag: archiva-r676265~321 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=adb4a8a7e4b0c0c57cb8db193c7c08246fa0624d;p=archiva.git MRM-731 - variable in url pom are not replaced. Applying same fix as in branch/archiva-1.0.x git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@635795 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionFilter.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionFilter.java index 22b5ae055..1c2f989ba 100644 --- a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionFilter.java +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionFilter.java @@ -104,11 +104,23 @@ public class ProjectModelExpressionFilter try { // Setup some common properties. - props.setProperty( "pom.groupId", StringUtils.defaultString( evaluator.expand( model.getGroupId() ) ) ); - props.setProperty( "pom.artifactId", StringUtils.defaultString( evaluator - .expand( model.getArtifactId() ) ) ); - props.setProperty( "pom.version", StringUtils.defaultString( evaluator.expand( model.getVersion() ) ) ); - props.setProperty( "pom.name", StringUtils.defaultString( evaluator.expand( model.getName() ) ) ); + String groupId = StringUtils.defaultString( evaluator.expand( model.getGroupId() ) ); + String artifactId = StringUtils.defaultString( evaluator.expand( model.getArtifactId() ) ); + String version = StringUtils.defaultString( evaluator.expand( model.getVersion() ) ); + String name = StringUtils.defaultString( evaluator.expand( model.getName() ) ); + + /* Archiva doesn't need to handle a full expression language with object tree walking + * as the requirements within Archiva are much smaller, a quick replacement of the + * important fields (groupId, artifactId, version, name) are handled specifically. + */ + props.setProperty( "pom.groupId", groupId ); + props.setProperty( "pom.artifactId", artifactId ); + props.setProperty( "pom.version", version ); + props.setProperty( "pom.name", name ); + props.setProperty( "project.groupId", groupId ); + props.setProperty( "project.artifactId", artifactId ); + props.setProperty( "project.version", version ); + props.setProperty( "project.name", name ); // Evaluate everything. ret.setVersion( evaluator.expand( ret.getVersion() ) ); diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionExpanderTest.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionExpanderTest.java index e9c0ec84f..ead286346 100644 --- a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionExpanderTest.java +++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionExpanderTest.java @@ -91,7 +91,7 @@ public class ProjectModelExpressionExpanderTest assertEquals( "Dependency [" + dep.getArtifactId() + "] Version", "1.0-SNAPSHOT", dep.getVersion() ); } } - + /** * [MRM-487] pom version is not resolved * [MRM-488] properties in pom are not resolved (at least while browsing) @@ -112,10 +112,16 @@ public class ProjectModelExpressionExpanderTest String evaluatedModelText = toModelText( filteredModel ); // Test xml buffer for the existance of an unevaluated expression. + boolean foundUnevaluated = false; if ( evaluatedModelText.indexOf( "${" ) != ( -1 ) ) { System.err.println( "Found Expression:\n" + evaluatedModelText ); - fail( "Found Unevaluated Expression. (see System.err)" ); + foundUnevaluated = true; + } + + if ( foundUnevaluated ) + { + fail( "Found Unevaluated Expression. (see System.err for details)" ); } } diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/2.0.4-SNAPSHOT/test-2.0.4-SNAPSHOT.pom b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/2.0.4-SNAPSHOT/test-2.0.4-SNAPSHOT.pom index a6707223e..ca115b505 100644 --- a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/2.0.4-SNAPSHOT/test-2.0.4-SNAPSHOT.pom +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/2.0.4-SNAPSHOT/test-2.0.4-SNAPSHOT.pom @@ -102,7 +102,8 @@ TEST/Archiva - ${kb.site.url}/${prj.url.relative} + + http://j.random.server.com/docs/${project.groupId}/${project.artifactId}/${project.version} scm:svn:${prj.svn}/${prj.svn.branch}