Psycho Punch
Psycho Punch

Reputation: 6892

How to setup and use internal Maven repository?

Good day, everyone.

I'm trying to setup an internal repository that I can share with some people within a local network with no access to the Internet. So far, I have setup Archiva in my local machine and point the repository to my ~/.m2/repository. I asked those people to setup their Maven settings.xml and add the following profile:

 <profile>
 <id>archiva</id>

 <repositories>
  <repository>
   <id>archiva</id>
   <url>http://mymachine:8087/archiva/repository/internal/</url>
   <releases>
    <enabled>true</enabled>
   </releases>
   <snapshots>
    <enabled>true</enabled>
   </snapshots>
  </repository>
 </repositories>
 <pluginRepositories>
  <pluginRepository>
   <id>archiva</id>
   <url>http://mymachine:8087/archiva/repository/internal/</url>
   <releases>
    <enabled>true</enabled>
   </releases>
   <snapshots>
    <enabled>true</enabled>
   </snapshots>
  </pluginRepository>
 </pluginRepositories>
 </profile>

I've also asked them to set this profile as always active. However, when they try to generate a new Java project using mvn archetype:generate, they always get an error. I actually forgot what the error was but it had something to do with the goal. They can download the jars from Archiva but the generation still fails. I also gave them a copy of the archetype catalog but it's still failing. What am I missing?

Upvotes: 0

Views: 6947

Answers (2)

yegor256
yegor256

Reputation: 105213

I have setup Archiva in my local machine and point the repository to my ~/.m2/repository

I think that this is a wrong idea. You mix two concepts together. Archiva is a foreign repository, while ~/.m2 is a local repository. They should be kept separately, even if the physical machine is the same.

Upvotes: 4

gatoatigrado
gatoatigrado

Reputation: 16868

Are you familiar with archetypes? They are project templates, and you need to create an archetype project (and mvn deploy it to your server) so that they can initialize first. Then, they'll pull with code like,

mvn archetype:generate -DarchetypeGroupId=edu.berkeley.cs.sketch -DarchetypeArtifactId=skalch-archetype2 ...

See full example at ntung.com/mvn. I have an example of an archetype project here (github). They're pretty basic and easy to read. Note that the archetype project is a maven project itself, so the top level pom.xml is for the archetype, and the src/main/resources/archetype-resources/pom.xml is where you want to put your above code referencing your server.

Maybe you mean to type archetype:create instead of archetype:generate? See http://maven.apache.org/guides/getting-started/index.html#How_do_I_setup_Maven if that's the case.

BTW, since Maven uses so many plugins, good luck getting it to work without an internet connection! You might try buildr instead.

Upvotes: 2

Related Questions