Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Commit

Permalink
Don't remove plugins from the main (not pluginManagement) section...o…
Browse files Browse the repository at this point in the history
…nly remove their version if necessary.
  • Loading branch information
jdcasey committed Oct 3, 2013
1 parent 5c3302b commit bf27dad
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 101 deletions.
41 changes: 14 additions & 27 deletions src/main/java/com/redhat/rcm/version/mgr/mod/ToolchainModder.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,10 @@ public boolean inject( final Project project, final VersionManagerSession sessio
return changed;
}

private boolean adjustReportPlugins( final Project project, final List<ModelBase> bases,
final Set<VersionlessProjectKey> pluginRefs,
private boolean adjustReportPlugins( final Project project, final List<ModelBase> bases, final Set<VersionlessProjectKey> pluginRefs,
final VersionManagerSession session )
{
final VersionlessProjectKey parentKey =
project.getParent() != null ? new VersionlessProjectKey( project.getParent() ) : null;
final VersionlessProjectKey parentKey = project.getParent() != null ? new VersionlessProjectKey( project.getParent() ) : null;

boolean changed = false;

Expand Down Expand Up @@ -225,8 +223,7 @@ private boolean attemptToolchainParentInjection( final Project project, final Ve
changed = true;
}

final VersionlessProjectKey vtk =
new VersionlessProjectKey( toolchainKey.getGroupId(), toolchainKey.getArtifactId() );
final VersionlessProjectKey vtk = new VersionlessProjectKey( toolchainKey.getGroupId(), toolchainKey.getArtifactId() );

final VersionlessProjectKey vpk = new VersionlessProjectKey( parent );

Expand All @@ -245,8 +242,7 @@ private boolean attemptToolchainParentInjection( final Project project, final Ve
return changed;
}

private boolean injectPluginManagement( final Project project, final Set<VersionlessProjectKey> pluginRefs,
final VersionManagerSession session )
private boolean injectPluginManagement( final Project project, final Set<VersionlessProjectKey> pluginRefs, final VersionManagerSession session )
{
logger.info( "Injecting pluginManagement section from toolchain for: " + project.getKey() );

Expand Down Expand Up @@ -297,8 +293,7 @@ private boolean injectPluginManagement( final Project project, final Set<Version
return changed;
}

private boolean injectPluginUsages( final Project project, final Set<VersionlessProjectKey> pluginRefs,
final VersionManagerSession session )
private boolean injectPluginUsages( final Project project, final Set<VersionlessProjectKey> pluginRefs, final VersionManagerSession session )
{
logger.info( "Injecting plugin usages from toolchain for project: " + project.getKey() );

Expand Down Expand Up @@ -347,8 +342,7 @@ private boolean injectPluginUsages( final Project project, final Set<Versionless
return changed;
}

private boolean stripRemovedPlugins( final Project project, final List<ModelBase> bases,
final VersionManagerSession session )
private boolean stripRemovedPlugins( final Project project, final List<ModelBase> bases, final VersionManagerSession session )
{
logger.info( "Deleting plugins marked for removal for project: " + project.getKey() );

Expand Down Expand Up @@ -405,8 +399,7 @@ private boolean stripRemovedPlugins( final Project project, final List<ModelBase
final Reporting reporting = base.getReporting();
if ( reporting != null )
{
final Map<String, ReportPlugin> pluginMap =
new HashMap<String, ReportPlugin>( reporting.getReportPluginsAsMap() );
final Map<String, ReportPlugin> pluginMap = new HashMap<String, ReportPlugin>( reporting.getReportPluginsAsMap() );
for ( final VersionlessProjectKey key : removedPlugins )
{
final ReportPlugin existing = pluginMap.get( key.getId() );
Expand All @@ -424,22 +417,18 @@ private boolean stripRemovedPlugins( final Project project, final List<ModelBase
return changed;
}

private boolean stripToolchainPluginInfo( final Project project, final List<ModelBase> bases,
final Set<VersionlessProjectKey> pluginRefs,
private boolean stripToolchainPluginInfo( final Project project, final List<ModelBase> bases, final Set<VersionlessProjectKey> pluginRefs,
final VersionManagerSession session )
{
logger.info( "Stripping toolchain plugin info for project: " + project.getKey() );
boolean changed = false;
for ( final ModelBase base : bases )
{
changed =
stripToolchainPluginInfo( project, base, project.getPlugins( base ), pluginRefs, session ) || changed;
changed = stripToolchainPluginInfo( project, base, project.getPlugins( base ), pluginRefs, session, false ) || changed;

logger.info( "Stripping toolchain pluginManagement info for project: " + project.getKey() );

changed =
stripToolchainPluginInfo( project, base, project.getManagedPlugins( base ), pluginRefs, session )
|| changed;
changed = stripToolchainPluginInfo( project, base, project.getManagedPlugins( base ), pluginRefs, session, true ) || changed;
}

project.flushPluginMaps();
Expand All @@ -448,8 +437,7 @@ private boolean stripToolchainPluginInfo( final Project project, final List<Mode
}

private boolean stripToolchainPluginInfo( final Project project, final ModelBase base, final List<Plugin> plugins,
final Set<VersionlessProjectKey> pluginRefs,
final VersionManagerSession session )
final Set<VersionlessProjectKey> pluginRefs, final VersionManagerSession session, final boolean managed )
{
boolean changed = false;
if ( plugins != null )
Expand Down Expand Up @@ -504,22 +492,21 @@ private boolean stripToolchainPluginInfo( final Project project, final ModelBase
// Unless strict mode is set, remove the plugin version. It SHOULD come from the toolchain.
// The capture-POM will assist with adding missing plugins to the toolchain.
plugin.setVersion( null );
changed = true;
}

if ( managedPlugin != null )
{
logger.info( "Stripping plugin version from: " + pluginKey );

if ( isEmpty( plugin.getDependencies() ) && isEmpty( plugin.getExecutions() )
&& plugin.getConfiguration() == null )
if ( managed && isEmpty( plugin.getDependencies() ) && isEmpty( plugin.getExecutions() ) && plugin.getConfiguration() == null )
{
logger.info( "Removing plugin: " + pluginKey );

plugins.remove( plugin );
changed = true;
}

changed = true;

final VersionlessProjectKey parentKey = project.getVersionlessParentKey();
if ( parentKey != null )
{
Expand Down
Loading

0 comments on commit bf27dad

Please sign in to comment.