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

Dependency incorrectly reported as "Unused declared"

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.6
    • Component/s: analyze
    • Labels:
      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

              • Assignee:
                hboutemy Hervé Boutemy
                Reporter:
                odehon01 Olivier Dehon
              • Votes:
                13 Vote for this issue
                Watchers:
                18 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: