]> source.dussan.org Git - archiva.git/commitdiff
[MRM-731] variable in url pom are not replaced.
authorJoakim Erdfelt <joakime@apache.org>
Thu, 6 Mar 2008 17:40:26 +0000 (17:40 +0000)
committerJoakim Erdfelt <joakime@apache.org>
Thu, 6 Mar 2008 17:40:26 +0000 (17:40 +0000)
* Added test case outlined in JIRA.
* Fixed filter for ${pom.*} and ${project.*} expression expansion.

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@634361 13f79535-47bb-0310-9956-ffa450edef68

archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionFilter.java
archiva-1.0.x/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionExpanderTest.java
archiva-1.0.x/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 22b5ae055155f18c318ccce9227cd44bc601fc5a..1c2f989ba4271cd2898ab5bc4d7143517d56f9db 100644 (file)
@@ -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() ) );
index e9c0ec84f5f6a176731d379de481e184096291cb..ead2863466e5a7df77bbf4d7e3fbc18b53a94800 100644 (file)
@@ -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)" );
         }
     }
 
index a6707223ef7f321a6ce792d6332dc944180571bc..ca115b5058f834dadc8d576f84e6d32c577f9d73 100644 (file)
                <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>