-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MSHARED-1286]: Display if dependency is optional in tree
This should reintroduce that dependency:tree shows if a dependency is optional which was removed in 3.3.0 of dependency plugin.
- Loading branch information
1 parent
791dbc8
commit 6c1bff3
Showing
8 changed files
with
170 additions
and
2 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
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,7 @@ | ||
org.apache.maven.its.dependency-tree:test:jar:1.0-SNAPSHOT | ||
+- org.apache.maven:maven-settings:jar:2.0.6:compile | ||
| +- org.codehaus.plexus:plexus-utils:jar:1.4.1:compile | ||
| \- org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile | ||
| +- junit:junit:jar:3.8.1:compile | ||
| \- classworlds:classworlds:jar:1.1-alpha-2:compile | ||
\- org.apache.maven:maven-model:jar:2.0.5:compile (optional) |
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,18 @@ | ||
# 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. | ||
|
||
invoker.goals = org.apache.maven.its.dependency-tree:graph-maven-plugin:graph |
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,68 @@ | ||
<?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.its.dependency-tree</groupId> | ||
<artifactId>test</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<name>Test</name> | ||
<description> | ||
Test dependency-tree with actual Maven version through dependency:tree (easier than shade, or MPIR:dependencies). | ||
Needs to be run in sequence with Maven 2.2.1, 3.0.x and 3.1-alpha-1+ to check the 3 graph API implementations. | ||
</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-settings</artifactId> | ||
<version>2.0.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-model</artifactId> | ||
<version>2.0.5</version> | ||
<optional>true</optional> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.its.dependency-tree</groupId> | ||
<artifactId>graph-maven-plugin</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<configuration> | ||
<outputFile>target/tree.txt</outputFile> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
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,23 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
|
||
actual = new File( basedir, "target/tree.txt" ).readLines() | ||
expected = new File( basedir, "expected.txt" ).readLines() | ||
assert actual.equals( expected ) |
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
45 changes: 45 additions & 0 deletions
45
...est/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyNodeTest.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,45 @@ | ||
/* | ||
* 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.shared.dependency.graph.internal; | ||
|
||
import org.apache.maven.artifact.Artifact; | ||
import org.apache.maven.artifact.DefaultArtifact; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static java.util.Collections.emptyList; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class DefaultDependencyNodeTest { | ||
|
||
private final Artifact artifact = new DefaultArtifact("group", "artifact", "1.2", "compile", "jar", "", null); | ||
|
||
@Test | ||
public void nodeString_should_display_if_dependency_is_optonal() { | ||
DefaultDependencyNode optionalNode = | ||
new DefaultDependencyNode(null, artifact, "1.0", "compile", "1.0", true, emptyList()); | ||
assertEquals("group:artifact:jar:1.2:compile (optional)", optionalNode.toNodeString()); | ||
} | ||
|
||
@Test | ||
public void nodeString_for_mandatory_depenendency_does_not_contain_optional_information() { | ||
DefaultDependencyNode optionalNode = | ||
new DefaultDependencyNode(null, artifact, "1.0", "compile", "1.0", false, emptyList()); | ||
assertEquals("group:artifact:jar:1.2:compile", optionalNode.toNodeString()); | ||
} | ||
} |