From ee7a83da1deefb4dd406d7becc87cd00244b6dd4 Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Thu, 19 Mar 2009 06:14:43 +0000 Subject: [PATCH] [MRM-731] submitted by Jan Ancajas o fix project properties being left out during cloning of the archivaProject (with unit test) git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@755846 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva/model/ArchivaModelCloner.java | 1 + .../EffectiveProjectModelFilterTest.java | 61 +++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/ArchivaModelCloner.java b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/ArchivaModelCloner.java index b77840150..a4bfed13b 100644 --- a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/ArchivaModelCloner.java +++ b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/ArchivaModelCloner.java @@ -65,6 +65,7 @@ public class ArchivaModelCloner cloned.setPlugins( clonePlugins( model.getPlugins() ) ); cloned.setReports( cloneReports( model.getReports() ) ); cloned.setDependencyManagement( cloneDependencies( model.getDependencyManagement() ) ); + cloned.setProperties( clone(model.getProperties() ) ); return cloned; } diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilterTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilterTest.java index aa4ec3513..fae996e6f 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilterTest.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilterTest.java @@ -158,6 +158,67 @@ public class EffectiveProjectModelFilterTest effectiveModel.getVersion() ); } } + + /* + * Test before and after the properties are evaluated. pom snippet: 2.0.5 + * 1.0-beta-2 1.0-alpha-10-SNAPSHOT + */ + public void testEffectiveProjectProperty() + throws Exception + { + initTestResolverFactory(); + EffectiveProjectModelFilter filter = lookupEffective(); + + String pomFile = "/org/apache/maven/archiva/archiva/1.0-SNAPSHOT/archiva-1.0-SNAPSHOT.pom"; + ArchivaProjectModel startModel = createArchivaProjectModel( DEFAULT_REPOSITORY + pomFile ); + + String plexusSecurityVersion = "1.0-alpha-10-SNAPSHOT"; + String wagonVersion = "1.0-beta-2"; + + boolean passedPlexusVersionChecking = false; + boolean passedWagonVersionChecking = false; + + List startDeps = startModel.getDependencyManagement(); + for ( Dependency startDep : startDeps ) + { + if ( "org.codehaus.plexus.security".equals( startDep.getGroupId() ) ) + { + assertEquals( startDep.getVersion(), "${plexus-security.version}" ); + } + else if ( "org.apache.maven.wagon".equals( startDep.getGroupId() ) ) + { + assertEquals( startDep.getVersion(), "${wagon.version}" ); + } + } + + ArchivaProjectModel effectiveModel = filter.filter( startModel ); + + List effectiveDeps = effectiveModel.getDependencyManagement(); + for ( Dependency dependency : effectiveDeps ) + { + if ( "org.codehaus.plexus.security".equals( dependency.getGroupId() ) ) + { + assertEquals( dependency.getVersion(), plexusSecurityVersion ); + + if ( !passedPlexusVersionChecking ) + { + passedPlexusVersionChecking = true; + } + } + else if ( "org.apache.maven.wagon".equals( dependency.getGroupId() ) ) + { + assertEquals( dependency.getVersion(), wagonVersion ); + + if ( !passedWagonVersionChecking ) + { + passedWagonVersionChecking = true; + } + } + + } + assertTrue( passedPlexusVersionChecking ); + assertTrue( passedWagonVersionChecking ); + } private ProjectModelResolverFactory initTestResolverFactory() throws Exception -- 2.39.5