Uploaded image for project: 'Maven Dependency Plugin'
  1. Maven Dependency Plugin
  2. MDEP-790

New Goals: analyze-main and analyze-test

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      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:

      1. 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.
      2. Determine in which dependencies each used class is present.  Add these dependencies to the used-dependency set.
      3. If any used class is present in multiple used-dependency dependencies, add that class and list of dependencies to the multiple-definition map.
      4. Add any dependency declared in the usedDependencies parameter to the used-dependency set.
      5. The declared-dependency set contains the main-artifact and the compile-scope dependency set from the maven resolver.
      6. Add each dependency in the declared-dependency set that is not in the used-dependency set to the declared-but-unused list.
      7. Remove any dependency from the declared-but-unused set that matches patterns declared in the ignoreUnusedDeclaredDependencies parameter.
      8. The classpath-dependency set contains the main-artifact and the compile-scope, provided-scope, and system-scope dependency sets from the maven resolver.
      9. Add each dependency in the used-dependency set that is not in the classpath-dependency set to the used-but-undeclared set
      10. Remove any dependency from the used-but-undeclared set that matches patterns declared in the  ignoreUsedUndeclaredDependencies parameter.
      11. If the multiple-definition map is non-empty, print as warning the class name and artifacts the class is defined in.
      12. Print remaining members of declared-but-unused set to the console
      13. Print remaining members of used-but-undeclared set to the console
      14. 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:
      1. 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.
      8. 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 

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              chonton Charles Honton
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: