-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NCL-5717: Remove nexus-staging-maven-plugin by default
- Loading branch information
Showing
21 changed files
with
823 additions
and
25 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
...in/java/org/commonjava/maven/ext/core/impl/NexusStagingMavenPluginRemovalManipulator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (C) 2012 Red Hat, Inc. | ||
* | ||
* Licensed 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. | ||
*/ | ||
package org.commonjava.maven.ext.core.impl; | ||
|
||
import org.commonjava.maven.ext.common.model.Project; | ||
import org.commonjava.maven.ext.core.ManipulationSession; | ||
import org.commonjava.maven.ext.core.state.NexusStagingMavenPluginRemovalState; | ||
import org.commonjava.maven.ext.core.state.PluginState; | ||
|
||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* {@link Manipulator} implementation that can remove nexus-staging-maven-plugin from a project's pom file. | ||
* Configuration is stored in a {@link PluginState} instance, which is in turn stored in the | ||
* {@link ManipulationSession}. | ||
*/ | ||
@Named("nexus-staging-maven-plugin-removal-manipulator") | ||
@Singleton | ||
public class NexusStagingMavenPluginRemovalManipulator | ||
extends PluginRemovalManipulator { | ||
/** | ||
* Initialize the {@link PluginState} state holder in the {@link ManipulationSession}. This state holder detects | ||
* version-change configuration from the Maven user properties (-D properties from the CLI) and makes it available | ||
* for later. | ||
* | ||
* @param session the session | ||
*/ | ||
@Override | ||
public void init( ManipulationSession session ) | ||
{ | ||
this.session = session; | ||
session.setState( new NexusStagingMavenPluginRemovalState() ); | ||
} | ||
|
||
/** | ||
* Apply the alignment changes to the list of {@link Project}s given. | ||
* | ||
* @param projects the projects to apply changes to | ||
*/ | ||
@Override | ||
public Set<Project> applyChanges( final List<Project> projects ) | ||
{ | ||
return applyChanges( projects, session.getState( NexusStagingMavenPluginRemovalState.class ) ); | ||
} | ||
|
||
/** | ||
* Determines the order in which manipulators are run, with the lowest number running first. | ||
* Uses a 100-point scale. | ||
* | ||
* @return one greater than current index for {@code PluginRemovalManipulator} | ||
*/ | ||
@Override | ||
public int getExecutionIndex() | ||
{ | ||
return 53; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...rc/main/java/org/commonjava/maven/ext/core/state/NexusStagingMavenPluginRemovalState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright (C) 2012 Red Hat, Inc. | ||
* | ||
* Licensed 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. | ||
*/ | ||
package org.commonjava.maven.ext.core.state; | ||
|
||
import org.commonjava.maven.atlas.ident.ref.ProjectRef; | ||
import org.commonjava.maven.atlas.ident.ref.SimpleVersionlessArtifactRef; | ||
import org.commonjava.maven.ext.annotation.ConfigValue; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
/** | ||
* Captures configuration relating to nexus-staging-maven-plugin removal from the POMs. | ||
*/ | ||
public final class NexusStagingMavenPluginRemovalState | ||
extends PluginRemovalState | ||
{ | ||
/** | ||
* The name of the property which contains a boolean controlling whether or not to remove. | ||
* | ||
* {@code -DnexusStagingMavenPluginRemoval=<true|false>} | ||
*/ | ||
@ConfigValue( docIndex = "plugin-manip.html#nexus-staging-maven-plugin-removal" ) | ||
private static final String NEXUS_STAGING_MAVEN_PLUGIN_REMOVAL_PROPERTY = "nexusStagingMavenPluginRemoval"; | ||
|
||
/** | ||
* The {@code <groupId>:<artifactId>} coordinates of nexus-staging-maven-plugin. | ||
*/ | ||
private static final String NEXUS_STAGING_MAVEN_PLUGIN_SPEC = "org.sonatype.plugins:nexus-staging-maven-plugin"; | ||
|
||
/** The user properties. */ | ||
private Properties userProperties; | ||
|
||
/** | ||
* Initializes this state with the given {@code userProps}. | ||
* | ||
* The value {@link #isEnabled} will be set based on the value of the {@code nexusStagingMavenPluginRemoval} | ||
* boolean property. | ||
* | ||
* @param userProps the user properties | ||
*/ | ||
@Override | ||
public void initialise( final Properties userProps ) | ||
{ | ||
this.userProperties = userProps; | ||
} | ||
|
||
/** | ||
* Always enabled unless {@code nexusStagingMavenPluginRemoval} is set to {@code false} in the user properties | ||
* or the CLI {@code -D} options. | ||
* | ||
* @see State#isEnabled() | ||
*/ | ||
@Override | ||
public boolean isEnabled() | ||
{ | ||
return Boolean.parseBoolean( userProperties.getProperty( NEXUS_STAGING_MAVEN_PLUGIN_REMOVAL_PROPERTY, | ||
Boolean.TRUE.toString() ) ); | ||
} | ||
|
||
/** | ||
* Always returns a singleton {@link List} containing a {@link ProjectRef} with the coordinates | ||
* {@code org.sonatype.plugins:nexus-staging-maven-plugin}. | ||
* | ||
* @return a singleton {@link List} containing a {@link ProjectRef} with the coordinates | ||
* {@code org.sonatype.plugins:nexus-staging-maven-plugin} | ||
*/ | ||
@Override | ||
public List<ProjectRef> getPluginRemoval() | ||
{ | ||
return Collections.singletonList( SimpleVersionlessArtifactRef.parse( NEXUS_STAGING_MAVEN_PLUGIN_SPEC ) ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
integration-test/src/it/nexus-staging-maven-plugin-removal-disabled/invoker.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# | ||
# Copyright (C) 2012 Red Hat, Inc. | ||
# | ||
# Licensed 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. | ||
# | ||
|
||
invoker.goals=install |
Oops, something went wrong.