================================== Usefull maven "howtos" and FAQs ================================== .. contents:: How to reduce the process of "install" to run as fast as possible. ------------------------------------------------------------------- Can reduce install execution skiping test execution and compilation, javadoc generation, test signature checking, license checking, and attach sources in jar. mvn -Dsource.skip=true -Dmaven.test.skip=true -DskipTests -Dmaven.javadoc.skip=true -Danimal.sniffer.skip=true -Dlicense.skip=true install How show the list of files that have problems with the header. ---------------------------------------------------------------- You can use the mave plugin "license" to check the headers of the files in the project. Use:: mvn -Dlicense.quiet=false license:check How to skip license check from command line ---------------------------------------------- If in the project is enabled by default the checking of the headers of files, you can skip this setting the property "license.skip" to true in the command line:: mvn -Dlicense.skip=true install How to skip attach sources in jar from command line ------------------------------------------------------ If in the project is enabled by default the generation of jar whith the sources of the project, you can disable this setting the property "source.skip" to true in the command line:: mvn -Dsource.skip=true install How to skip test compile from command line -------------------------------------------- You can skip the compilation of test setting the propety "maven.test.skip" to true in the command line:: mvn -Dmaven.test.skip=true install How to skip test execution from command line ---------------------------------------------- You can skip the tests execution setting the propety "skipTests" to true in the command line:: mvn -DskipTests install How to skip javadoc generation from command line -------------------------------------------------- You can skip the javadoc generation setting the property "maven.javadoc.skip" to true in the command line:: mvn -Dmaven.javadoc.skip=true install How to skip test signature cheks from command line --------------------------------------------------- You can skip the signature check setting the property "animal.sniffer.skip" to true in the command line:: mvn -Danimal.sniffer.skip=true install How to install a project without install submodules ---------------------------------------------------------- To install a project with submodules and only install the parent project without submodules use the option "--non-recursive" :: mvn --non-recursive install How to check and fix the header of source files. -------------------------------------------------- You can check the headers of the files in you project using the goal "license". To check the header use:: mvn license:check To fix the header use:: mvn license:format How to skip test compilation -------------------------------- To configure a project to don't run the compilation of test you can add to this pom the next configuration of the plugin "maven-compiler-plugin":: ... org.apache.maven.plugins maven-compiler-plugin default-testCompile process-test-sources testCompile true ... Skip test execution ---------------------- To configure a project to don't run the execution of test you can add to this pom the next configuration of the plugin "maven-surefire-plugin":: ... org.apache.maven.plugins maven-surefire-plugin true ... Continue on test failure ----------------------------- You can configure a project to continue on test execution failure. To do this add to the pom of the project the next configuration of plugin "maven-surefire-plugin" :: ... org.apache.maven.plugins maven-surefire-plugin true ... Set java compatibility -------------------------- To set the compatibility with a java version add to the pom of the project the next configuration of plugin "maven-compiler-plugin" :: ... org.apache.maven.plugins maven-compiler-plugin 1.5 1.5 ISO-8859-1 ... Packaging tests in jar ------------------------ Test classes do not packaging in jar by default. To packing add to pom:: ... org.apache.maven.plugins maven-jar-plugin test-jar **/** ... How to set a dependency with tests jar ----------------------------------------- You can set a dependency with a test jar adding to the declaration of the dependency the scope of test and the type of "test-jar":: ... ... test-jar test How use ant in maven ------------------------- You can use ant embed in the pom of you project. To do this use:: maven-antrun-plugin 1.7 generate-sources Hello world! run Fail when execute "mvn deploy" with "No connector available" ------------------------------------------------------------- When execute a "mvn deploy" fail with the error:: [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project org.gvsig.desktop: Failed to deploy artifacts/metadata: No connector available to access repository gvsig-repository (dav:https://devel.gvsig.org/m2repo/j2se) of type default using the available factories WagonRepositoryConnectorFactory -> [Help 1] [ERROR] This happens to be configured the webdav wagon as an extension in the section "build":: ... org.apache.maven.wagon wagon-webdav-jackrabbit 1.0-beta-7 ... Fail when execute "mvn release: prepare" with "svn command failed... Could not authenticate" ------------------------------------------------------------------------------------------------ When running "mvn release: prepare" updates poms, compiles, and then fails with the following error :: [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.1:prepare (default-cli) on project org.gvsig.desktop: Unable to commit files [ERROR] Provider message: [ERROR] The svn command failed. [ERROR] Command output: [ERROR] svn: Commit failed (details follow): [ERROR] svn: MKACTIVITY of '/svn/gvsig-desktop/!svn/act/931a27bc-57e8-45d9-adcd-5a2cf54a7045': authorization failed: Could not authenticate to server: rejected Basic challenge (https://devel.gvsig.org) [ERROR] -> [Help 1] [ERROR] [ERROR] Apparently maven in linux system use the svn of system and if you're not authenticated when trying to access to the repository, svn fails. This is solved by executing a commit from the command line on some file of the project (only if you have not enabled the option "store-passwords = no" in $ HOME / .subversion / config). For example, you can add or remove at the end of "pom.xml" a blank line and then run from the command line :: svn ci -m "" pom.xml