svn-gvsig-desktop / tags / org.gvsig.desktop-2.0.279 / maven-howto.rst @ 46826
History | View | Annotate | Download (14.4 KB)
1 |
|
---|---|
2 |
================================== |
3 |
Usefull maven "howtos" and FAQs |
4 |
================================== |
5 |
|
6 |
.. contents:: |
7 |
|
8 |
How to reduce the process of "install" to run as fast as possible. |
9 |
------------------------------------------------------------------- |
10 |
|
11 |
Can reduce install execution skiping test execution and compilation, |
12 |
javadoc generation, test signature checking, license checking, and |
13 |
attach sources in jar. |
14 |
|
15 |
mvn -Danimal.sniffer.skip=true -Dsource.skip=true -Dmaven.javadoc.skip=true -Dmaven.test.skip=true -DskipTests -Dgvsig.skip.downloadPluginTemplates=true install |
16 |
|
17 |
How to increment the build number of gvSIG plugins |
18 |
---------------------------------------------------- |
19 |
|
20 |
To increase the build number of gvSIG plugins, yo can do: |
21 |
|
22 |
mvn -Dincrease-build-number process-sources |
23 |
|
24 |
How to deploy a package of a gvSIG plugin |
25 |
-------------------------------------------- |
26 |
|
27 |
Yo can deploy the package of a gvSIG plugin with: |
28 |
|
29 |
mvn -Ddeploy-package -Duser=USER -Dpassword=PASSWORD install |
30 |
|
31 |
Notes: |
32 |
- Require that the gvsig.package.info.poolURL property that this set to the correct value. |
33 |
- The process uses WEBDAV to upload the packages, gvspkg and gvspki, and require |
34 |
access to write in the location specified by gvsig.package.info.poolURL |
35 |
- If "user" or "password" is not present, the process ask its each time it need. |
36 |
- If folder specified in gvsig.package.info.poolURL does not exist, the process try to create it. |
37 |
- The process create a file "addon-request.txt" in the target with the information to |
38 |
add to the ticket to request the update of the package in the main repository of |
39 |
packages of gvSIG. |
40 |
|
41 |
How show the list of files that have problems with the header. |
42 |
---------------------------------------------------------------- |
43 |
|
44 |
You can use the mave plugin "license" to check the headers of the files in |
45 |
the project. Use:: |
46 |
|
47 |
mvn -Dlicense.quiet=false license:check |
48 |
|
49 |
How to skip license check from command line |
50 |
---------------------------------------------- |
51 |
|
52 |
If in the project is enabled by default the checking of the headers |
53 |
of files, you can skip this setting the property "license.skip" to |
54 |
true in the command line:: |
55 |
|
56 |
mvn -Dlicense.skip=true install |
57 |
|
58 |
How to skip attach sources in jar from command line |
59 |
------------------------------------------------------ |
60 |
|
61 |
If in the project is enabled by default the generation of jar whith |
62 |
the sources of the project, you can disable this setting the property |
63 |
"source.skip" to true in the command line:: |
64 |
|
65 |
mvn -Dsource.skip=true install |
66 |
|
67 |
How to skip test compile from command line |
68 |
-------------------------------------------- |
69 |
|
70 |
You can skip the compilation of test setting the propety "maven.test.skip" |
71 |
to true in the command line:: |
72 |
|
73 |
mvn -Dmaven.test.skip=true install |
74 |
|
75 |
|
76 |
How to skip test execution from command line |
77 |
---------------------------------------------- |
78 |
|
79 |
You can skip the tests execution setting the propety "skipTests" to true |
80 |
in the command line:: |
81 |
|
82 |
mvn -DskipTests install |
83 |
|
84 |
How to skip javadoc generation from command line |
85 |
-------------------------------------------------- |
86 |
|
87 |
You can skip the javadoc generation setting the property |
88 |
"maven.javadoc.skip" to true in the command line:: |
89 |
|
90 |
mvn -Dmaven.javadoc.skip=true install |
91 |
|
92 |
How to skip test signature cheks from command line |
93 |
--------------------------------------------------- |
94 |
|
95 |
You can skip the signature check setting the property |
96 |
"animal.sniffer.skip" to true in the command line:: |
97 |
|
98 |
mvn -Danimal.sniffer.skip=true install |
99 |
|
100 |
How to install a project without install submodules |
101 |
---------------------------------------------------------- |
102 |
|
103 |
To install a project with submodules and only install the |
104 |
parent project without submodules use the option "--non-recursive" :: |
105 |
|
106 |
mvn --non-recursive install |
107 |
|
108 |
How to check and fix the header of source files. |
109 |
-------------------------------------------------- |
110 |
|
111 |
You can check the headers of the files in you project |
112 |
using the goal "license". To check the header use:: |
113 |
|
114 |
mvn license:check |
115 |
|
116 |
To fix the header use:: |
117 |
|
118 |
mvn license:format |
119 |
|
120 |
How to skip test compilation |
121 |
-------------------------------- |
122 |
|
123 |
To configure a project to don't run the compilation |
124 |
of test you can add to this pom the next configuration of |
125 |
the plugin "maven-compiler-plugin":: |
126 |
|
127 |
<build> |
128 |
<plugins> |
129 |
... |
130 |
<plugin> |
131 |
<!-- Skip compilation tests --> |
132 |
<groupId>org.apache.maven.plugins</groupId> |
133 |
<artifactId>maven-compiler-plugin</artifactId> |
134 |
<executions> |
135 |
<execution> |
136 |
<id>default-testCompile</id> |
137 |
<phase>process-test-sources</phase> |
138 |
<goals> |
139 |
<goal>testCompile</goal> |
140 |
</goals> |
141 |
<configuration> |
142 |
<skip>true</skip> |
143 |
</configuration> |
144 |
</execution> |
145 |
</executions> |
146 |
</plugin> |
147 |
... |
148 |
</plugins> |
149 |
</build> |
150 |
|
151 |
Skip test execution |
152 |
---------------------- |
153 |
|
154 |
To configure a project to don't run the execution |
155 |
of test you can add to this pom the next configuration of |
156 |
the plugin "maven-surefire-plugin":: |
157 |
|
158 |
|
159 |
<build> |
160 |
<plugins> |
161 |
... |
162 |
<plugin> |
163 |
<!-- Skip test execution --> |
164 |
<groupId>org.apache.maven.plugins</groupId> |
165 |
<artifactId>maven-surefire-plugin</artifactId> |
166 |
<configuration> |
167 |
<skipTests>true</skipTests> |
168 |
</configuration> |
169 |
</plugin> |
170 |
... |
171 |
</plugins> |
172 |
</build> |
173 |
|
174 |
Continue on test failure |
175 |
----------------------------- |
176 |
|
177 |
You can configure a project to continue on test execution |
178 |
failure. To do this add to the pom of the project the next |
179 |
configuration of plugin "maven-surefire-plugin" :: |
180 |
|
181 |
<build> |
182 |
<plugins> |
183 |
... |
184 |
<plugin> |
185 |
<!-- Continue on test failure --> |
186 |
<groupId>org.apache.maven.plugins</groupId> |
187 |
<artifactId>maven-surefire-plugin</artifactId> |
188 |
<configuration> |
189 |
<testFailureIgnore>true</testFailureIgnore> |
190 |
</configuration> |
191 |
</plugin> |
192 |
... |
193 |
</plugins> |
194 |
</build> |
195 |
|
196 |
|
197 |
Set java compatibility |
198 |
-------------------------- |
199 |
|
200 |
To set the compatibility with a java version add to the |
201 |
pom of the project the next configuration of plugin |
202 |
"maven-compiler-plugin" :: |
203 |
|
204 |
<build> |
205 |
<plugins> |
206 |
... |
207 |
<plugin> |
208 |
<!-- Set java compatibility --> |
209 |
<groupId>org.apache.maven.plugins</groupId> |
210 |
<artifactId>maven-compiler-plugin</artifactId> |
211 |
<configuration> |
212 |
<source>1.5</source> |
213 |
<target>1.5</target> |
214 |
<encoding>ISO-8859-1</encoding> |
215 |
</configuration> |
216 |
</plugin> |
217 |
... |
218 |
</plugins> |
219 |
</build> |
220 |
|
221 |
Packaging tests in jar |
222 |
------------------------ |
223 |
|
224 |
Test classes do not packaging in jar by default. |
225 |
To packing add to pom:: |
226 |
|
227 |
<build> |
228 |
<plugins> |
229 |
... |
230 |
<plugin> |
231 |
<!-- Packaging tests in jar --> |
232 |
<groupId>org.apache.maven.plugins</groupId> |
233 |
<artifactId>maven-jar-plugin</artifactId> |
234 |
<executions> |
235 |
<!-- Generates a jar file only with the test classes --> |
236 |
<execution> |
237 |
<goals> |
238 |
<goal>test-jar</goal> |
239 |
</goals> |
240 |
<configuration> |
241 |
<includes> |
242 |
<include>**/**</include> |
243 |
</includes> |
244 |
</configuration> |
245 |
</execution> |
246 |
</executions> |
247 |
</plugin> |
248 |
... |
249 |
</plugins> |
250 |
</build> |
251 |
|
252 |
How to set a dependency with tests jar |
253 |
----------------------------------------- |
254 |
|
255 |
You can set a dependency with a test jar adding to |
256 |
the declaration of the dependency the scope of |
257 |
test and the type of "test-jar":: |
258 |
|
259 |
<dependency> |
260 |
<groupId>...</groupId> |
261 |
<artifactId>...</artifactId> |
262 |
<type>test-jar</type> |
263 |
<scope>test</scope> |
264 |
</dependency> |
265 |
|
266 |
How use ant in maven |
267 |
------------------------- |
268 |
|
269 |
You can use ant embed in the pom of you project. |
270 |
To do this use:: |
271 |
|
272 |
<plugin> |
273 |
<artifactId>maven-antrun-plugin</artifactId> |
274 |
<version>1.7</version> |
275 |
<executions> |
276 |
<execution> |
277 |
<phase>generate-sources</phase> |
278 |
<configuration> |
279 |
<target> |
280 |
<echo>Hello world!</echo> |
281 |
</target> |
282 |
</configuration> |
283 |
<goals> |
284 |
<goal>run</goal> |
285 |
</goals> |
286 |
</execution> |
287 |
</executions> |
288 |
</plugin> |
289 |
|
290 |
Fail when execute "mvn deploy" with "No connector available" |
291 |
------------------------------------------------------------- |
292 |
|
293 |
When execute a "mvn deploy" fail with the error:: |
294 |
|
295 |
[INFO] ------------------------------------------------------------------------ |
296 |
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy |
297 |
(default-deploy) on project org.gvsig.desktop: Failed to deploy artifacts/metadata: |
298 |
No connector available to access repository gvsig-repository (dav:https://devel.gvsig.org/m2repo/j2se) |
299 |
of type default using the available factories WagonRepositoryConnectorFactory -> [Help 1] |
300 |
[ERROR] |
301 |
|
302 |
This happens to be configured the webdav wagon as an extension in the section "build":: |
303 |
|
304 |
... |
305 |
<build> |
306 |
<extensions> |
307 |
<extension> |
308 |
<groupId>org.apache.maven.wagon</groupId> |
309 |
<artifactId>wagon-webdav-jackrabbit</artifactId> |
310 |
<version>1.0-beta-7</version> |
311 |
</extension> |
312 |
</extensions> |
313 |
... |
314 |
|
315 |
Fail when execute "mvn release: prepare" with "svn command failed... Could not authenticate" |
316 |
------------------------------------------------------------------------------------------------ |
317 |
|
318 |
When running "mvn release: prepare" updates poms, compiles, and then |
319 |
fails with the following error :: |
320 |
|
321 |
[INFO] ------------------------------------------------------------------------ |
322 |
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.1:prepare |
323 |
(default-cli) on project org.gvsig.desktop: Unable to commit files |
324 |
[ERROR] Provider message: |
325 |
[ERROR] The svn command failed. |
326 |
[ERROR] Command output: |
327 |
[ERROR] svn: Commit failed (details follow): |
328 |
[ERROR] svn: MKACTIVITY of '/svn/gvsig-desktop/!svn/act/931a27bc-57e8-45d9-adcd-5a2cf54a7045': |
329 |
authorization failed: Could not authenticate to server: rejected Basic challenge (https://devel.gvsig.org) |
330 |
[ERROR] -> [Help 1] |
331 |
[ERROR] |
332 |
[ERROR] |
333 |
|
334 |
Apparently maven in linux system use the svn of system and if you're not |
335 |
authenticated when trying to access to the repository, svn fails. |
336 |
|
337 |
This is solved by executing a commit from the command line on |
338 |
some file of the project (only if you have not enabled the option |
339 |
"store-passwords = no" in $ HOME / .subversion / config). For example, you |
340 |
can add or remove at the end of "pom.xml" a blank line and then run |
341 |
from the command line :: |
342 |
|
343 |
svn ci -m "" pom.xml |
344 |
|
345 |
Alternatively can excute:: |
346 |
|
347 |
svn list https://devel.gvsig.org/svn/gvsig-desktop/ |
348 |
|
349 |
And manually accept the certificate permanently. |
350 |
|
351 |
Another option that works on Windows in declaring the user and password in the command: |
352 |
|
353 |
mvn release:prepare -Dusername=[username] -Dpassword=[password] |
354 |
|
355 |
Fail when execute "mvn release:perform" with unable to find valid certification |
356 |
------------------------------------------------------------------------------------------------ |
357 |
|
358 |
When running "mvn release:perform" fail with unable to find valid certification:: |
359 |
|
360 |
|
361 |
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project org.gvsig.tools: Failed to deploy artifacts: Could not transfer artifact org.gvsig:org.gvsig.tools:pom:3.0.15 from/to gvsig-repository (dav:https://devel.gvsig.org/m2repo/j2se): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1] |
362 |
[INFO] [ERROR] |
363 |
[INFO] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. |
364 |
[INFO] [ERROR] Re-run Maven using the -X switch to enable full debug logging. |
365 |
[INFO] [ERROR] |
366 |
[INFO] [ERROR] For more information about the errors and possible solutions, please read the following articles: |
367 |
[INFO] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException |
368 |
|
369 |
Consulte la seccion "Acceso de escritura al repositorio maven de gvSIG" de |
370 |
|
371 |
http://www.gvsig.org/plone/projects/gvsig-desktop/docs/devel/gvsig-devel-guide/2.0.0/trabajar-con-el-nucleo-de-gvsig/gvsig-compilation/initial-configuration/initial-configuration/?searchterm=maven%20java%20certification |
372 |
|
373 |
How to deploy a jar to gvSIG maven repository |
374 |
--------------------------------------------------- |
375 |
|
376 |
Si queremos subir el fichero: |
377 |
|
378 |
- file formsrt.jar |
379 |
- artifactId formsrt |
380 |
- groupId com.jeta |
381 |
- version 2.1.0_M3-1 |
382 |
|
383 |
Al repositorio de gvSIG tendriamos que: |
384 |
|
385 |
- primero crear la carpeta https://devel.gvsig.org/m2repo/j2se/com/jeta/2.1.0_M3-1 en caso de que no exista. |
386 |
Podemos hacerlo usando un cliente de webdav, por ejemplo el cadaver. |
387 |
|
388 |
- Podemos necesitar instalar los certificados correspondientes al https del servidor de gvSIG. |
389 |
Para ello podemos seguir las instrucciones indicadas en: |
390 |
|
391 |
http://docs.gvsig.org/plone/projects/gvsig-desktop/docs/devel/gvsig-devel-guide/2.0.0/trabajar-con-el-nucleo-de-gvsig/gvsig-compilation/initial-configuration/initial-configuration#acceso-de-escritura-al-repositorio-maven-de-gvsig |
392 |
|
393 |
- Nos aseguraremos que en el settings.xml estan incluidos en la seccion servers los datos para acceder al servidor de gvSIG:: |
394 |
|
395 |
<?xml version="1.0" encoding="UTF-8"?> |
396 |
<settings xmlns="http://maven.apache.org/POM/4.0.0" |
397 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
398 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 |
399 |
http://maven.apache.org/xsd/settings-1.0.0.xsd"> |
400 |
<servers> |
401 |
<server> |
402 |
<id>gvsig-repository</id> |
403 |
<username>USUARIO</username> |
404 |
<password>CLAVE</password> |
405 |
<filePermissions>664</filePermissions> |
406 |
<directoryPermissions>774</directoryPermissions> |
407 |
</server> |
408 |
</servers> |
409 |
</settings> |
410 |
|
411 |
- Luego subimos el fichero ejectando el siguiente comando maven:: |
412 |
|
413 |
mvn deploy:deploy-file \ |
414 |
-Durl=https://devel.gvsig.org/m2repo/j2se \ |
415 |
-DrepositoryId=gvsig-repository \ |
416 |
-DgroupId=com.jeta \ |
417 |
-DartifactId=formsrt \ |
418 |
-Dversion=2.1.0_M3-1 \ |
419 |
-Dpackaging=jar \ |
420 |
-Dfile=formsrt.jar \ |
421 |
-Ddescription="Abeille runtime 2.1.0_M3 with the jgoodies clases removeds." |
422 |
|
423 |
- Si queremos subir un "tar.gz", sustituiremos el packaging por "tar.gz", por ejemplo: |
424 |
|
425 |
mvn deploy:deploy-file \ |
426 |
-Durl=https://devel.gvsig.org/m2repo/j2se \ |
427 |
-DrepositoryId=gvsig-repository \ |
428 |
-DgroupId=org.gdal \ |
429 |
-DartifactId=gdal \ |
430 |
-Dversion=1.11.2.1 \ |
431 |
-Dpackaging=tar.gz \ |
432 |
-Dclassifier="osgeolive-9.0-ubuntu-14.04.3-amd64" \ |
433 |
-Dfile=gdal-1.11.2.1-osgeolive-9.0-ubuntu-14.04.3-amd64.tar.gz \ |
434 |
-Ddescription="GDAL extraido del OSGEO live 9.0 (Ubuntu 14.04.3 x86_64)" |