svn-gvsig-desktop / tags / org.gvsig.desktop-2.0.340 / maven-howto.rst @ 47603
History | View | Annotate | Download (14.4 KB)
1 | 40435 | jjdelcerro | |
---|---|---|---|
2 | 40513 | jjdelcerro | ================================== |
3 | Usefull maven "howtos" and FAQs |
||
4 | ================================== |
||
5 | 40471 | jjdelcerro | |
6 | 40513 | jjdelcerro | .. contents:: |
7 | 40435 | jjdelcerro | |
8 | 40513 | jjdelcerro | How to reduce the process of "install" to run as fast as possible. |
9 | ------------------------------------------------------------------- |
||
10 | 40435 | jjdelcerro | |
11 | 40513 | jjdelcerro | Can reduce install execution skiping test execution and compilation, |
12 | 42481 | jjdelcerro | javadoc generation, test signature checking, license checking, and |
13 | 40513 | jjdelcerro | attach sources in jar. |
14 | 40471 | jjdelcerro | |
15 | 41698 | jjdelcerro | mvn -Danimal.sniffer.skip=true -Dsource.skip=true -Dmaven.javadoc.skip=true -Dmaven.test.skip=true -DskipTests -Dgvsig.skip.downloadPluginTemplates=true install |
16 | 40513 | jjdelcerro | |
17 | 40842 | jjdelcerro | 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 | 40880 | jjdelcerro | mvn -Dincrease-build-number process-sources |
23 | 42481 | jjdelcerro | |
24 | 40842 | jjdelcerro | 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 | 42481 | jjdelcerro | - The process uses WEBDAV to upload the packages, gvspkg and gvspki, and require |
34 | 40842 | jjdelcerro | 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 | 42481 | jjdelcerro | - The process create a file "addon-request.txt" in the target with the information to |
38 | 40842 | jjdelcerro | add to the ticket to request the update of the package in the main repository of |
39 | packages of gvSIG. |
||
40 | 42481 | jjdelcerro | |
41 | 40513 | jjdelcerro | 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 | 40472 | jjdelcerro | mvn -Dlicense.quiet=false license:check |
48 | 40471 | jjdelcerro | |
49 | 40513 | jjdelcerro | How to skip license check from command line |
50 | ---------------------------------------------- |
||
51 | 40471 | jjdelcerro | |
52 | 40513 | jjdelcerro | 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 | 40471 | jjdelcerro | mvn -Dlicense.skip=true install |
57 | |||
58 | 40513 | jjdelcerro | How to skip attach sources in jar from command line |
59 | ------------------------------------------------------ |
||
60 | 40469 | jjdelcerro | |
61 | 42481 | jjdelcerro | If in the project is enabled by default the generation of jar whith |
62 | 40513 | jjdelcerro | the sources of the project, you can disable this setting the property |
63 | "source.skip" to true in the command line:: |
||
64 | |||
65 | 40469 | jjdelcerro | mvn -Dsource.skip=true install |
66 | |||
67 | 40513 | jjdelcerro | How to skip test compile from command line |
68 | -------------------------------------------- |
||
69 | 40435 | jjdelcerro | |
70 | 42481 | jjdelcerro | You can skip the compilation of test setting the propety "maven.test.skip" |
71 | 40513 | jjdelcerro | to true in the command line:: |
72 | |||
73 | 40435 | jjdelcerro | mvn -Dmaven.test.skip=true install |
74 | |||
75 | |||
76 | 40513 | jjdelcerro | 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 | 40435 | jjdelcerro | mvn -DskipTests install |
83 | |||
84 | 40513 | jjdelcerro | How to skip javadoc generation from command line |
85 | -------------------------------------------------- |
||
86 | 40435 | jjdelcerro | |
87 | 40513 | jjdelcerro | You can skip the javadoc generation setting the property |
88 | "maven.javadoc.skip" to true in the command line:: |
||
89 | |||
90 | 40435 | jjdelcerro | mvn -Dmaven.javadoc.skip=true install |
91 | |||
92 | 40513 | jjdelcerro | How to skip test signature cheks from command line |
93 | --------------------------------------------------- |
||
94 | 40435 | jjdelcerro | |
95 | 40513 | jjdelcerro | You can skip the signature check setting the property |
96 | "animal.sniffer.skip" to true in the command line:: |
||
97 | |||
98 | 40435 | jjdelcerro | mvn -Danimal.sniffer.skip=true install |
99 | |||
100 | 40513 | jjdelcerro | How to install a project without install submodules |
101 | ---------------------------------------------------------- |
||
102 | 40435 | jjdelcerro | |
103 | 40513 | jjdelcerro | To install a project with submodules and only install the |
104 | parent project without submodules use the option "--non-recursive" :: |
||
105 | |||
106 | 40435 | jjdelcerro | mvn --non-recursive install |
107 | |||
108 | 40513 | jjdelcerro | How to check and fix the header of source files. |
109 | -------------------------------------------------- |
||
110 | 40469 | jjdelcerro | |
111 | 42481 | jjdelcerro | You can check the headers of the files in you project |
112 | 40513 | jjdelcerro | 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 | 42481 | jjdelcerro | |
120 | 40513 | jjdelcerro | How to skip test compilation |
121 | -------------------------------- |
||
122 | 40435 | jjdelcerro | |
123 | 40513 | jjdelcerro | 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 | 40435 | jjdelcerro | |
127 | 40513 | jjdelcerro | <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 | 40435 | jjdelcerro | |
151 | 40513 | jjdelcerro | Skip test execution |
152 | ---------------------- |
||
153 | 40435 | jjdelcerro | |
154 | 40513 | jjdelcerro | 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 | 40435 | jjdelcerro | |
158 | 40513 | jjdelcerro | |
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 | 42481 | jjdelcerro | 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 | 40513 | jjdelcerro | 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 | 42481 | jjdelcerro | To set the compatibility with a java version add to the |
201 | pom of the project the next configuration of plugin |
||
202 | 40513 | jjdelcerro | "maven-compiler-plugin" :: |
203 | |||
204 | <build> |
||
205 | <plugins> |
||
206 | ... |
||
207 | <plugin> |
||
208 | <!-- Set java compatibility --> |
||
209 | 40435 | jjdelcerro | <groupId>org.apache.maven.plugins</groupId> |
210 | 40513 | jjdelcerro | <artifactId>maven-compiler-plugin</artifactId> |
211 | 40435 | jjdelcerro | <configuration> |
212 | 40513 | jjdelcerro | <source>1.5</source> |
213 | <target>1.5</target> |
||
214 | <encoding>ISO-8859-1</encoding> |
||
215 | 40435 | jjdelcerro | </configuration> |
216 | 40513 | jjdelcerro | </plugin> |
217 | ... |
||
218 | </plugins> |
||
219 | </build> |
||
220 | 40435 | jjdelcerro | |
221 | 40513 | jjdelcerro | Packaging tests in jar |
222 | ------------------------ |
||
223 | 40435 | jjdelcerro | |
224 | 40513 | jjdelcerro | Test classes do not packaging in jar by default. |
225 | To packing add to pom:: |
||
226 | 40435 | jjdelcerro | |
227 | 40513 | jjdelcerro | <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 | 40435 | jjdelcerro | <configuration> |
241 | 40513 | jjdelcerro | <includes> |
242 | <include>**/**</include> |
||
243 | </includes> |
||
244 | 40435 | jjdelcerro | </configuration> |
245 | 40513 | jjdelcerro | </execution> |
246 | </executions> |
||
247 | 42481 | jjdelcerro | </plugin> |
248 | 40513 | jjdelcerro | ... |
249 | </plugins> |
||
250 | </build> |
||
251 | 40435 | jjdelcerro | |
252 | 40513 | jjdelcerro | How to set a dependency with tests jar |
253 | ----------------------------------------- |
||
254 | 40435 | jjdelcerro | |
255 | 40513 | jjdelcerro | 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 | 40435 | jjdelcerro | |
259 | 40513 | jjdelcerro | <dependency> |
260 | <groupId>...</groupId> |
||
261 | <artifactId>...</artifactId> |
||
262 | <type>test-jar</type> |
||
263 | <scope>test</scope> |
||
264 | </dependency> |
||
265 | 40435 | jjdelcerro | |
266 | 40513 | jjdelcerro | How use ant in maven |
267 | ------------------------- |
||
268 | 40435 | jjdelcerro | |
269 | 40513 | jjdelcerro | You can use ant embed in the pom of you project. |
270 | To do this use:: |
||
271 | 40435 | jjdelcerro | |
272 | 40513 | jjdelcerro | <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 | 40435 | jjdelcerro | |
290 | 40513 | jjdelcerro | Fail when execute "mvn deploy" with "No connector available" |
291 | ------------------------------------------------------------- |
||
292 | 40435 | jjdelcerro | |
293 | 40513 | jjdelcerro | When execute a "mvn deploy" fail with the error:: |
294 | 40480 | jjdelcerro | |
295 | 40513 | jjdelcerro | [INFO] ------------------------------------------------------------------------ |
296 | 42481 | jjdelcerro | [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 | 40513 | jjdelcerro | of type default using the available factories WagonRepositoryConnectorFactory -> [Help 1] |
300 | 42481 | jjdelcerro | [ERROR] |
301 | |||
302 | 40513 | jjdelcerro | 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 | 42481 | jjdelcerro | [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.1:prepare |
323 | 40513 | jjdelcerro | (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 | 42481 | jjdelcerro | [ERROR] svn: MKACTIVITY of '/svn/gvsig-desktop/!svn/act/931a27bc-57e8-45d9-adcd-5a2cf54a7045': |
329 | 40513 | jjdelcerro | authorization failed: Could not authenticate to server: rejected Basic challenge (https://devel.gvsig.org) |
330 | [ERROR] -> [Help 1] |
||
331 | [ERROR] |
||
332 | 42481 | jjdelcerro | [ERROR] |
333 | 40513 | jjdelcerro | |
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 | 42481 | jjdelcerro | 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 | 40513 | jjdelcerro | from the command line :: |
342 | |||
343 | svn ci -m "" pom.xml |
||
344 | 41352 | jjdelcerro | |
345 | Alternatively can excute:: |
||
346 | |||
347 | 42481 | jjdelcerro | svn list https://devel.gvsig.org/svn/gvsig-desktop/ |
348 | 41352 | jjdelcerro | |
349 | And manually accept the certificate permanently. |
||
350 | |||
351 | 40986 | jldominguez | Another option that works on Windows in declaring the user and password in the command: |
352 | 40513 | jjdelcerro | |
353 | 40986 | jldominguez | mvn release:prepare -Dusername=[username] -Dpassword=[password] |
354 | |||
355 | 41353 | jjdelcerro | Fail when execute "mvn release:perform" with unable to find valid certification |
356 | ------------------------------------------------------------------------------------------------ |
||
357 | 40986 | jldominguez | |
358 | 41353 | jjdelcerro | When running "mvn release:perform" fail with unable to find valid certification:: |
359 | |||
360 | |||
361 | 42481 | jjdelcerro | [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 | 41353 | jjdelcerro | |
369 | 42481 | jjdelcerro | Consulte la seccion "Acceso de escritura al repositorio maven de gvSIG" de |
370 | 41353 | jjdelcerro | |
371 | 42481 | jjdelcerro | 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 | 41353 | jjdelcerro | |
373 | 42481 | jjdelcerro | How to deploy a jar to gvSIG maven repository |
374 | --------------------------------------------------- |
||
375 | 41353 | jjdelcerro | |
376 | 42481 | jjdelcerro | 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 | 42519 | jjdelcerro | - Si queremos subir un "tar.gz", sustituiremos el packaging por "tar.gz", por ejemplo: |
424 | 42481 | jjdelcerro | |
425 | 42519 | jjdelcerro | 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)" |