Skip to content

Commit 1fa1805

Browse files
authored
[MPLUGIN-519][MPLUGIN-520] Parent POM 42, prerequisite of 3.6.3, get rid of maven-compat (#280)
Update parent POM to 42, up prerequisite to 3.6.3. As parent 42 removes implicit (sisu) indexing, added explicitly indexing to all modules, as I think they all need it (may be wrong here). The Mojo `AddPluginArtifactMetadataMojo` pulls in classes that have transitive (classes) coming from maven-compat. In fact, this mojo is not required at all since Maven 3.9.0 as resolver handles all transparently. --- https://issues.apache.org/jira/browse/MPLUGIN-519 https://issues.apache.org/jira/browse/MPLUGIN-520
1 parent e746d9c commit 1fa1805

File tree

9 files changed

+80
-35
lines changed

9 files changed

+80
-35
lines changed

maven-plugin-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
in order to include them the resulting JAR. It is also used to generate a generic help goal.</description>
3636

3737
<prerequisites>
38-
<maven>${maven3Version}</maven>
38+
<maven>3.6.3</maven>
3939
</prerequisites>
4040

4141
<properties>

maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ assert descriptorFile.isFile()
2828
def pluginDescriptor = new XmlParser().parse( descriptorFile );
2929

3030
assert pluginDescriptor.requiredJavaVersion.text() == '1.8'
31-
assert pluginDescriptor.requiredMavenVersion.text() == '3.2.5'
31+
assert pluginDescriptor.requiredMavenVersion.text() == '3.9.6'
3232

3333
def mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "first" }[0]
3434

maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.apache.maven.plugins.annotations.Mojo;
3939
import org.apache.maven.plugins.annotations.Parameter;
4040
import org.apache.maven.plugins.annotations.ResolutionScope;
41-
import org.apache.maven.settings.Settings;
4241
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
4342
import org.apache.maven.tools.plugin.ExtendedPluginDescriptor;
4443
import org.apache.maven.tools.plugin.PluginToolsRequest;
@@ -221,14 +220,6 @@ public class DescriptorGeneratorMojo extends AbstractGeneratorMojo {
221220
@Parameter(property = "internalJavadocVersion", defaultValue = "${java.version}")
222221
protected String internalJavadocVersion;
223222

224-
/**
225-
* The Maven Settings, for evaluating proxy settings used to access {@link #javadocLinks}
226-
*
227-
* @since 3.7.0
228-
*/
229-
@Component
230-
private Settings settings;
231-
232223
@Component
233224
private MavenSession mavenSession;
234225

@@ -351,7 +342,7 @@ public void generate() throws MojoExecutionException {
351342
request.setInternalJavadocBaseUrl(internalJavadocBaseUrl);
352343
request.setInternalJavadocVersion(internalJavadocVersion);
353344
request.setExternalJavadocBaseUrls(externalJavadocBaseUrls);
354-
request.setSettings(settings);
345+
request.setSettings(mavenSession.getSettings());
355346

356347
mojoScanner.populatePluginDescriptor(request);
357348
request.setPluginDescriptor(extendPluginDescriptor(request));

maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/AddPluginArtifactMetadataMojo.java

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
*/
1919
package org.apache.maven.plugin.plugin.metadata;
2020

21-
import org.apache.maven.artifact.Artifact;
22-
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
23-
import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
24-
import org.apache.maven.artifact.repository.metadata.Versioning;
2521
import org.apache.maven.plugin.AbstractMojo;
2622
import org.apache.maven.plugin.MojoExecutionException;
2723
import org.apache.maven.plugin.descriptor.PluginDescriptor;
@@ -30,6 +26,10 @@
3026
import org.apache.maven.plugins.annotations.Mojo;
3127
import org.apache.maven.plugins.annotations.Parameter;
3228
import org.apache.maven.project.MavenProject;
29+
import org.apache.maven.rtinfo.RuntimeInformation;
30+
import org.eclipse.aether.util.version.GenericVersionScheme;
31+
import org.eclipse.aether.version.InvalidVersionSpecificationException;
32+
import org.eclipse.aether.version.VersionScheme;
3333

3434
/**
3535
* Inject any plugin-specific
@@ -42,8 +42,8 @@
4242
* <li>to define plugin mapping in the group</li>
4343
* </ol>
4444
*
45-
* @see ArtifactRepositoryMetadata
46-
* @see GroupRepositoryMetadata
45+
* @see org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata
46+
* @see org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata
4747
*
4848
* @since 2.0
4949
*/
@@ -69,25 +69,33 @@ public class AddPluginArtifactMetadataMojo extends AbstractMojo {
6969
@Parameter(defaultValue = "false", property = "maven.plugin.skip")
7070
private boolean skip;
7171

72+
@Component
73+
private RuntimeInformation runtimeInformation;
74+
75+
private final VersionScheme versionScheme = new GenericVersionScheme();
76+
7277
/** {@inheritDoc} */
7378
@Override
7479
public void execute() throws MojoExecutionException {
7580
if (skip) {
7681
getLog().warn("Execution skipped");
7782
return;
7883
}
79-
Artifact projectArtifact = project.getArtifact();
80-
81-
Versioning versioning = new Versioning();
82-
versioning.setLatest(projectArtifact.getVersion());
83-
versioning.updateTimestamp();
84-
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata(projectArtifact, versioning);
85-
projectArtifact.addMetadata(metadata);
86-
87-
GroupRepositoryMetadata groupMetadata = new GroupRepositoryMetadata(project.getGroupId());
88-
groupMetadata.addPluginMapping(getGoalPrefix(), project.getArtifactId(), project.getName());
84+
// nothing if Maven is 3.9+
85+
try {
86+
if (versionScheme
87+
.parseVersion("3.9.0")
88+
.compareTo(versionScheme.parseVersion(runtimeInformation.getMavenVersion()))
89+
< 1) {
90+
getLog().info("This Mojo is not used in Maven version 3.9.0 and above");
91+
return;
92+
}
93+
} catch (InvalidVersionSpecificationException e) {
94+
// not happening with generic
95+
throw new MojoExecutionException(e);
96+
}
8997

90-
projectArtifact.addMetadata(groupMetadata);
98+
LegacySupport.execute(project, getGoalPrefix());
9199
}
92100

93101
/**
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.plugin.plugin.metadata;
20+
21+
import org.apache.maven.artifact.Artifact;
22+
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
23+
import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
24+
import org.apache.maven.artifact.repository.metadata.Versioning;
25+
import org.apache.maven.plugin.MojoExecutionException;
26+
import org.apache.maven.project.MavenProject;
27+
28+
public class LegacySupport {
29+
public static void execute(MavenProject project, String goalPrefix) throws MojoExecutionException {
30+
Artifact projectArtifact = project.getArtifact();
31+
Versioning versioning = new Versioning();
32+
versioning.setLatest(projectArtifact.getVersion());
33+
versioning.updateTimestamp();
34+
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata(projectArtifact, versioning);
35+
projectArtifact.addMetadata(metadata);
36+
GroupRepositoryMetadata groupMetadata = new GroupRepositoryMetadata(project.getGroupId());
37+
groupMetadata.addPluginMapping(goalPrefix, project.getArtifactId(), project.getName());
38+
projectArtifact.addMetadata(groupMetadata);
39+
}
40+
}

maven-plugin-report-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<description>The Plugin Report Plugin is used to create reports about the plugin being built.</description>
3535

3636
<prerequisites>
37-
<maven>${maven3Version}</maven>
37+
<maven>3.6.3</maven>
3838
</prerequisites>
3939

4040
<properties>

maven-plugin-report-plugin/src/it/plugin-report-annotations/verify.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ assert !pluginInfo.text.contains('Memory')
2727
assert !pluginInfo.text.contains('Disk Space')
2828
// check JDK and Maven requirements
2929
assert pluginInfo.text.contains('1.8')
30-
assert pluginInfo.text.contains('3.2.5')
30+
assert pluginInfo.text.contains('3.9.6')
3131

3232
// deprecated info and description
3333
assert pluginInfo.text.contains('<div><strong>Deprecated.</strong> You don\'t use test goals, do you?</div><br />')

maven-plugin-report-plugin/src/it/plugin-report/verify.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ assert !pluginInfo.text.contains('Memory')
2626
assert !pluginInfo.text.contains('Disk Space')
2727
// check JDK and Maven requirements
2828
assert pluginInfo.text.contains('1.8')
29-
assert pluginInfo.text.contains('3.2.5')
29+
assert pluginInfo.text.contains('3.9.6')
3030

3131
// deprecated info and description
3232
assert pluginInfo.text.contains('<div><strong>Deprecated.</strong> You don\'t use test goals, do you?</div><br />')

pom.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<groupId>org.apache.maven</groupId>
2525
<artifactId>maven-parent</artifactId>
26-
<version>41</version>
26+
<version>42</version>
2727
<relativePath />
2828
</parent>
2929

@@ -93,15 +93,15 @@
9393
<javaVersion>8</javaVersion>
9494
<pluginTestingHarnessVersion>3.3.0</pluginTestingHarnessVersion>
9595
<maven4Version>4.0.0-alpha-4</maven4Version>
96-
<maven3Version>3.2.5</maven3Version>
96+
<maven3Version>3.9.6</maven3Version>
9797
<slf4jVersion>1.7.36</slf4jVersion>
9898
<antVersion>1.10.14</antVersion>
9999
<maven.site.path>plugin-tools-archives/plugin-tools-LATEST</maven.site.path>
100100
<!-- whenever the ASM version is updated also the
101101
maven-plugin-tools-annotations/src/main/java/o/a/m/tools/plugins/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor#CLASS_VERSION_TO_JAVA_STRING
102102
needs to be updated as well -->
103103
<asmVersion>9.7</asmVersion>
104-
<plexusUtilsVersion>4.0.0</plexusUtilsVersion>
104+
<plexusUtilsVersion>4.0.1</plexusUtilsVersion>
105105
<plexusXmlVersion>3.0.0</plexusXmlVersion>
106106
<reportingApiVersion>3.1.1</reportingApiVersion>
107107
<reportingImplVersion>3.2.0</reportingImplVersion>
@@ -374,6 +374,12 @@
374374
</plugin>
375375
</plugins>
376376
</pluginManagement>
377+
<plugins>
378+
<plugin>
379+
<groupId>org.eclipse.sisu</groupId>
380+
<artifactId>sisu-maven-plugin</artifactId>
381+
</plugin>
382+
</plugins>
377383
</build>
378384

379385
<profiles>

0 commit comments

Comments
 (0)