mirror of https://github.com/apache/maven.git
Cleaning up the pluginRepositories warning, and isolating it to a compatibility aspect so we can scan Model and Profile instances as they pass through the system more cleanly and ignore violations from POMs that are resolved in the repository.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@643188 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8ff17e2654
commit
7442d682d1
|
@ -30,6 +30,9 @@ import java.util.List;
|
|||
|
||||
public class ProfilesConversionUtils
|
||||
{
|
||||
|
||||
public static final String PROFILES_XML_SOURCE = "profiles.xml";
|
||||
|
||||
private ProfilesConversionUtils()
|
||||
{
|
||||
}
|
||||
|
@ -40,7 +43,7 @@ public class ProfilesConversionUtils
|
|||
|
||||
profile.setId( profileXmlProfile.getId() );
|
||||
|
||||
profile.setSource( "profiles.xml" );
|
||||
profile.setSource( PROFILES_XML_SOURCE );
|
||||
|
||||
org.apache.maven.profiles.Activation profileActivation = profileXmlProfile.getActivation();
|
||||
|
||||
|
@ -64,9 +67,9 @@ public class ProfilesConversionUtils
|
|||
activation.setProperty( prop );
|
||||
}
|
||||
|
||||
|
||||
|
||||
ActivationOS profileOs = profileActivation.getOs();
|
||||
|
||||
|
||||
if ( profileOs != null )
|
||||
{
|
||||
org.apache.maven.model.ActivationOS os = new org.apache.maven.model.ActivationOS();
|
||||
|
@ -76,7 +79,7 @@ public class ProfilesConversionUtils
|
|||
os.setName( profileOs.getName() );
|
||||
os.setVersion( profileOs.getVersion() );
|
||||
}
|
||||
|
||||
|
||||
org.apache.maven.profiles.ActivationFile profileFile = profileActivation.getFile();
|
||||
|
||||
if ( profileFile != null )
|
||||
|
|
|
@ -1,17 +1,113 @@
|
|||
package org.apache.maven.project.aspect.compat;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.project.build.model.ModelLineage;
|
||||
import org.apache.maven.project.build.model.ModelLineageIterator;
|
||||
import org.apache.maven.project.build.model.ModelLineageBuilder;
|
||||
import org.apache.maven.project.DefaultMavenProjectBuilder;
|
||||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||
import org.apache.maven.profiles.build.DefaultProfileAdvisor;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.profiles.ProfileManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
|
||||
public privileged aspect Maven20xProjectCompatAspect
|
||||
{
|
||||
|
||||
//DO NOT USE, it is here only for backward compatibility reasons. The existing
|
||||
// maven-assembly-plugin (2.2-beta-1) is accessing it via reflection.
|
||||
private pointcut reactorProjectBuilds():
|
||||
cflow( execution( * DefaultMavenProjectBuilder.buildFromSourceFileInternal( .. ) ) )
|
||||
&& !cflow( execution( * MavenMetadataSource.*( .. ) ) );
|
||||
|
||||
// the aspect weaving seems not to work for reflection from plugin.
|
||||
// private Map DefaultMavenProjectBuilder.processedProjectCache = new HashMap();
|
||||
private pointcut lineageBuildResumed( DefaultMavenProjectBuilder projectBuilder, ModelLineage lineage ):
|
||||
call( * ModelLineageBuilder.resumeBuildingModelLineage( ModelLineage, .. ) )
|
||||
&& this( projectBuilder )
|
||||
&& args( lineage, .. );
|
||||
|
||||
after( DefaultMavenProjectBuilder projectBuilder, ModelLineage lineage ):
|
||||
reactorProjectBuilds()
|
||||
&& lineageBuildResumed( projectBuilder, lineage )
|
||||
{
|
||||
for ( ModelLineageIterator it = lineage.lineageIterator(); it.hasNext(); )
|
||||
{
|
||||
Model model = (Model) it.next();
|
||||
List pluginRepos = model.getPluginRepositories();
|
||||
|
||||
if ( pluginRepos != null && !pluginRepos.isEmpty() )
|
||||
{
|
||||
StringBuffer message = new StringBuffer();
|
||||
message.append( "The <pluginRepositories/> section of the POM has been deprecated. Please update your POM (" );
|
||||
message.append( model.getId() );
|
||||
message.append( ")." );
|
||||
|
||||
projectBuilder.logger.warn( message.toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private pointcut externalProfilesApplied( DefaultProfileAdvisor advisor, ProfileManager profileManager ):
|
||||
execution( * DefaultProfileAdvisor.applyActivatedExternalProfiles( .., ProfileManager+ ) )
|
||||
&& this( advisor )
|
||||
&& args( .., profileManager );
|
||||
|
||||
|
||||
private boolean settingsProfilesChecked = false;
|
||||
|
||||
before( DefaultProfileAdvisor advisor, ProfileManager profileManager ):
|
||||
reactorProjectBuilds()
|
||||
&& externalProfilesApplied( advisor, profileManager )
|
||||
{
|
||||
if ( profileManager == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Map profilesById = profileManager.getProfilesById();
|
||||
Set invalidProfiles = new HashSet();
|
||||
|
||||
boolean settingsProfilesEncountered = false;
|
||||
for ( Iterator it = profilesById.values().iterator(); it.hasNext(); )
|
||||
{
|
||||
Profile profile = (Profile) it.next();
|
||||
|
||||
if ( "settings.xml".equals( profile.getSource() ) )
|
||||
{
|
||||
settingsProfilesEncountered = true;
|
||||
|
||||
if ( settingsProfilesChecked )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
List pluginRepos = profile.getPluginRepositories();
|
||||
if ( pluginRepos != null && !pluginRepos.isEmpty() )
|
||||
{
|
||||
invalidProfiles.add( profile );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !invalidProfiles.isEmpty() )
|
||||
{
|
||||
StringBuffer message = new StringBuffer();
|
||||
message.append( "The <pluginRepositories/> section of the POM has been deprecated. Please update the following profiles:\n" );
|
||||
|
||||
for ( Iterator it = invalidProfiles.iterator(); it.hasNext(); )
|
||||
{
|
||||
Profile profile = (Profile) it.next();
|
||||
message.append( "\n- " ).append( profile.getId() ).append( " (source: " ).append( profile.getSource() ).append( ")" );
|
||||
}
|
||||
|
||||
message.append( "\n" );
|
||||
|
||||
advisor.logger.warn( message.toString() );
|
||||
}
|
||||
|
||||
settingsProfilesChecked = settingsProfilesChecked || settingsProfilesEncountered;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1034,7 +1034,6 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
if ( ( model.getPluginRepositories() != null ) && !model.getPluginRepositories().isEmpty() )
|
||||
{
|
||||
getLogger().warn( "The <pluginRepositories/> section of the POM has been deprecated. Please update your POMs." );
|
||||
repoSet.addAll( model.getPluginRepositories() );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue