mirror of https://github.com/apache/maven.git
Fixed problems with merging profile-defined properties into the project, and fixed the ITs testing profile definitions in the process.
This should finally resolve MNG-421 git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@189768 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2ab04f7c84
commit
8a257be6fc
|
@ -20,5 +20,5 @@ it0018
|
|||
it0019
|
||||
it0020
|
||||
it0021
|
||||
#it0022
|
||||
#it0023
|
||||
it0022
|
||||
it0023
|
||||
|
|
|
@ -1 +1 @@
|
|||
target/classes/org/apache/maven/it0022/test.txt
|
||||
target/test.txt
|
||||
|
|
|
@ -1 +1 @@
|
|||
package
|
||||
core-it:touch
|
|
@ -4,23 +4,21 @@
|
|||
<artifactId>maven-it0022</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<artifactId>maven-core-it-plugin</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<configuration>
|
||||
<test>${test}</test>
|
||||
<pluginItem>${test}</pluginItem>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-projecthelp-plugin</artifactId>
|
||||
<version>2.0-alpha-3-SNAPSHOT</version>
|
||||
</plugin -->
|
||||
</plugins>
|
||||
</build>
|
||||
</model>
|
||||
</model>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</activation>
|
||||
|
||||
<properties>
|
||||
<test>**/SomeAddTest*</test>
|
||||
<test>test.txt</test>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
package org.apache.maven.it0022;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
public class SomeAddTest
|
||||
extends TestCase
|
||||
{
|
||||
|
||||
public void testAdd() throws Exception
|
||||
{
|
||||
String className = Person.class.getName().replace( '.', '/' ) + ".class";
|
||||
|
||||
URL resource = Person.class.getClassLoader().getResource( className );
|
||||
|
||||
File personFile = new File( resource.getPath() ).getAbsoluteFile();
|
||||
File dir = personFile.getParentFile();
|
||||
|
||||
File testFile = new File( dir, "test.txt" );
|
||||
|
||||
FileWriter writer = new FileWriter( testFile );
|
||||
writer.write("this is a test");
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package org.apache.maven.it0022;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
public class SomeRemoveTest
|
||||
extends TestCase
|
||||
{
|
||||
|
||||
public void testRemove()
|
||||
{
|
||||
String className = Person.class.getName().replace( '.', '/' ) + ".class";
|
||||
|
||||
URL resource = Person.class.getClassLoader().getResource( className );
|
||||
|
||||
File personFile = new File( resource.getPath() ).getAbsoluteFile();
|
||||
File dir = personFile.getParentFile();
|
||||
|
||||
File testFile = new File( dir, "test.txt" );
|
||||
|
||||
if( testFile.exists() )
|
||||
{
|
||||
testFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1 +1 @@
|
|||
target/classes/org/apache/maven/it0023/test.txt
|
||||
target/test.txt
|
||||
|
|
|
@ -1 +1 @@
|
|||
package
|
||||
core-it:touch
|
|
@ -4,23 +4,21 @@
|
|||
<artifactId>maven-it0023</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<artifactId>maven-core-it-plugin</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<configuration>
|
||||
<test>${test}</test>
|
||||
<pluginItem>${test}</pluginItem>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-projecthelp-plugin</artifactId>
|
||||
<version>2.0-alpha-3-SNAPSHOT</version>
|
||||
</plugin -->
|
||||
</plugins>
|
||||
</build>
|
||||
</model>
|
||||
</model>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</activation>
|
||||
|
||||
<properties>
|
||||
<test>**/SomeAddTest*</test>
|
||||
<test>test.txt</test>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
package org.apache.maven.it0023;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
public class SomeAddTest
|
||||
extends TestCase
|
||||
{
|
||||
|
||||
public void testAdd() throws Exception
|
||||
{
|
||||
String className = Person.class.getName().replace( '.', '/' ) + ".class";
|
||||
|
||||
URL resource = Person.class.getClassLoader().getResource( className );
|
||||
|
||||
File personFile = new File( resource.getPath() ).getAbsoluteFile();
|
||||
File dir = personFile.getParentFile();
|
||||
|
||||
File testFile = new File( dir, "test.txt" );
|
||||
|
||||
FileWriter writer = new FileWriter( testFile );
|
||||
writer.write("this is a test");
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package org.apache.maven.it0023;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
public class SomeRemoveTest
|
||||
extends TestCase
|
||||
{
|
||||
|
||||
public void testRemove()
|
||||
{
|
||||
String className = Person.class.getName().replace( '.', '/' ) + ".class";
|
||||
|
||||
URL resource = Person.class.getClassLoader().getResource( className );
|
||||
|
||||
File personFile = new File( resource.getPath() ).getAbsoluteFile();
|
||||
File dir = personFile.getParentFile();
|
||||
|
||||
File testFile = new File( dir, "test.txt" );
|
||||
|
||||
if( testFile.exists() )
|
||||
{
|
||||
testFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -36,6 +36,8 @@ public final class ModelNormalizationUtils
|
|||
{
|
||||
Profile profile = new Profile();
|
||||
|
||||
profile.setId( settingsProfile.getId() );
|
||||
|
||||
profile.setSource( "settings.xml" );
|
||||
|
||||
org.apache.maven.settings.Activation settingsActivation = settingsProfile.getActivation();
|
||||
|
@ -59,8 +61,8 @@ public final class ModelNormalizationUtils
|
|||
}
|
||||
}
|
||||
|
||||
profile.addEvalProperties( settingsProfile.getProperties() );
|
||||
|
||||
profile.setProperties( settingsProfile.getProperties() );
|
||||
|
||||
List repos = settingsProfile.getRepositories();
|
||||
if ( repos != null )
|
||||
{
|
||||
|
@ -88,6 +90,8 @@ public final class ModelNormalizationUtils
|
|||
{
|
||||
Profile profile = new Profile();
|
||||
|
||||
profile.setId( profileXmlProfile.getId() );
|
||||
|
||||
profile.setSource( "profiles.xml" );
|
||||
|
||||
org.apache.maven.profiles.Activation profileActivation = profileXmlProfile.getActivation();
|
||||
|
@ -117,7 +121,7 @@ public final class ModelNormalizationUtils
|
|||
profile.setActivation( new AlwaysOnActivation() );
|
||||
}
|
||||
|
||||
profile.addEvalProperties( profileXmlProfile.getProperties() );
|
||||
profile.setProperties( profileXmlProfile.getProperties() );
|
||||
|
||||
List repos = profileXmlProfile.getRepositories();
|
||||
if ( repos != null )
|
||||
|
|
|
@ -135,11 +135,11 @@ public class PluginParameterExpressionEvaluator
|
|||
// Check properties that have been injected via profiles before we default over to
|
||||
// system properties.
|
||||
|
||||
if( context.getProject().getProfileConfiguration() != null )
|
||||
if( context.getProject().getProfileProperties() != null )
|
||||
{
|
||||
value = context.getProject().getProfileConfiguration().getProperty( expression );
|
||||
value = context.getProject().getProfileProperties().getProperty( expression );
|
||||
}
|
||||
|
||||
|
||||
if( value == null )
|
||||
{
|
||||
// We will attempt to get nab a system property as a way to specify a
|
||||
|
|
|
@ -664,24 +664,6 @@
|
|||
</association>
|
||||
</field>
|
||||
</fields>
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
<version>4.0.0</version>
|
||||
<code><![CDATA[
|
||||
private Properties evalProperties = new Properties();
|
||||
|
||||
public void addEvalProperties( Properties properties )
|
||||
{
|
||||
this.evalProperties.putAll( properties );
|
||||
}
|
||||
|
||||
public Properties getEvalProperties()
|
||||
{
|
||||
return evalProperties;
|
||||
}
|
||||
]]></code>
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
<!-- @todo: is any of this too CVS specific? Investigate other SCMs -->
|
||||
<class>
|
||||
|
@ -2328,6 +2310,7 @@
|
|||
// We don't want this to be parseable...it's sort of 'hidden'
|
||||
// default source for this profile is in the pom itself.
|
||||
private String source = "pom";
|
||||
private Properties properties = new Properties();
|
||||
|
||||
public void setSource( String source )
|
||||
{
|
||||
|
@ -2338,6 +2321,21 @@
|
|||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Profile {id: " + getId() + ", source: " + getSource() + "}";
|
||||
}
|
||||
|
||||
public void setProperties( Properties properties )
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public Properties getProperties()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
]]></code>
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
<plugin>
|
||||
<groupId>org.codehaus.modello</groupId>
|
||||
<artifactId>modello-maven-plugin</artifactId>
|
||||
<version>1.0-alpha-3-SNAPSHOT</version>
|
||||
<version>1.0-alpha-2</version>
|
||||
<!-- version>1.0-alpha-3-SNAPSHOT</version -->
|
||||
<configuration>
|
||||
<version>4.0.0</version>
|
||||
<model>maven.mdo</model>
|
||||
|
|
|
@ -67,6 +67,7 @@ import java.util.Iterator;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -283,22 +284,27 @@ public class DefaultMavenProjectBuilder
|
|||
modelCache.put( key, model );
|
||||
}
|
||||
|
||||
// TODO: Add profiles support here?
|
||||
List activeProfiles = new ArrayList( externalProfiles );
|
||||
|
||||
List activePomProfiles = profileActivationCalculator.calculateActiveProfiles( model.getProfiles() );
|
||||
|
||||
activeProfiles.addAll( activePomProfiles );
|
||||
|
||||
Properties profileProperties = new Properties();
|
||||
|
||||
for ( Iterator it = activeProfiles.iterator(); it.hasNext(); )
|
||||
{
|
||||
Profile profile = (Profile) it.next();
|
||||
|
||||
modelInheritanceAssembler.mergeProfileWithModel( model, profile );
|
||||
|
||||
profileProperties.putAll( profile.getProperties() );
|
||||
}
|
||||
|
||||
// TODO: Clean this up...we're using this to 'jump' the interpolation step for model properties not expressed in XML.
|
||||
|
||||
model = modelInterpolator.interpolate( model );
|
||||
|
||||
|
||||
// interpolation is before injection, because interpolation is off-limits in the injected variables
|
||||
modelDefaultsInjector.injectDefaults( model );
|
||||
|
||||
|
@ -306,7 +312,9 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
project = new MavenProject( model );
|
||||
|
||||
project.addActiveProfiles( activePomProfiles );
|
||||
project.addProfileProperties( profileProperties );
|
||||
|
||||
project.setActiveProfiles( activeProfiles );
|
||||
|
||||
project.setPluginArtifactRepositories( ProjectUtils.buildArtifactRepositories( model.getPluginRepositories(), artifactRepositoryFactory, container ) );
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public class MavenProject
|
|||
|
||||
private List remoteArtifactRepositories;
|
||||
|
||||
private Properties profileConfiguration;
|
||||
private Properties profileProperties = new Properties();
|
||||
|
||||
private List collectedProjects = Collections.EMPTY_LIST;
|
||||
|
||||
|
@ -891,17 +891,17 @@ public class MavenProject
|
|||
return model.getPluginRepositories();
|
||||
}
|
||||
|
||||
public Properties getProfileConfiguration()
|
||||
public Properties getProfileProperties()
|
||||
{
|
||||
return profileConfiguration;
|
||||
return profileProperties;
|
||||
}
|
||||
|
||||
public void addProfileConfiguration( Properties profileConfiguration )
|
||||
public void addProfileProperties( Properties profileConfiguration )
|
||||
{
|
||||
this.profileConfiguration = profileConfiguration;
|
||||
this.profileProperties.putAll( profileConfiguration );
|
||||
}
|
||||
|
||||
public void addActiveProfiles( List activeProfiles )
|
||||
public void setActiveProfiles( List activeProfiles )
|
||||
{
|
||||
this.activeProfiles.addAll( activeProfiles );
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ public class DefaultModelInheritanceAssembler
|
|||
public void mergeProfileWithModel( Model model, Profile profile )
|
||||
{
|
||||
assembleModelBaseInheritance( model, profile );
|
||||
|
||||
|
||||
assembleBuildBaseInheritance( model.getBuild(), profile.getBuild() );
|
||||
}
|
||||
|
||||
|
@ -221,9 +221,6 @@ public class DefaultModelInheritanceAssembler
|
|||
}
|
||||
|
||||
assembleDependencyManagementInheritance( child, parent );
|
||||
|
||||
// Evaluation Properties :: aggregate
|
||||
child.addEvalProperties( parent.getEvalProperties() );
|
||||
}
|
||||
|
||||
private void assembleDependencyManagementInheritance( ModelBase child, ModelBase parent )
|
||||
|
|
Loading…
Reference in New Issue