mirror of https://github.com/apache/maven.git
o Deleted processors which have been replaced by mergers. To recap, the mergers operate on two instead of three models which reduces complexity. While the mergers are currently not overly beauty either, the plan is to have them generated by Modello via merge rules that would be annotated to the model classes/associations.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@773428 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a08fffa609
commit
4fdc5512eb
|
@ -1,30 +0,0 @@
|
|||
package org.apache.maven.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
public interface Processor
|
||||
{
|
||||
void process( Object parent, Object child, Object target, boolean isChildMostSpecialized );
|
||||
|
||||
List<Model> getParentModels();
|
||||
|
||||
}
|
|
@ -21,7 +21,6 @@ package org.apache.maven.model;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -30,31 +29,8 @@ import org.apache.maven.model.inheritance.DefaultInheritanceAssembler;
|
|||
import org.apache.maven.model.inheritance.InheritanceAssembler;
|
||||
import org.apache.maven.model.management.DefaultManagementInjector;
|
||||
import org.apache.maven.model.management.ManagementInjector;
|
||||
import org.apache.maven.model.processors.BuildProcessor;
|
||||
import org.apache.maven.model.processors.CiManagementProcessor;
|
||||
import org.apache.maven.model.processors.ContributorsProcessor;
|
||||
import org.apache.maven.model.processors.DependencyManagementProcessor;
|
||||
import org.apache.maven.model.processors.DevelopersProcessor;
|
||||
import org.apache.maven.model.processors.DistributionManagementProcessor;
|
||||
import org.apache.maven.model.processors.IssueManagementProcessor;
|
||||
import org.apache.maven.model.processors.LicensesProcessor;
|
||||
import org.apache.maven.model.processors.MailingListProcessor;
|
||||
import org.apache.maven.model.processors.ModelProcessor;
|
||||
import org.apache.maven.model.processors.ModuleProcessor;
|
||||
import org.apache.maven.model.processors.OrganizationProcessor;
|
||||
import org.apache.maven.model.processors.ParentProcessor;
|
||||
import org.apache.maven.model.processors.PluginsManagementProcessor;
|
||||
import org.apache.maven.model.processors.PrerequisitesProcessor;
|
||||
import org.apache.maven.model.processors.ProfilePropertiesProcessor;
|
||||
import org.apache.maven.model.processors.ProfilesModuleProcessor;
|
||||
import org.apache.maven.model.processors.ProfilesProcessor;
|
||||
import org.apache.maven.model.processors.PropertiesProcessor;
|
||||
import org.apache.maven.model.processors.ReportingProcessor;
|
||||
import org.apache.maven.model.processors.RepositoriesProcessor;
|
||||
import org.apache.maven.model.processors.ScmProcessor;
|
||||
import org.apache.maven.model.profile.DefaultProfileInjector;
|
||||
import org.apache.maven.model.profile.ProfileInjector;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
/*
|
||||
* TODO: Get rid of this class and go back to an inheritance assembler, profile injector and default injector, all
|
||||
|
@ -88,15 +64,7 @@ public class ProcessorContext
|
|||
throw new IOException("Could not find child model");
|
||||
}
|
||||
|
||||
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(), new ProfilesProcessor() );
|
||||
Model target = processModelsForInheritance( convertDomainModelsToMavenModels( domainModels ), processors, false );
|
||||
Model target = processModelsForInheritance( convertDomainModelsToMavenModels( domainModels ) );
|
||||
if(listeners != null)
|
||||
{
|
||||
for(ModelEventListener listener : listeners)
|
||||
|
@ -115,103 +83,22 @@ public class ProcessorContext
|
|||
|
||||
public static DomainModel mergeProfilesIntoModel(Collection<Profile> profiles, DomainModel domainModel) throws IOException
|
||||
{
|
||||
List<Model> profileModels = new ArrayList<Model>();
|
||||
List<Model> externalProfileModels = new ArrayList<Model>();
|
||||
|
||||
for(Profile profile : profiles)
|
||||
{
|
||||
if("pom".equals(profile.getSource()))
|
||||
{
|
||||
profileModels.add( attachProfileNodesToModel(profile) );
|
||||
}
|
||||
else
|
||||
{
|
||||
externalProfileModels.add(attachProfileNodesToModel(profile));
|
||||
}
|
||||
}
|
||||
profileModels.addAll(externalProfileModels);//external takes precedence
|
||||
|
||||
Model model = domainModel.getModel();
|
||||
|
||||
for ( Profile profile : profiles )
|
||||
{
|
||||
profileInjector.injectProfile( model, profile );
|
||||
}
|
||||
if ( true )
|
||||
{
|
||||
return domainModel;
|
||||
}
|
||||
|
||||
profileModels.add( 0, model );
|
||||
List<Processor> processors =
|
||||
Arrays.<Processor> asList( new BuildProcessor( new ArrayList<Processor>() ), new ProfilesModuleProcessor(),
|
||||
new ProfilePropertiesProcessor(), 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(), new ProfilesProcessor() );
|
||||
|
||||
//Remove the plugin management and dependency management so they aren't applied again with the profile processing
|
||||
PluginManagement mng = null;
|
||||
if( model.getBuild() != null)
|
||||
{
|
||||
mng = model.getBuild().getPluginManagement();
|
||||
model.getBuild().setPluginManagement( null );
|
||||
}
|
||||
|
||||
DependencyManagement depMng = model.getDependencyManagement();
|
||||
|
||||
Model target = processModelsForInheritance(profileModels, processors, true);
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Merge Dependency Management
|
||||
target.setDependencyManagement( depMng );
|
||||
|
||||
DomainModel targetModel = new DomainModel( target, domainModel.isMostSpecialized());
|
||||
targetModel.setParentFile(domainModel.getParentFile());
|
||||
targetModel.setProjectDirectory(domainModel.getProjectDirectory());
|
||||
return targetModel;
|
||||
return domainModel;
|
||||
}
|
||||
|
||||
private static Model attachProfileNodesToModel(Profile profile)
|
||||
{
|
||||
Profile p = copyOfProfile(profile);
|
||||
|
||||
Model model = new Model();
|
||||
model.setModules( p.getModules() );
|
||||
model.setDependencies(p.getDependencies());
|
||||
model.setDependencyManagement( p.getDependencyManagement());
|
||||
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;
|
||||
}
|
||||
|
||||
private static List<Model> convertDomainModelsToMavenModels(List<DomainModel> domainModels) throws IOException
|
||||
{
|
||||
List<Model> models = new ArrayList<Model>();
|
||||
for(DomainModel domainModel : domainModels)
|
||||
{
|
||||
DomainModel dm = (DomainModel) domainModel;
|
||||
DomainModel dm = domainModel;
|
||||
if(dm.getModel() != null)
|
||||
{
|
||||
if(dm.isMostSpecialized())
|
||||
|
@ -236,59 +123,19 @@ public class ProcessorContext
|
|||
|
||||
private static InheritanceAssembler inheritanceAssembler = new DefaultInheritanceAssembler();
|
||||
|
||||
private static Model processModelsForInheritance(List<Model> models, List<Processor> processors, boolean isProfile)
|
||||
private static Model processModelsForInheritance(List<Model> models)
|
||||
{
|
||||
ModelProcessor modelProcessor = new ModelProcessor( processors, isProfile );
|
||||
Collections.reverse( models );
|
||||
|
||||
Model previousModel = null;
|
||||
|
||||
for ( Model currentModel : models )
|
||||
{
|
||||
inheritanceAssembler.assembleModelInheritance( currentModel, previousModel );
|
||||
previousModel = currentModel;
|
||||
}
|
||||
if ( true )
|
||||
{
|
||||
return previousModel;
|
||||
}
|
||||
|
||||
int length = models.size();
|
||||
Model target = new Model();
|
||||
if(length == 1)
|
||||
{
|
||||
modelProcessor.process( null, models.get( 0 ), target, true );
|
||||
|
||||
} else if( length == 2)
|
||||
{
|
||||
modelProcessor.process( models.get( 0 ), models.get( 1 ), target, true );
|
||||
}
|
||||
else {
|
||||
for ( int i = 0; i < length - 1; i++ )
|
||||
{
|
||||
if(i == 0)
|
||||
{
|
||||
modelProcessor.process( null, models.get( 0 ), target, false );
|
||||
}
|
||||
else if ( i < length - 2 )
|
||||
{
|
||||
modelProcessor.process( models.get( i ), models.get( i + 1 ), target, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
modelProcessor.process( models.get( i ), models.get( i + 1 ), target, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
|
||||
}
|
||||
|
||||
private static void addPlugin(Build build, String id)
|
||||
{
|
||||
Plugin p1 = new Plugin();
|
||||
p1.setArtifactId(id);
|
||||
build.addPlugin(p1);
|
||||
return previousModel;
|
||||
}
|
||||
|
||||
private static ManagementInjector managementInjector = new DefaultManagementInjector();
|
||||
|
@ -296,108 +143,8 @@ public class ProcessorContext
|
|||
public static Model processManagementNodes(Model target)
|
||||
throws IOException
|
||||
{
|
||||
// Plugin plugin = new Plugin();
|
||||
// plugin.setArtifactId("maven-compiler-plugin");
|
||||
// target.getBuild().addPlugin(plugin);
|
||||
// Dependency Management
|
||||
managementInjector.injectManagement( target );
|
||||
if ( true )
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
DependencyManagementProcessor depProc = new DependencyManagementProcessor();
|
||||
if ( target.getDependencyManagement() != null )
|
||||
{
|
||||
depProc.process( null, new ArrayList<Dependency>( target.getDependencyManagement().getDependencies() ),
|
||||
target.getDependencies(), true );
|
||||
}
|
||||
|
||||
// Plugin Management
|
||||
PluginsManagementProcessor procMng = new PluginsManagementProcessor();
|
||||
if ( target.getBuild() != null && target.getBuild().getPluginManagement() != null)
|
||||
{
|
||||
procMng.process( null, new ArrayList<Plugin>( target.getBuild().getPluginManagement().getPlugins() ),
|
||||
target.getBuild().getPlugins(), true );
|
||||
}
|
||||
|
||||
return target;
|
||||
return target;
|
||||
}
|
||||
|
||||
public static Profile copyOfProfile(Profile profile)
|
||||
{
|
||||
Profile p = new Profile();
|
||||
p.setModules( new ArrayList<String>(profile.getModules()) );
|
||||
p.setDependencies(new ArrayList<Dependency>(profile.getDependencies()));
|
||||
p.setDependencyManagement( profile.getDependencyManagement());
|
||||
p.setDistributionManagement( profile.getDistributionManagement() );
|
||||
p.setProperties( profile.getProperties() );
|
||||
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;
|
||||
}
|
||||
|
||||
private static BuildBase copyBuild(BuildBase base)
|
||||
{
|
||||
if(base == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
BuildBase b = new BuildBase();
|
||||
b.setDefaultGoal( base.getDefaultGoal() );
|
||||
b.setDirectory( base.getDirectory() );
|
||||
b.setFilters( new ArrayList<String>(base.getFilters()) );
|
||||
b.setFinalName( base.getFinalName() );
|
||||
b.setPluginManagement( copyPluginManagement(base.getPluginManagement()) );
|
||||
b.setPlugins( copyPlugins(base.getPlugins()) );
|
||||
b.setResources( new ArrayList<Resource>(base.getResources()) );
|
||||
b.setTestResources( new ArrayList<Resource>(base.getTestResources()) );
|
||||
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)
|
||||
{
|
||||
List<Plugin> ps = new ArrayList<Plugin>();
|
||||
for(Plugin p : plugins)
|
||||
{
|
||||
ps.add( copyPlugin(p) );
|
||||
}
|
||||
return ps;
|
||||
}
|
||||
|
||||
private static Plugin copyPlugin(Plugin plugin)
|
||||
{
|
||||
Plugin p = new Plugin();
|
||||
p.setArtifactId( plugin.getArtifactId() );
|
||||
if(plugin.getConfiguration() != null)
|
||||
{
|
||||
p.setConfiguration( new Xpp3Dom((Xpp3Dom) plugin.getConfiguration()) );
|
||||
}
|
||||
|
||||
p.setDependencies( new ArrayList<Dependency>(plugin.getDependencies()) );
|
||||
p.setExecutions( new ArrayList<PluginExecution>(plugin.getExecutions()) );
|
||||
p.setGoals( plugin.getGoals() );
|
||||
p.setGroupId( plugin.getGroupId() );
|
||||
p.setInherited( plugin.getInherited() );
|
||||
p.setVersion( plugin.getVersion() );
|
||||
return p;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,160 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Processor;
|
||||
|
||||
public abstract class BaseProcessor implements Processor
|
||||
{
|
||||
|
||||
Collection<Processor> processors;
|
||||
|
||||
private List<Model> parentModels;
|
||||
|
||||
|
||||
public BaseProcessor( Collection<Processor> processors )
|
||||
{
|
||||
if ( processors == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "processors: null" );
|
||||
}
|
||||
|
||||
this.processors = processors;
|
||||
parentModels = new ArrayList<Model>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ordered from least specialized to most specialized.
|
||||
*/
|
||||
public List<Model> getParentModels()
|
||||
{
|
||||
return parentModels;
|
||||
}
|
||||
|
||||
public BaseProcessor()
|
||||
{
|
||||
this(new ArrayList<Processor>());
|
||||
}
|
||||
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
if ( target == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "target: null" );
|
||||
}
|
||||
|
||||
if(parent instanceof Model)
|
||||
{
|
||||
parentModels.add( (Model) parent );
|
||||
}
|
||||
for ( Processor processor : processors )
|
||||
{
|
||||
processor.process( parent, child, target, isChildMostSpecialized );
|
||||
}
|
||||
}
|
||||
|
||||
protected String normalizeUriWithRelativePath(String u, String artifactId, Model parent)
|
||||
{
|
||||
if(u == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
String slashes = getSlashes(new URI(u).getRawSchemeSpecificPart());
|
||||
URI uri = new URI(u + "/"
|
||||
+ getModulePathAdjustment(parent, artifactId));
|
||||
|
||||
String normalized = uri.normalize().toASCIIString();
|
||||
if("file".equals(uri.getScheme()))//UNC Paths
|
||||
{
|
||||
normalized = normalized.replaceFirst("/", slashes);
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String getSlashes(String uri)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(byte b : uri.getBytes())
|
||||
{
|
||||
if(b == 47)
|
||||
{
|
||||
sb.append("/");
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String getModulePathAdjustment(Model moduleProject,
|
||||
String artifactId) {
|
||||
|
||||
Map<String, String> moduleAdjustments = new HashMap<String, String>();
|
||||
List<String> modules = moduleProject.getModules();
|
||||
if (modules != null) {
|
||||
for (Iterator<String> it = modules.iterator(); it.hasNext();) {
|
||||
String modulePath = it.next();
|
||||
String moduleName = modulePath;
|
||||
|
||||
if (moduleName.endsWith("/") || moduleName.endsWith("\\")) {
|
||||
moduleName = moduleName.substring(0,
|
||||
moduleName.length() - 1);
|
||||
}
|
||||
|
||||
int lastSlash = moduleName.lastIndexOf('/');
|
||||
|
||||
if (lastSlash < 0) {
|
||||
lastSlash = moduleName.lastIndexOf('\\');
|
||||
}
|
||||
|
||||
String adjustment = null;
|
||||
|
||||
if (lastSlash > -1) {
|
||||
moduleName = moduleName.substring(lastSlash + 1);
|
||||
adjustment = modulePath.substring(0, lastSlash);
|
||||
}
|
||||
|
||||
moduleAdjustments.put(moduleName, adjustment);
|
||||
}
|
||||
}
|
||||
String adjust = moduleAdjustments.get(artifactId);
|
||||
return (adjust != null) ? adjust + "/" + artifactId : "/" + artifactId;
|
||||
}
|
||||
}
|
|
@ -1,264 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.BuildBase;
|
||||
import org.apache.maven.model.Extension;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.ModelEventListener;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginManagement;
|
||||
import org.apache.maven.model.Processor;
|
||||
import org.apache.maven.model.Resource;
|
||||
|
||||
public class BuildProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
private List<ModelEventListener> listeners;
|
||||
|
||||
public BuildProcessor( Collection<Processor> processors )
|
||||
{
|
||||
super( processors );
|
||||
listeners = new ArrayList<ModelEventListener>();
|
||||
}
|
||||
|
||||
public BuildProcessor( Collection<Processor> processors, List<ModelEventListener> listeners)
|
||||
{
|
||||
super( processors );
|
||||
listeners = (listeners == null) ? new ArrayList<ModelEventListener>() : new ArrayList<ModelEventListener>(listeners);
|
||||
}
|
||||
|
||||
public void processWithProfile( BuildBase build, Model target )
|
||||
{
|
||||
processBuild(null, build, target, false, true );
|
||||
}
|
||||
|
||||
private void processBuild(Model p, BuildBase build, Model t, boolean isChildMostSpecialized, boolean isProfile)
|
||||
{
|
||||
|
||||
if(t.getBuild() == null)
|
||||
{
|
||||
t.setBuild( new Build() );
|
||||
}
|
||||
|
||||
PluginsProcessor pluginsProcessor = new PluginsProcessor();
|
||||
if(build == null && !( p == null || p.getBuild() == null))
|
||||
{
|
||||
copy(p.getBuild(), t.getBuild(), isProfile);
|
||||
copyFilters(p.getBuild(), t.getBuild());
|
||||
pluginsProcessor.process( p.getBuild().getPlugins(), null, t.getBuild().getPlugins(), isChildMostSpecialized );
|
||||
inheritManagement(p.getBuild().getPluginManagement(), null, t.getBuild());
|
||||
}
|
||||
else if(build != null && !( p == null || p.getBuild() == null))
|
||||
{
|
||||
copy(p.getBuild(), t.getBuild(), isProfile);
|
||||
copy(build, t.getBuild(), isProfile);
|
||||
|
||||
copyFilters(build, t.getBuild());
|
||||
copyFilters(p.getBuild(), t.getBuild());
|
||||
|
||||
pluginsProcessor.process( p.getBuild().getPlugins(), build.getPlugins(), t.getBuild().getPlugins(), isChildMostSpecialized );
|
||||
inheritManagement(p.getBuild().getPluginManagement(), build.getPluginManagement(), t.getBuild());
|
||||
}
|
||||
else if(build != null )
|
||||
{
|
||||
copy(build, t.getBuild(), isProfile);
|
||||
copyFilters(build, t.getBuild());
|
||||
pluginsProcessor.process( null, build.getPlugins(), t.getBuild().getPlugins(), isChildMostSpecialized );
|
||||
inheritManagement(null, build.getPluginManagement(), t.getBuild());
|
||||
}
|
||||
}
|
||||
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
Model t = (Model) target;
|
||||
Model c = (Model) child;
|
||||
Model p = (Model) parent;
|
||||
|
||||
processBuild(p, c.getBuild(), t, isChildMostSpecialized, false );
|
||||
}
|
||||
|
||||
private static void inheritManagement(PluginManagement parent, PluginManagement child, Build target)
|
||||
{
|
||||
PluginsProcessor proc = new PluginsProcessor();
|
||||
List<Plugin> p = (parent == null) ? new ArrayList<Plugin>() : parent.getPlugins();
|
||||
List<Plugin> c = (child == null) ? new ArrayList<Plugin>() : child.getPlugins();
|
||||
|
||||
if(!c.isEmpty() || !p.isEmpty())
|
||||
{
|
||||
if(target.getPluginManagement() == null)
|
||||
{
|
||||
target.setPluginManagement( new PluginManagement() );
|
||||
}
|
||||
proc.process( p, c, target.getPluginManagement().getPlugins(), false );
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyFilters(BuildBase source, Build target)
|
||||
{
|
||||
List<String> filters = new ArrayList<String>(target.getFilters());
|
||||
for(String filter : source.getFilters())
|
||||
{
|
||||
if(!filters.contains( filter ))
|
||||
{
|
||||
filters.add( filter );
|
||||
}
|
||||
}
|
||||
|
||||
// SortedSet<String> s = new TreeSet<String>( new ArrayList<String>( target.getFilters() ) );
|
||||
// s.addAll( source.getFilters() );
|
||||
// List<String> l = Arrays.asList(s.toArray( new String[s.size()]) );
|
||||
|
||||
target.setFilters( filters );
|
||||
}
|
||||
|
||||
private static void copy(BuildBase source, Build target, boolean isProfile)
|
||||
{
|
||||
if(source.getFinalName() != null)
|
||||
{
|
||||
target.setFinalName( source.getFinalName() );
|
||||
}
|
||||
|
||||
if(source.getDefaultGoal() != null)
|
||||
{
|
||||
target.setDefaultGoal( source.getDefaultGoal() );
|
||||
}
|
||||
|
||||
if(source.getDirectory() != null)
|
||||
{
|
||||
target.setDirectory( source.getDirectory() );
|
||||
}
|
||||
|
||||
if(!source.getResources().isEmpty())
|
||||
{
|
||||
List<Resource> resources = new ArrayList<Resource>();
|
||||
for(Resource resource : source.getResources())
|
||||
{
|
||||
Resource r = new Resource();
|
||||
r.setDirectory( resource.getDirectory());
|
||||
r.setFiltering( resource.getFiltering() );
|
||||
r.setMergeId( resource.getMergeId() );
|
||||
r.setTargetPath( resource.getTargetPath() );
|
||||
r.setExcludes( new ArrayList<String>(resource.getExcludes()) );
|
||||
r.setIncludes( new ArrayList<String>(resource.getIncludes()) );
|
||||
resources.add( r );
|
||||
}
|
||||
target.setResources( resources );
|
||||
}
|
||||
|
||||
if(!source.getTestResources().isEmpty())
|
||||
{
|
||||
List<Resource> resources = new ArrayList<Resource>();
|
||||
for(Resource resource : source.getTestResources())
|
||||
{
|
||||
Resource r = new Resource();
|
||||
r.setDirectory( resource.getDirectory());
|
||||
r.setFiltering( resource.isFiltering() );
|
||||
r.setMergeId( resource.getMergeId() );
|
||||
r.setTargetPath( resource.getTargetPath() );
|
||||
r.setExcludes( new ArrayList<String>(resource.getExcludes()) );
|
||||
r.setIncludes( new ArrayList<String>(resource.getIncludes()) );
|
||||
resources.add( r );
|
||||
}
|
||||
target.setTestResources( resources );
|
||||
}
|
||||
if(!isProfile)
|
||||
{
|
||||
copyBuild((Build) source, target);
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyBuild(Build source, Build target)
|
||||
{
|
||||
if(source.getOutputDirectory() != null)
|
||||
{
|
||||
target.setOutputDirectory( source.getOutputDirectory() );
|
||||
}
|
||||
|
||||
if(source.getScriptSourceDirectory() != null)
|
||||
{
|
||||
target.setScriptSourceDirectory( source.getScriptSourceDirectory() );
|
||||
}
|
||||
|
||||
if(source.getSourceDirectory() != null)
|
||||
{
|
||||
target.setSourceDirectory( source.getSourceDirectory() );
|
||||
}
|
||||
|
||||
if(source.getTestOutputDirectory() != null)
|
||||
{
|
||||
target.setTestOutputDirectory( source.getTestOutputDirectory() );
|
||||
}
|
||||
|
||||
if(source.getTestSourceDirectory() != null)
|
||||
{
|
||||
target.setTestSourceDirectory( source.getTestSourceDirectory() );
|
||||
}
|
||||
/*
|
||||
List<Dependency> childDependencies =
|
||||
new ArrayList<Dependency>(dependencies.subList( length - 1 , dependencies.size() ) );
|
||||
dependencies.removeAll( childDependencies );
|
||||
dependencies.addAll( 0, childDependencies );
|
||||
*/
|
||||
int i = target.getExtensions().size();
|
||||
|
||||
List<Extension> m = new ArrayList<Extension>();
|
||||
for(Extension extension : source.getExtensions())
|
||||
{
|
||||
Extension match = isMatch(extension, target.getExtensions());
|
||||
if(match != null)
|
||||
{
|
||||
match.setArtifactId( extension.getArtifactId() );
|
||||
match.setGroupId( extension.getGroupId() );
|
||||
match.setVersion( extension.getVersion() );
|
||||
m.add( match );
|
||||
}
|
||||
else
|
||||
{
|
||||
Extension e = new Extension();
|
||||
e.setArtifactId( extension.getArtifactId() );
|
||||
e.setGroupId( extension.getGroupId() );
|
||||
e.setVersion( extension.getVersion() );
|
||||
m.add( e );
|
||||
}
|
||||
}
|
||||
target.getExtensions().removeAll( m );
|
||||
target.getExtensions().addAll( 0, m );
|
||||
}
|
||||
|
||||
private static Extension isMatch(Extension extension, List<Extension> extensions)
|
||||
{
|
||||
for(Extension e : extensions)
|
||||
{
|
||||
if(e.getGroupId().equals( extension.getGroupId() ) && e.getArtifactId().equals( extension.getArtifactId() ))
|
||||
{
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.model.CiManagement;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Notifier;
|
||||
|
||||
public class CiManagementProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
Model t = (Model) target;
|
||||
Model c = (Model) child;
|
||||
Model p = (Model) parent;
|
||||
|
||||
if ( c.getCiManagement() != null )
|
||||
{
|
||||
CiManagement childMng = c.getCiManagement();
|
||||
CiManagement mng = new CiManagement();
|
||||
|
||||
mng.setSystem( childMng.getSystem() );
|
||||
mng.setUrl( childMng.getUrl() );
|
||||
t.setCiManagement( mng );
|
||||
addNotifiers( c.getCiManagement().getNotifiers(), t.getCiManagement() );
|
||||
}
|
||||
else if ( p != null && p.getCiManagement() != null )
|
||||
{
|
||||
CiManagement parentMng = p.getCiManagement();
|
||||
CiManagement mng = new CiManagement();
|
||||
|
||||
mng.setSystem( parentMng.getSystem() );
|
||||
mng.setUrl( parentMng.getUrl() );
|
||||
t.setCiManagement( mng );
|
||||
addNotifiers( p.getCiManagement().getNotifiers(), t.getCiManagement() );
|
||||
}
|
||||
}
|
||||
|
||||
private static void addNotifiers( List<Notifier> notifiers, CiManagement ciManagement )
|
||||
{
|
||||
if ( notifiers == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<Notifier> n = new ArrayList<Notifier>();
|
||||
|
||||
for ( Notifier notifier : notifiers )
|
||||
{
|
||||
Notifier notifierCopy = new Notifier();
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.putAll( notifier.getConfiguration() );
|
||||
notifierCopy.setConfiguration( properties );
|
||||
|
||||
notifierCopy.setAddress( notifier.getAddress() );
|
||||
notifierCopy.setSendOnError( notifier.isSendOnError() );
|
||||
notifierCopy.setSendOnFailure( notifier.isSendOnFailure() );
|
||||
notifierCopy.setSendOnSuccess( notifier.isSendOnSuccess() );
|
||||
notifierCopy.setSendOnWarning( notifier.isSendOnWarning() );
|
||||
notifierCopy.setType( notifier.getType() );
|
||||
n.add( notifierCopy );
|
||||
|
||||
}
|
||||
ciManagement.getNotifiers().addAll( n );
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.model.Contributor;
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
public class ContributorsProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
||||
Model p = (Model) parent;
|
||||
Model c = (Model) child;
|
||||
Model t = (Model) target;
|
||||
|
||||
if ( !c.getContributors().isEmpty() )
|
||||
{
|
||||
copyContributors( c.getContributors(), t );
|
||||
}
|
||||
else if ( p != null && !p.getContributors().isEmpty() )
|
||||
{
|
||||
copyContributors( p.getContributors(), t );
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyContributors( List<Contributor> contributors, Model target )
|
||||
{
|
||||
for ( Contributor contributor : contributors )
|
||||
{
|
||||
Contributor copy = new Contributor();
|
||||
copy.setName( contributor.getName() );
|
||||
copy.setEmail( contributor.getEmail() );
|
||||
copy.setUrl( contributor.getUrl() );
|
||||
copy.setOrganization( contributor.getOrganization() );
|
||||
copy.setOrganizationUrl( contributor.getOrganizationUrl() );
|
||||
copy.setTimezone( contributor.getTimezone() );
|
||||
copy.setRoles( new ArrayList<String>( contributor.getRoles() ) );
|
||||
Properties props = new Properties();
|
||||
props.putAll( contributor.getProperties() );
|
||||
copy.setProperties( props );
|
||||
target.addContributor( copy );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
|
||||
|
||||
public class DependenciesProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
private boolean isDependencyManagement;
|
||||
|
||||
public DependenciesProcessor() {}
|
||||
|
||||
public DependenciesProcessor(boolean isDependencyManagement) {
|
||||
this.isDependencyManagement = isDependencyManagement;
|
||||
}
|
||||
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
List<Dependency> c = (child != null) ? (List<Dependency>) child : new ArrayList<Dependency>() ;
|
||||
List<Dependency> p = null;
|
||||
|
||||
if ( parent != null )
|
||||
{
|
||||
p = (List<Dependency>) parent;
|
||||
}
|
||||
List<Dependency> dependencies = (List<Dependency>) target;
|
||||
|
||||
DependencyProcessor processor = new DependencyProcessor(isDependencyManagement);
|
||||
if ( ( p == null || p.isEmpty() ) && !c.isEmpty() )
|
||||
{
|
||||
for ( Dependency dependency : c )
|
||||
{
|
||||
processor.process( null, dependency, dependencies, isChildMostSpecialized );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !c.isEmpty() )
|
||||
{
|
||||
|
||||
for ( Dependency parentDependency : p )
|
||||
{
|
||||
processor.process( parentDependency, null, dependencies, isChildMostSpecialized );
|
||||
}
|
||||
|
||||
int length = dependencies.size();
|
||||
|
||||
for ( Dependency childDependency : c )
|
||||
{
|
||||
processor.process( null, childDependency, dependencies, isChildMostSpecialized );
|
||||
}
|
||||
|
||||
//Move elements so child dependencies are first
|
||||
List<Dependency> childDependencies =
|
||||
new ArrayList<Dependency>(dependencies.subList( length - 1 , dependencies.size() ) );
|
||||
dependencies.removeAll( childDependencies );
|
||||
dependencies.addAll( 0, childDependencies );
|
||||
}
|
||||
else if( p != null)
|
||||
{
|
||||
for ( Dependency d2 : p )
|
||||
{
|
||||
processor.process( d2, null, dependencies, isChildMostSpecialized );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Exclusion;
|
||||
|
||||
public class DependencyManagementProcessor extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
||||
List<Dependency> depManagement = (List<Dependency> ) child;
|
||||
List<Dependency> targetDependencies = (List<Dependency>) target;
|
||||
|
||||
for(Dependency depMng : depManagement)
|
||||
{
|
||||
for(Dependency targetDep : targetDependencies)
|
||||
{
|
||||
if(match(depMng, targetDep))
|
||||
{
|
||||
copy(depMng, targetDep );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void copy( Dependency dependency, Dependency targetDependency )
|
||||
{
|
||||
if ( targetDependency.getArtifactId() == null )
|
||||
{
|
||||
targetDependency.setArtifactId( dependency.getArtifactId() );
|
||||
}
|
||||
|
||||
if ( targetDependency.getClassifier() == null )
|
||||
{
|
||||
targetDependency.setClassifier( dependency.getClassifier() );
|
||||
}
|
||||
|
||||
if ( targetDependency.getGroupId() == null )
|
||||
{
|
||||
targetDependency.setGroupId( dependency.getGroupId() );
|
||||
}
|
||||
|
||||
if ( targetDependency.getScope() == null )
|
||||
{
|
||||
targetDependency.setScope( dependency.getScope() );
|
||||
}
|
||||
|
||||
if ( targetDependency.getSystemPath() == null )
|
||||
{
|
||||
targetDependency.setSystemPath( dependency.getSystemPath() );
|
||||
}
|
||||
|
||||
if ( targetDependency.getType() == null )
|
||||
{
|
||||
targetDependency.setType( dependency.getType() );
|
||||
}
|
||||
|
||||
if ( targetDependency.getVersion() == null )
|
||||
{
|
||||
targetDependency.setVersion( dependency.getVersion() );
|
||||
}
|
||||
|
||||
if ( !dependency.getExclusions().isEmpty() )
|
||||
{
|
||||
List<Exclusion> targetExclusions = targetDependency.getExclusions();
|
||||
for ( Exclusion e : dependency.getExclusions() )
|
||||
{
|
||||
if ( !containsExclusion( e, targetExclusions ) )
|
||||
{
|
||||
Exclusion e1 = new Exclusion();
|
||||
e1.setArtifactId( e.getArtifactId() );
|
||||
e1.setGroupId( e.getGroupId() );
|
||||
targetDependency.addExclusion( e1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
targetDependency.setOptional( dependency.isOptional() );
|
||||
}
|
||||
|
||||
private static boolean containsExclusion( Exclusion exclusion, List<Exclusion> exclusions )
|
||||
{
|
||||
if(exclusions == null || exclusions.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( Exclusion e : exclusions )
|
||||
{
|
||||
if ( e.getGroupId().equals( exclusion.getGroupId() )
|
||||
&& e.getArtifactId().equals( exclusion.getArtifactId() ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean match( Dependency d1, Dependency d2 )
|
||||
{
|
||||
return getId( d1 ).equals( getId( d2 ) );
|
||||
}
|
||||
|
||||
private String getId( Dependency d )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( d.getGroupId() ).append( ":" ).append( d.getArtifactId() );
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
|
@ -1,222 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Exclusion;
|
||||
|
||||
public class DependencyProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
private boolean isDependencyManagement;
|
||||
|
||||
public DependencyProcessor(){ }
|
||||
|
||||
public DependencyProcessor(boolean isDependencyManagement)
|
||||
{
|
||||
this.isDependencyManagement = isDependencyManagement;
|
||||
}
|
||||
/*
|
||||
* Process children first
|
||||
*/
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
||||
List<Dependency> t = (List<Dependency>) target;
|
||||
|
||||
if ( parent == null && child == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if ( parent == null && child != null )
|
||||
{
|
||||
boolean isAdd = true;
|
||||
Dependency targetDependency = contains((Dependency) child, t);
|
||||
if(targetDependency == null)
|
||||
{
|
||||
targetDependency = new Dependency();
|
||||
}
|
||||
else
|
||||
{
|
||||
isAdd = false;
|
||||
}
|
||||
|
||||
if(!isAdd)
|
||||
{
|
||||
t.remove( targetDependency );
|
||||
}
|
||||
|
||||
copy( (Dependency) child, targetDependency);
|
||||
|
||||
t.add( targetDependency );
|
||||
|
||||
}
|
||||
else if ( parent != null && child == null )
|
||||
{
|
||||
boolean isAdd = true;
|
||||
Dependency targetDependency = contains((Dependency) parent, t);
|
||||
if(targetDependency == null)
|
||||
{
|
||||
targetDependency = new Dependency();
|
||||
}
|
||||
else
|
||||
{
|
||||
isAdd = false;
|
||||
}
|
||||
copy( (Dependency) parent, targetDependency);
|
||||
if(isAdd) t.add( targetDependency );
|
||||
}
|
||||
else
|
||||
// JOIN
|
||||
{
|
||||
Dependency targetDependency = new Dependency();
|
||||
copy( (Dependency) parent, targetDependency );
|
||||
copy( (Dependency) child, targetDependency);
|
||||
/*
|
||||
if( isMatch( (Dependency) child, (Dependency) parent))
|
||||
{
|
||||
copy( (Dependency) child, targetDependency);
|
||||
}
|
||||
else
|
||||
{
|
||||
copy( (Dependency) parent, targetDependency );
|
||||
copy( (Dependency) child, targetDependency);
|
||||
}
|
||||
*/
|
||||
t.add( targetDependency );
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isMatch(Dependency d1, Dependency d2)
|
||||
{
|
||||
return d1.getGroupId().equals(d2.getGroupId()) && d1.getArtifactId().equals(d2.getArtifactId());
|
||||
}
|
||||
|
||||
private Dependency contains(Dependency d1, List<Dependency> dependencies)
|
||||
{
|
||||
for(Dependency d : dependencies)
|
||||
{
|
||||
if( match(d, d1))
|
||||
{
|
||||
return d;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean match( Dependency d1, Dependency d2 )
|
||||
{
|
||||
// TODO: Version ranges ?
|
||||
return getId( d1 ).equals( getId( d2 ) );
|
||||
|
||||
}
|
||||
|
||||
private String getId( Dependency d )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( d.getGroupId() ).append( ":" ).append( d.getArtifactId() );
|
||||
sb.append( ":" ).append(
|
||||
d.getType() == null ? "jar"
|
||||
: d.getType() ).append(
|
||||
":" ).append(
|
||||
d.getClassifier() );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private boolean isMatch(Object source, Object target, boolean isDependencyManagement)
|
||||
{
|
||||
return (source != null && !isDependencyManagement) || target == null;
|
||||
}
|
||||
|
||||
private void copy( Dependency source, Dependency targetDependency)
|
||||
{
|
||||
if ( isMatch(source.getArtifactId(), targetDependency.getArtifactId(), isDependencyManagement) )
|
||||
{
|
||||
targetDependency.setArtifactId( source.getArtifactId() );
|
||||
}
|
||||
|
||||
if ( isMatch(source.getClassifier(), targetDependency.getClassifier(), isDependencyManagement) )
|
||||
{
|
||||
targetDependency.setClassifier( source.getClassifier() );
|
||||
}
|
||||
|
||||
if ( isMatch(source.getGroupId(), targetDependency.getGroupId(), isDependencyManagement) )
|
||||
{
|
||||
targetDependency.setGroupId( source.getGroupId() );
|
||||
}
|
||||
|
||||
targetDependency.setScope( source.getScope() );
|
||||
|
||||
if ( isMatch(source.getSystemPath(), targetDependency.getSystemPath(), isDependencyManagement) )
|
||||
{
|
||||
targetDependency.setSystemPath( source.getSystemPath() );
|
||||
}
|
||||
|
||||
if ( isMatch(source.getType(), targetDependency.getType(), isDependencyManagement))
|
||||
{
|
||||
targetDependency.setType( source.getType() );
|
||||
}
|
||||
|
||||
if ( isMatch(source.getVersion(), targetDependency.getVersion(), isDependencyManagement) )
|
||||
{
|
||||
targetDependency.setVersion( source.getVersion() );
|
||||
}
|
||||
|
||||
if ( !source.getExclusions().isEmpty() )
|
||||
{
|
||||
List<Exclusion> targetExclusions = targetDependency.getExclusions();
|
||||
for ( Exclusion e : source.getExclusions() )
|
||||
{
|
||||
if ( !containsExclusion( e, targetExclusions ) )
|
||||
{
|
||||
Exclusion e1 = new Exclusion();
|
||||
e1.setArtifactId( e.getArtifactId() );
|
||||
e1.setGroupId( e.getGroupId() );
|
||||
targetDependency.addExclusion( e1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
targetDependency.setOptional( source.isOptional() );
|
||||
}
|
||||
|
||||
private static boolean containsExclusion( Exclusion exclusion, List<Exclusion> exclusions )
|
||||
{
|
||||
if(exclusions == null || exclusions.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( Exclusion e : exclusions )
|
||||
{
|
||||
if ( e.getGroupId().equals( exclusion.getGroupId() )
|
||||
&& e.getArtifactId().equals( exclusion.getArtifactId() ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.model.Developer;
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
public class DevelopersProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
||||
Model p = (Model) parent;
|
||||
Model c = (Model) child;
|
||||
Model t = (Model) target;
|
||||
|
||||
if ( !c.getDevelopers().isEmpty() )
|
||||
{
|
||||
copyDevelopers( c.getDevelopers(), t );
|
||||
}
|
||||
else if ( p != null && !p.getDevelopers().isEmpty() )
|
||||
{
|
||||
copyDevelopers( p.getDevelopers(), t );
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyDevelopers( List<Developer> developers, Model target )
|
||||
{
|
||||
for ( Developer developer : developers )
|
||||
{
|
||||
Developer copy = new Developer();
|
||||
copy.setId( developer.getId() );
|
||||
copy.setName( developer.getName() );
|
||||
copy.setEmail( developer.getEmail() );
|
||||
copy.setUrl( developer.getUrl() );
|
||||
copy.setOrganization( developer.getOrganization() );
|
||||
copy.setOrganizationUrl( developer.getOrganizationUrl() );
|
||||
copy.setTimezone( developer.getTimezone() );
|
||||
copy.setRoles( new ArrayList<String>( developer.getRoles() ) );
|
||||
Properties props = new Properties();
|
||||
props.putAll( developer.getProperties() );
|
||||
copy.setProperties( props );
|
||||
target.addDeveloper( copy );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,163 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import org.apache.maven.model.DeploymentRepository;
|
||||
import org.apache.maven.model.DistributionManagement;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Relocation;
|
||||
import org.apache.maven.model.Site;
|
||||
|
||||
public class DistributionManagementProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
||||
Model t = (Model) target;
|
||||
Model c = (Model) child;
|
||||
Model p = (Model) parent;
|
||||
|
||||
if ( t.getDependencyManagement() == null
|
||||
&& ( p != null && p.getDistributionManagement() != null || c.getDistributionManagement() != null ) )
|
||||
{
|
||||
t.setDistributionManagement( new DistributionManagement() );
|
||||
}
|
||||
|
||||
if ( c.getDistributionManagement() != null )
|
||||
{
|
||||
if ( p != null && p.getDistributionManagement() != null )
|
||||
{
|
||||
copy( p.getDistributionManagement(), t.getDistributionManagement(), false, c.getArtifactId(), p );
|
||||
}
|
||||
copy( c.getDistributionManagement(), t.getDistributionManagement(), isChildMostSpecialized,
|
||||
c.getArtifactId(), p );
|
||||
}
|
||||
else if ( p != null && p.getDistributionManagement() != null )
|
||||
{
|
||||
copy( p.getDistributionManagement(), t.getDistributionManagement(), false, c.getArtifactId(), p );
|
||||
}
|
||||
else if(t.getDistributionManagement() != null && t.getDistributionManagement().getSite() != null)
|
||||
{
|
||||
copySite( t.getDistributionManagement().getSite(), t.getDistributionManagement().getSite(), false, c.getArtifactId(), p );
|
||||
// copy( t.getDistributionManagement(), t.getDistributionManagement(), isChildMostSpecialized, c.getArtifactId() );
|
||||
}
|
||||
}
|
||||
|
||||
private void copy( DistributionManagement source, DistributionManagement target, boolean isChild,
|
||||
String artifactId, Model parent )
|
||||
{
|
||||
if ( source.getDownloadUrl() != null )
|
||||
{
|
||||
target.setDownloadUrl( source.getDownloadUrl() );
|
||||
}
|
||||
|
||||
if ( isChild && source.getRelocation() != null )
|
||||
{
|
||||
Relocation sourceRelocation = source.getRelocation();
|
||||
Relocation r = new Relocation();
|
||||
r.setArtifactId( sourceRelocation.getArtifactId() );
|
||||
r.setGroupId( sourceRelocation.getGroupId() );
|
||||
r.setMessage( sourceRelocation.getMessage() );
|
||||
r.setVersion( sourceRelocation.getVersion() );
|
||||
target.setRelocation( r );
|
||||
}
|
||||
|
||||
if ( source.getStatus() != null )
|
||||
{
|
||||
target.setStatus( source.getStatus() );
|
||||
}
|
||||
|
||||
if ( source.getRepository() != null )
|
||||
{
|
||||
target.setRepository( new DeploymentRepository() );
|
||||
copyRepository( source.getRepository(), target.getRepository() );
|
||||
}
|
||||
|
||||
if ( source.getSnapshotRepository() != null )
|
||||
{
|
||||
target.setSnapshotRepository( new DeploymentRepository() );
|
||||
copyRepository( source.getSnapshotRepository(), target.getSnapshotRepository() );
|
||||
}
|
||||
|
||||
if ( source.getSite() != null )
|
||||
{
|
||||
target.setSite( new Site() );
|
||||
copySite( source.getSite(), target.getSite(), isChild, artifactId, parent );
|
||||
}
|
||||
}
|
||||
|
||||
private void copyRepository( DeploymentRepository source, DeploymentRepository target )
|
||||
{
|
||||
if ( source.getId() != null )
|
||||
{
|
||||
target.setId( source.getId() );
|
||||
}
|
||||
|
||||
if ( source.getLayout() != null )
|
||||
{
|
||||
target.setLayout( source.getLayout() );
|
||||
}
|
||||
|
||||
if ( source.getUrl() != null )
|
||||
{
|
||||
target.setUrl( source.getUrl() );
|
||||
}
|
||||
|
||||
if ( source.getName() != null )
|
||||
{
|
||||
target.setName( source.getName() );
|
||||
}
|
||||
|
||||
target.setUniqueVersion( source.isUniqueVersion() );
|
||||
}
|
||||
|
||||
private void copySite( Site source, Site target, boolean isChild, String artifactId, Model parent )
|
||||
{
|
||||
if ( source.getId() != null )
|
||||
{
|
||||
target.setId( source.getId() );
|
||||
}
|
||||
|
||||
if ( source.getName() != null )
|
||||
{
|
||||
target.setName( source.getName() );
|
||||
}
|
||||
|
||||
if ( target.getUrl() == null )
|
||||
{
|
||||
if ( isChild )
|
||||
{
|
||||
target.setUrl( source.getUrl() );
|
||||
}
|
||||
else
|
||||
{
|
||||
target.setUrl(normalizeUriWithRelativePath(source.getUrl(), artifactId, parent));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
target.setUrl( target.getUrl() + (target.getUrl().endsWith("/") ? "" : "/")+ artifactId );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import org.apache.maven.model.IssueManagement;
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
public class IssueManagementProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
Model t = (Model) target;
|
||||
Model c = (Model) child;
|
||||
Model p = (Model) parent;
|
||||
|
||||
if ( c.getIssueManagement() != null )
|
||||
{
|
||||
IssueManagement childMng = c.getIssueManagement();
|
||||
IssueManagement mng = new IssueManagement();
|
||||
|
||||
mng.setSystem( childMng.getSystem() );
|
||||
mng.setUrl( childMng.getUrl() );
|
||||
t.setIssueManagement( mng );
|
||||
}
|
||||
else if ( p != null && p.getIssueManagement() != null )
|
||||
{
|
||||
IssueManagement parentMng = p.getIssueManagement();
|
||||
IssueManagement mng = new IssueManagement();
|
||||
|
||||
mng.setSystem( parentMng.getSystem() );
|
||||
mng.setUrl( parentMng.getUrl() );
|
||||
t.setIssueManagement( mng );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import org.apache.maven.model.License;
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
public class LicensesProcessor extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
Model t = (Model) target;
|
||||
Model c = (Model) child;
|
||||
Model p = (Model) parent;
|
||||
|
||||
if(c.getLicenses().isEmpty() && p != null)
|
||||
{
|
||||
for(License license : p.getLicenses())
|
||||
{
|
||||
License l = new License();
|
||||
l.setUrl( license.getUrl());
|
||||
l.setDistribution( license.getDistribution() );
|
||||
l.setComments( license.getComments() );
|
||||
l.setName( license.getName() );
|
||||
t.addLicense( l );
|
||||
}
|
||||
}
|
||||
else if(isChildMostSpecialized )
|
||||
{
|
||||
for(License license : c.getLicenses())
|
||||
{
|
||||
License l = new License();
|
||||
l.setUrl( license.getUrl());
|
||||
l.setDistribution( license.getDistribution() );
|
||||
l.setComments( license.getComments() );
|
||||
l.setName( license.getName() );
|
||||
t.addLicense( l );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.MailingList;
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
public class MailingListProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
Model t = (Model) target;
|
||||
Model c = (Model) child;
|
||||
Model p = (Model) parent;
|
||||
|
||||
if ( !c.getMailingLists().isEmpty() )
|
||||
{
|
||||
copyMailingLists( c.getMailingLists(), t );
|
||||
}
|
||||
else if ( p != null && !p.getMailingLists().isEmpty() )
|
||||
{
|
||||
copyMailingLists( p.getMailingLists(), t );
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyMailingLists( List<MailingList> mailingLists, Model target )
|
||||
{
|
||||
List<MailingList> targetList = target.getMailingLists();
|
||||
for ( MailingList mailingList : mailingLists )
|
||||
{
|
||||
MailingList listCopy = new MailingList();
|
||||
listCopy.setArchive( mailingList.getArchive() );
|
||||
listCopy.setName( mailingList.getName() );
|
||||
listCopy.setOtherArchives( new ArrayList<String>( mailingList.getOtherArchives() ) );
|
||||
listCopy.setPost( mailingList.getPost() );
|
||||
listCopy.setSubscribe( mailingList.getSubscribe() );
|
||||
listCopy.setUnsubscribe( mailingList.getUnsubscribe() );
|
||||
targetList.add( listCopy );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,189 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.DependencyManagement;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Processor;
|
||||
|
||||
/*
|
||||
* hold original pom
|
||||
* Track where a property is from
|
||||
*/
|
||||
public class ModelProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
|
||||
private boolean isProfile;
|
||||
|
||||
public ModelProcessor( Collection<Processor> processors, boolean isProfile )
|
||||
{
|
||||
super( processors );
|
||||
this.isProfile = isProfile;
|
||||
}
|
||||
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
||||
Model c = (Model) child;
|
||||
Model t = (Model) target;
|
||||
Model p = null;
|
||||
if ( parent != null )
|
||||
{
|
||||
p = (Model) parent;
|
||||
}
|
||||
|
||||
// Version
|
||||
if ( c.getVersion() == null )
|
||||
{
|
||||
if ( c.getParent() != null )
|
||||
{
|
||||
t.setVersion( c.getParent().getVersion() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
t.setVersion( c.getVersion() );
|
||||
}
|
||||
|
||||
// GroupId
|
||||
if ( c.getGroupId() == null )
|
||||
{
|
||||
if ( c.getParent() != null )
|
||||
{
|
||||
t.setGroupId( c.getParent().getGroupId() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
t.setGroupId( c.getGroupId() );
|
||||
}
|
||||
|
||||
// ArtifactId
|
||||
if ( c.getArtifactId() == null )
|
||||
{
|
||||
if ( c.getParent() != null )
|
||||
{
|
||||
t.setArtifactId( c.getParent().getArtifactId() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
t.setArtifactId( c.getArtifactId() );
|
||||
}
|
||||
|
||||
t.setModelVersion( c.getModelVersion() );
|
||||
if(c.getPackaging() != null)
|
||||
{
|
||||
t.setPackaging( c.getPackaging() );
|
||||
}
|
||||
else
|
||||
{
|
||||
t.setPackaging( "jar" );
|
||||
}
|
||||
|
||||
if ( isChildMostSpecialized )
|
||||
{
|
||||
t.setName( c.getName() );
|
||||
}
|
||||
|
||||
if(c.getDescription() != null)
|
||||
{
|
||||
t.setDescription( c.getDescription() );
|
||||
}
|
||||
else if(p != null && p.getDescription() != null)
|
||||
{
|
||||
t.setDescription(p.getDescription());
|
||||
}
|
||||
|
||||
if ( c.getInceptionYear() != null )
|
||||
{
|
||||
t.setInceptionYear( c.getInceptionYear() );
|
||||
}
|
||||
else if ( p != null )
|
||||
{
|
||||
t.setInceptionYear( p.getInceptionYear() );
|
||||
}
|
||||
|
||||
if ( c.getUrl() != null )
|
||||
{
|
||||
t.setUrl( c.getUrl() );
|
||||
}
|
||||
else if(p != null && p.getUrl() != null)
|
||||
{
|
||||
t.setUrl( normalizeUriWithRelativePath(p.getUrl(), t.getArtifactId(), p) );
|
||||
}
|
||||
else if (t.getUrl() != null)
|
||||
{
|
||||
t.setUrl( t.getUrl() + "/" + t.getArtifactId() );
|
||||
}
|
||||
|
||||
//Dependencies
|
||||
List<Dependency> deps = new ArrayList<Dependency>();
|
||||
DependenciesProcessor dependenciesProcessor = new DependenciesProcessor();
|
||||
dependenciesProcessor.process( (p != null) ? p.getDependencies() : null, c.getDependencies(), deps, isChildMostSpecialized );
|
||||
|
||||
if(deps.size() > 0)
|
||||
{
|
||||
//Multiple profiles may be processed so we need to add them
|
||||
if(isProfile)
|
||||
{
|
||||
t.getDependencies().addAll( deps );
|
||||
}
|
||||
else
|
||||
{
|
||||
t.setDependencies(deps);
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//Dependency Management
|
||||
List<Dependency> mngDeps = new ArrayList<Dependency>();
|
||||
dependenciesProcessor.process( (p != null && p.getDependencyManagement() != null) ? p.getDependencyManagement().getDependencies(): null,
|
||||
(c.getDependencyManagement() != null) ? c.getDependencyManagement().getDependencies(): null, mngDeps, isChildMostSpecialized );
|
||||
if(mngDeps.size() > 0)
|
||||
{
|
||||
if(t.getDependencyManagement() == null)
|
||||
{
|
||||
t.setDependencyManagement( new DependencyManagement() );
|
||||
}
|
||||
t.getDependencyManagement().getDependencies().addAll( mngDeps );
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> getParentNames(List<Model> models)
|
||||
{
|
||||
List<String> names = new ArrayList<String>();
|
||||
for(Model m : models)
|
||||
{
|
||||
names.add(m.getArtifactId());
|
||||
}
|
||||
Collections.reverse(names);
|
||||
return names;
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
public class ModuleProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
/**
|
||||
* No parent
|
||||
*/
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
||||
if ( isChildMostSpecialized )
|
||||
{
|
||||
Model t = (Model) target;
|
||||
Model c = (Model) child;
|
||||
t.setModules( new ArrayList<String>( c.getModules() ) );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Organization;
|
||||
|
||||
public class OrganizationProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
Model t = (Model) target;
|
||||
Model c = (Model) child;
|
||||
Model p = (Model) parent;
|
||||
|
||||
if ( c.getOrganization() != null )
|
||||
{
|
||||
copy( c.getOrganization(), t );
|
||||
}
|
||||
else if ( p != null && p.getOrganization() != null )
|
||||
{
|
||||
copy( p.getOrganization(), t );
|
||||
}
|
||||
}
|
||||
|
||||
private static void copy( Organization source, Model target )
|
||||
{
|
||||
Organization o = new Organization();
|
||||
o.setName( source.getName() );
|
||||
o.setUrl( source.getUrl() );
|
||||
|
||||
target.setOrganization( o );
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Parent;
|
||||
|
||||
public class ParentProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
|
||||
public ParentProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
Model t = (Model) target;
|
||||
Model c = (Model) child;
|
||||
if ( c.getParent() != null )
|
||||
{
|
||||
Parent p = new Parent();
|
||||
p.setGroupId( c.getParent().getGroupId() );
|
||||
p.setArtifactId( c.getParent().getArtifactId() );
|
||||
p.setVersion( c.getParent().getVersion() );
|
||||
p.setRelativePath( c.getParent().getRelativePath() );
|
||||
t.setParent( p );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,361 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
import org.codehaus.plexus.util.xml.Xpp3DomUtils;
|
||||
|
||||
public class PluginProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
List<Plugin> t = (List<Plugin>) target;
|
||||
|
||||
if ( parent == null && child == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if ( parent == null && child != null )
|
||||
{
|
||||
|
||||
boolean isAdd = true;
|
||||
Plugin targetPlugin = find((Plugin) child, t);
|
||||
if(targetPlugin == null)
|
||||
{
|
||||
targetPlugin = new Plugin();
|
||||
}
|
||||
else
|
||||
{
|
||||
isAdd = false;
|
||||
}
|
||||
|
||||
copy( (Plugin) child, targetPlugin, true );
|
||||
copyDependencies( new ArrayList<Dependency>(),
|
||||
new ArrayList<Dependency>(( (Plugin) child).getDependencies() ), targetPlugin, true );
|
||||
if(isAdd) t.add( targetPlugin );
|
||||
}
|
||||
else if ( parent != null && child == null )
|
||||
{
|
||||
boolean isAdd = true;
|
||||
Plugin targetPlugin = find((Plugin) parent, t);
|
||||
if(targetPlugin == null)
|
||||
{
|
||||
targetPlugin = new Plugin();
|
||||
}
|
||||
else
|
||||
{
|
||||
isAdd = false;
|
||||
}
|
||||
|
||||
copy( (Plugin) parent, targetPlugin, false );
|
||||
copyDependencies( new ArrayList<Dependency>(( (Plugin) parent).getDependencies() ), new ArrayList<Dependency>(),
|
||||
targetPlugin, true );
|
||||
if(isAdd) t.add( targetPlugin );
|
||||
}
|
||||
else
|
||||
// JOIN
|
||||
{
|
||||
if( match( (Plugin) parent, (Plugin) child) )
|
||||
{
|
||||
boolean isAdd = true;
|
||||
Plugin targetPlugin = find((Plugin) parent, t);
|
||||
if(targetPlugin == null)
|
||||
{
|
||||
targetPlugin = new Plugin();
|
||||
}
|
||||
else
|
||||
{
|
||||
isAdd = false;
|
||||
}
|
||||
copy( (Plugin) parent, targetPlugin, false );
|
||||
copy( (Plugin) child, targetPlugin, true );
|
||||
copyDependencies( new ArrayList<Dependency>(( (Plugin) parent).getDependencies() ),
|
||||
new ArrayList<Dependency>(( (Plugin) child).getDependencies() ), targetPlugin, true );
|
||||
if(isAdd) t.add( targetPlugin );
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin targetPlugin = new Plugin();
|
||||
copy( (Plugin) parent, targetPlugin, false );
|
||||
copy( (Plugin) child, targetPlugin, true );
|
||||
|
||||
copyDependencies( new ArrayList<Dependency>(( (Plugin) parent).getDependencies() ),
|
||||
new ArrayList<Dependency>(( (Plugin) child).getDependencies() ), targetPlugin, true );
|
||||
// copyDependencies( (Plugin) parent, targetPlugin, false );
|
||||
t.add( targetPlugin );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void process( Plugin parent, List<Plugin> t, boolean isChildMostSpecialized )
|
||||
{
|
||||
if (parent == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isAdd = true;
|
||||
Plugin targetPlugin = find((Plugin) parent, t);
|
||||
if (targetPlugin == null) {
|
||||
targetPlugin = new Plugin();
|
||||
} else {
|
||||
isAdd = false;
|
||||
}
|
||||
|
||||
copy2((Plugin) parent, targetPlugin, false);
|
||||
copyDependencies(new ArrayList<Dependency>(((Plugin) parent)
|
||||
.getDependencies()), new ArrayList<Dependency>(), targetPlugin,
|
||||
true);
|
||||
if (isAdd)
|
||||
t.add(targetPlugin);
|
||||
}
|
||||
|
||||
private static Plugin find(Plugin p1, List<Plugin> plugins)
|
||||
{
|
||||
for(Plugin t : plugins)
|
||||
{
|
||||
if(match(p1, t)){
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean match( Plugin d1, Plugin d2 )
|
||||
{
|
||||
return getId( d1 ).equals( getId( d2 ));
|
||||
}
|
||||
|
||||
private static String getId( Plugin d )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( (d.getGroupId() != null) ? d.getGroupId() : "org.apache.maven.plugins").append( ":" ).append( d.getArtifactId() ).append( ":" );
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
private static void copyDependencies(List<Dependency> parent, List<Dependency> child, Plugin target, boolean isChild)
|
||||
{
|
||||
if(parent.isEmpty() && child.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
DependenciesProcessor proc = new DependenciesProcessor();
|
||||
proc.process( parent, child, target.getDependencies(), isChild );
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't overwrite values
|
||||
*
|
||||
* @param source
|
||||
* @param target
|
||||
* @param isChild
|
||||
*/
|
||||
public static void copy2(Plugin source, Plugin target, boolean isChild)
|
||||
{
|
||||
if(!isChild && source.getInherited() != null && !source.getInherited().equalsIgnoreCase( "true" ))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(target.getArtifactId() == null)
|
||||
{
|
||||
target.setArtifactId( source.getArtifactId() );
|
||||
}
|
||||
|
||||
if(target.getGroupId() == null || !source.getGroupId().equals("org.apache.maven.plugins"))
|
||||
{
|
||||
target.setGroupId( source.getGroupId() );
|
||||
}
|
||||
|
||||
if(target.getInherited() == null)
|
||||
{
|
||||
target.setInherited( source.getInherited() );
|
||||
}
|
||||
|
||||
if(target.getVersion() == null)
|
||||
{
|
||||
target.setVersion( source.getVersion() );
|
||||
}
|
||||
|
||||
for( PluginExecution pe : source.getExecutions())
|
||||
{
|
||||
PluginExecution idMatch = contains(pe, target.getExecutions());
|
||||
if(idMatch != null)//Join
|
||||
{
|
||||
copyPluginExecution(pe, idMatch, isChild);
|
||||
}
|
||||
else
|
||||
{
|
||||
PluginExecution targetPe = new PluginExecution();
|
||||
copyPluginExecution(pe, targetPe, isChild);
|
||||
target.addExecution( targetPe );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(source.getConfiguration() != null)
|
||||
{
|
||||
//TODO: Not copying
|
||||
if(target.getConfiguration() != null)
|
||||
{
|
||||
target.setConfiguration( new Xpp3Dom(Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) source.getConfiguration(), (Xpp3Dom) target.getConfiguration() )));
|
||||
}
|
||||
else
|
||||
{
|
||||
target.setConfiguration( new Xpp3Dom((Xpp3Dom) source.getConfiguration() ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// p2.setConfiguration( configuration ) merge nodes
|
||||
//Goals
|
||||
target.setExtensions(source.isExtensions());
|
||||
|
||||
}
|
||||
|
||||
private static void copy(Plugin source, Plugin target, boolean isChild)
|
||||
{
|
||||
if(!isChild && source.getInherited() != null && !source.getInherited().equalsIgnoreCase( "true" ))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(source.getArtifactId() != null)
|
||||
{
|
||||
target.setArtifactId( source.getArtifactId() );
|
||||
}
|
||||
|
||||
target.setGroupId( source.getGroupId() );
|
||||
|
||||
if(source.getInherited() != null)
|
||||
{
|
||||
target.setInherited( source.getInherited() );
|
||||
}
|
||||
|
||||
if(source.getVersion() != null)
|
||||
{
|
||||
target.setVersion( source.getVersion() );
|
||||
}
|
||||
|
||||
for( PluginExecution pe : source.getExecutions())
|
||||
{
|
||||
PluginExecution idMatch = contains(pe, target.getExecutions());
|
||||
if(idMatch != null)//Join
|
||||
{
|
||||
copyPluginExecution(pe, idMatch, isChild);
|
||||
}
|
||||
else
|
||||
{
|
||||
PluginExecution targetPe = new PluginExecution();
|
||||
copyPluginExecution(pe, targetPe, isChild);
|
||||
target.addExecution( targetPe );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(source.getConfiguration() != null)
|
||||
{
|
||||
//TODO: Not copying
|
||||
if(target.getConfiguration() != null)
|
||||
{
|
||||
target.setConfiguration( new Xpp3Dom(Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) source.getConfiguration(), (Xpp3Dom) target.getConfiguration() ) ));
|
||||
}
|
||||
else
|
||||
{
|
||||
target.setConfiguration( new Xpp3Dom((Xpp3Dom) source.getConfiguration() ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// p2.setConfiguration( configuration ) merge nodes
|
||||
//Goals
|
||||
target.setExtensions(source.isExtensions());
|
||||
|
||||
}
|
||||
|
||||
private static PluginExecution contains(PluginExecution pe, List<PluginExecution> executions)
|
||||
{
|
||||
String executionId = (pe.getId() != null) ? pe.getId() : "";
|
||||
for(PluginExecution e : executions)
|
||||
{
|
||||
String id = (e.getId() != null) ? e.getId() : "";
|
||||
if(executionId.equals( id ))
|
||||
{
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void copyPluginExecution(PluginExecution source, PluginExecution target, boolean isChild)
|
||||
{
|
||||
if(!isChild && source.getInherited() != null && !source.getInherited().equalsIgnoreCase( "true" ))
|
||||
{
|
||||
return;
|
||||
}
|
||||
target.setId( source.getId() );
|
||||
|
||||
if(isChild && source.getInherited() != null)
|
||||
{
|
||||
target.setInherited( source.getInherited() );
|
||||
}
|
||||
|
||||
if(source.getPhase() != null)
|
||||
{
|
||||
target.setPhase( source.getPhase() );
|
||||
}
|
||||
|
||||
List<String> targetGoals = new ArrayList<String>(target.getGoals());
|
||||
List<String> setGoals = new ArrayList<String>();
|
||||
for(String goal : source.getGoals())
|
||||
{
|
||||
if(targetGoals.contains( goal ))
|
||||
{
|
||||
targetGoals.remove( goal );
|
||||
}
|
||||
}
|
||||
setGoals.addAll( source.getGoals() );
|
||||
setGoals.addAll( targetGoals );
|
||||
target.setGoals( setGoals );
|
||||
|
||||
if(source.getConfiguration() != null)
|
||||
{
|
||||
if(target.getConfiguration() != null)
|
||||
{
|
||||
target.setConfiguration( new Xpp3Dom(Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) source.getConfiguration(), (Xpp3Dom) target.getConfiguration() )));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
target.setConfiguration( new Xpp3Dom( (Xpp3Dom) source.getConfiguration()) );
|
||||
//System.out.println("+++++++++++COPY PE+++++++++++++++++" + target.getConfiguration());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,189 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
/**
|
||||
* Used for applying plugin management to the pom (not for inheritance).
|
||||
*
|
||||
*/
|
||||
public class PluginsManagementProcessor extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
||||
List<Plugin> pluginManagement = (List<Plugin> ) child;
|
||||
List<Plugin> targetPlugin = (List<Plugin>) target;
|
||||
|
||||
for(Plugin depMng : pluginManagement)
|
||||
{
|
||||
for(Plugin targetDep : targetPlugin)
|
||||
{ //PluginManagement is first in ordering
|
||||
if(match(depMng, targetDep) )
|
||||
{
|
||||
copy(depMng, targetDep );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean match( Plugin d1, Plugin d2 )
|
||||
{
|
||||
return getId( d1 ).equals( getId( d2 ) ) ;
|
||||
}
|
||||
|
||||
private static String getId( Plugin d )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( d.getGroupId() ).append( ":" ).append( d.getArtifactId() );
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static void copy(Plugin source, Plugin target)
|
||||
{
|
||||
if(target.getArtifactId() == null)
|
||||
{
|
||||
target.setArtifactId( source.getArtifactId() );
|
||||
}
|
||||
|
||||
target.setGroupId( source.getGroupId() );
|
||||
|
||||
if(target.getInherited() == null)
|
||||
{
|
||||
target.setInherited( source.getInherited() );
|
||||
}
|
||||
|
||||
if(target.getVersion() == null)
|
||||
{
|
||||
target.setVersion( source.getVersion() );
|
||||
}
|
||||
|
||||
List<PluginExecution> executions = new ArrayList<PluginExecution>();
|
||||
for( PluginExecution pe : source.getExecutions())
|
||||
{
|
||||
PluginExecution idMatch = contains(pe, target.getExecutions());
|
||||
if(idMatch != null)//Join
|
||||
{
|
||||
copyPluginExecution(pe, idMatch);
|
||||
target.getExecutions().remove( idMatch );
|
||||
executions.add( idMatch );
|
||||
}
|
||||
else
|
||||
{
|
||||
PluginExecution targetPe = new PluginExecution();
|
||||
copyPluginExecution(pe, targetPe);
|
||||
executions.add( targetPe );
|
||||
}
|
||||
}
|
||||
|
||||
executions.addAll( target.getExecutions() );
|
||||
target.setExecutions( executions );
|
||||
|
||||
DependenciesProcessor proc = new DependenciesProcessor(true);
|
||||
if(target.getDependencies().isEmpty())
|
||||
{
|
||||
|
||||
proc.process( new ArrayList<Dependency>(), new ArrayList<Dependency>(source.getDependencies()), target.getDependencies(), false );
|
||||
}
|
||||
else
|
||||
{
|
||||
proc.process( new ArrayList<Dependency>(source.getDependencies()), new ArrayList<Dependency>(), target.getDependencies(), false );
|
||||
}
|
||||
|
||||
if(source.getConfiguration() != null)
|
||||
{
|
||||
//TODO: Not copying
|
||||
if(target.getConfiguration() != null)
|
||||
{
|
||||
target.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) target.getConfiguration(), (Xpp3Dom) source.getConfiguration() ));
|
||||
}
|
||||
else
|
||||
{
|
||||
target.setConfiguration( source.getConfiguration() );
|
||||
}
|
||||
}
|
||||
|
||||
target.setExtensions(source.isExtensions());
|
||||
|
||||
}
|
||||
|
||||
private static PluginExecution contains(PluginExecution pe, List<PluginExecution> executions)
|
||||
{
|
||||
String executionId = (pe.getId() != null) ? pe.getId() : "";
|
||||
for(PluginExecution e : executions)
|
||||
{
|
||||
String id = (e.getId() != null) ? e.getId() : "";
|
||||
if(executionId.equals( id ))
|
||||
{
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void copyPluginExecution(PluginExecution source, PluginExecution target)
|
||||
{
|
||||
if(target.getId() != null)
|
||||
{
|
||||
target.setId( source.getId() );
|
||||
}
|
||||
|
||||
if ( target.getInherited() == null )
|
||||
{
|
||||
target.setInherited( source.getInherited() );
|
||||
}
|
||||
|
||||
if ( target.getPhase() == null )
|
||||
{
|
||||
target.setPhase( source.getPhase() );
|
||||
}
|
||||
|
||||
List<String> goals = new ArrayList<String>(target.getGoals());
|
||||
for(String goal : source.getGoals())
|
||||
{
|
||||
if(!goals.contains( goal ))
|
||||
{
|
||||
goals.add( goal );
|
||||
}
|
||||
|
||||
}
|
||||
target.setGoals( goals );
|
||||
if(source.getConfiguration() != null)
|
||||
{
|
||||
if(target.getConfiguration() != null)
|
||||
{
|
||||
//Target is dominant
|
||||
target.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) target.getConfiguration(), (Xpp3Dom) source.getConfiguration() ));
|
||||
}
|
||||
else
|
||||
{
|
||||
target.setConfiguration( source.getConfiguration() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Plugin;
|
||||
|
||||
public class PluginsProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
List<Plugin> c = (child != null) ? (List<Plugin>) child : new ArrayList<Plugin>() ;
|
||||
List<Plugin> p = null;
|
||||
|
||||
if ( parent != null )
|
||||
{
|
||||
p = (List<Plugin>) parent;
|
||||
}
|
||||
|
||||
List<Plugin> plugins = (List<Plugin>) target;
|
||||
|
||||
PluginProcessor processor = new PluginProcessor();
|
||||
|
||||
if ( ( p == null || p.isEmpty() ) && !c.isEmpty() )
|
||||
{
|
||||
for ( Plugin plugin : c )
|
||||
{
|
||||
processor.process( null, plugin, plugins, isChildMostSpecialized );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !c.isEmpty() )
|
||||
{
|
||||
List<Plugin> parentDependencies = new ArrayList<Plugin>();
|
||||
for ( Plugin childPlugin : c)
|
||||
{
|
||||
for ( Plugin parentPlugin : p)
|
||||
{
|
||||
if ( match( childPlugin, parentPlugin ) )
|
||||
{
|
||||
processor.process( parentPlugin, childPlugin, plugins, isChildMostSpecialized );// JOIN
|
||||
}
|
||||
else
|
||||
{
|
||||
processor.process( null, childPlugin, plugins, isChildMostSpecialized );
|
||||
if(!parentDependencies.contains(parentPlugin))
|
||||
{
|
||||
parentDependencies.add( parentPlugin );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process Parents after child to keep plugin order but don't want to overwrite the child values. Use different method
|
||||
*/
|
||||
for ( Plugin d2 : parentDependencies )
|
||||
{
|
||||
processor.process( d2, plugins, isChildMostSpecialized );
|
||||
}
|
||||
|
||||
}
|
||||
else if( p != null)
|
||||
{
|
||||
for ( Plugin d2 : p )
|
||||
{
|
||||
processor.process( d2, null, plugins, isChildMostSpecialized );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static boolean match( Plugin d1, Plugin d2 )
|
||||
{
|
||||
return getId( d1 ).equals( getId( d2 ));
|
||||
}
|
||||
|
||||
private static String getId( Plugin d )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( (d.getGroupId() != null) ? d.getGroupId() : "org.apache.maven.plugins").append( ":" ).append( d.getArtifactId() ).append( ":" );
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Prerequisites;
|
||||
|
||||
public class PrerequisitesProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
||||
if ( isChildMostSpecialized )
|
||||
{
|
||||
Model t = (Model) target;
|
||||
Model c = (Model) child;
|
||||
if ( c.getPrerequisites() == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
Prerequisites prerequisites = new Prerequisites();
|
||||
prerequisites.setMaven( c.getPrerequisites().getMaven() );
|
||||
t.setPrerequisites( prerequisites );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
public class ProfilePropertiesProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
Model t = (Model) target, c = (Model) child, p = (Model) parent;
|
||||
|
||||
Properties properties = new Properties();
|
||||
|
||||
if ( c.getProperties() != null )
|
||||
{
|
||||
properties.putAll( c.getProperties() );
|
||||
}
|
||||
|
||||
if ( p != null && p.getProperties() != null )
|
||||
{
|
||||
properties.putAll( p.getProperties() );
|
||||
}
|
||||
|
||||
if ( !properties.isEmpty() )
|
||||
{
|
||||
if(t.getProperties().isEmpty())
|
||||
{
|
||||
t.setProperties( properties );
|
||||
}
|
||||
else
|
||||
{
|
||||
add(properties, t.getProperties());
|
||||
//t.getProperties().putAll( properties );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add source properties to target if the property does not exist: parent over child
|
||||
*
|
||||
* @param source
|
||||
* @param target
|
||||
*/
|
||||
private static void add(Properties source, Properties target)
|
||||
{
|
||||
for(Object key : source.keySet())
|
||||
{
|
||||
if(!target.containsKey(key))
|
||||
{
|
||||
target.put(key, source.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
public class ProfilesModuleProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
Model t = (Model) target;
|
||||
Model c = (Model) child;
|
||||
Model p = (Model) parent;
|
||||
List<String> modules = new ArrayList<String>();
|
||||
|
||||
for ( String module : c.getModules() )
|
||||
{
|
||||
if(!modules.contains( module ))
|
||||
{
|
||||
modules.add(module);
|
||||
}
|
||||
}
|
||||
if(p != null)
|
||||
{
|
||||
for ( String module : p.getModules() )
|
||||
{
|
||||
if(!modules.contains( module ))
|
||||
{
|
||||
modules.add(module);
|
||||
}
|
||||
}
|
||||
}
|
||||
t.setModules( modules );
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.ProcessorContext;
|
||||
import org.apache.maven.model.Profile;
|
||||
|
||||
|
||||
public class ProfilesProcessor extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
Model t = (Model) target;
|
||||
List<Profile> profiles = ((Model) child).getProfiles();
|
||||
List<Profile> copies = new ArrayList<Profile>();
|
||||
for(Profile p : profiles)
|
||||
{
|
||||
copies.add( ProcessorContext.copyOfProfile(p) );
|
||||
}
|
||||
t.setProfiles( copies );
|
||||
//TODO - copy
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
public class PropertiesProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
Model t = (Model) target, c = (Model) child, p = (Model) parent;
|
||||
|
||||
Properties properties = new Properties();
|
||||
|
||||
if ( p != null && p.getProperties() != null )
|
||||
{
|
||||
properties.putAll( p.getProperties() );
|
||||
}
|
||||
|
||||
if ( c.getProperties() != null )
|
||||
{
|
||||
properties.putAll( c.getProperties() );
|
||||
}
|
||||
|
||||
if ( !properties.isEmpty() )
|
||||
{
|
||||
if(t.getProperties().isEmpty())
|
||||
{
|
||||
t.setProperties( properties );
|
||||
}
|
||||
else
|
||||
{
|
||||
t.getProperties().putAll( properties );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,162 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.ReportPlugin;
|
||||
import org.apache.maven.model.ReportSet;
|
||||
import org.apache.maven.model.Reporting;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
public class ReportingProcessor extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
||||
Model t = (Model) target, c = (Model) child, p = (Model) parent;
|
||||
if(p != null && p.getReporting() != null)
|
||||
{
|
||||
if(t.getReporting() == null)
|
||||
{
|
||||
t.setReporting( new Reporting() );
|
||||
}
|
||||
|
||||
copy(p.getReporting(), t.getReporting());
|
||||
}
|
||||
|
||||
if(c.getReporting() != null)
|
||||
{
|
||||
if(t.getReporting() == null)
|
||||
{
|
||||
t.setReporting( new Reporting() );
|
||||
}
|
||||
|
||||
copy(c.getReporting(), t.getReporting());
|
||||
}
|
||||
}
|
||||
|
||||
private static void copy(Reporting source, Reporting target)
|
||||
{
|
||||
if(source.getOutputDirectory() != null)
|
||||
{
|
||||
target.setOutputDirectory( source.getOutputDirectory() );
|
||||
|
||||
}
|
||||
|
||||
target.setExcludeDefaults( source.isExcludeDefaults() );
|
||||
|
||||
for ( ReportPlugin plugin : source.getPlugins() )
|
||||
{
|
||||
ReportPlugin match = contains(plugin, target.getPlugins());
|
||||
if(match == null)
|
||||
{
|
||||
target.addPlugin( copyNewPlugin( plugin ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
copyPluginToPlugin(plugin, match);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static ReportPlugin contains(ReportPlugin plugin, List<ReportPlugin> list)
|
||||
{
|
||||
for(ReportPlugin p :list)
|
||||
{
|
||||
if(match(p, plugin))
|
||||
{
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void copyPluginToPlugin(ReportPlugin source, ReportPlugin target)
|
||||
{
|
||||
if(source.getInherited() != null)
|
||||
{
|
||||
target.setInherited( source.getInherited() );
|
||||
}
|
||||
|
||||
if(source.getVersion() != null)
|
||||
{
|
||||
target.setVersion( source.getVersion() );
|
||||
}
|
||||
|
||||
if(source.getConfiguration() != null)
|
||||
{
|
||||
if(target.getConfiguration() != null)
|
||||
{
|
||||
target.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) source.getConfiguration(), (Xpp3Dom) target.getConfiguration() ));
|
||||
}
|
||||
else
|
||||
{
|
||||
target.setConfiguration( source.getConfiguration() );
|
||||
}
|
||||
}
|
||||
|
||||
for(ReportSet rs : source.getReportSets())
|
||||
{
|
||||
ReportSet r = new ReportSet();
|
||||
r.setId( rs.getId() );
|
||||
r.setInherited( rs.getInherited() );
|
||||
r.setReports( new ArrayList<String>(rs.getReports()) );
|
||||
r.setConfiguration( rs.getConfiguration() );
|
||||
target.addReportSet( r );
|
||||
}
|
||||
}
|
||||
|
||||
private static ReportPlugin copyNewPlugin(ReportPlugin plugin)
|
||||
{
|
||||
ReportPlugin rp = new ReportPlugin();
|
||||
rp.setArtifactId( plugin.getArtifactId() );
|
||||
rp.setGroupId( plugin.getGroupId() );
|
||||
rp.setInherited( plugin.getInherited() );
|
||||
rp.setVersion( plugin.getVersion() );
|
||||
rp.setConfiguration( plugin.getConfiguration() );
|
||||
|
||||
for(ReportSet rs : plugin.getReportSets())
|
||||
{
|
||||
ReportSet r = new ReportSet();
|
||||
r.setId( rs.getId() );
|
||||
r.setInherited( rs.getInherited() );
|
||||
r.setReports( new ArrayList<String>(rs.getReports()) );
|
||||
r.setConfiguration( rs.getConfiguration() );
|
||||
rp.addReportSet( r );
|
||||
}
|
||||
return rp;
|
||||
}
|
||||
|
||||
private static boolean match( ReportPlugin d1, ReportPlugin d2 )
|
||||
{
|
||||
return getId( d1 ).equals( getId( d2 ));
|
||||
}
|
||||
|
||||
private static String getId( ReportPlugin d )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( d.getGroupId() ).append( ":" ).append( d.getArtifactId() ).append( ":" );
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.model.RepositoryPolicy;
|
||||
|
||||
public class RepositoriesProcessor extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
||||
Model t = (Model) target, c = (Model) child, p = (Model) parent;
|
||||
if(p != null)
|
||||
{
|
||||
copy( p.getRepositories(), t.getRepositories() );
|
||||
copy( p.getPluginRepositories(), t.getPluginRepositories() );
|
||||
}
|
||||
copy(c.getPluginRepositories(), t.getPluginRepositories());
|
||||
copy( c.getRepositories(), t.getRepositories() );
|
||||
}
|
||||
|
||||
private static void copy(List<Repository> sources, List<Repository> targets)
|
||||
{
|
||||
for(Repository repository : sources)
|
||||
{
|
||||
Repository match = matches(repository, targets);
|
||||
Repository r = null;
|
||||
if(match != null)
|
||||
{
|
||||
r = match;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = new Repository();
|
||||
}
|
||||
|
||||
r.setId( repository.getId() );
|
||||
r.setLayout( repository.getLayout() );
|
||||
r.setName( repository.getName() );
|
||||
r.setUrl( repository.getUrl() );
|
||||
if(repository.getReleases() != null)
|
||||
{
|
||||
r.setReleases( copy(repository.getReleases()) );
|
||||
}
|
||||
if(repository.getSnapshots() != null)
|
||||
{
|
||||
r.setSnapshots( copy(repository.getSnapshots()) );
|
||||
}
|
||||
if (match == null)
|
||||
{
|
||||
targets.add( r );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Repository matches(Repository repository, List<Repository> targets)
|
||||
{
|
||||
for(Repository r : targets)
|
||||
{
|
||||
if(r.getId() != null && r.getId().equals(repository.getId()))
|
||||
{
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static RepositoryPolicy copy(RepositoryPolicy policy)
|
||||
{
|
||||
RepositoryPolicy p = new RepositoryPolicy();
|
||||
p.setChecksumPolicy( policy.getChecksumPolicy() );
|
||||
p.setEnabled(policy.getEnabled());
|
||||
p.setUpdatePolicy( policy.getUpdatePolicy() );
|
||||
return p;
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
package org.apache.maven.model.processors;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Scm;
|
||||
|
||||
public class ScmProcessor extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
Model t = (Model) target;
|
||||
Model c = (Model) child;
|
||||
Model p = (Model) parent;
|
||||
if((p == null || p.getScm() == null) && (c == null || c.getScm() == null))
|
||||
{
|
||||
//return;
|
||||
}
|
||||
Scm targetScm = (t.getScm() == null) ? new Scm() : t.getScm();
|
||||
|
||||
copyUrl( ((p != null) ? p.getScm() : null), c.getScm(), targetScm, c.getArtifactId(), p);
|
||||
copyConnection( ((p != null) ? p.getScm() : null), c.getScm(), targetScm, c.getArtifactId(), p);
|
||||
copyDeveloperConnection( ((p != null) ? p.getScm() : null), c.getScm(), targetScm, c.getArtifactId(), p);
|
||||
copyTag( ( ( p != null ) ? p.getScm() : null ), c.getScm(), targetScm );
|
||||
|
||||
if(t.getScm() ==null && (targetScm.getConnection() !=null || targetScm.getDeveloperConnection() != null || targetScm.getUrl() != null))
|
||||
{
|
||||
t.setScm(targetScm);
|
||||
}
|
||||
}
|
||||
|
||||
private void copyUrl(Scm p, Scm c, Scm t, String artifactId, Model parent )
|
||||
{
|
||||
if(c != null && c.getUrl() != null)
|
||||
{
|
||||
t.setUrl( c.getUrl() );
|
||||
}
|
||||
else if(p != null && p.getUrl() != null)
|
||||
{
|
||||
t.setUrl( normalizeUriWithRelativePath(p.getUrl(), artifactId, parent));
|
||||
}
|
||||
else if(t.getUrl() != null) {
|
||||
t.setUrl( t.getUrl() + "/" + artifactId );
|
||||
}
|
||||
}
|
||||
|
||||
private void copyConnection(Scm p, Scm c, Scm t, String artifactId, Model parent )
|
||||
{
|
||||
if(c!= null && c.getConnection() != null)
|
||||
{
|
||||
t.setConnection( c.getConnection() );
|
||||
}
|
||||
else if(p != null && p.getConnection() != null)
|
||||
{
|
||||
t.setConnection( normalizeUriWithRelativePath(p.getConnection(), artifactId, parent));
|
||||
}
|
||||
else if(t.getConnection() != null) {
|
||||
t.setConnection( t.getConnection() + "/" + artifactId );
|
||||
}
|
||||
}
|
||||
|
||||
private void copyDeveloperConnection(Scm p, Scm c, Scm t, String artifactId, Model parent )
|
||||
{
|
||||
if(c!= null && c.getDeveloperConnection() != null)
|
||||
{
|
||||
t.setDeveloperConnection( c.getDeveloperConnection() );
|
||||
}
|
||||
else if(p != null && p.getDeveloperConnection() != null)
|
||||
{
|
||||
t.setDeveloperConnection( normalizeUriWithRelativePath(p.getDeveloperConnection(), artifactId, parent) );
|
||||
}
|
||||
else if(t.getDeveloperConnection() != null){
|
||||
t.setDeveloperConnection( t.getDeveloperConnection() + "/" + artifactId );
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyTag( Scm p, Scm c, Scm t )
|
||||
{
|
||||
if ( c != null && c.getTag() != null )
|
||||
{
|
||||
t.setTag( c.getTag() );
|
||||
}
|
||||
else if ( p != null && p.getTag() != null )
|
||||
{
|
||||
t.setTag( p.getTag() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue