[
https://issues.apache.org/jira/browse/MNG-6490?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16662416#comment-16662416
]
ASF GitHub Bot commented on MNG-6490:
-------------------------------------
asfgit closed pull request #188: [MNG-6490] Maven fails reporting circular
dependency when the depende…
URL: https://github.com/apache/maven/pull/188
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
index 4018618f9b..1c84776784 100644
---
a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
+++
b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
@@ -546,21 +546,21 @@ private void validate20RawDependenciesSelfReferencing(
ModelProblemCollector pro
List<Dependency>
dependencies, String prefix,
ModelBuildingRequest request )
{
- // We only check for groupId/artifactId cause if there is another
- // module with the same groupId/artifactId this will fail the build
+ // We only check for groupId/artifactId/version/classifier cause if
there is another
+ // module with the same groupId/artifactId/version/classifier this
will fail the build
// earlier like "Project '...' is duplicated in the reactor.
- // So it is sufficient to check only groupId/artifactId and not the
+ // So it is sufficient to check only
groupId/artifactId/version/classifier and not the
// packaging type.
for ( Dependency dependency : dependencies )
{
- String key = dependency.getGroupId() + ":" +
dependency.getArtifactId() + ":" + dependency.getVersion();
+ String key = dependency.getGroupId() + ":" +
dependency.getArtifactId() + ":" + dependency.getVersion()
+ + ( dependency.getClassifier() != null ? ":" +
dependency.getClassifier() : "" );
String mKey = m.getGroupId() + ":" + m.getArtifactId() + ":" +
m.getVersion();
if ( key.equals( mKey ) )
{
// This means a module which is build has a dependency which
has the same
- // groupId, artifactId and version coordinates. This is in
consequence
- // a self reference or in other words a circular reference
which can not
- // being resolved.
+ // groupId, artifactId, version and classifier coordinates.
This is in consequence
+ // a self reference or in other words a circular reference
which can not being resolved.
addViolation( problems, Severity.FATAL, Version.V31, prefix +
" " + key, key, "is referencing itself.",
dependency );
@@ -605,14 +605,14 @@ private void validateEffectiveDependencies(
ModelProblemCollector problems, Mode
private void validateEffectiveModelAgainstDependency( String prefix,
ModelProblemCollector problems, Model m,
Dependency d,
ModelBuildingRequest request )
{
- String key = d.getGroupId() + ":" + d.getArtifactId() + ":" +
d.getVersion();
+ String key = d.getGroupId() + ":" + d.getArtifactId() + ":" +
d.getVersion()
+ + ( d.getClassifier() != null ? ":" + d.getClassifier() : ""
);
String mKey = m.getGroupId() + ":" + m.getArtifactId() + ":" +
m.getVersion();
if ( key.equals( mKey ) )
{
// This means a module which is build has a dependency which has
the same
- // groupId, artifactId and version coordinates. This is in
consequence
- // a self reference or in other words a circular reference which
can not
- // being resolved.
+ // groupId, artifactId, version and classifier coordinates. This
is in consequence
+ // a self reference or in other words a circular reference which
can not being resolved.
addViolation( problems, Severity.FATAL, Version.V31, prefix + " "
+ key, key, "is referencing itself.", d );
}
diff --git
a/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
b/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
index b02e0d90b3..3f31526e8f 100644
---
a/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
+++
b/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
@@ -729,6 +729,13 @@ public void testSelfReferencingDependencyInRawModel()
}
+ public void testSelfReferencingDependencyWithClassifierInRawModel() throws
Exception
+ {
+ SimpleProblemCollector result = validateRaw(
"raw-model/self-referencing-classifier.xml" );
+
+ assertViolations( result, 0, 0, 0 );
+ }
+
public void testCiFriendlySha1()
throws Exception
{
diff --git
a/maven-model-builder/src/test/resources/poms/validation/raw-model/self-referencing-classifier.xml
b/maven-model-builder/src/test/resources/poms/validation/raw-model/self-referencing-classifier.xml
new file mode 100644
index 0000000000..099e501a2c
--- /dev/null
+++
b/maven-model-builder/src/test/resources/poms/validation/raw-model/self-referencing-classifier.xml
@@ -0,0 +1,39 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.example.group</groupId>
+ <artifactId>testvalidpom</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <description>
+ This will test if the module validator recognized that this dependency
with classifier
+ is not the same as the module itself.
+ </description>
+ <dependencies>
+ <dependency>
+ <groupId>com.example.group</groupId>
+ <artifactId>testvalidpom</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <classifier>linux</classifier>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Maven shall not fail reporting circular dependency when the dependency is a
> classified secondary artifact
> ---------------------------------------------------------------------------------------------------------
>
> Key: MNG-6490
> URL: https://issues.apache.org/jira/browse/MNG-6490
> Project: Maven
> Issue Type: Bug
> Components: Dependencies
> Affects Versions: 3.5.2, 3.5.3, 3.5.4
> Environment: Ubuntu 16.0.4 LTS, Ubuntu 18.0.4 LTS, Mac OS High
> Sierra, Oracle and OpenJDK 8, Oracle Java 11,
> Reporter: John Canny
> Assignee: Sylwester Lachiewicz
> Priority: Blocker
> Fix For: 3.6.0
>
>
> As of maven 3.5.2, 3.5.3, 3.5.4, the following pom fails with the error
> "dependencies.dependency. Main:MainJar:1' for Main:MainJar:1 is referencing
> itself"
> But the dependency is not circular, it references a classified jar (in our
> use cases its an architecture-dependent native code container jar). The pom
> below allows the main jar to be built without building the dependency every
> time (other lines conditionally build the dependency), and ensures the
> appropriate pre-built dependency is loaded. Behavior in maven 3.5.0 and
> earlier was correct (i.e. no error). This breaks several of the usage
> scenarios for classified artifacts...
>
> {code:xml}<project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd">
> <modelVersion>4.0.0</modelVersion>
> <groupId>Main</groupId>
> <artifactId>MainJar</artifactId>
> <packaging>jar</packaging>
> <version>1</version>
> <dependencies>
> <dependency>
> <groupId>${project.groupId}</groupId>
> <artifactId>${project.artifactId}</artifactId>
> <version>${project.version}</version>
> <classifier>linux</classifier>
> </dependency>
> </dependencies>
> </project>{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)