Author: sisbell Date: Wed Apr 29 17:59:09 2009 New Revision: 769856 URL: http://svn.apache.org/viewvc?rev=769856&view=rev Log: Removed uses of interpolator property from the profiles. This was more of a convenience since InterpolatorProperty was used in multiple places. Not needed anymore.
Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/profiles/matchers/JdkMatcherTest.java maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/ProfileActivationException.java maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/ProfileManagerInfo.java maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/DefaultMatcher.java maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/FileMatcher.java maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/JdkMatcher.java maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/ProfileMatcher.java maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/PropertyMatcher.java Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=769856&r1=769855&r2=769856&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original) +++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Wed Apr 29 17:59:09 2009 @@ -463,10 +463,7 @@ .getGlobalProfileManager().getProfileActivationContext() != null ) ? projectBuilderConfiguration.getGlobalProfileManager().getProfileActivationContext().getExplicitlyInactiveProfileIds() : new ArrayList<String>(); - List<InterpolatorProperty> interpolatorProperties = new ArrayList<InterpolatorProperty>(); - interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( projectBuilderConfiguration.getExecutionProperties(), PomInterpolatorTag.EXECUTION_PROPERTIES.name() ) ); - - ProfileManagerInfo profileInfo = new ProfileManagerInfo(interpolatorProperties, activeProfileIds, inactiveProfileIds); + ProfileManagerInfo profileInfo = new ProfileManagerInfo(projectBuilderConfiguration.getExecutionProperties(), activeProfileIds, inactiveProfileIds); DomainModel domainModel = new DomainModel( pomFile ); domainModel.setProjectDirectory( pomFile.getParentFile() ); domainModel.setMostSpecialized( true ); Modified: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/profiles/matchers/JdkMatcherTest.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/profiles/matchers/JdkMatcherTest.java?rev=769856&r1=769855&r2=769856&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/profiles/matchers/JdkMatcherTest.java (original) +++ maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/profiles/matchers/JdkMatcherTest.java Wed Apr 29 17:59:09 2009 @@ -1,10 +1,9 @@ package org.apache.maven.profiles.matchers; -import java.util.Collections; +import java.util.Properties; import org.apache.maven.model.Activation; import org.apache.maven.model.Profile; -import org.apache.maven.model.interpolator.InterpolatorProperty; import junit.framework.TestCase; @@ -19,6 +18,9 @@ p.setActivation(a); JdkMatcher m = new JdkMatcher(); - assertTrue(m.isMatch(p, Collections.singletonList(new InterpolatorProperty("${java.version}", "1.5.0_16")))); + Properties props = new Properties(); + props.setProperty("${java.version}", "1.5.0_16"); + + assertTrue(m.isMatch(p, props )); } } Modified: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java?rev=769856&r1=769855&r2=769856&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java (original) +++ maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java Wed Apr 29 17:59:09 2009 @@ -1339,7 +1339,7 @@ throws Exception { Properties props = new Properties(); - props.put("java.version", "1.5.0_15"); + props.put("${java.version}", "1.5.0_15"); PomTestWrapper pom = buildPom( "jdk-activation", props ); assertEquals(3, pom.getMavenProject().getActiveProfiles().size()); Modified: maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java?rev=769856&r1=769855&r2=769856&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java (original) +++ maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java Wed Apr 29 17:59:09 2009 @@ -202,7 +202,7 @@ public static Collection<Profile> getActiveProfiles(List<Profile> profiles, ProfileManagerInfo profileContextInfo) { - List<InterpolatorProperty> properties = profileContextInfo.getInterpolatorProperties(); + Properties properties = profileContextInfo.getInterpolatorProperties(); Collection<String> activeProfileIds = profileContextInfo.getActiveProfileIds(); Collection<String> inactiveProfileIds = profileContextInfo.getInactiveProfileIds(); @@ -271,17 +271,9 @@ private boolean isActive( Profile profile, ProfileActivationContext context ) throws ProfileActivationException { - List<InterpolatorProperty> interpolatorProperties = new ArrayList<InterpolatorProperty>(); - if(context.getExecutionProperties() != null) - { - interpolatorProperties.addAll(InterpolatorProperty.toInterpolatorProperties( - context.getExecutionProperties(), - PomInterpolatorTag.EXECUTION_PROPERTIES.name())); - } - for(ProfileMatcher matcher : matchers) { - if(matcher.isMatch(profile, interpolatorProperties)) + if(matcher.isMatch(profile, context.getExecutionProperties())) { return true; } Modified: maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/ProfileActivationException.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/ProfileActivationException.java?rev=769856&r1=769855&r2=769856&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/ProfileActivationException.java (original) +++ maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/ProfileActivationException.java Wed Apr 29 17:59:09 2009 @@ -23,7 +23,9 @@ extends Exception { - public ProfileActivationException( String message, Throwable cause ) + private static final long serialVersionUID = -90820222109103638L; + + public ProfileActivationException( String message, Throwable cause ) { super( message, cause ); } Modified: maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/ProfileManagerInfo.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/ProfileManagerInfo.java?rev=769856&r1=769855&r2=769856&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/ProfileManagerInfo.java (original) +++ maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/ProfileManagerInfo.java Wed Apr 29 17:59:09 2009 @@ -2,26 +2,25 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.List; +import java.util.Properties; -import org.apache.maven.model.interpolator.InterpolatorProperty; public class ProfileManagerInfo { - private List<InterpolatorProperty> interpolatorProperties; + private Properties interpolatorProperties; private Collection<String> activeProfileIds; private Collection<String> inactiveProfileIds; - public ProfileManagerInfo(List<InterpolatorProperty> interpolatorProperties, Collection<String> activeProfileIds, Collection<String> inactiveProfileIds) + public ProfileManagerInfo(Properties interpolatorProperties, Collection<String> activeProfileIds, Collection<String> inactiveProfileIds) { - this.interpolatorProperties = (interpolatorProperties != null) ? interpolatorProperties : new ArrayList<InterpolatorProperty>(); + this.interpolatorProperties = (interpolatorProperties != null) ? interpolatorProperties : new Properties(); this.activeProfileIds = (activeProfileIds != null) ? activeProfileIds : new ArrayList<String>(); this.inactiveProfileIds = (inactiveProfileIds != null) ? inactiveProfileIds : new ArrayList<String>(); } - public List<InterpolatorProperty> getInterpolatorProperties() { + public Properties getInterpolatorProperties() { return interpolatorProperties; } Modified: maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/DefaultMatcher.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/DefaultMatcher.java?rev=769856&r1=769855&r2=769856&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/DefaultMatcher.java (original) +++ maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/DefaultMatcher.java Wed Apr 29 17:59:09 2009 @@ -19,14 +19,13 @@ * under the License. */ -import java.util.List; +import java.util.Properties; import org.apache.maven.model.Profile; -import org.apache.maven.model.interpolator.InterpolatorProperty; public class DefaultMatcher implements ProfileMatcher { - public boolean isMatch( Profile profile, List<InterpolatorProperty> properties ) + public boolean isMatch( Profile profile, Properties properties ) { if(profile.getActivation() == null) { Modified: maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/FileMatcher.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/FileMatcher.java?rev=769856&r1=769855&r2=769856&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/FileMatcher.java (original) +++ maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/FileMatcher.java Wed Apr 29 17:59:09 2009 @@ -1,15 +1,14 @@ package org.apache.maven.profiles.matchers; import java.io.File; -import java.util.List; +import java.util.Properties; import org.apache.maven.model.ActivationFile; import org.apache.maven.model.Profile; -import org.apache.maven.model.interpolator.InterpolatorProperty; public class FileMatcher implements ProfileMatcher { - public boolean isMatch(Profile profile, List<InterpolatorProperty> properties) { + public boolean isMatch(Profile profile, Properties properties) { if (profile == null) { throw new IllegalArgumentException("profile: null"); } Modified: maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/JdkMatcher.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/JdkMatcher.java?rev=769856&r1=769855&r2=769856&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/JdkMatcher.java (original) +++ maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/JdkMatcher.java Wed Apr 29 17:59:09 2009 @@ -3,9 +3,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Properties; +import java.util.Map.Entry; import org.apache.maven.model.Profile; -import org.apache.maven.model.interpolator.InterpolatorProperty; public class JdkMatcher implements ProfileMatcher @@ -14,16 +15,17 @@ private static final String JDK_VERSION = "${java.version}"; public boolean isMatch(Profile profile, - List<InterpolatorProperty> properties) { + Properties properties) { String version = null; - for(InterpolatorProperty ip : properties) + for ( Entry<Object, Object> ip : properties.entrySet() ) { if(ip.getKey().equals(JDK_VERSION)) { - version = ip.getValue(); + version = (String) ip.getValue(); break; - } + } } + if ( version == null ) { return false; Modified: maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/ProfileMatcher.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/ProfileMatcher.java?rev=769856&r1=769855&r2=769856&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/ProfileMatcher.java (original) +++ maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/ProfileMatcher.java Wed Apr 29 17:59:09 2009 @@ -19,12 +19,11 @@ * under the License. */ -import java.util.List; +import java.util.Properties; import org.apache.maven.model.Profile; -import org.apache.maven.model.interpolator.InterpolatorProperty; public interface ProfileMatcher { - boolean isMatch( Profile profile, List<InterpolatorProperty> properties ); + boolean isMatch( Profile profile, Properties properties ); } Modified: maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/PropertyMatcher.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/PropertyMatcher.java?rev=769856&r1=769855&r2=769856&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/PropertyMatcher.java (original) +++ maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/PropertyMatcher.java Wed Apr 29 17:59:09 2009 @@ -20,13 +20,14 @@ */ import java.util.List; +import java.util.Properties; +import java.util.Map.Entry; import org.apache.maven.model.Profile; -import org.apache.maven.model.interpolator.InterpolatorProperty; public class PropertyMatcher implements ProfileMatcher { - public boolean isMatch( Profile profile, List<InterpolatorProperty> properties ) + public boolean isMatch( Profile profile, Properties properties ) { if (profile == null) { throw new IllegalArgumentException("profile: null"); @@ -49,12 +50,14 @@ return !name.startsWith("!"); } - for(InterpolatorProperty ip : properties) { - if(ip.getKey().equals("${" + name + "}")) { - return ip.getValue().equals(value); - } + for ( Entry<Object, Object> ip : properties.entrySet() ) + { + if(ip.getKey().equals("${" + name + "}")) + { + return ((String) ip.getValue()).equals(value); + } } - + return false; } }