1

Disclaimer - talk n00by to me!

I'm a complete n00b with Artifactory and Maven. I've searched everything I can find online and really have not been able to find anything other that it should be dead simple to import! And because of that, I'm having a hard time finding help for when it doesn't I think.

I have no doubt that this is due to my lack of knowledge with Maven, Artifactory, and Nexus. I just don't know what to do to fix it. The old machine has Maven and points to a Nexus repository.

Assumption

My understanding is that the Maven .m2 folder should be a Maven-structured repository, and I should be able to import it?

Exported the .m2 directory

I have rsynch transfered the entire .m2 directory. Here is a snippet of the .m2 directory, looking only at antlr:

.m2/
|
| - settings.xml
| + repository/
|   |
|   + antlr/
|     |
|     + antlr/
|       |
|       + 2.7.7/
|         |
|         - contains jars, pom, sha1 files
|
|
| + org/
|   |
|   + antlr/
|     |
|     + antlr-master/...
|     + stringtemplate/...
|     + antlr-runtime/
|       |
|       + 3.1.3/
|         |
|         - contains poms, sha1, jars

So, I'm wondering, is this actually supporting the Maven2 layout? It looks like there are jars that are not falling in the org.package format. Does the above not match the import layout format from here? As far as I can tell, it does.

Log only says "No repositories found"

I've tried

  • pointing to that root .m2 folder,
  • pointing to sub-folders such as repository/org
  • zipping the entire .m2 folder it,
  • zipping it at different sub-folders such as the org folder
  • I've tried taking one item out, pointing at the antlr..

Nothing seems to work. I've enabled the Verbose log, which I know redirects to the import-export log and is supposed to provide more information. All that it says is no repositories found.

I'm at a loss as to where to point or what to do. Any help is greatly appreciated!

Damon
  • 1,249
  • 1
  • 15
  • 27

2 Answers2

1

There are 2 options:

  1. Importing many repositories. For that you need to have repositories configured and directories that match the repository names, under which the groupId directories are found. So, assuming you have a repository named "repository", you'll point to .m2

  2. Importing the content of a single repository. For that you select an existing repository and point to the root of the content (repository).

Matt Clark
  • 27,671
  • 19
  • 68
  • 123
JBaruch
  • 22,610
  • 5
  • 62
  • 90
  • 1
    thanks, this helped point me in the right direction. Knowing that pointing to `.m2` was the correct action, I started working more against that *(#1 above)*. What I was messing up is I left the *"Target Local Repository"* set to *"All Repositories."* I created a `legacy-local` repository and then chose it as the target to import to, thinking over time we'll go through reorganize this appropriately. – Damon Aug 19 '13 at 18:48
1

I think you ask the wrong question. There is no need to import .m2 into Artifactory. Normally, your chain of tools should work in this way:

  • IDE: create sources, compile files, generate JARs for development.
  • Maven: search and download libraries, build artifacts with a defined lifecycle.
  • Artifactory / Nexus: deploy own created artifacts, so that they may be used by others. Mirror / proxy a repository from the public to speed up downloads.

So I don't see why you should use the import of m2 to Artifactory or Nexus. Do the following steps to get the chain working.

  1. Setup Artifactory / Nexus, so that they are connected to the Internet. When you then ask Artifactory / Nexus to get log4j, it should be automatically downloaded and cached for you.
  2. Ensure that the repository manager you have setup is included in your settings.xml of your Maven installation as a mirror. See the documentation of settings for details.

When you now do a build with Maven, the following will be done:

  1. Maven searches in its local .m2 repository for the resources needed for the build (plugins and libraries).
  2. If some is not found, it goes to the mirror, and searches there. This is your local installed Artifactory or Nexus, that now searches in its own database.
  3. If the resource is not found as well, it is searched in the known repositories on the world (and downloaded).
  4. The found resource is now stored in your Artifactory or Nexus, so when others use the same repository manager, they will immediately delivered.
  5. Finally it is cached in your local Maven repository .m2.
mliebelt
  • 15,345
  • 7
  • 55
  • 92
  • In Artifactory you can easily generate the needed Maven `settings.xml` from the UI, no need to stuggle with the Maven XML bowlerplate. BTW, how Nexus sneaked in to this discussion? – JBaruch Aug 17 '13 at 10:49
  • @JBaruch Nexus came in because that is what we are migrating from. – Damon Aug 19 '13 at 15:39
  • @mliebelt thanks, that work flow helps. Two things that were motivating me to import: 1. legacy dependencies and worrying that they may not exist anymore (may not be a real problem?) 2. Our local / own artifacts, ensuring these are stored; understanding that we should be able to just build again and store. In the end, I was asked to migrate the repository, including moving the existing artifacts. I couldn't copy the Nexus library because the request kept timing out. But if everything should just download correctly after it's configured, I agree, I probably don't need to import. – Damon Aug 19 '13 at 15:52
  • 1
    @mliebelt based on your comments here, I ended up finding [this post](http://stackoverflow.com/questions/1039362/tips-for-maintaining-an-internal-maven-repository) which suggested if you are going to import, place them into a legacy archive for the time being. That allows me to get them in and resolved but clean as we go. – Damon Aug 19 '13 at 18:54