dash1e
dash1e

Reputation: 7807

Maven (m2e): access dependecy jar file programmatically

I know that it is not correct to ask something without posting code, but it is about 2 days that I'm trying to resolve this problem without success.

What I need is to be able, using a plugin that already exists or implementing one, to get a single file (a properties file) from a dependency jar and export it in my current plugin source folder because I need to us the same properties. The file is a costs definition file, that some other tool are not able to access it using java URL classpath (so I need to access it directly on filesystem).

I tried to solve the problem with "maven-dependency-plugin" but in m2e (eclipse) when the dependencies are resolved inside the workspace it does not work. And I want that it works in both case: when the dependency project is in eclipse workspace and when it is not.

So I can accept to implement my own plugin to do this, if no other plugin exists. But I'm not able to find how in the plugin I can get the dependecy path.

My plugin do this

Set<Artifact> artifacts = project.getDependencyArtifacts();
for (Artifact artifact : artifacts) {
   ...
}

but I cannot find documentation on how to get the artifact path so I can extract the file I need in both case: in eclipse (with m2e when the dependency project is in workspace) and out of eclipse when the dependecy project came from repository (and I run maven from command line).

Upvotes: 1

Views: 291

Answers (1)

khmarbaise
khmarbaise

Reputation: 97379

I would say you should take a deep look at the maven-remote-resources-plugin which solves you problem in a good way.

Upvotes: 1

Related Questions