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