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

Dependency incorrectly reported as "Unused declared"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.6
    • analyze
    • None

    Description

      When a dependency is only required for a constant in a JAR, dependency:analyze incorrectly reports the dependency as "Unused declared".
      Example:

      Constants.jar has 1 class called Constants.java:

      package com.myco.util;
      
      public class Constants 
      {
          private Constants() {};
      
          public static final double PI = 3.14159;
      }
      

      Then App jar has App.java as:

      package com.myco.app;
      
      public class App 
      {
          public static void main( String[] args )
          {
              System.out.println( com.myco.util.Constants.PI );
          }
      }
      

      Since the constant gets optimized away in the generated App.class, the dependency is not detected, even though the project won't compile without it.

      Attachments

        Issue Links

          Activity

            People

              hboutemy Herve Boutemy
              odehon01 Olivier Dehon
              Votes:
              13 Vote for this issue
              Watchers:
              18 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: