/** * Method updateModelBase * * @param value * @param element * @param counter * @param xmlTag */ //CHECKSTYLE_OFF: LineLength protected void updateModelBase( ModelBase value, String xmlTag, Counter counter, Element element ) { boolean shouldExist = value != null; Element root = updateElement( counter, element, xmlTag, shouldExist ); if ( shouldExist ) { Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleLists( innerCount, root, value.getModules(), "modules", "module" ); iterateRepository( innerCount, root, value.getRepositories(), "repositories", "repository" ); iterateRepository( innerCount, root, value.getPluginRepositories(), "pluginRepositories", "pluginRepository" ); iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" ); findAndReplaceXpp3DOM( innerCount, root, "reports", (Xpp3Dom) value.getReports() ); updateReporting( value.getReporting(), "reporting", innerCount, root ); updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root ); updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount, root ); findAndReplaceProperties( innerCount, root, "properties", value.getProperties() ); } }
/** * Method updateModelBase * * @param value * @param element * @param counter * @param xmlTag */ protected void updateModelBase( ModelBase value, String xmlTag, Counter counter, Element element ) { boolean shouldExist = value != null; Element root = updateElement( counter, element, xmlTag, shouldExist ); if ( shouldExist ) { Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleLists( innerCount, root, value.getModules(), "modules", "module" ); iterateRepository( innerCount, root, value.getRepositories(), "repositories", "repository" ); iterateRepository( innerCount, root, value.getPluginRepositories(), "pluginRepositories", "pluginRepository" ); iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" ); findAndReplaceXpp3DOM( innerCount, root, "reports", (Xpp3Dom) value.getReports() ); updateReporting( value.getReporting(), "reporting", innerCount, root ); updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root ); updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount, root ); findAndReplaceProperties( innerCount, root, "properties", value.getProperties() ); } }
public Map<String, Plugin> getPluginMap( final ModelBase base ) { final BuildBase build; if ( base instanceof Model ) { build = ( (Model) base ).getBuild(); } else { build = ( (Profile) base ).getBuild(); } if ( build == null ) { return Collections.emptyMap(); } final Map<String, Plugin> result = build.getPluginsAsMap(); if ( result == null ) { return Collections.emptyMap(); } return result; }
/** * Go through the plugin / plugin-execution configurations and find references to the <code>skip</code> parameter for the given Maven plugin * (specified by artifactId), both in managed and concrete plugin declarations (where available). */ private List<SkipReference> findSkipRefs( final ModelBase base, final String pluginArtifactId, final Project project ) throws ManipulationException { final String key = ga( MAVEN_PLUGIN_GROUPID, pluginArtifactId ); final List<SkipReference> result = new ArrayList<>(); Map<String, Plugin> pluginMap = project.getManagedPluginMap( base ); Plugin plugin = pluginMap.get( key ); result.addAll( findSkipRefs( plugin, project ) ); pluginMap = project.getPluginMap( base ); plugin = pluginMap.get( key ); result.addAll( findSkipRefs( plugin, project ) ); return result; }
protected void mergeModelBase_Properties( ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context ) { Properties merged = new Properties(); if ( sourceDominant ) { merged.putAll( target.getProperties() ); merged.putAll( source.getProperties() ); } else { merged.putAll( source.getProperties() ); merged.putAll( target.getProperties() ); } target.setProperties( merged ); target.setLocation( "properties", InputLocation.merge( target.getLocation( "properties" ), source.getLocation( "properties" ), sourceDominant ) ); }
private static void scanForSubmodulesIn(ModelBase projectOrProfile, File basedir, Set<File> registered) throws IllegalArgumentException { for (String module : projectOrProfile.getModules()) { if (module == null) { //#205690 apparently in some rare scenarios module can be null, I was not able to reproduce myself //maven itself checks for null value during validation, but at later stages doesn't always check. //additional aspect for consideration is that in this case the value is taken from Model class not MavenProject continue; } registerWithSubmodules(FileUtilities.resolveFilePath(basedir, module), registered); } }
private static void interpolate(Map<String, String> dict, MavenProject p) { if (p == null) { return; } interpolate(dict, p.getParent()); interpolate(dict, p.getModel()); for (ModelBase model: p.getActiveProfiles()) { interpolate(dict, model); } }
public Map<String, Plugin> getManagedPluginMap( final ModelBase base ) { if ( base instanceof Model ) { final Build build = ( (Model) base ).getBuild(); if ( build == null ) { return Collections.emptyMap(); } final PluginManagement pm = build.getPluginManagement(); if ( pm == null ) { return Collections.emptyMap(); } final Map<String, Plugin> result = pm.getPluginsAsMap(); if ( result == null ) { return Collections.emptyMap(); } return result; } return Collections.emptyMap(); }
protected void mergeModelBase( ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context ) { mergeModelBase_DistributionManagement( target, source, sourceDominant, context ); mergeModelBase_Modules( target, source, sourceDominant, context ); mergeModelBase_Repositories( target, source, sourceDominant, context ); mergeModelBase_PluginRepositories( target, source, sourceDominant, context ); mergeModelBase_Dependencies( target, source, sourceDominant, context ); mergeModelBase_Reporting( target, source, sourceDominant, context ); mergeModelBase_DependencyManagement( target, source, sourceDominant, context ); mergeModelBase_Properties( target, source, sourceDominant, context ); }
protected void mergeModelBase_Modules( ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context ) { List<String> src = source.getModules(); if ( !src.isEmpty() ) { List<String> tgt = target.getModules(); List<String> merged = new ArrayList<String>( tgt.size() + src.size() ); merged.addAll( tgt ); merged.addAll( src ); target.setModules( merged ); } }
@Override protected void mergeModelBase_Modules( ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context ) { List<String> src = source.getModules(); if ( !src.isEmpty() && sourceDominant ) { List<Integer> indices = new ArrayList<Integer>(); List<String> tgt = target.getModules(); Set<String> excludes = new LinkedHashSet<String>( tgt ); List<String> merged = new ArrayList<String>( tgt.size() + src.size() ); merged.addAll( tgt ); for ( int i = 0, n = tgt.size(); i < n; i++ ) { indices.add( Integer.valueOf( i ) ); } for ( int i = 0, n = src.size(); i < n; i++ ) { String s = src.get( i ); if ( !excludes.contains( s ) ) { merged.add( s ); indices.add( Integer.valueOf( ~i ) ); } } target.setModules( merged ); target.setLocation( "modules", InputLocation.merge( target.getLocation( "modules" ), source.getLocation( "modules" ), indices ) ); } }
public void mergeModelBase( ModelBase target, ModelBase source ) { mergeModelBase( target, source, true, Collections.emptyMap() ); }