summaryrefslogtreecommitdiffstats
path: root/archiva-docs/src/site/apt/userguide/using-repository.apt
blob: 9d4bec32cf7c26a195bcb12ebf1e5e7edb8ffd94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
 ------
 Using as a Repository
 ------

~~ Licensed to the Apache Software Foundation (ASF) under one                      
~~ or more contributor license agreements.  See the NOTICE file                    
~~ distributed with this work for additional information                           
~~ regarding copyright ownership.  The ASF licenses this file                      
~~ to you under the Apache License, Version 2.0 (the                               
~~ "License"); you may not use this file except in compliance                      
~~ with the License.  You may obtain a copy of the License at                      
~~                                                                                 
~~   http://www.apache.org/licenses/LICENSE-2.0                                    
~~                                                                                 
~~ Unless required by applicable law or agreed to in writing,                      
~~ software distributed under the License is distributed on an                     
~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY                          
~~ KIND, either express or implied.  See the License for the                       
~~ specific language governing permissions and limitations                         
~~ under the License.                                                              

Configuring Maven 2 to use an Archiva repository

  To get your local Maven 2 installation to use an Archiva proxy you need to add the repositories you require to your 'settings.xml'. This file is usually found in ${user.dir}/.m2/settings.xml (see the {{{http://maven.apache.org/settings.html}Settings Reference}}). 

  How you configure the settings depends on how you would like to utilise the repository. You can add the Archiva repository as an additional repository to others already declared by the project, or lock down the
  environment to only use the Archiva repositories (possibly proxying content from a remote repository).

* Locking down to only use Archiva

  If you would like Archiva to serve as the only repository used by your Maven installation, you can use the Maven mirror settings to force this behaviour.

  First, you need to select the default repository to use when none is configured by adding the following to the <<<settings.xml>>> file:

+-------------------------------------------------------------------------+
<settings>
  ...
  <mirrors>
    <mirror>
      <id>archiva.default</id>
      <url>http://repo.mycompany.com:8080/archiva/repository/internal/</url>
      <mirrorOf>external:*</mirrorOf>
    </mirror>
  </mirrors>
  ...
</settings>
+-------------------------------------------------------------------------+

  <<Note:>> <There are other controls you can use on what is mirrored. See Maven's
{{{http://maven.apache.org/guides/mini/guide-mirror-settings.html} Guide to
Mirror Settings}} for more information.>

  With this in place, all repository requests will be sent to the internal repository (which by default is configured to proxy the central repository).

  If you have separate Archiva repositories that you wish to use, you can add an extra mirror declaration as needed:

+-------------------------------------------------------------------------+
    ...
    <mirror>
      <id>archiva.apache.snapshots</id>
      <url>http://repo.mycompany.com:8080/archiva/repository/snapshots/</url>
      <mirrorOf>apache.snapshots</mirrorOf>
    </mirror>
    ...
+-------------------------------------------------------------------------+

  <<WARNING:>> Maven, as of version 2.0.8, does not properly report the correct URL in errors when a mirror is used - so although the Archiva instance is being consulted any error messages will still reflect
  the original URL described in the POM.

* Using Archiva as an additional repository
  
  You will need to add one entry for each repository that is setup in Archiva. If your repository contains plugins; remember to also include a \<pluginRepository\> setting.

  [[1]] Create a new profile to setup your repositories

+-------------------------------------------------------------------------+
<settings>
  ...
  <profiles>
    <profile>
      <id>Repository Proxy</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <!-- ******************************************************* -->
      <!-- repositories for jar artifacts -->
      <!-- ******************************************************* -->
      <repositories>
        <repository>
          ...
        </repository>
        ...   
      </repositories>
      <!-- ******************************************************* -->
      <!-- repositories for maven plugins -->
      <!-- ******************************************************* -->
      <pluginRepositories>
        <pluginRepository>
          ...
        </pluginRepository>
        ...   
      </pluginRepositories>
    </profile>
    ...
  </profiles>
  ...
</settings>
+-------------------------------------------------------------------------+

  [[2]] Add your repository configuration to the profile

  You can copy the repository configuration from the POM Snippet on the Archiva Administration Page for a normal repository. It should look much like:

+-------------------------------------------------------------------------+
    <repository>
      <id>repository-1</id>
      <url>http://repo.mycompany.com:8080/archiva/repository/internal/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
+-------------------------------------------------------------------------+

  [[3]] Add the necessary security configuration

  This is only necessary if the guest account does not have read access to the given repository.

+-------------------------------------------------------------------------+
<settings>
  ...
  <servers>
    <server>
      <id>repository-1</id>
      <username>{archiva-user}</username>
      <password>{archiva-pwd}</password>
    </server>
    ...
  </servers>
  ...
</settings>
+-------------------------------------------------------------------------+