svn-gvsig-desktop / tags / org.gvsig.desktop-2.0.40 / maven-howto.rst @ 41980
History | View | Annotate | Download (12 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 | javadoc generation, test signature checking, license checking, and |
||
13 | attach sources in jar. |
||
14 | 40471 | jjdelcerro | |
15 | 40816 | jjdelcerro | mvn -Danimal.sniffer.skip=true -Dmaven.test.skip=true -Dsource.skip=true -DskipTests -Dmaven.javadoc.skip=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 | 40842 | jjdelcerro | |
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 | 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 | 40513 | jjdelcerro | 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 | 40469 | jjdelcerro | mvn -Dsource.skip=true install |
66 | |||
67 | 40513 | jjdelcerro | How to skip test compile from command line |
68 | -------------------------------------------- |
||
69 | 40435 | jjdelcerro | |
70 | 40513 | jjdelcerro | You can skip the compilation of test setting the propety "maven.test.skip" |
71 | 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 | 40513 | jjdelcerro | 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 | 40469 | 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 | 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 | 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 | </plugin> |
||
248 | ... |
||
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 | [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 | 40480 | jjdelcerro | |
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 | [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 | 41352 | jjdelcerro | |
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 | 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 | [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 |