Statistics
| Revision:

gvsig-vectorediting / org.gvsig.vectorediting / trunk / org.gvsig.vectorediting / org.gvsig.vectorediting.app / maven-howto.rst @ 5

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
  
92
How to skip test compilation
93
--------------------------------
94

    
95
To configure a project to don't run the compilation
96
of test you can add to this pom the next configuration of
97
the plugin "maven-compiler-plugin"::
98

    
99
  <build>
100
    <plugins>
101
      ...
102
      <plugin>
103
        <!-- Skip compilation tests -->
104
        <groupId>org.apache.maven.plugins</groupId>
105
        <artifactId>maven-compiler-plugin</artifactId>
106
        <executions>
107
          <execution>
108
            <id>default-testCompile</id>
109
            <phase>process-test-sources</phase>
110
            <goals>
111
              <goal>testCompile</goal>
112
            </goals>
113
            <configuration>
114
              <skip>true</skip>
115
            </configuration>
116
          </execution>
117
        </executions>
118
      </plugin>
119
      ...
120
    </plugins>
121
  </build>
122

    
123
Skip test execution
124
----------------------
125

    
126
To configure a project to don't run the execution
127
of test you can add to this pom the next configuration of
128
the plugin "maven-surefire-plugin"::
129

    
130

    
131
  <build>
132
    <plugins>
133
      ...
134
      <plugin>
135
        <!-- Skip test execution -->
136
        <groupId>org.apache.maven.plugins</groupId>
137
        <artifactId>maven-surefire-plugin</artifactId>
138
        <configuration>
139
          <skipTests>true</skipTests>
140
        </configuration>
141
      </plugin>
142
      ...
143
    </plugins>
144
  </build>
145

    
146
Continue on test failure
147
-----------------------------
148

    
149
You can configure a project to continue on test execution 
150
failure. To do this add to the pom of the project the next 
151
configuration of plugin "maven-surefire-plugin" ::
152

    
153
  <build>
154
    <plugins>
155
      ...
156
      <plugin>
157
        <!-- Continue on test failure -->
158
        <groupId>org.apache.maven.plugins</groupId>
159
        <artifactId>maven-surefire-plugin</artifactId>
160
        <configuration>
161
          <testFailureIgnore>true</testFailureIgnore>
162
        </configuration>
163
      </plugin>
164
      ...
165
    </plugins>
166
  </build>
167

    
168

    
169
Set java compatibility
170
--------------------------
171

    
172
To set the compatibility with a java version  add to the 
173
pom of the project the next configuration of plugin 
174
"maven-compiler-plugin" ::
175

    
176
  <build>
177
    <plugins>
178
      ...
179
      <plugin>
180
          <!-- Set java compatibility -->
181
          <groupId>org.apache.maven.plugins</groupId>
182
          <artifactId>maven-compiler-plugin</artifactId>
183
          <configuration>
184
              <source>1.5</source>
185
              <target>1.5</target>
186
              <encoding>ISO-8859-1</encoding>
187
          </configuration>
188
      </plugin>
189
      ...
190
    </plugins>
191
  </build>
192

    
193
Packaging tests in jar
194
------------------------
195

    
196
Test classes do not packaging in jar by default.
197
To packing add to pom::
198

    
199
  <build>
200
    <plugins>
201
      ...
202
      <plugin>
203
        <!-- Packaging tests in jar -->
204
        <groupId>org.apache.maven.plugins</groupId>
205
        <artifactId>maven-jar-plugin</artifactId>
206
        <executions>
207
          <!-- Generates a jar file only with the test classes -->
208
          <execution>
209
            <goals>
210
              <goal>test-jar</goal>
211
            </goals>
212
            <configuration>
213
              <includes>
214
                <include>**/**</include>
215
              </includes>
216
            </configuration>
217
          </execution>
218
        </executions>
219
      </plugin> 
220
      ...
221
    </plugins>
222
  </build>
223

    
224
How to set a dependency with tests jar
225
-----------------------------------------
226

    
227
You can set a dependency with a test jar adding to
228
the declaration of the dependency the scope of
229
test and the type of "test-jar"::
230

    
231
  <dependency>
232
      <groupId>...</groupId>
233
      <artifactId>...</artifactId>
234
      <type>test-jar</type>
235
      <scope>test</scope>
236
  </dependency>
237

    
238
How use ant in maven
239
-------------------------
240

    
241
You can use ant embed in the pom of you project.
242
To do this use::
243

    
244
  <plugin>
245
    <artifactId>maven-antrun-plugin</artifactId>
246
    <version>1.7</version>
247
    <executions>
248
      <execution>
249
        <phase>generate-sources</phase>
250
        <configuration>
251
          <target>
252
            <echo>Hello world!</echo>
253
          </target>
254
        </configuration>
255
        <goals>
256
          <goal>run</goal>
257
        </goals>
258
      </execution>
259
    </executions>
260
  </plugin>
261

    
262
Fail when execute "mvn deploy" with "No connector available"
263
-------------------------------------------------------------
264

    
265
When execute a "mvn deploy" fail with the error::
266

    
267
  [INFO] ------------------------------------------------------------------------
268
  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy 
269
    (default-deploy) on project org.gvsig.desktop: Failed to deploy artifacts/metadata: 
270
    No connector available to access repository gvsig-repository (dav:https://devel.gvsig.org/m2repo/j2se) 
271
    of type default using the available factories WagonRepositoryConnectorFactory -> [Help 1]
272
  [ERROR] 
273
  
274
This happens to be configured the webdav wagon as an extension in the section "build"::
275

    
276
  ...
277
  <build>
278
    <extensions>
279
        <extension>
280
            <groupId>org.apache.maven.wagon</groupId>
281
            <artifactId>wagon-webdav-jackrabbit</artifactId>
282
            <version>1.0-beta-7</version>
283
        </extension>
284
    </extensions>
285
  ...
286

    
287
Fail when execute "mvn release: prepare" with "svn command failed... Could not authenticate"
288
------------------------------------------------------------------------------------------------
289

    
290
When running "mvn release: prepare" updates poms, compiles, and then
291
fails with the following error ::
292

    
293
  [INFO] ------------------------------------------------------------------------
294
  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.1:prepare 
295
    (default-cli) on project org.gvsig.desktop: Unable to commit files
296
  [ERROR] Provider message:
297
  [ERROR] The svn command failed.
298
  [ERROR] Command output:
299
  [ERROR] svn: Commit failed (details follow):
300
  [ERROR] svn: MKACTIVITY of '/svn/gvsig-desktop/!svn/act/931a27bc-57e8-45d9-adcd-5a2cf54a7045': 
301
    authorization failed: Could not authenticate to server: rejected Basic challenge (https://devel.gvsig.org)
302
  [ERROR] -> [Help 1]
303
  [ERROR] 
304
  [ERROR]
305

    
306
Apparently maven in linux system use the svn of system and if you're not
307
authenticated when trying to access to the repository, svn fails.
308

    
309
This is solved by executing a commit from the command line on
310
some file of the project (only if you have not enabled the option 
311
"store-passwords = no" in $ HOME / .subversion / config). For example, you 
312
can add or remove at the end of "pom.xml" a blank line and then run 
313
from the command line ::
314

    
315
  svn ci -m "" pom.xml
316
  
317
Another option that works on Windows in declaring the user and password in the command:
318

    
319
mvn release:prepare -Dusername=[username] -Dpassword=[password]
320

    
321