Skip to content

Commit

Permalink
Fix for issue #35
Browse files Browse the repository at this point in the history
Multiple system dependencies can actually reference the same
file. Remove the BiHashMap, replace with a Multimap.
  • Loading branch information
hgschmie committed Oct 23, 2019
1 parent 7041897 commit accf195
Show file tree
Hide file tree
Showing 8 changed files with 292 additions and 14 deletions.
16 changes: 16 additions & 0 deletions src/it/test-issue-35-classpath/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Licensed 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=clean verify
invoker.buildResult = success
107 changes: 107 additions & 0 deletions src/it/test-issue-35-classpath/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<!--
~ Licensed 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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>@project.groupId@.@project.artifactId@</groupId>
<artifactId>basepom</artifactId>
<version>1.0.under-test</version>
</parent>

<artifactId>test-issue-35-classpath</artifactId>

<dependencies>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-jvm</artifactId>
<version>1.5.0</version>
<classifier>agent</classifier>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-dbms</artifactId>
<version>3.4.11</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<configuration>
<failBuildInCaseOfConflict>true</failBuildInCaseOfConflict>
<includeBootClasspath>true</includeBootClasspath>
<exceptions>
<exception>
<conflictingDependencies>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-jvm</artifactId>
<classifier>agent</classifier>
</dependency>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
</conflictingDependencies>
<packages>
<package>org.jolokia</package>
</packages>
</exception>
<exception>
<conflictingDependencies>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-jvm</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
</dependency>
</conflictingDependencies>
<packages>
<package>org.json.simple</package>
</packages>
</exception>
<!-- Add an exception for the tools jar to the classpath,
at least on MacOS AdoptOpenJDK 8, the rt.jar clashes
with the tools.jar.
-->
<exception>
<bootClasspath>true</bootClasspath>
<conflictingDependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
</dependency>
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
</dependency>
</conflictingDependencies>
<packages>
<package>sun.tools</package>
<package>sun.applet</package>
</packages>
</exception>
</exceptions>
</configuration>
</plugin>
</plugins>
</build>
</project>
22 changes: 22 additions & 0 deletions src/it/test-issue-35-classpath/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Licensed 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.
*/
import static org.basepom.mojo.duplicatefinder.groovy.ITools.*

def (result, xml) = loadXmlAndResult(basedir, "test")

// the jolokia agent actually conflicts quite a bit, so there are two expected conflicts.
// an additional conflict is the tools jar with the rt.jar from the runtime
overallState(NO_CONFLICT, 3, NOT_FAILED, result)

return true
16 changes: 16 additions & 0 deletions src/it/test-issue-35/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Licensed 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=clean verify
invoker.buildResult = success
85 changes: 85 additions & 0 deletions src/it/test-issue-35/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!--
~ Licensed 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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>@project.groupId@.@project.artifactId@</groupId>
<artifactId>basepom</artifactId>
<version>1.0.under-test</version>
</parent>

<artifactId>test-issue-35</artifactId>

<dependencies>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-jvm</artifactId>
<version>1.5.0</version>
<classifier>agent</classifier>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-dbms</artifactId>
<version>3.4.11</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<configuration>
<failBuildInCaseOfConflict>true</failBuildInCaseOfConflict>
<exceptions>
<exception>
<conflictingDependencies>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-jvm</artifactId>
<classifier>agent</classifier>
</dependency>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
</conflictingDependencies>
<packages>
<package>org.jolokia</package>
</packages>
</exception>
<exception>
<conflictingDependencies>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-jvm</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
</dependency>
</conflictingDependencies>
<packages>
<package>org.json.simple</package>
</packages>
</exception>
</exceptions>
</configuration>
</plugin>
</plugins>
</build>
</project>
21 changes: 21 additions & 0 deletions src/it/test-issue-35/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Licensed 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.
*/
import static org.basepom.mojo.duplicatefinder.groovy.ITools.*

def (result, xml) = loadXmlAndResult(basedir, "test")

// the jolokia agent actually conflicts quite a bit, so there are two expected conflicts.
overallState(NO_CONFLICT, 2, NOT_FAILED, result)

return true
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
Expand Down Expand Up @@ -286,7 +287,7 @@ public void setIgnoredDependencies(final Dependency[] dependencies) throws Inval
}

@Override
public void execute() throws MojoExecutionException
public void execute() throws MojoExecutionException, MojoFailureException
{
try {
if (skip) {
Expand Down Expand Up @@ -419,13 +420,16 @@ else if (!includePomProjects && "pom".equals(project.getArtifact().getType())) {
}
}
catch (final DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Could not resolve dependencies", e);
throw new MojoFailureException("Could not resolve dependencies", e);
}
catch (final InvalidVersionSpecificationException e) {
throw new MojoExecutionException("Invalid version specified", e);
throw new MojoFailureException("Invalid version specified", e);
}
catch (final OverConstrainedVersionException e) {
throw new MojoExecutionException("Version too constrained", e);
throw new MojoFailureException("Version too constrained", e);
}
catch (final IOException e) {
throw new MojoExecutionException("While loading artifacts", e);
}
}
}
Expand Down
Loading

0 comments on commit accf195

Please sign in to comment.