maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r761825 - in /maven/components/trunk: maven-project-builder/src/main/java/org/apache/maven/project/processor/ maven-project/src/main/java/org/apache/maven/profiles/ maven-project/src/main/java/org/apache/maven/profiles/matchers/ maven-proje...
Date Fri, 03 Apr 2009 22:35:03 GMT
Author: sisbell
Date: Fri Apr  3 22:35:02 2009
New Revision: 761825

URL: http://svn.apache.org/viewvc?rev=761825&view=rev
Log:
[MNG-3106,3983,4107] - profile fixes.

Added:
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/matchers/FileMatcher.java
Modified:
    maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/ProcessorContext.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/matchers/PropertyMatcher.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java

Modified: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/ProcessorContext.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/ProcessorContext.java?rev=761825&r1=761824&r2=761825&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/ProcessorContext.java
(original)
+++ maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/ProcessorContext.java
Fri Apr  3 22:35:02 2009
@@ -133,6 +133,9 @@
         model.setDistributionManagement( p.getDistributionManagement() );
         model.setProperties( p.getProperties() );  
         model.setModules( new ArrayList<String>(p.getModules() ) );
+        model.setRepositories(p.getRepositories());
+        model.setPluginRepositories(p.getPluginRepositories());
+        model.setReporting(p.getReporting());
         BuildProcessor proc = new BuildProcessor( new ArrayList<Processor>());
         proc.processWithProfile( p.getBuild(), model);
         return model;
@@ -548,6 +551,9 @@
         p.setBuild( copyBuild(profile.getBuild()) );
         p.setId( profile.getId() );
         p.setActivation( profile.getActivation() );
+        p.setRepositories(profile.getRepositories());
+        p.setPluginRepositories(profile.getPluginRepositories());
+        p.setReporting(profile.getReporting());        
         return p;
     }
     

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java?rev=761825&r1=761824&r2=761825&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
(original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
Fri Apr  3 22:35:02 2009
@@ -22,11 +22,11 @@
 import org.apache.maven.model.Activation;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Profile;
-import org.apache.maven.model.Parent;
 import org.apache.maven.profiles.ProfileActivationContext;
 import org.apache.maven.profiles.ProfileActivationException;
 import org.apache.maven.profiles.ProfileManager;
 import org.apache.maven.profiles.matchers.DefaultMatcher;
+import org.apache.maven.profiles.matchers.FileMatcher;
 import org.apache.maven.profiles.matchers.ProfileMatcher;
 import org.apache.maven.profiles.matchers.PropertyMatcher;
 import org.apache.maven.shared.model.InterpolatorProperty;
@@ -50,7 +50,7 @@
     private static final ProfileMatcher defaultMatcher = new DefaultMatcher();
 
     private static final List<ProfileMatcher> matchers =
-        Collections.unmodifiableList( Arrays.asList( new DefaultMatcher(), new PropertyMatcher()
) );    
+        (List<ProfileMatcher>) Collections.unmodifiableList( Arrays.asList( new DefaultMatcher(),
new PropertyMatcher(), new FileMatcher() ) );    
 
     /**
      * the properties passed to the profile manager are the props that
@@ -134,7 +134,6 @@
     {
         List<Profile> activeFromPom = new ArrayList<Profile>();
         List<Profile> activeExternal = new ArrayList<Profile>();
-
         for ( Iterator it = profilesById.entrySet().iterator(); it.hasNext(); )
         {
             Map.Entry entry = (Entry) it.next();
@@ -142,17 +141,8 @@
             String profileId = (String) entry.getKey();
             Profile profile = (Profile) entry.getValue();
 
-            boolean shouldAdd = false;
-            if ( profileActivationContext.isExplicitlyActive( profileId ) )
-            {
-                shouldAdd = true;
-            }
-            else if ( isActive( profile, profileActivationContext ) )
-            {
-                shouldAdd = true;
-            }
-
-            if ( !profileActivationContext.isExplicitlyInactive( profileId ) && shouldAdd
)
+            if ( !profileActivationContext.isExplicitlyInactive( profileId )
+            		&& (profileActivationContext.isExplicitlyActive( profileId ) || isActive(
profile, profileActivationContext ) ) )
             {
                 if ( "pom".equals( profile.getSource() ) )
                 {
@@ -207,9 +197,12 @@
 	    List<Profile> projectProfiles = new ArrayList<Profile>();
 	    ProfileManager externalProfileManager = config.getGlobalProfileManager();
 	    
-	    ProfileActivationContext profileActivationContext = (externalProfileManager == null)
? new ProfileActivationContext( config.getExecutionProperties(), false ):
+	    Properties props = new Properties(config.getExecutionProperties());
+	    props.putAll(config.getUserProperties());
+	    
+	    ProfileActivationContext profileActivationContext = (externalProfileManager == null)
? new ProfileActivationContext( props, false ):
 	        externalProfileManager.getProfileActivationContext();
-	 
+	    
 	    if(externalProfileManager != null)
 	    {           
 	    	projectProfiles.addAll( externalProfileManager.getActiveProfiles() );    

Added: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/matchers/FileMatcher.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/matchers/FileMatcher.java?rev=761825&view=auto
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/matchers/FileMatcher.java
(added)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/matchers/FileMatcher.java
Fri Apr  3 22:35:02 2009
@@ -0,0 +1,34 @@
+package org.apache.maven.profiles.matchers;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.model.ActivationFile;
+import org.apache.maven.model.Profile;
+import org.apache.maven.shared.model.InterpolatorProperty;
+
+public class FileMatcher implements ProfileMatcher {
+
+	public boolean isMatch(Profile profile, List<InterpolatorProperty> properties) {
+		if (profile == null) {
+			throw new IllegalArgumentException("profile: null");
+		}
+
+		if(profile.getActivation() == null || profile.getActivation().getFile() == null)
+		{
+			return false;
+		}
+		
+		ActivationFile f = profile.getActivation().getFile();
+		
+		if (f.getExists() != null && !new File(f.getExists()).exists()) {
+			return false;
+		}
+		
+		if (f.getMissing() != null && new File(f.getMissing()).exists()) {
+			return false;
+		}
+		
+		return true;
+	}
+}

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/matchers/PropertyMatcher.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/matchers/PropertyMatcher.java?rev=761825&r1=761824&r2=761825&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/matchers/PropertyMatcher.java
(original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/matchers/PropertyMatcher.java
Fri Apr  3 22:35:02 2009
@@ -31,7 +31,7 @@
         if (profile == null) {
             throw new IllegalArgumentException("profile: null");
         }
-
+        
         if(profile.getActivation() == null || profile.getActivation().getProperty() == null)
         {
             return false;

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=761825&r1=761824&r2=761825&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
(original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Fri Apr  3 22:35:02 2009
@@ -43,7 +43,6 @@
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.apache.maven.profiles.DefaultProfileManager;
-import org.apache.maven.profiles.ProfileActivationContext;
 import org.apache.maven.profiles.ProfileActivationException;
 import org.apache.maven.profiles.ProfileManagerInfo;
 import org.apache.maven.profiles.ProfileManager;
@@ -147,9 +146,14 @@
         {
         	throw new ProjectBuildingException( "", "Failed to activate pom profiles.");	
         }
-        
+		
         try
         {
+            for(Profile p : projectProfiles)
+    		{
+    			logger.debug("Merging profile into model (build): Model = " + domainModel.getId()
+ ", Profile = " + p.getId() );
+    		}
+    		        	
             domainModel = ProcessorContext.mergeProfilesIntoModel( projectProfiles, domainModel
);
         }
         catch ( IOException e )
@@ -159,7 +163,7 @@
 		//Interpolation
         MavenProject project = interpolateDomainModel( domainModel, configuration, pomFile
);
         project.setActiveProfiles( projectProfiles );
-
+         
         Build build = project.getBuild();
         // NOTE: setting this script-source root before path translation, because
         // the plugin tools compose basedir and scriptSourceRoot into a single file.
@@ -174,6 +178,8 @@
    
         return project;
     }
+    
+  //  private static void setRepositoriesOn(MavenProject project, )
 
     //!! This is used by the RR plugin
     public MavenProject buildFromRepository( Artifact artifact, List<ArtifactRepository>
remoteArtifactRepositories, ArtifactRepository localRepository, boolean allowStubs )
@@ -242,6 +248,11 @@
         
         try
         {
+            for(Profile p : projectProfiles)
+    		{
+    			logger.debug("Merging profile into model (buildFromRepository): Model = " + domainModel.getId()
+ ", Profile = " + p.getId() );
+    		}
+    		           	
             domainModel = ProcessorContext.mergeProfilesIntoModel( projectProfiles, domainModel
);
         }
         catch ( IOException e )
@@ -471,6 +482,10 @@
             		Collection<Profile> profiles = DefaultProfileManager.getActiveProfiles(dm.getModel().getProfiles(),
profileInfo);
             		if(!profiles.isEmpty())
             		{
+            			for(Profile p : profiles)
+            			{
+            				logger.debug("Merging profile into model: Model = " + dm.getId() + ", Profile
= " + p.getId() );
+            			}
             			profileModels.add(ProcessorContext.mergeProfilesIntoModel( profiles, dm ));
 
             		}
             		else

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java?rev=761825&r1=761824&r2=761825&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
(original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
Fri Apr  3 22:35:02 2009
@@ -240,7 +240,15 @@
         }
         */
 
-        setRemoteArtifactRepositories( (projectBuilderConfiguration.getRemoteRepositories()
!= null) ? projectBuilderConfiguration.getRemoteRepositories() : new ArrayList<ArtifactRepository>());
      
+        setRemoteArtifactRepositories( (projectBuilderConfiguration.getRemoteRepositories()
!= null) ? projectBuilderConfiguration.getRemoteRepositories() : new ArrayList<ArtifactRepository>());
+		for(Repository r: model.getPluginRepositories())
+		{
+			try {
+				remoteArtifactRepositories.add(repositorySystem.buildArtifactRepository( r ));
+			} catch (InvalidRepositoryException e) {
+
+			}
+		}        
     }
 
     /**
@@ -378,7 +386,7 @@
     {
         return remoteArtifactRepositories;
     }
-
+    
     public boolean hasParent()
     {
         return getParent() != null;



Mime
View raw message