Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dependency:analyze functionality #17

Open
sviperll opened this issue May 6, 2015 · 3 comments
Open

dependency:analyze functionality #17

sviperll opened this issue May 6, 2015 · 3 comments

Comments

@sviperll
Copy link
Contributor

sviperll commented May 6, 2015

maven-dependency-plugin provides very useful analyze goal. This goal allows you to find out unused and indirect dependencies.

maven-dependency-plugin operates over runtime dependencies only. The result is that if you use an annotation or compile-time constant from some package, this package will be considered unused. I think takari can overcome this limitation using compile-time information gathering, much like accessRulesViolation option works.

@ifedorenko
Copy link
Contributor

Can you explain the problem you are trying to solve, maybe using small example project and observed/desired behaviour?

@sviperll
Copy link
Contributor Author

sviperll commented May 6, 2015

I want a better replacement for dependency:analyze

dependency:analyze is limited, as stated here

Natural goal is to keep dependencies at minimum, this is good by many reasons: minimizing chance of incompatibility, breakage, integration problems, abandonment of one of dependencies.

Unavoidable requirement on a way to this goal is knowing your dependencies. You can have some dependencies on you dependency-list just in case. You can use classes from package not stated on dependency-list (as a transitive dependency). Using transitive dependencies is bad since it's additional implicit assumption that some package will always depend on some another package. And it is very difficult to find what's wrong when this assumption is not true any more. dependency:analyze allows you to find and eliminate such cases and thus keep you project healthy.

@electrum
Copy link

electrum commented Aug 15, 2017

Module foo:

public class Foo {
    public static final String FOO = "hello world";
}

Module bar:

@MyAnnotation(value = Foo.FOO)

Now, suppose bar depends on foo and the above constant is the only thing it uses from foo. The Java compiler will inline the constant into the annotation and thus there will be no usages in the class files, causing dependency:analyze to incorrectly report that you aren't using it.

This situation can be quite difficult to figure out, especially if you don't understand how the plugin works and aren't intimately familiar with inlining rules, class files, etc. However, in my experience, it rarely occurs in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants