Skip to content

Commit

Permalink
Add a switch to include pom projects.
Browse files Browse the repository at this point in the history
Add a new configuration setting, includePomProjects and property that
allows executing the duplicate finder plugin on projects with POM
packaging.

For backwards compatibility, this is turned off by default.
  • Loading branch information
Henning Schmiedehausen committed Jun 17, 2015
1 parent 5bed472 commit 4810f25
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changes

##### 1.2.0

* Add `includePomProjects` configuration setting to allow projects with POM packaging to
be checked. Suggested by #11. Thanks @camshoff.

##### 1.1.2 - 2015-06-16

__1.1.2 will be the last release that works with JDK 6! With Maven having moved to JDK 7, there
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<parent>
<groupId>org.basepom</groupId>
<artifactId>basepom-standard-oss</artifactId>
<version>11</version>
<version>12</version>
</parent>

<groupId>org.basepom.maven</groupId>
Expand Down
16 changes: 16 additions & 0 deletions src/it/test-pom-project/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
52 changes: 52 additions & 0 deletions src/it/test-pom-project/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!--
~ 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-pom-project</artifactId>
<packaging>pom</packaging>

<dependencies>
<dependency>
<groupId>testjar</groupId>
<artifactId>first-jar</artifactId>
<version>1.0.under-test</version>
</dependency>
<dependency>
<groupId>testjar</groupId>
<artifactId>second-jar</artifactId>
<version>1.0.under-test</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<configuration>
<includePomProjects>true</includePomProjects>
</configuration>
</plugin>
</plugins>
</build>
</project>
22 changes: 22 additions & 0 deletions src/it/test-pom-project/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 = loadTestXml(basedir)

overallState(CONFLICT_DIFF, 1, NOT_FAILED, result) // This is "1" because both conflictResults are in the same conflict.
checkConflictResult("conflict-same-content", TYPE_RESOURCE, CONFLICT_EQUAL, NOT_EXCEPTED, NOT_PRINTED, NOT_FAILED, findConflictResult(result, 2, FIRST_JAR, SECOND_JAR))
checkConflictResult("conflict-different-content", TYPE_RESOURCE, CONFLICT_DIFF, NOT_EXCEPTED, PRINTED, NOT_FAILED, findConflictResult(result, 2, FIRST_JAR, SECOND_JAR))

return true
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,14 @@ public final class DuplicateFinderMojo extends AbstractMojo
@Parameter(defaultValue="sun.boot.class.path", property = "duplicate-finder.bootClasspathProperty")
protected String bootClasspathProperty = "sun.boot.class.path";

/**
* Include POM projects in validation.
*
* @since 1.2.0
*/
@Parameter(defaultValue="false", property = "duplicate-finder.includePomProjects")
protected boolean includePomProjects = false;

private final EnumSet<ConflictState> printState = EnumSet.of(CONFLICT_CONTENT_DIFFERENT);
private final EnumSet<ConflictState> failState = EnumSet.noneOf(ConflictState.class);

Expand Down Expand Up @@ -281,7 +289,7 @@ public void execute() throws MojoExecutionException
if (skip) {
LOG.report(quiet, "Skipping duplicate-finder execution!");
}
else if ("pom".equals(project.getArtifact().getType())) {
else if (!includePomProjects && "pom".equals(project.getArtifact().getType())) {
LOG.report(quiet, "Ignoring POM project!");
}
else {
Expand Down

0 comments on commit 4810f25

Please sign in to comment.