views:

65

answers:

2

If you are using closed repository, but your application uses some dependencies from external(maven public) repository.

Is there a way the list can be generated with dependencies which are from internal and which from external repository.

Or I have to do it manually, put just the internal repositories and which dependencies my build fails for those are external, or there is a third way you think will get the results better. Thank you

EDIT

@Pascal Thivent

Here is the deal :

Lets say that my project uses only 2 dependencies: First one is : junit Second one is : velocity

Now lets assume that log4j is transitive dependency of junit(which is the one of the dependencies used by my project).

And lets assume that velocity doesn't have any transitive dependencies. And lets imagine that velocity is on my corporate repository, and I know that junit is being downloaded from maven repository, but I don't know about log4j because I didn't put it in <dependecies> tag.

Is there a way I can get a list of dependencies or something .. which will group dependencies by repositories they are coing from or something similar like this :

velocity - corporate repository junit - maven repository log4j - maven repository

Or if I use the mirrorof to specify to use explicitly the corporate repository, will maven tell me which artifacts I'm missing, including the ones in transitive dependencies?

tnx

+5  A: 

I would use dependency:purge-local-repository for this purpose and analyze the console output to see from where dependencies are (re)resovled.

And if at the end you are using a corporate repository and want to force Maven to use it for all requests (i.e. never access a public repository), then you should declare the corporate repository as mirrorOf all repositories in your settings.xml:

<settings>
  ...
  <mirrors>
    <mirror>
      <id>corporate-repository</id>
      <mirrorOf>*</mirrorOf>
      <name>Maven Repository Manager running on repo.mycompany.com</name>
      <url>http://repo.mycompany.com/proxy&lt;/url&gt;
    </mirror>
  </mirrors>
  ...
</settings>

But I'm maybe extrapolating too much here.

Update:

Or if I use the mirrorof to specify to use explicitly the corporate repository, will maven tell me which artifacts I'm missing, including the ones in transitive dependencies?

Yes.

Pascal Thivent
@Pascal Thivent thank you Pascal I think that I what I seek, before running let me ask you first .. purge-local-repository .. I'm not going to purge/delete anything from local repository by running this am I ?
c0mrade
@c0mrade Well, the documentation of the mojo explicitly says: *Remove the project dependencies from the local repository, and optionally re-resolve them.* So, yes, this is going to remove the project dependencies from the local repository (that was the idea actually). But this shouldn't be a problem unless you installed an artifact manually in your local repository for this project. And if you have a doubt, then just make a backup or your local repository first (e.g. `cp ~/.m2/repository ~/.m2/repository.orig`).
Pascal Thivent
@Pascal Thivent thank you again, I think I didn't express myself the way I wanted I see where you are coming from. The thing is that we want to use only our "corporate" repository, as you explained in your answer above how that can be done, but the thing is we have some dependencies on our corporate, some on maven repository. I want to download them all so they can be uploaded to corporate repository and used only from there, now the thing is I don't know which dependencies are downloaded from where .. if I knew all the external dependencies I'd download them and use them from c repository
c0mrade
@c0mrade Hmm... I'm confused :) Anyway, one thing that would work is: 1. declare the corporate repo as `mirrorOf` all as I mentioned 2. use `purge-local-repository` and install every missing dependency or add required repositories to proxy at the corporate repository level until the build is fixed. If you do this locally on one machine, this should not interrupt the work.
Pascal Thivent
@Pascal Thivent let me rephrase my question, I think it will be more clear, I'm myself confused a bit right now .. let me try to explain at least ..
c0mrade
@Pascal Thivent thank you m8
c0mrade
A: 

I guess you must use Nexus or Artifactory on your corporate repository server to transparently download artifacts from remote repositories into your corporate repository as needed.

If you want to know only the transitive dependencies of your project m2eclipse gives a dependency graph, hierarchy for it.

Chandru
@Chandru we have them up and running already
c0mrade
When you proxy remote repositories you're going to download from public repositories only once.
Chandru