forked from apache/maven-resolver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MRESOLVER-345] Conflict resolution in verbose mode is sensitive to v…
…ersion ordering (apache#271) Our two collector implementations produce slightly different dirty trees when in transitive dependencies ranges are in use. The new BF produces (w/ and w/o skipper) produces this dirty tree: ``` menforcer426:aid:ext:1 compile +- menforcer426:bid:ext:1 compile | +- menforcer426:cid:ext:3 compile | +- menforcer426:cid:ext:2 compile | \- menforcer426:cid:ext:1 compile +- menforcer426:cid:ext:3 compile +- menforcer426:cid:ext:2 compile \- menforcer426:cid:ext:1 compile ``` The "old" DF produces this one: ``` menforcer426:aid:ext:1 compile +- menforcer426:bid:ext:1 compile | +- menforcer426:cid:ext:1 compile | +- menforcer426:cid:ext:2 compile | \- menforcer426:cid:ext:3 compile +- menforcer426:cid:ext:1 compile +- menforcer426:cid:ext:2 compile \- menforcer426:cid:ext:3 compile ``` Spot the difference: the two dirty trees are "semantically" (or content-wise?) equal/same, except for the artifact ordering, where there was a version range (collector in this case discovers available versions that "fits" range and created nodes for them, one for each version that lies within version constraint). DF collector relies and provides "metadata based" ordering (as metadata contained the versions), while BF explicitly sorts them in descending order (for internal optimization purposes). Point is, both dirty trees are ok. But, Conflict resolver in verbose mode for two inputs above produces different outputs. For DF with "divergence found", while for BF "no divergence found" (correctly). Overall changes in this PR: * most are test and test related resources * cosmetic changes like javadoc typos, adding override etc * added reusable `DependencyGraphDumper` * key changes are in `ConflictResolver` covered by `ConflictResolverTest` UT changes * overall fix is to make `ConflictResolver` insensitive to input dirty tree version ordering, make sure output is same for "semantically" (or content-wise?) same inputs. How tested this: * built/installed this PR * built maven-3.9.x with this resolver * ran maven IT suite -- OK * ran apache/maven-enforcer#259 w/ built maven (so fixed resolver is used). This PR contains only one reproducer IT that fails with any released Maven version -- OK w/ maven built as above. Just realized how enforcer ITs are good source of inspiration for resolver use cases, so many if not all of new tests are actually inspired by enforcer ITs. --- https://issues.apache.org/jira/browse/MRESOLVER-345
- Loading branch information
Showing
32 changed files
with
780 additions
and
75 deletions.
There are no files selected for viewing
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
84 changes: 84 additions & 0 deletions
84
...ppets/src/main/java/org/apache/maven/resolver/examples/DependencyHierarchyWithRanges.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,84 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package org.apache.maven.resolver.examples; | ||
|
||
import java.io.File; | ||
import java.util.Collections; | ||
|
||
import org.apache.maven.resolver.examples.util.Booter; | ||
import org.eclipse.aether.DefaultRepositorySystemSession; | ||
import org.eclipse.aether.RepositorySystem; | ||
import org.eclipse.aether.artifact.Artifact; | ||
import org.eclipse.aether.artifact.DefaultArtifact; | ||
import org.eclipse.aether.collection.CollectRequest; | ||
import org.eclipse.aether.collection.CollectResult; | ||
import org.eclipse.aether.repository.RemoteRepository; | ||
import org.eclipse.aether.repository.RepositoryPolicy; | ||
import org.eclipse.aether.resolution.ArtifactDescriptorRequest; | ||
import org.eclipse.aether.resolution.ArtifactDescriptorResult; | ||
import org.eclipse.aether.util.graph.manager.DependencyManagerUtils; | ||
import org.eclipse.aether.util.graph.transformer.ConflictResolver; | ||
|
||
/** | ||
* Visualizes the transitive dependencies of an artifact similar to m2e's dependency hierarchy view. Artifact in this | ||
* test is not "plain" one as is original "demo" {@link GetDependencyHierarchy}, but specially crafted for case | ||
* described in MRESOLVER-345. | ||
* | ||
* @see <a href="https://issues.apache.org/jira/browse/MRESOLVER-345">MRESOLVER-345</a> | ||
*/ | ||
public class DependencyHierarchyWithRanges { | ||
|
||
/** | ||
* Main. | ||
*/ | ||
public static void main(String[] args) throws Exception { | ||
System.out.println("------------------------------------------------------------"); | ||
System.out.println(DependencyHierarchyWithRanges.class.getSimpleName()); | ||
|
||
RepositorySystem system = Booter.newRepositorySystem(Booter.selectFactory(args)); | ||
|
||
DefaultRepositorySystemSession session = Booter.newRepositorySystemSession(system); | ||
|
||
session.setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_IGNORE); // to not bother with checksums | ||
session.setConfigProperty(ConflictResolver.CONFIG_PROP_VERBOSE, true); | ||
session.setConfigProperty(DependencyManagerUtils.CONFIG_PROP_VERBOSE, true); | ||
|
||
// this artifact is in "remote" repository in src/main/remote-repository | ||
Artifact artifact = new DefaultArtifact("org.apache.maven.resolver.demo.mresolver345:a:1.0"); | ||
|
||
File remoteRepoBasedir = new File("src/main/remote-repository"); | ||
|
||
ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest(); | ||
descriptorRequest.setArtifact(artifact); | ||
descriptorRequest.setRepositories(Collections.singletonList(new RemoteRepository.Builder( | ||
"remote", "default", remoteRepoBasedir.toURI().toASCIIString()) | ||
.build())); | ||
ArtifactDescriptorResult descriptorResult = system.readArtifactDescriptor(session, descriptorRequest); | ||
|
||
CollectRequest collectRequest = new CollectRequest(); | ||
collectRequest.setRootArtifact(descriptorResult.getArtifact()); | ||
collectRequest.setDependencies(descriptorResult.getDependencies()); | ||
collectRequest.setManagedDependencies(descriptorResult.getManagedDependencies()); | ||
collectRequest.setRepositories(descriptorRequest.getRepositories()); | ||
|
||
CollectResult collectResult = system.collectDependencies(session, collectRequest); | ||
|
||
collectResult.getRoot().accept(Booter.DUMPER_SOUT); | ||
} | ||
} |
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
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
40 changes: 40 additions & 0 deletions
40
...ts/src/main/remote-repository/org/apache/maven/resolver/demo/mresolver345/a/1.0/a-1.0.pom
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,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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>org.apache.maven.resolver.demo.mresolver345</groupId> | ||
<artifactId>a</artifactId> | ||
<version>1.0</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven.resolver.demo.mresolver345</groupId> | ||
<artifactId>b</artifactId> | ||
<version>1.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven.resolver.demo.mresolver345</groupId> | ||
<artifactId>c</artifactId> | ||
<version>[1.0, 3.0]</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
35 changes: 35 additions & 0 deletions
35
...ts/src/main/remote-repository/org/apache/maven/resolver/demo/mresolver345/b/1.0/b-1.0.pom
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,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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>org.apache.maven.resolver.demo.mresolver345</groupId> | ||
<artifactId>b</artifactId> | ||
<version>1.0</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven.resolver.demo.mresolver345</groupId> | ||
<artifactId>c</artifactId> | ||
<version>[1.0, 3.0]</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
27 changes: 27 additions & 0 deletions
27
...ts/src/main/remote-repository/org/apache/maven/resolver/demo/mresolver345/c/1.0/c-1.0.pom
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,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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>org.apache.maven.resolver.demo.mresolver345</groupId> | ||
<artifactId>c</artifactId> | ||
<version>1.0</version> | ||
|
||
</project> |
27 changes: 27 additions & 0 deletions
27
...ts/src/main/remote-repository/org/apache/maven/resolver/demo/mresolver345/c/2.0/c-2.0.pom
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,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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>org.apache.maven.resolver.demo.mresolver345</groupId> | ||
<artifactId>c</artifactId> | ||
<version>2.0</version> | ||
|
||
</project> |
27 changes: 27 additions & 0 deletions
27
...ts/src/main/remote-repository/org/apache/maven/resolver/demo/mresolver345/c/3.0/c-3.0.pom
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,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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>org.apache.maven.resolver.demo.mresolver345</groupId> | ||
<artifactId>c</artifactId> | ||
<version>3.0</version> | ||
|
||
</project> |
33 changes: 33 additions & 0 deletions
33
...c/main/remote-repository/org/apache/maven/resolver/demo/mresolver345/c/maven-metadata.xml
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,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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. | ||
--> | ||
<metadata> | ||
<groupId>org.apache.maven.resolver.demo.mresolver345</groupId> | ||
<artifactId>c</artifactId> | ||
<versioning> | ||
<latest>3.0</latest> | ||
<release>3.0</release> | ||
<versions> | ||
<version>1.0</version> | ||
<version>2.0</version> | ||
<version>3.0</version> | ||
</versions> | ||
<lastUpdated>20230320074804</lastUpdated> | ||
</versioning> | ||
</metadata> |
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
Oops, something went wrong.