Skip to content

Commit 38a128f

Browse files
authored
[MNG-8180] Back out from failing the build (#1642)
Just warn for now, we cannot go from builds-ok w/ 3.9.8 to fails-the-build in 3.9.9. Warning can raise awareness, and this pattern is bad as it is, but users now become aware that they may have rogue plugin.xml (just like maven-compat had). The original bug is fixed (Maven deploys unrelated metadata). Same change is to be ported to master as well. --- https://issues.apache.org/jira/browse/MNG-8180
1 parent f2135c1 commit 38a128f

File tree

5 files changed

+14
-110
lines changed

5 files changed

+14
-110
lines changed

maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataGenerator.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
import org.eclipse.aether.installation.InstallRequest;
4343
import org.eclipse.aether.metadata.Metadata;
4444
import org.eclipse.aether.util.ConfigUtils;
45+
import org.slf4j.Logger;
46+
import org.slf4j.LoggerFactory;
4547

4648
/**
4749
* Maven G level metadata generator.
@@ -51,6 +53,8 @@
5153
class PluginsMetadataGenerator implements MetadataGenerator {
5254
private static final String PLUGIN_DESCRIPTOR_LOCATION = "META-INF/maven/plugin.xml";
5355

56+
private final Logger logger = LoggerFactory.getLogger(getClass());
57+
5458
private final Map<Object, PluginsMetadata> processedPlugins;
5559

5660
private final Date timestamp;
@@ -142,20 +146,20 @@ private PluginInfo extractPluginInfo(Artifact artifact) {
142146
// here groupId and artifactId cannot be null
143147
return new PluginInfo(groupId, artifactId, goalPrefix, name);
144148
} else {
145-
throw new InvalidArtifactPluginMetadataException(
146-
"Artifact " + artifact.getGroupId() + ":"
147-
+ artifact.getArtifactId()
148-
+ " JAR (to be installed/deployed) contains Maven Plugin metadata for plugin "
149-
+ groupId + ":" + artifactId + "; coordinates are conflicting. "
150-
+ "Most probably your JAR contains rogue Maven Plugin metadata, "
151-
+ "possible causes may be: shaded in Maven Plugin or some rogue resource)");
149+
logger.warn(
150+
"Artifact {}:{}"
151+
+ " JAR (about to be installed/deployed) contains Maven Plugin metadata for"
152+
+ " conflicting coordinates: {}:{}."
153+
+ " Your JAR contains rogue Maven Plugin metadata."
154+
+ " Possible causes may be: shaded into this JAR some Maven Plugin or some rogue resource.",
155+
artifact.getGroupId(),
156+
artifact.getArtifactId(),
157+
groupId,
158+
artifactId);
152159
}
153160
}
154161
}
155162
} catch (Exception e) {
156-
if (e instanceof InvalidArtifactPluginMetadataException) {
157-
throw (InvalidArtifactPluginMetadataException) e;
158-
}
159163
// here we can have: IO. ZIP or Plexus Conf Ex: but we should not interfere with user intent
160164
}
161165
}
@@ -170,10 +174,4 @@ private static String mayGetChild(Xpp3Dom node, String child) {
170174
}
171175
return null;
172176
}
173-
174-
public static final class InvalidArtifactPluginMetadataException extends IllegalArgumentException {
175-
InvalidArtifactPluginMetadataException(String s) {
176-
super(s);
177-
}
178-
}
179177
}

maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,15 @@
1818
*/
1919
package org.apache.maven.repository.internal;
2020

21-
import java.nio.file.Files;
2221
import java.util.Arrays;
2322
import java.util.List;
2423

25-
import org.eclipse.aether.DefaultRepositorySystemSession;
2624
import org.eclipse.aether.artifact.Artifact;
2725
import org.eclipse.aether.artifact.DefaultArtifact;
2826
import org.eclipse.aether.collection.CollectRequest;
2927
import org.eclipse.aether.collection.CollectResult;
3028
import org.eclipse.aether.graph.Dependency;
3129
import org.eclipse.aether.graph.DependencyNode;
32-
import org.eclipse.aether.installation.InstallRequest;
33-
import org.eclipse.aether.repository.LocalRepository;
3430
import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
3531
import org.eclipse.aether.resolution.ArtifactDescriptorResult;
3632
import org.eclipse.aether.resolution.ArtifactRequest;
@@ -197,29 +193,4 @@ public void testNewLocalRepositoryManager() throws Exception {
197193
public void testNewSyncContext() throws Exception {
198194
// SyncContext newSyncContext( RepositorySystemSession session, boolean shared );
199195
}
200-
201-
public void testRoguePlugin() throws Exception {
202-
Artifact artifact = new DefaultArtifact("ut.simple:rogue-plugin:1.0");
203-
204-
ArtifactRequest artifactRequest = new ArtifactRequest();
205-
artifactRequest.setArtifact(artifact);
206-
artifactRequest.addRepository(newTestRepository());
207-
208-
ArtifactResult artifactResult = system.resolveArtifact(session, artifactRequest);
209-
checkArtifactResult(artifactResult, "rogue-plugin-1.0.jar");
210-
211-
InstallRequest installRequest = new InstallRequest();
212-
installRequest.addArtifact(artifactResult.getArtifact());
213-
214-
DefaultRepositorySystemSession loc = new DefaultRepositorySystemSession(session);
215-
loc.setLocalRepositoryManager(system.newLocalRepositoryManager(
216-
session, new LocalRepository(Files.createTempDirectory("local").toFile())));
217-
try {
218-
system.install(loc, installRequest);
219-
fail("install should fail");
220-
} catch (Exception e) {
221-
assertTrue(e instanceof PluginsMetadataGenerator.InvalidArtifactPluginMetadataException);
222-
assertTrue(e.getMessage().contains("coordinates are conflicting"));
223-
}
224-
}
225196
}

maven-resolver-provider/src/test/resources/repo/ut/simple/rogue-plugin/1.0/rogue-plugin-1.0.pom

Lines changed: 0 additions & 31 deletions
This file was deleted.

maven-resolver-provider/src/test/resources/repo/ut/simple/rogue-plugin/maven-metadata.xml

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)