diff options
author | Joakim Erdfelt <joakime@apache.org> | 2008-03-11 03:59:04 +0000 |
---|---|---|
committer | Joakim Erdfelt <joakime@apache.org> | 2008-03-11 03:59:04 +0000 |
commit | adb4a8a7e4b0c0c57cb8db193c7c08246fa0624d (patch) | |
tree | 07c5cc7cb615197a7d70214328b23b030e6f29de /archiva-base/archiva-repository-layer/src | |
parent | 2697769fb1c389cbda7b820b09b9128e5e9d7ccb (diff) | |
download | archiva-adb4a8a7e4b0c0c57cb8db193c7c08246fa0624d.tar.gz archiva-adb4a8a7e4b0c0c57cb8db193c7c08246fa0624d.zip |
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
Diffstat (limited to 'archiva-base/archiva-repository-layer/src')
3 files changed, 27 insertions, 8 deletions
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 @@ <prj.confluence.path>TEST/Archiva</prj.confluence.path> </properties> - <url>${kb.site.url}/${prj.url.relative}</url> + <!-- MRM-731 : variable in url pom are not replaced. --> + <url>http://j.random.server.com/docs/${project.groupId}/${project.artifactId}/${project.version}</url> <scm> <connection>scm:svn:${prj.svn}/${prj.svn.branch}</connection> |