diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
index 13184933f3..8da1f8a1f7 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
@@ -238,9 +238,9 @@ public class PluginParameterExpressionEvaluator
// Check properties that have been injected via profiles before we default over to
// system properties.
- if ( project.getProfileProperties() != null )
+ if ( project.getProperties() != null )
{
- value = project.getProfileProperties().getProperty( expression );
+ value = project.getProperties().getProperty( expression );
}
if ( value == null )
diff --git a/maven-model/maven.mdo b/maven-model/maven.mdo
index 14a34cf543..4bc6bb567d 100644
--- a/maven-model/maven.mdo
+++ b/maven-model/maven.mdo
@@ -682,6 +682,18 @@
DistributionManagement
+
+ properties
+ 4.0.0
+
+ Properties
+
+ String
+ *
+
+
@@ -2563,18 +2575,6 @@
BuildBase
-
- properties
- 4.0.0
-
- Properties
-
- String
- *
-
-
diff --git a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
index bc6d3ab1cb..a12dfd6051 100644
--- a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
+++ b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
@@ -85,7 +85,6 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import java.util.Set;
/**
@@ -433,16 +432,12 @@ public class DefaultMavenProjectBuilder
List activeProfiles;
- Properties profileProperties = new Properties();
-
superProjectProfileManager.addProfiles( superModel.getProfiles() );
- activeProfiles = injectActiveProfiles( superProjectProfileManager, superModel, profileProperties );
+ activeProfiles = injectActiveProfiles( superProjectProfileManager, superModel );
MavenProject superProject = new MavenProject( superModel );
- superProject.addProfileProperties( profileProperties );
-
superProject.setActiveProfiles( activeProfiles );
//noinspection CollectionDeclaredAsConcreteClass
@@ -558,13 +553,6 @@ public class DefaultMavenProjectBuilder
modelCache.put( key, model );
}
- Properties profileProperties = project.getProfileProperties();
-
- if ( profileProperties == null )
- {
- profileProperties = new Properties();
- }
-
List activeProfiles = project.getActiveProfiles();
if ( activeProfiles == null )
@@ -572,7 +560,7 @@ public class DefaultMavenProjectBuilder
activeProfiles = new ArrayList();
}
- List injectedProfiles = injectActiveProfiles( profileMgr, model, profileProperties );
+ List injectedProfiles = injectActiveProfiles( profileMgr, model );
activeProfiles.addAll( injectedProfiles );
@@ -610,10 +598,6 @@ public class DefaultMavenProjectBuilder
project.setActiveProfiles( activeProfiles );
- project.addProfileProperties( profileProperties );
-
- project.assembleProfilePropertiesInheritance();
-
// TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
Artifact projectArtifact = artifactFactory.createBuildArtifact( project.getGroupId(), project.getArtifactId(),
project.getVersion(), project.getPackaging() );
@@ -692,15 +676,13 @@ public class DefaultMavenProjectBuilder
List activeProfiles;
- Properties profileProperties = new Properties();
-
try
{
profileManager.addProfiles( model.getProfiles() );
loadProjectExternalProfiles( profileManager, projectDir );
- activeProfiles = injectActiveProfiles( profileManager, model, profileProperties );
+ activeProfiles = injectActiveProfiles( profileManager, model );
}
catch ( ProfileActivationException e )
{
@@ -709,8 +691,6 @@ public class DefaultMavenProjectBuilder
MavenProject project = new MavenProject( model );
- project.addProfileProperties( profileProperties );
-
project.setActiveProfiles( activeProfiles );
lineage.addFirst( project );
@@ -819,7 +799,7 @@ public class DefaultMavenProjectBuilder
return project;
}
- private List injectActiveProfiles( ProfileManager profileManager, Model model, Properties profileProperties )
+ private List injectActiveProfiles( ProfileManager profileManager, Model model )
throws ProjectBuildingException
{
List activeProfiles;
@@ -840,8 +820,6 @@ public class DefaultMavenProjectBuilder
Profile profile = (Profile) it.next();
profileInjector.inject( profile, model );
-
- profileProperties.putAll( profile.getProperties() );
}
}
else
@@ -1106,16 +1084,12 @@ public class DefaultMavenProjectBuilder
List activeProfiles;
- Properties profileProperties = new Properties();
-
profileManager.addProfiles( superModel.getProfiles() );
- activeProfiles = injectActiveProfiles( profileManager, superModel, profileProperties );
+ activeProfiles = injectActiveProfiles( profileManager, superModel );
MavenProject project = new MavenProject( superModel );
- project.addProfileProperties( profileProperties );
-
project.setActiveProfiles( activeProfiles );
project.setOriginalModel( superModel );
diff --git a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
index 15212a76c6..6b85fdd2d3 100644
--- a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
+++ b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
@@ -61,7 +61,6 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import java.util.Stack;
/**
* The concern of the project is provide runtime values based on the model.
@@ -92,8 +91,6 @@ public class MavenProject
private List remoteArtifactRepositories;
- private Properties profileProperties = new Properties();
-
private List collectedProjects = Collections.EMPTY_LIST;
private List attachedArtifacts;
@@ -174,8 +171,6 @@ public class MavenProject
this.testCompileSourceRoots = new ArrayList( project.testCompileSourceRoots );
this.scriptSourceRoots = new ArrayList( project.scriptSourceRoots );
- this.profileProperties = new Properties( project.profileProperties );
-
this.model = ModelUtils.cloneModel( project.model );
if ( project.originalModel != null )
@@ -603,6 +598,97 @@ public class MavenProject
return list;
}
+ public List getSystemClasspathElements()
+ throws DependencyResolutionRequiredException
+ {
+ List list = new ArrayList( getArtifacts().size() );
+
+ list.add( getBuild().getOutputDirectory() );
+
+ for ( Iterator i = getArtifacts().iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+
+ if ( isAddedToClasspath( a ) )
+ {
+ // TODO: let the scope handler deal with this
+ if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) )
+ {
+ String refId = getProjectReferenceId( a.getGroupId(), a.getArtifactId() );
+ MavenProject project = (MavenProject) projectReferences.get( refId );
+ if ( project != null )
+ {
+ list.add( project.getBuild().getOutputDirectory() );
+ }
+ else
+ {
+ File file = a.getFile();
+ if ( file == null )
+ {
+ throw new DependencyResolutionRequiredException( a );
+ }
+ list.add( file.getPath() );
+ }
+ }
+ }
+ }
+ return list;
+ }
+
+ public List getSystemArtifacts()
+ {
+ List list = new ArrayList( getArtifacts().size() );
+
+ for ( Iterator i = getArtifacts().iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+
+ // TODO: classpath check doesn't belong here - that's the other method
+ if ( isAddedToClasspath( a ) )
+ {
+ // TODO: let the scope handler deal with this
+ if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) )
+ {
+ list.add( a );
+ }
+ }
+ }
+ return list;
+ }
+
+ public List getSystemDependencies()
+ {
+ Set artifacts = getArtifacts();
+
+ if ( artifacts == null || artifacts.isEmpty() )
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ List list = new ArrayList( artifacts.size() );
+
+ for ( Iterator i = getArtifacts().iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+
+ // TODO: let the scope handler deal with this
+ if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) )
+ {
+ Dependency dependency = new Dependency();
+
+ dependency.setArtifactId( a.getArtifactId() );
+ dependency.setGroupId( a.getGroupId() );
+ dependency.setVersion( a.getVersion() );
+ dependency.setScope( a.getScope() );
+ dependency.setType( a.getType() );
+ dependency.setClassifier( a.getClassifier() );
+
+ list.add( dependency );
+ }
+ }
+ return list;
+ }
+
private static boolean isAddedToClasspath( Artifact artifact )
{
String type = artifact.getType();
@@ -1071,14 +1157,20 @@ public class MavenProject
return model.getPluginRepositories();
}
+ /**
+ * @deprecated use getProperties() instead
+ */
public Properties getProfileProperties()
{
- return profileProperties;
+ return getProperties();
}
+ /**
+ * @deprecated should add properties to the model instead
+ */
public void addProfileProperties( Properties profileConfiguration )
{
- this.profileProperties.putAll( profileConfiguration );
+ getProperties().putAll( profileConfiguration );
}
public void setActiveProfiles( List activeProfiles )
@@ -1328,35 +1420,13 @@ public class MavenProject
return groupId + ":" + artifactId;
}
- public void assembleProfilePropertiesInheritance()
- {
- Stack propertyStack = new Stack();
-
- MavenProject current = this;
- while ( current != null )
- {
- Properties toAdd = current.profileProperties;
-
- if ( toAdd != null && !toAdd.isEmpty() )
- {
- propertyStack.push( toAdd );
- }
-
- current = current.getParent();
- }
-
- Properties newProfilesProperties = new Properties();
-
- while ( !propertyStack.isEmpty() )
- {
- newProfilesProperties.putAll( (Properties) propertyStack.pop() );
- }
-
- this.profileProperties = newProfilesProperties;
- }
-
public void attachArtifact( String type, String classifier, File file )
{
}
+ public Properties getProperties()
+ {
+ return getModel().getProperties();
+ }
+
}
diff --git a/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java b/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
index 6994adcdee..9032f654ba 100644
--- a/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
+++ b/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
@@ -34,6 +34,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.TreeMap;
public final class ModelUtils
@@ -465,10 +466,12 @@ public final class ModelUtils
newModel.setParent( cloneParent( model.getParent() ) );
newModel.setVersion( model.getVersion() );
newModel.setArtifactId( model.getArtifactId() );
+ newModel.setProperties( new Properties( model.getProperties() ) );
newModel.setGroupId( model.getGroupId() );
newModel.setPackaging( model.getPackaging() );
newModel.setModules( cloneModules( model.getModules() ) );
assembler.copyModel( newModel, model );
+
return newModel;
}
diff --git a/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java b/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
index e3e328e6a5..df03f6b185 100644
--- a/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
+++ b/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
@@ -35,6 +35,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.TreeMap;
/**
@@ -172,6 +173,12 @@ public class DefaultModelInheritanceAssembler
assembleDependencyManagementInheritance( child, parent );
assembleDistributionManagementInheritance( child, parent );
+
+ Properties props = new Properties();
+ props.putAll( parent.getProperties() );
+ props.putAll( child.getProperties() );
+
+ child.setProperties( props );
}
private void assembleDistributionManagementInheritance( Model child, Model parent )
diff --git a/maven-project/src/main/java/org/apache/maven/project/injection/DefaultProfileInjector.java b/maven-project/src/main/java/org/apache/maven/project/injection/DefaultProfileInjector.java
index 9e114d0da2..2aaed88818 100644
--- a/maven-project/src/main/java/org/apache/maven/project/injection/DefaultProfileInjector.java
+++ b/maven-project/src/main/java/org/apache/maven/project/injection/DefaultProfileInjector.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.TreeMap;
/**
@@ -61,6 +62,12 @@ public class DefaultProfileInjector
injectDistributionManagement( profile, model );
injectBuild( profile, model );
+
+ Properties props = new Properties();
+ props.putAll( model.getProperties() );
+ props.putAll( profile.getProperties() );
+
+ model.setProperties( props );
}
private void injectBuild( Profile profile, Model model )
diff --git a/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java b/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java
index 72c59644d6..fd213d477f 100644
--- a/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java
+++ b/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java
@@ -104,6 +104,11 @@ public class RegexBasedModelInterpolator
{
value = ReflectionValueExtractor.evaluate( realExpr, model );
}
+
+ if ( value == null )
+ {
+ value = model.getProperties().getProperty( realExpr );
+ }
}
catch ( Exception e )
{