Reputation: 7298
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?
Upvotes: 3
Views: 2413
Reputation: 7298
So this what I tried to get the difference of the runtime and compile file sets (although this makes the assumption that there's nothing in the compile fileset that's not also in the runtime fileset)
<artifact:dependencies filesetId="runtime" scopes="runtime">
<artifact:pom file="pom.xml" id="myProject" />
</artifact:dependencies>
<artifact:dependencies filesetId="compile" scopes="compile">
<artifact:pom file="pom.xml" id="myProject" />
</artifact:dependencies>
<difference id="difference" >
<resources refid="runtime" />
<resources refid="compile" />
</difference>
However, this wasn't producing the results that I expected, so I did the following, and found that the runtime fileset did not contain the compile dependencies.
<echo message="${toString:runtime}" />
<echo message="${toString:compile}" />
So I can just use the runtime scope...
Upvotes: 0
Reputation: 32677
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.
Upvotes: 1