summaryrefslogtreecommitdiffstats
path: root/archiva-site/src/site/apt/guides/maven-configuration.apt
blob: e4b868b73986ff87abfe2a649f593cc3f796601e (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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
 -----
 Client Configuration
 -----
 -----
 17 November 2006
 -----

~~ 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.

~~ NOTE: For help with the syntax of this file, see:
~~ http://maven.apache.org/guides/mini/guide-apt-format.html

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}}). 
  
  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.

  <URL-TO-ARCHIVA> => where to find Archiva eg. http://localhost:8080/archiva
  
  <REPOSITORY-ID> => Identifer for the proxied repository inside Archiva

  <URL-NAME> => Another identifier, this time for normal repositories [one of the these will go away]
  

* Configuring a Repository
  
  [[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>URL-TO-ARCHIVA/repository/URL-NAME</url>
    <releases>
      <enabled>true</enabled>
    </releases>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </repository>
+-------------------------------------------------------------------------+

  You can also copy this for a proxied repository, but make sure to change /repository/ to /proxy/ and to change from the "URL Name" to the "Repository Identifier". This should look much like this:
  
+-------------------------------------------------------------------------+
  <repository>
    <id>maven-release</id>
    <url>URL-TO-ARCHIVA/proxy/REPOSITORY-ID</url>
    <releases>
      <enabled>true</enabled>
    </releases>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </repository>
+-------------------------------------------------------------------------+
      

* Configuring Maven-2 to deploy to an Archiva repository
  
  [[1]] Create a user in Archiva to use for deployment

  [[2]] The deployment user needs the Role 'Repository Manager' for each repository that you want to deploy to

  [[3]] Define the server for deployment inside your 'settings.xml', use the newly created user for authentication

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

* Deploying to Archiva

  [[1]] Configure the distributionManagement part of your pom.xml
 
+-------------------------------------------------------------------------+
  <project>
    ...
    <distributionManagement>
      <repository>
        <id>deployment.webdav</id>
        <name>Internal Release Repository</name>
        <url>dav:URL-TO-ARCHIVA/repository/REPOSITORY-ID/</url>
      </repository>
      <snapshotRepository>
        <id>deployment.webdav</id>
        <name>Internal Snapshot Repository</name>
        <url>dav:URL-TO-ARCHIVA/repository/REPOSITORY-ID/</url>
      </snapshotRepository>
    </distributionManagement>
    ...
  </project>
+-------------------------------------------------------------------------+

  [[2]] Add a build extension to your pom.xml to use webdav

+-------------------------------------------------------------------------+
  <project>
    ...
    <build>
      <extensions>
        <extension>
          <groupId>org.apache.maven.wagon</groupId>
          <artifactId>wagon-webdav</artifactId>
          <version>1.0-beta-1</version>
        </extension>
      </extensions>
    </build>
    ...
  </project>
+-------------------------------------------------------------------------+

  [[3]] Finally the user that is running archiva (tomcat-user, plexus-user,..) must have write access to the deployment repository.   
  
* Deploying Third-Party Artifacts to Archiva

  [[1]] In the directory from which you intend to execute "<<<mvn
  deploy:deploy-file>>>", save the following content as <<<pom.xml>>>.
  
+-------+
<project>
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.example</groupId>
   <artifactId>webdav-deploy</artifactId>
   <packaging>pom</packaging>
   <version>1</version>
   <name>Webdav Deployment POM</name>
   
   <build>
      <extensions>
         <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-webdav</artifactId>
            <version>1.0-beta-2</version>
         </extension>
      </extensions>
   </build>

</project>
+-------+

  This pom will not be deployed with the artifact, it simply serves to make the
  wagon-webdav jar available to the build process.
  
  Alternately, save this file somewhere else, and use "<<<mvn ... -f
  /path/to/filename>>>" to force the use of an alternate POM file.
  
  [[2]] Deploy the artifact:
  
+------+
mvn deploy:deploy-file -Dfile=filename.jar -DpomFile=filename.pom
    -DrepositoryId=deployment.webdav
    -Durl=dav:URL-TO-ARCHIVA/repository/REPOSITORY-ID
+------+