0

I want to read classes within dependency jars getting downloaded during maven build(dynamically) and write them in a file inside resources folder. Is there a way to do it? I am new to maven and I tried all possibilities to do this but couldn't find a way. Any help would be appreciated.

Harsh Gupta
  • 339
  • 4
  • 20

1 Answers1

1

You can try using the maven-dependency-plugin and generating a dependency tree with an outputFile. I don't have a running example, but you can take a look of the plugin documentation here: http://maven.apache.org/plugins/maven-dependency-plugin/tree-mojo.html On the usage section you have configuration approaches that may be useful to achieve what you need. You can also generate the dependency tree in a separate maven run with this command:

mvn dependency:tree -Doutput=/path/to/file

as is told in the usage section of the plugin documentation.

Hope this helps

Francisco Valle
  • 613
  • 10
  • 10
  • This won't allow me to read the jar as stream isnt't it ? Because my aim is to read the classes within that jar file. – Harsh Gupta Nov 17 '16 at 16:12
  • You can take a look to this post http://stackoverflow.com/questions/205573/at-runtime-find-all-classes-in-a-java-application-that-extend-a-base-class this solution may be valid to write a test who writes loaded classes by classloader to a file. You can also execute main class with -verbose:class which gives you a list of loaded classes. Hopes this be useful to achieve your needs. – Francisco Valle Nov 18 '16 at 10:00