Skip to content

Commit

Permalink
Fix #36
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarsotovalero committed Mar 9, 2021
1 parent 0303e68 commit 7e134f9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ this [plugin](https://maven.apache.org/plugins/maven-dependency-plugin/analyze-m
original source code of the application nor its original `pom.xml`. It can be executed as a Maven goal through the
command line or integrated directly into the Maven build lifecycle.

For a visual idea of what DepClean can do for you, have a look at
For a visual illustration of what DepClean can provide for your project, have a look at
the [depclean-web](https://github.com/castor-software/depclean-web) project.

## How does it work?
Expand All @@ -44,7 +44,6 @@ With this usage information, DepClean constructs a new `pom.xml` based on the fo

If all the tests pass, and the project builds correctly after these changes, then it means that the dependencies identified as bloated can be removed. DepClean produces a file named `pom-debloated.xml`, located in the root of the project, which is a clean version of the original `pom.xml` without bloated dependencies.


## Usage

You can configure the `pom.xml` file of your Maven project to use DepClean as part of the build:
Expand Down Expand Up @@ -106,7 +105,7 @@ Of course, it is also possible to execute DepClean with parameters directly from
can be executed directly as follows:

```bash
mvn se.kth.castor:depclean-maven-plugin:1.1.3:depclean -Dfail.if.unused.direct=true -Dignore.scopes=provided,test,runtime,system,import
mvn se.kth.castor:depclean-maven-plugin:1.1.3:depclean -DfailIfUnusedDirect=true -DignoreScopes=provided,test,runtime,system,import
```

## Installing and building from source
Expand Down Expand Up @@ -134,7 +133,7 @@ Once the plugin is installed, you can execute the `depclean` plugin goal directl
mvn compile
mvn compiler:testCompile
# Then, executed DepClean
mvn se.kth.castor:depclean-maven-plugin:1.1.3:depclean -Dcreate.pom.debloated=true -Dcreate.result.json=true
mvn se.kth.castor:depclean-maven-plugin:1.1.3:depclean -DcreatePomDebloated=true -DcreateResultJson=true
```

This is an example of the output (note the dependencies are ordered according to the JAR size):
Expand Down
5 changes: 4 additions & 1 deletion depclean-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<description>Core library of DepClean</description>
<name>depclean-core</name>

<properties>
<sonar.coverage.jacoco.xmlReportPaths>target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
</properties>

<dependencies>
<!-- Bytecode manipulation -->
<dependency>
Expand Down Expand Up @@ -57,5 +61,4 @@
<scope>compile</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,28 @@ public class DepCleanMojo extends AbstractMojo {
* If this is true, DepClean creates a debloated version of the pom without unused dependencies,
* called "debloated-pom.xml", in root of the project.
*/
@Parameter(property = "create.pom.debloated", defaultValue = "false")
@Parameter(property = "creatPomDebloated", defaultValue = "false")
private boolean createPomDebloated;

/**
* If this is true, DepClean creates a JSON file with the result of the analysis. The file is called
* "debloat-result.json" and it is located in the root of the project.
*/
@Parameter(property = "create.result.json", defaultValue = "false")
@Parameter(property = "createResultJson", defaultValue = "false")
private boolean createResultJson;

/**
* 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 <code>groupId:artifactId:version</code>.
*/
@Parameter(property = "ignore.dependencies")
@Parameter(property = "ignoreDependencies")
private Set<String> ignoreDependencies;

/**
* Ignore dependencies with specific scopes from the DepClean analysis.
*/
@Parameter(property = "ignore.scopes")
@Parameter(property = "ignoreScopes")
private Set<String> ignoreScopes;

/**
Expand All @@ -133,34 +133,34 @@ public class DepCleanMojo extends AbstractMojo {
* unused. This property is useful to detect dependencies that have a compile scope but
* are only used during testing. Hence, these dependencies should have a test scope.
*/
@Parameter(property = "ignore.tests", defaultValue = "false")
@Parameter(property = "ignoreTests", defaultValue = "false")
private boolean ignoreTests;

/**
* If this is true, and DepClean reported any unused direct dependency in the dependency tree,
* then the project's build fails immediately after running DepClean.
*/
@Parameter(property = "fail.if.unused.direct", defaultValue = "false")
@Parameter(property = "failIfUnusedDirect", defaultValue = "false")
private boolean failIfUnusedDirect;

/**
* If this is true, and DepClean reported any unused transitive dependency in the dependency tree,
* then the project's build fails immediately after running DepClean.
*/
@Parameter(property = "fail.if.unused.transitive", defaultValue = "false")
@Parameter(property = "failIfUnusedTransitive", defaultValue = "false")
private boolean failIfUnusedTransitive;

/**
* If this is true, and DepClean reported any unused inherited dependency in the dependency tree,
* then the project's build fails immediately after running DepClean.
*/
@Parameter(property = "fail.if.unused.inherited", defaultValue = "false")
@Parameter(property = "failIfUnusedInherited", defaultValue = "false")
private boolean failIfUnusedInherited;

/**
* Skip plugin execution completely.
*/
@Parameter(defaultValue = "false")
@Parameter(property = "skipDepClean", defaultValue = "false")
private boolean skipDepClean;

@Component
Expand Down

0 comments on commit 7e134f9

Please sign in to comment.