Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Mar 28, 2024
2 parents bffb6ee + 0224d0b commit c0a3d55
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion qulice-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
<pomInclude>relocation/pom.xml</pomInclude>
<pomInclude>pom-xpath-validator-violations</pomInclude>
<pomInclude>duplicate-finder-violations</pomInclude>
<!--<pomInclude>duplicate-finder-ignore-deps</pomInclude>-->
<pomInclude>duplicate-finder-ignore-deps</pomInclude>
<pomInclude>log-check/pom.xml</pomInclude>
<pomInclude>hibernate-validator-check/pom.xml</pomInclude>
<pomInclude>pmd-duplicate-string-literals-violations/pom.xml</pomInclude>
Expand Down
12 changes: 7 additions & 5 deletions qulice-maven-plugin/src/it/duplicate-finder-ignore-deps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
<groupId>com.qulice</groupId>
<artifactId>qulice-maven-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<excludes>
<exclude>duplicatefinder:org.apache.xmlgraphics:batik-ext:1.7</exclude>
<exclude>duplicatefinder:xml-apis:xml-apis</exclude>
<exclude>duplicatefinder:org.w3c.dom.*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<configuration>
<excludes>
<exclude>duplicate:org.apache.xmlgraphics:batik-ext:1.7</exclude>
</excludes>
</configuration>
<goals>
<goal>check</goal>
</goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,61 +35,52 @@
import java.util.Collection;
import java.util.LinkedList;
import java.util.Properties;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;

/**
* Validate with maven-duplicate-finder-plugin.
* @since 0.5
* @todo #250 Maven-duplicate-finder-plugin should support exclusions.
* Let's add exclusions of following formats (examples):
* - duplicate:about.html
* - duplicate:org.eclipse.sisu:org.eclipse.sisu.plexus:0.0.0.M5
* - duplicate:org.codehaus.groovy.ast.expr.RegexExpression
* - duplicate:org.eclipse.sisu:org.eclipse.sisu.plexus:0.0.0.M5
* |xml-apis:xml-apis:1.0.0|about.html
* - duplicate:org.eclipse.sisu:org.eclipse.sisu.plexus:0.0.0.M5
* |xml-apis:xml-apis:1.0.0|org.w3c.dom.UserDataHandler
* See https://github.com/tpc2/qulice/issues/152#issuecomment-39028953
* and https://github.com/teamed/qulice/issues/250 for details
* @todo #1118 ignored dependencies and resources should be placed in different parameters,
* and current implementation use ':' symbol as a flag if it is resource or dependency.
* Resource can be presented as a regular expression with that symbol, can cause some problem.
*/
public final class DuplicateFinderValidator implements MavenValidator {

// @checkstyle MethodBodyCommentsCheck (50 lines)
// @todo #250 Fix a problem with maven configuration of duplicate finder
// plugin in commented out code below, and enable
// duplicate-finder-ignore-deps IT in pom.xml.
// @todo #1198 Duplicate-finder-plugin was moved to
// https://github.com/basepom/duplicate-finder-maven-plugin
// Let's update it to the new version
@Override
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
public void validate(final MavenEnvironment env)
throws ValidationException {
if (!env.exclude("duplicatefinder", "")) {
final String prefix = "duplicatefinder";
if (!env.exclude(prefix, "")) {
final Properties props = new Properties();
props.put("failBuildInCaseOfConflict", "true");
props.put("checkTestClasspath", "false");
props.put("useResultFile", "false");
props.put(
"ignoredResourcePatterns",
CollectionUtils.union(
env.excludes("duplicatefinder"),
env.excludes(prefix).stream()
.filter(s -> !s.contains(":"))
.collect(Collectors.toList()),
Arrays.asList("META-INF/.*", "module-info.class")
)
);
final Collection<Properties> deps = new LinkedList<>();
// for (String sdep : env.excludes("duplicatefinder")) {
// if (StringUtils.countMatches(sdep, ":") == 2) {
// String[] parts = sdep.split(":");
// Properties main = new Properties();
// Properties prop = new Properties();
// prop.put("groupId", parts[0]);
// prop.put("artifactId", parts[1]);
// prop.put("version", parts[2]);
// main.put("dependency", prop);
// deps.add(prop);
// }
// }
for (final String sdep : env.excludes(prefix)) {
final String[] parts = sdep.split(":");
if (parts.length < 2) {
continue;
}
final Properties main = new Properties();
final Properties prop = new Properties();
prop.put("groupId", parts[0]);
prop.put("artifactId", parts[1]);
if (parts.length > 2) {
prop.put("version", parts[2]);
}
main.put("dependency", prop);
deps.add(main);
}
props.put("ignoredDependencies", deps);
env.executor().execute(
"org.basepom.maven:duplicate-finder-maven-plugin:2.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,16 @@ private Xpp3Dom toXppDom(final Properties config, final String name) {
xpp.addChild(child);
} else if (entry.getValue() instanceof Collection) {
final Xpp3Dom child = new Xpp3Dom(entry.getKey().toString());
for (final Object val
: Collection.class.cast(entry.getValue())) {
final Xpp3Dom row = new Xpp3Dom(entry.getKey().toString());
if (val != null) {
for (final Object val : Collection.class.cast(entry.getValue())) {
if (val instanceof Properties) {
child.addChild(
this.toXppDom(
Properties.class.cast(val),
entry.getKey().toString()
).getChild(0)
);
} else if (val != null) {
final Xpp3Dom row = new Xpp3Dom(entry.getKey().toString());
row.setValue(val.toString());
child.addChild(row);
}
Expand Down
1 change: 1 addition & 0 deletions qulice-maven-plugin/src/site/apt/example-exclude.apt.vm
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ Exclude
dependencies. To exclude all dependency checks <<<dependencies:.*>>> should
be used.

To disable duplicatefinder check you should write empty value <<<duplicatefinder:>>>.

0 comments on commit c0a3d55

Please sign in to comment.