diff --git a/README.md b/README.md index f9d8cbbf..225acaa9 100644 --- a/README.md +++ b/README.md @@ -49,12 +49,15 @@ The Maven plugin can be configured with the following additional parameters. | Name | Type | Description | |:----------|:-------------:| :-------------| -| `` | `Set` | Add a list of dependencies, identified by their coordinates, to be ignored by DepClean during the analysis and considered as used dependencies. Useful to override incomplete result caused by bytecode-level analysis. Dependency format is `groupId:artifactId:version`.| +| `` | `Set` | Add a list of dependencies, identified by their coordinates, to be ignored by DepClean during the analysis and considered as used dependencies. Useful to override incomplete result caused by bytecode-level analysis. **Dependency format is:** `groupId:artifactId:version`.| +| `` | `Set` | Add a list of scopes, to be ignored by DepClean during the analysis. Useful to not analyze dependencies with scopes that are not needed at runtime. **Valid scopes are:** `compile`, `provided`, `test`, `runtime`, `system`, `import`. **Default value is:** ``.| | `` | `boolean` | If this is true, DepClean creates a debloated version of the pom without unused dependencies called `debloated-pom.xml`, in root of the project. **Default value is:** `false`.| | `` | `boolean` | If this is true, and DepClean reported any unused dependency in the dependency tree, the build fails immediately after running DepClean. **Default value is:** `false`.| | `` | `boolean` | Skip plugin execution completely. **Default value is:** `false`.| + + ## Installing and building from source Prerequisites: diff --git a/depclean-maven-plugin/src/main/java/se/kth/depclean/DepCleanMojo.java b/depclean-maven-plugin/src/main/java/se/kth/depclean/DepCleanMojo.java index 4415526a..756d328c 100644 --- a/depclean-maven-plugin/src/main/java/se/kth/depclean/DepCleanMojo.java +++ b/depclean-maven-plugin/src/main/java/se/kth/depclean/DepCleanMojo.java @@ -101,10 +101,10 @@ public class DepCleanMojo extends AbstractMojo private Set ignoreDependencies; /** - * Exclude dependencies with specific scopes from the DepClean analysis. + * Ignore dependencies with specific scopes from the DepClean analysis. */ - @Parameter(property = "exclude.scopes") - private Set excludeScope; + @Parameter(property = "ignore.scopes") + private Set ignoreScopes; /** * If this is true, and DepClean reported any unused dependency in the dependency tree, @@ -194,14 +194,13 @@ public void execute() throws MojoExecutionException, MojoFailureException unusedUndeclaredArtifacts.removeAll(unusedDeclaredArtifacts); /* Exclude dependencies with specific scopes from the DepClean analysis */ - if (excludeScope.size() >= 1) { + if (ignoreScopes.size() >= 1) { usedUndeclaredArtifacts = excludeScope(usedUndeclaredArtifacts); usedDeclaredArtifacts = excludeScope(usedDeclaredArtifacts); unusedDeclaredArtifacts = excludeScope(unusedDeclaredArtifacts); unusedUndeclaredArtifacts = excludeScope(unusedUndeclaredArtifacts); } - /* Use artifacts coordinates for the report instead of the Artifact object */ Set usedDeclaredArtifactsCoordinates = new HashSet<>(); usedDeclaredArtifacts.forEach(s -> usedDeclaredArtifactsCoordinates.add(s.getGroupId() + ":" + s.getArtifactId() + ":" + s.getVersion() + ":" + s.getScope())); @@ -342,7 +341,7 @@ private Set excludeScope(Set artifacts) Iterator iterator = artifacts.iterator(); while (iterator.hasNext()) { Artifact artifact = iterator.next(); - if (!excludeScope.contains(artifact.getScope())) { + if (!ignoreScopes.contains(artifact.getScope())) { nonExcludedArtifacts.add(artifact); } } diff --git a/pom.xml b/pom.xml index f9ec6550..71f9f1ea 100644 --- a/pom.xml +++ b/pom.xml @@ -3,254 +3,257 @@ 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"> - - se.kth.castor - depclean-parent-pom - 1.0.0 - pom - 4.0.0 + + se.kth.castor + depclean-parent-pom + 1.0.0 + pom + 4.0.0 - depclean-parent-pom + depclean-parent-pom - - - UTF-8 - UTF-8 - 1.8 - 1.8 - 1.8 - 1.8 - 0.8.2 - 4.3.0 - + + + UTF-8 + UTF-8 + 1.8 + 1.8 + 1.8 + 1.8 + 0.8.2 + 4.3.0 + - - DepClean is a tool that automatically debloats dependencies in Java projects - https://github.com/castor-software/depclean + + DepClean is a tool that automatically debloats dependencies in Java projects + https://github.com/castor-software/depclean - - GitHub Issues - https://github.com/castor-software/depclean/issues - + + GitHub Issues + https://github.com/castor-software/depclean/issues + - - https://github.com/castor-software/depclean/ - scm:git:git:github.com/castor-software/depclean.git - scm:git:git@github.com:castor-software/depclean.git - + + https://github.com/castor-software/depclean/ + scm:git:git:github.com/castor-software/depclean.git + scm:git:git@github.com:castor-software/depclean.git + - - - - MIT License - http://www.opensource.org/licenses/mit-license.php - repo - - + + + + MIT License + http://www.opensource.org/licenses/mit-license.php + repo + + - - - - cesarsotovalero - César Soto Valero - cesarsotovlaero@gmail.com - Castor Software Research Centre - https://www.castor.kth.se/ - - + + + + cesarsotovalero + César Soto Valero + cesarsotovlaero@gmail.com + Castor Software Research Centre + https://www.castor.kth.se/ + + - - - depclean-core - depclean-maven-plugin - + + + depclean-core + depclean-maven-plugin + - - - - junit - junit - 4.12 - test - - + + + + junit + junit + 4.12 + test + + - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + - - - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + - - - maven-compiler-plugin - 3.1 - - ${maven.compiler.source} - ${maven.compiler.target} - - + + + maven-compiler-plugin + 3.1 + + ${maven.compiler.source} + ${maven.compiler.target} + + - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - - attach-javadocs - - jar - - - - + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + 8 + + + + attach-javadocs + + jar + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - org.apache.maven.plugins - maven-surefire-plugin - 2.21.0 - - - **/resources/**/*.java - - - + + + org.apache.maven.plugins + maven-surefire-plugin + 2.21.0 + + + **/resources/**/*.java + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - org.jacoco - jacoco-maven-plugin - ${maven.jacoco.plugin.version} - - - - prepare-agent - - - - report - prepare-package - - report - - - - + + + org.jacoco + jacoco-maven-plugin + ${maven.jacoco.plugin.version} + + + + prepare-agent + + + + report + prepare-package + + report + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - + - - - - - org.eluder.coveralls - coveralls-maven-plugin - ${maven.coveralls.plugin.version} - - - - + + + + + org.eluder.coveralls + coveralls-maven-plugin + ${maven.coveralls.plugin.version} + + + +