svn-gvsig-desktop / trunk / org.gvsig.desktop / maven-howto.rst @ 40728
History | View | Annotate | Download (9.29 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 -Dsource.skip=true -Dmaven.test.skip=true -DskipTests -Dmaven.javadoc.skip=true -Danimal.sniffer.skip=true -Dlicense.skip=true install |
16 |
|
17 |
How show the list of files that have problems with the header. |
18 |
---------------------------------------------------------------- |
19 |
|
20 |
You can use the mave plugin "license" to check the headers of the files in |
21 |
the project. Use:: |
22 |
|
23 |
mvn -Dlicense.quiet=false license:check |
24 |
|
25 |
How to skip license check from command line |
26 |
---------------------------------------------- |
27 |
|
28 |
If in the project is enabled by default the checking of the headers |
29 |
of files, you can skip this setting the property "license.skip" to |
30 |
true in the command line:: |
31 |
|
32 |
mvn -Dlicense.skip=true install |
33 |
|
34 |
How to skip attach sources in jar from command line |
35 |
------------------------------------------------------ |
36 |
|
37 |
If in the project is enabled by default the generation of jar whith |
38 |
the sources of the project, you can disable this setting the property |
39 |
"source.skip" to true in the command line:: |
40 |
|
41 |
mvn -Dsource.skip=true install |
42 |
|
43 |
How to skip test compile from command line |
44 |
-------------------------------------------- |
45 |
|
46 |
You can skip the compilation of test setting the propety "maven.test.skip" |
47 |
to true in the command line:: |
48 |
|
49 |
mvn -Dmaven.test.skip=true install |
50 |
|
51 |
|
52 |
How to skip test execution from command line |
53 |
---------------------------------------------- |
54 |
|
55 |
You can skip the tests execution setting the propety "skipTests" to true |
56 |
in the command line:: |
57 |
|
58 |
mvn -DskipTests install |
59 |
|
60 |
How to skip javadoc generation from command line |
61 |
-------------------------------------------------- |
62 |
|
63 |
You can skip the javadoc generation setting the property |
64 |
"maven.javadoc.skip" to true in the command line:: |
65 |
|
66 |
mvn -Dmaven.javadoc.skip=true install |
67 |
|
68 |
How to skip test signature cheks from command line |
69 |
--------------------------------------------------- |
70 |
|
71 |
You can skip the signature check setting the property |
72 |
"animal.sniffer.skip" to true in the command line:: |
73 |
|
74 |
mvn -Danimal.sniffer.skip=true install |
75 |
|
76 |
How to install a project without install submodules |
77 |
---------------------------------------------------------- |
78 |
|
79 |
To install a project with submodules and only install the |
80 |
parent project without submodules use the option "--non-recursive" :: |
81 |
|
82 |
mvn --non-recursive install |
83 |
|
84 |
How to check and fix the header of source files. |
85 |
-------------------------------------------------- |
86 |
|
87 |
You can check the headers of the files in you project |
88 |
using the goal "license". To check the header use:: |
89 |
|
90 |
mvn license:check |
91 |
|
92 |
To fix the header use:: |
93 |
|
94 |
mvn license:format |
95 |
|
96 |
How to skip test compilation |
97 |
-------------------------------- |
98 |
|
99 |
To configure a project to don't run the compilation |
100 |
of test you can add to this pom the next configuration of |
101 |
the plugin "maven-compiler-plugin":: |
102 |
|
103 |
<build> |
104 |
<plugins> |
105 |
... |
106 |
<plugin> |
107 |
<!-- Skip compilation tests --> |
108 |
<groupId>org.apache.maven.plugins</groupId> |
109 |
<artifactId>maven-compiler-plugin</artifactId> |
110 |
<executions> |
111 |
<execution> |
112 |
<id>default-testCompile</id> |
113 |
<phase>process-test-sources</phase> |
114 |
<goals> |
115 |
<goal>testCompile</goal> |
116 |
</goals> |
117 |
<configuration> |
118 |
<skip>true</skip> |
119 |
</configuration> |
120 |
</execution> |
121 |
</executions> |
122 |
</plugin> |
123 |
... |
124 |
</plugins> |
125 |
</build> |
126 |
|
127 |
Skip test execution |
128 |
---------------------- |
129 |
|
130 |
To configure a project to don't run the execution |
131 |
of test you can add to this pom the next configuration of |
132 |
the plugin "maven-surefire-plugin":: |
133 |
|
134 |
|
135 |
<build> |
136 |
<plugins> |
137 |
... |
138 |
<plugin> |
139 |
<!-- Skip test execution --> |
140 |
<groupId>org.apache.maven.plugins</groupId> |
141 |
<artifactId>maven-surefire-plugin</artifactId> |
142 |
<configuration> |
143 |
<skipTests>true</skipTests> |
144 |
</configuration> |
145 |
</plugin> |
146 |
... |
147 |
</plugins> |
148 |
</build> |
149 |
|
150 |
Continue on test failure |
151 |
----------------------------- |
152 |
|
153 |
You can configure a project to continue on test execution |
154 |
failure. To do this add to the pom of the project the next |
155 |
configuration of plugin "maven-surefire-plugin" :: |
156 |
|
157 |
<build> |
158 |
<plugins> |
159 |
... |
160 |
<plugin> |
161 |
<!-- Continue on test failure --> |
162 |
<groupId>org.apache.maven.plugins</groupId> |
163 |
<artifactId>maven-surefire-plugin</artifactId> |
164 |
<configuration> |
165 |
<testFailureIgnore>true</testFailureIgnore> |
166 |
</configuration> |
167 |
</plugin> |
168 |
... |
169 |
</plugins> |
170 |
</build> |
171 |
|
172 |
|
173 |
Set java compatibility |
174 |
-------------------------- |
175 |
|
176 |
To set the compatibility with a java version add to the |
177 |
pom of the project the next configuration of plugin |
178 |
"maven-compiler-plugin" :: |
179 |
|
180 |
<build> |
181 |
<plugins> |
182 |
... |
183 |
<plugin> |
184 |
<!-- Set java compatibility --> |
185 |
<groupId>org.apache.maven.plugins</groupId> |
186 |
<artifactId>maven-compiler-plugin</artifactId> |
187 |
<configuration> |
188 |
<source>1.5</source> |
189 |
<target>1.5</target> |
190 |
<encoding>ISO-8859-1</encoding> |
191 |
</configuration> |
192 |
</plugin> |
193 |
... |
194 |
</plugins> |
195 |
</build> |
196 |
|
197 |
Packaging tests in jar |
198 |
------------------------ |
199 |
|
200 |
Test classes do not packaging in jar by default. |
201 |
To packing add to pom:: |
202 |
|
203 |
<build> |
204 |
<plugins> |
205 |
... |
206 |
<plugin> |
207 |
<!-- Packaging tests in jar --> |
208 |
<groupId>org.apache.maven.plugins</groupId> |
209 |
<artifactId>maven-jar-plugin</artifactId> |
210 |
<executions> |
211 |
<!-- Generates a jar file only with the test classes --> |
212 |
<execution> |
213 |
<goals> |
214 |
<goal>test-jar</goal> |
215 |
</goals> |
216 |
<configuration> |
217 |
<includes> |
218 |
<include>**/**</include> |
219 |
</includes> |
220 |
</configuration> |
221 |
</execution> |
222 |
</executions> |
223 |
</plugin> |
224 |
... |
225 |
</plugins> |
226 |
</build> |
227 |
|
228 |
How to set a dependency with tests jar |
229 |
----------------------------------------- |
230 |
|
231 |
You can set a dependency with a test jar adding to |
232 |
the declaration of the dependency the scope of |
233 |
test and the type of "test-jar":: |
234 |
|
235 |
<dependency> |
236 |
<groupId>...</groupId> |
237 |
<artifactId>...</artifactId> |
238 |
<type>test-jar</type> |
239 |
<scope>test</scope> |
240 |
</dependency> |
241 |
|
242 |
How use ant in maven |
243 |
------------------------- |
244 |
|
245 |
You can use ant embed in the pom of you project. |
246 |
To do this use:: |
247 |
|
248 |
<plugin> |
249 |
<artifactId>maven-antrun-plugin</artifactId> |
250 |
<version>1.7</version> |
251 |
<executions> |
252 |
<execution> |
253 |
<phase>generate-sources</phase> |
254 |
<configuration> |
255 |
<target> |
256 |
<echo>Hello world!</echo> |
257 |
</target> |
258 |
</configuration> |
259 |
<goals> |
260 |
<goal>run</goal> |
261 |
</goals> |
262 |
</execution> |
263 |
</executions> |
264 |
</plugin> |
265 |
|
266 |
Fail when execute "mvn deploy" with "No connector available" |
267 |
------------------------------------------------------------- |
268 |
|
269 |
When execute a "mvn deploy" fail with the error:: |
270 |
|
271 |
[INFO] ------------------------------------------------------------------------ |
272 |
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy |
273 |
(default-deploy) on project org.gvsig.desktop: Failed to deploy artifacts/metadata: |
274 |
No connector available to access repository gvsig-repository (dav:https://devel.gvsig.org/m2repo/j2se) |
275 |
of type default using the available factories WagonRepositoryConnectorFactory -> [Help 1] |
276 |
[ERROR] |
277 |
|
278 |
This happens to be configured the webdav wagon as an extension in the section "build":: |
279 |
|
280 |
... |
281 |
<build> |
282 |
<extensions> |
283 |
<extension> |
284 |
<groupId>org.apache.maven.wagon</groupId> |
285 |
<artifactId>wagon-webdav-jackrabbit</artifactId> |
286 |
<version>1.0-beta-7</version> |
287 |
</extension> |
288 |
</extensions> |
289 |
... |
290 |
|
291 |
Fail when execute "mvn release: prepare" with "svn command failed... Could not authenticate" |
292 |
------------------------------------------------------------------------------------------------ |
293 |
|
294 |
When running "mvn release: prepare" updates poms, compiles, and then |
295 |
fails with the following error :: |
296 |
|
297 |
[INFO] ------------------------------------------------------------------------ |
298 |
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.1:prepare |
299 |
(default-cli) on project org.gvsig.desktop: Unable to commit files |
300 |
[ERROR] Provider message: |
301 |
[ERROR] The svn command failed. |
302 |
[ERROR] Command output: |
303 |
[ERROR] svn: Commit failed (details follow): |
304 |
[ERROR] svn: MKACTIVITY of '/svn/gvsig-desktop/!svn/act/931a27bc-57e8-45d9-adcd-5a2cf54a7045': |
305 |
authorization failed: Could not authenticate to server: rejected Basic challenge (https://devel.gvsig.org) |
306 |
[ERROR] -> [Help 1] |
307 |
[ERROR] |
308 |
[ERROR] |
309 |
|
310 |
Apparently maven in linux system use the svn of system and if you're not |
311 |
authenticated when trying to access to the repository, svn fails. |
312 |
|
313 |
This is solved by executing a commit from the command line on |
314 |
some file of the project (only if you have not enabled the option |
315 |
"store-passwords = no" in $ HOME / .subversion / config). For example, you |
316 |
can add or remove at the end of "pom.xml" a blank line and then run |
317 |
from the command line :: |
318 |
|
319 |
svn ci -m "" pom.xml |
320 |
|