Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get maven runtime dependencies in ant

I want to get the set of runtime dependencies from maven in ant. I'm using the maven ant tasks.

I know that you can limit the dependencies by scope (see docs):

<artifact:dependencies filesetId="dependency.fileset" useScope="runtime">
  <artifact:pom file="pom.xml" id="myProject" />
</artifact:dependencies>

and that the scope options (from the docs) are:

•compile - Includes scopes compile, system and provided
•runtime - Includes scopes compile and runtime
•test - Includes scopes system, provided, compile, runtime and test

However, I want to get only the runtime dependencies (i.e. exclude compile dependencies). My best idea so far is to get the runtime dependencies and the compile dependencies, and iterate through the runtime dependencies to find those that are not in the compile dependencies, but I haven't yet worked out how to do this.

Any ideas?

like image 388
amaidment Avatar asked Mar 20 '26 05:03

amaidment


1 Answers

You need something along the lines of:

...
<artifact:pom id="maven.project" file="pom.xml"/>

<artifact:dependencies useScope="runtime"
                       filesetId="dependencies.runtime"
                       pomRefId="maven.project"
                       settingsFile="${settings.xml}"/>
...

Then you can use the dependencies.runtime fileset as usual.

I hope this makes more sense.

like image 124
carlspring Avatar answered Mar 22 '26 02:03

carlspring



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!