|
25 | 25 | import org.codehaus.plexus.util.xml.Xpp3Dom;
|
26 | 26 |
|
27 | 27 | /**
|
28 |
| - * Plugin utility to detect if install or deploy is skipped in a build. |
| 28 | + * Plugin utility to detect if install or deploy is skipped in a build, or even nexus-staging. |
| 29 | + * It supports both disabling by parameter configuration or property. |
| 30 | + * Known limitation: it does not look at configuration done more precisely at plugin execution level. |
29 | 31 | */
|
30 | 32 | class PluginUtil {
|
| 33 | + private static final String NEXUS_STAGING = "nexus-staging"; |
| 34 | + |
31 | 35 | static boolean isSkip(MavenProject project) {
|
32 |
| - return isSkip(project, "install") || isSkip(project, "deploy"); |
| 36 | + return isSkip(project, "install") || isSkip(project, "deploy") || isSkip(project, NEXUS_STAGING); |
33 | 37 | }
|
34 | 38 |
|
35 | 39 | private static boolean isSkip(MavenProject project, String id) {
|
36 |
| - Plugin plugin = getPlugin(project, "org.apache.maven.plugins:maven-" + id + "-plugin"); |
37 |
| - String skip = getPluginParameter(plugin, "skip"); |
| 40 | + String pluginGa; |
| 41 | + String pluginParameter; |
| 42 | + String pluginProperty; |
| 43 | + if (id.equals(NEXUS_STAGING)) { |
| 44 | + pluginGa = "org.sonatype.plugins:" + id + "-maven-plugin"; |
| 45 | + pluginParameter = "skipNexusStagingDeployMojo"; |
| 46 | + pluginProperty = "skipNexusStagingDeployMojo"; |
| 47 | + } else { |
| 48 | + pluginGa = "org.apache.maven.plugins:maven-" + id + "-plugin"; |
| 49 | + pluginParameter = "skip"; |
| 50 | + pluginProperty = "maven." + id + ".skip"; |
| 51 | + } |
| 52 | + |
| 53 | + Plugin plugin = getPlugin(project, pluginGa); |
| 54 | + String skip = getPluginParameter(plugin, pluginParameter); |
38 | 55 | if (skip == null) {
|
39 |
| - skip = project.getProperties().getProperty("maven." + id + ".skip"); |
| 56 | + skip = project.getProperties().getProperty(pluginProperty); |
40 | 57 | }
|
41 | 58 | return Boolean.parseBoolean(skip);
|
42 | 59 | }
|
|
0 commit comments