mirror of https://github.com/apache/maven.git
[MNG-2174] plugin management dependencies.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@762892 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
81bd2d7cd1
commit
6c6513cad3
|
@ -95,7 +95,6 @@ public class ProcessorContext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
profileModels.addAll(externalProfileModels);//external takes precedence
|
profileModels.addAll(externalProfileModels);//external takes precedence
|
||||||
// Collections.reverse( profileModels );
|
|
||||||
|
|
||||||
Model model = domainModel.getModel();
|
Model model = domainModel.getModel();
|
||||||
profileModels.add( 0, model );
|
profileModels.add( 0, model );
|
||||||
|
@ -118,11 +117,23 @@ public class ProcessorContext
|
||||||
}
|
}
|
||||||
|
|
||||||
DependencyManagement depMng = model.getDependencyManagement();
|
DependencyManagement depMng = model.getDependencyManagement();
|
||||||
model.setDependencyManagement( depMng );
|
|
||||||
|
|
||||||
Model target = processModelsForInheritance(profileModels, processors);
|
Model target = processModelsForInheritance(profileModels, processors);
|
||||||
//TODO: Merge
|
|
||||||
|
PluginsManagementProcessor pmp = new PluginsManagementProcessor();
|
||||||
|
if( mng != null )
|
||||||
|
{
|
||||||
|
if(target.getBuild().getPluginManagement() != null)
|
||||||
|
{
|
||||||
|
pmp.process(null, mng.getPlugins(), target.getBuild().getPluginManagement().getPlugins(), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
target.getBuild().setPluginManagement( mng );
|
target.getBuild().setPluginManagement( mng );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Merge Dependency Management
|
||||||
target.setDependencyManagement( depMng );
|
target.setDependencyManagement( depMng );
|
||||||
|
|
||||||
PomClassicDomainModel targetModel = convertToDomainModel( target, domainModel.isMostSpecialized());
|
PomClassicDomainModel targetModel = convertToDomainModel( target, domainModel.isMostSpecialized());
|
||||||
|
@ -578,13 +589,25 @@ public class ProcessorContext
|
||||||
b.setDirectory( base.getDirectory() );
|
b.setDirectory( base.getDirectory() );
|
||||||
b.setFilters( new ArrayList<String>(base.getFilters()) );
|
b.setFilters( new ArrayList<String>(base.getFilters()) );
|
||||||
b.setFinalName( base.getFinalName() );
|
b.setFinalName( base.getFinalName() );
|
||||||
b.setPluginManagement( base.getPluginManagement() );
|
b.setPluginManagement( copyPluginManagement(base.getPluginManagement()) );
|
||||||
b.setPlugins( copyPlugins(base.getPlugins()) );
|
b.setPlugins( copyPlugins(base.getPlugins()) );
|
||||||
b.setResources( new ArrayList<Resource>(base.getResources()) );
|
b.setResources( new ArrayList<Resource>(base.getResources()) );
|
||||||
b.setTestResources( new ArrayList<Resource>(base.getTestResources()) );
|
b.setTestResources( new ArrayList<Resource>(base.getTestResources()) );
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static PluginManagement copyPluginManagement(PluginManagement mng)
|
||||||
|
{
|
||||||
|
if(mng == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginManagement pm = new PluginManagement();
|
||||||
|
pm.setPlugins(copyPlugins(mng.getPlugins()));
|
||||||
|
return pm;
|
||||||
|
}
|
||||||
|
|
||||||
private static List<Plugin> copyPlugins(List<Plugin> plugins)
|
private static List<Plugin> copyPlugins(List<Plugin> plugins)
|
||||||
{
|
{
|
||||||
List<Plugin> ps = new ArrayList<Plugin>();
|
List<Plugin> ps = new ArrayList<Plugin>();
|
||||||
|
|
|
@ -20,29 +20,14 @@ package org.apache.maven.project.processor;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.model.BuildBase;
|
|
||||||
import org.apache.maven.model.Dependency;
|
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
import org.apache.maven.model.Plugin;
|
|
||||||
import org.apache.maven.model.PluginExecution;
|
|
||||||
import org.apache.maven.model.Profile;
|
import org.apache.maven.model.Profile;
|
||||||
import org.apache.maven.model.Resource;
|
|
||||||
|
|
||||||
|
|
||||||
public class ProfilesProcessor extends BaseProcessor
|
public class ProfilesProcessor extends BaseProcessor
|
||||||
{
|
{
|
||||||
private static List<Processor> processors =
|
|
||||||
Arrays.<Processor> asList( new BuildProcessor( new ArrayList<Processor>() ), new ModuleProcessor(),
|
|
||||||
new PropertiesProcessor(), new ParentProcessor(), new OrganizationProcessor(),
|
|
||||||
new MailingListProcessor(), new IssueManagementProcessor(),
|
|
||||||
new CiManagementProcessor(), new ReportingProcessor(),
|
|
||||||
new RepositoriesProcessor(), new DistributionManagementProcessor(),
|
|
||||||
new LicensesProcessor(), new ScmProcessor(), new PrerequisitesProcessor(),
|
|
||||||
new ContributorsProcessor(), new DevelopersProcessor());
|
|
||||||
|
|
||||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||||
{
|
{
|
||||||
super.process( parent, child, target, isChildMostSpecialized );
|
super.process( parent, child, target, isChildMostSpecialized );
|
||||||
|
@ -54,23 +39,6 @@ public class ProfilesProcessor extends BaseProcessor
|
||||||
copies.add( ProcessorContext.copyOfProfile(p) );
|
copies.add( ProcessorContext.copyOfProfile(p) );
|
||||||
}
|
}
|
||||||
t.setProfiles( copies );
|
t.setProfiles( copies );
|
||||||
|
|
||||||
//TODO - copy
|
//TODO - copy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static Model attachProfileNodesToModel(Profile profile)
|
|
||||||
{
|
|
||||||
Model model = new Model();
|
|
||||||
model.setModules( new ArrayList<String>(profile.getModules()) );
|
|
||||||
model.setDependencies(new ArrayList<Dependency>(profile.getDependencies()));
|
|
||||||
model.setDependencyManagement( profile.getDependencyManagement());
|
|
||||||
model.setDistributionManagement( profile.getDistributionManagement() );
|
|
||||||
model.setProperties( profile.getProperties() );
|
|
||||||
model.setModules( new ArrayList<String>(profile.getModules() ) );
|
|
||||||
BuildProcessor proc = new BuildProcessor( new ArrayList<Processor>());
|
|
||||||
proc.processWithProfile( profile.getBuild(), model);
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1248,7 +1248,6 @@ public class PomConstructionTest
|
||||||
{
|
{
|
||||||
PomTestWrapper pom =
|
PomTestWrapper pom =
|
||||||
buildPom( "profile-injection-order", "pom-a", "pom-b", "pom-e", "pom-c", "pom-d" );
|
buildPom( "profile-injection-order", "pom-a", "pom-b", "pom-e", "pom-c", "pom-d" );
|
||||||
//System.out.println(pom.getDomainModel().asString());
|
|
||||||
assertEquals( "e", pom.getValue( "properties[1]/pomProperty" ) );
|
assertEquals( "e", pom.getValue( "properties[1]/pomProperty" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1314,6 +1313,14 @@ public class PomConstructionTest
|
||||||
assertEquals("c", pom.getValue( "build/extensions[3]/artifactId" ) );
|
assertEquals("c", pom.getValue( "build/extensions[3]/artifactId" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* MNG-2174 */
|
||||||
|
public void testProfilePluginMngDependencies()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
PomTestWrapper pom = buildPom( "profile-plugin-mng-dependencies/sub" , "maven-core-it");
|
||||||
|
assertEquals("a", pom.getValue( "build/plugins[1]/dependencies[1]/artifactId" ) );
|
||||||
|
}
|
||||||
|
|
||||||
/** MNG-4116 */
|
/** MNG-4116 */
|
||||||
public void testPercentEncodedUrlsMustNotBeDecoded()
|
public void testPercentEncodedUrlsMustNotBeDecoded()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.apache.maven.its.mng2174</groupId>
|
||||||
|
<artifactId>parent</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<name>Maven Integration Test :: MNG-2174</name>
|
||||||
|
<description>
|
||||||
|
Verify that plugin dependencies defined by plugin management of a parent profile are not lost when the
|
||||||
|
parent's main plugin management section is also present.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>sub</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.its.plugins</groupId>
|
||||||
|
<artifactId>maven-it-plugin-class-loader</artifactId>
|
||||||
|
<version>2.1-SNAPSHOT</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>maven-core-it</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.its.plugins</groupId>
|
||||||
|
<artifactId>maven-it-plugin-class-loader</artifactId>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.its.mng2174</groupId>
|
||||||
|
<artifactId>a</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
</project>
|
|
@ -0,0 +1,62 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.maven.its.mng2174</groupId>
|
||||||
|
<artifactId>parent</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.apache.maven.its.mng2174</groupId>
|
||||||
|
<artifactId>child</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<name>Maven Integration Test :: MNG-2174</name>
|
||||||
|
<description>
|
||||||
|
Verify that plugin dependencies defined by plugin management of a parent profile are not lost when the
|
||||||
|
parent's main plugin management section is also present.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.its.plugins</groupId>
|
||||||
|
<artifactId>maven-it-plugin-class-loader</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>test</id>
|
||||||
|
<phase>validate</phase>
|
||||||
|
<configuration>
|
||||||
|
<resourcePaths>mng-2174.properties</resourcePaths>
|
||||||
|
<pluginClassLoaderOutput>target/pcl.properties</pluginClassLoaderOutput>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>load</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
Loading…
Reference in New Issue