Charles Honton opened MDEP-790 and commented
As a user of the dependency plugin, I desire two new goals; analyze-main and analysis-test. Each goal is similar to the analyze-only goal.
The following parameters are supported:
|<ignoredUnusedDeclaredDependencies>|String[]|List of dependencies that will be ignored if they are declared but unused. The filter syntax is:
[groupId]:[artifactId]:[type]:[version]
where each pattern segment is optional and supports full and partial * wildcards. An empty pattern segment is treated as an implicit wildcard. *
For example, org.apache. {}will match all artifacts whose group id starts with org.apache., and :::{}-SNAPSHOT will match all snapshot artifacts.|
|<ignoredUsedUndeclaredDependencies>|String[]|List of dependencies that will be ignored if they are used but undeclared. The filter syntax is:
[groupId]:[artifactId]:[type]:[version]
where each pattern segment is optional and supports full and partial * wildcards. An empty pattern segment is treated as an implicit wildcard. *
For example, org.apache. {}will match all artifacts whose group id starts with org.apache., and :::{}-SNAPSHOT will match all snapshot artifacts.|
|<skip>|boolean|Skip plugin execution completely.
{}Default value is{}: false.
{}User property is{}: mdep.analyze.skip.|
|<skipMainAnalyze>|boolean|Skip analyze-main goal execution.
{}Default value is{}: false.
{}User property is{}: mdep.analyze.skipMain.|
|<skipTestAnalyze>|boolean|Skip analyze-test goal execution.
{}Default value is{}: false.
{}User property is{}: mdep.analyze.skipTest.|
|<usedDependencies>|String[]|Force dependencies as used, to override incomplete result caused by bytecode-level analysis. Dependency format is groupId:artifactId.|
The analyze-main goal will
- Require a Maven project to be executed.
- Require dependency resolution of artifacts in scope: compile.
- Bind by default to the lifecycle phase: process-classes.
The algorithm it implements is as follows:
- Use byte code inspection on each class in the main artifact to determine the set of classes required to compile the main sources. These classes are the used-classes set. If there is not a main artifact, the used-classes set is empty.
- Determine in which dependencies each used class is present. Add these dependencies to the used-dependency set.
- If any used class is present in multiple used-dependency dependencies, add that class and list of dependencies to the multiple-definition map.
- Add any dependency declared in the usedDependencies parameter to the used-dependency set.
- The declared-dependency set contains the main-artifact and the compile-scope dependency set from the maven resolver.
- Add each dependency in the declared-dependency set that is not in the used-dependency set to the declared-but-unused list.
- Remove any dependency from the declared-but-unused set that matches patterns declared in the ignoreUnusedDeclaredDependencies parameter.
- The classpath-dependency set contains the main-artifact and the compile-scope, provided-scope, and system-scope dependency sets from the maven resolver.
- Add each dependency in the used-dependency set that is not in the classpath-dependency set to the used-but-undeclared set
- Remove any dependency from the used-but-undeclared set that matches patterns declared in the ignoreUsedUndeclaredDependencies parameter.
- If the multiple-definition map is non-empty, print as warning the class name and artifacts the class is defined in.
- Print remaining members of declared-but-unused set to the console
- Print remaining members of used-but-undeclared set to the console
- If either declared-but-unused set or used-but-undeclared set is not empty, fail the build
The analyze-test goal will
- Require a Maven project to be executed.
- Require dependency resolution of artifacts in scope: test-compile.
- Bind by default to the lifecycle phase: process-test-classes.
The algorithm it implements is the same as analyze-main algorithm with the following modifications:
- Use the test artifact instead of the main artifact to determine the used-classes set.
5. The declared-dependency set contains the main-artifact, the test-artifact, and the test-scope dependency set from the maven resolver.
- The classpath-dependency set contains the main-artifact, the test-artifact, and the test-scope, compile-scope, provided-scope, and system-scope dependency sets from the maven resolver
Issue Links:
- MDEP-753 Non-test dependency reported as Non-test scoped test only dependency
("split from")
Charles Honton opened MDEP-790 and commented
As a user of the dependency plugin, I desire two new goals; analyze-main and analysis-test. Each goal is similar to the analyze-only goal.
The following parameters are supported:
|<ignoredUnusedDeclaredDependencies>|String[]|List of dependencies that will be ignored if they are declared but unused. The filter syntax is:
[groupId]:[artifactId]:[type]:[version]
where each pattern segment is optional and supports full and partial * wildcards. An empty pattern segment is treated as an implicit wildcard. *
For example, org.apache. {}will match all artifacts whose group id starts with org.apache., and :::{}-SNAPSHOT will match all snapshot artifacts.|
|<ignoredUsedUndeclaredDependencies>|String[]|List of dependencies that will be ignored if they are used but undeclared. The filter syntax is:
[groupId]:[artifactId]:[type]:[version]
where each pattern segment is optional and supports full and partial * wildcards. An empty pattern segment is treated as an implicit wildcard. *
For example, org.apache. {}will match all artifacts whose group id starts with org.apache., and :::{}-SNAPSHOT will match all snapshot artifacts.|
|<skip>|boolean|Skip plugin execution completely.
{}Default value is{}: false.
{}User property is{}: mdep.analyze.skip.|
|<skipMainAnalyze>|boolean|Skip analyze-main goal execution.
{}Default value is{}: false.
{}User property is{}: mdep.analyze.skipMain.|
|<skipTestAnalyze>|boolean|Skip analyze-test goal execution.
{}Default value is{}: false.
{}User property is{}: mdep.analyze.skipTest.|
|<usedDependencies>|String[]|Force dependencies as used, to override incomplete result caused by bytecode-level analysis. Dependency format is groupId:artifactId.|
The analyze-main goal will
The algorithm it implements is as follows:
The analyze-test goal will
The algorithm it implements is the same as analyze-main algorithm with the following modifications:
5. The declared-dependency set contains the main-artifact, the test-artifact, and the test-scope dependency set from the maven resolver.
Issue Links:
("split from")