maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Gardner <>
Subject dependency plugin - thoughts on providing a list of classes required at runtime to use with dependency:analyze?
Date Mon, 03 Oct 2011 16:14:12 GMT
For apps, particularly IoC managed webapps that use xml configuration,
the war projects tend to have a fair number of runtime dependencies
listed. There are typically two dependency resolution concerns related
to these runtime dependencies:

1 - Specifying unused runtime dependencies clutters the project's pom
file and makes the built artifact (such as a war) larger than it needs
to be
2 - Configuring an application to use some class at runtime but not
providing it as a runtime dependency can cause the application to fail
at runtime

I've looked over the DefaultProjectDependencyAnalyzer and see that in
the "buildDependencyClasses( MavenProject project , Map
artifactClassMap )" method it builds up a Set containing strings of
class names that are used in the project.
I think it should be fairly easy to augment this with a list of
additional "RuntimeDependencyClasses" that identify classes that the
user specifies are required at runtime - and then when the dependency
analyzer runs through it can mark the runtime-scoped artifacts that
provide those classes properly as being used declared / unused
undeclared dependencies.

The most useful way of providing this set of runtime dependencies I
think would be to have it take a list of files where each file
specified classes - one per line - that were marked as required at
runtime. Then you could have a file that you put stuff in manually for
things like annotations that are required at runtime but not found as
part of the build - and put those in manually. Another file could have
a list of classes that another build step prior to the dependency
analysis would be responsible for generating as a result of parsing
xml config files and overwriting that file.

This support might need to wait until after (handling runtime
dependencies differently) is taken care of. Adding support for
explicitly listing off certain classes that might not be found by
scanning but that should definitely be considered as 'used' might also
provide another way to handle things such as source-retained
annotations in

Two questions -
How do I use the "analyzer" configuration parameter to swap out the
analyzer component (do I just add an artifact to the plugin dependency
that contains my analyzer and specify the class in the "analyzer"
configuration? - is there a way for me to have my analyzer take
additional configuration parameters?) [I've searched for a while, but
haven't found any examples, either for this plugin or for swapping
components in general in maven]

For things that are marked as required at runtime but have no
artifacts providing them - there should probably be a new category in
the reporting for the class itself "Classes needed at runtime but are
not found in any declared or undeclared dependency:" and have it dump
out the class names that aren't found in any of the dependencies or
transitive dependencies. (Or it could just print error level warnings
when it can't find a class in the artifacts anywhere)


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message