FANDOM


Overview

Maven Repositories

Maven Plug-ins

Utilities

Source configuration management tools support

Code analysis tools support

  • PMD Plugin
    • http://maven.apache.org/plugins/maven-pmd-plugin/
    • allows you to automatically run the PMD code analysis tool on your project's source code and generate a site report with its results.
    • also supports the separate Copy/Paste Detector tool (or CPD) distributed with PMD.

Continuous integration tools support

Collaboration tools support

Packaging tools support

Programming languages support

Application frameworks support

Application servers support

Eclipse support

misc

Maven Skins

Readings

Sonatype books

Multi module project

Testing

Reporting

Maven assemblies

Maven snapshot repositories

Deployment process and security

Site process

Release process

Property and Interpolation

  • Built-in properties
project.groupId
project.artifactId
project.version
project.name
project.description
project.baseUri
project.build.sourceDirectory     // src/main/java
project.build.scriptSourceDirectory   // src/main/script
project.build.testSourceDirectory     // src/test/java
project.build.outputDirectory         // target/classes
project.build.testOutputDirectory     // target/test-classes
project.build.directory               // target
project.reporting.outputDirectory
project.parent.basedir
currentYear
 
env.PATH
env.HOME
env.JAVA_HOME

m2e

misc

HOWTOs

Simple POM

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  2.   <modelVersion>4.0.0</modelVersion>
  3.   <groupId>thirdstage.exercise</groupId>
  4.   <artifactId>rest</artifactId>
  5.   <version>0.0.1-SNAPSHOT</version>
  6.  
  7.   <prerequisites>
  8.     <maven>3.0</maven>
  9.   </prerequisites>
  10.  
  11.   <properties>
  12.     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  13.     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  14.     <!-- control build behavior -->
  15.     <skipTests>false</skipTests>
  16.     <maven.deploy.skip>true</maven.deploy.skip>
  17.     <maven.site.skip>false</maven.site.skip> <!-- consumed by maven-site-plugin -->
  18.     <maven.site.deploy.skip>true</maven.site.deploy.skip> <!-- consumed by maven-site-plugin -->
  19.     <generateProjectInfo>false</generateProjectInfo> <!-- consumed by maven-site-plugin -->
  20.     <generateReports>true</generateReports> <!-- consumed by maven-site-plugin -->
  21.     <maven.javadoc.skip>false</maven.javadoc.skip>
  22.     <findbugs.skip>true</findbugs.skip>
  23.     <checkstyle.skip>true</checkstyle.skip>
  24.     <dependencies.release.updatePolicy>never</dependencies.release.updatePolicy>
  25.     <!-- versions for Java SDK and dependencies -->
  26.     <java.version>1.8</java.version>
  27.     <jsr305.version>3.0.1</jsr305.version>
  28.     <slf4j.version>1.7.21</slf4j.version>
  29.     <logback.version>1.1.7</logback.version>
  30.     <junit.version>4.12</junit.version>
  31.     <testng.version>6.9.10</testng.version>
  32.     <mockito.version>2.6.9</mockito.version>
  33.     <commons.lang3.version>3.5</commons.lang3.version>
  34.     <typesafe-config.version>1.3.1</typesafe-config.version>
  35.     <jackson.version>2.7.4</jackson.version>
  36.     <swagger.version>1.5.12</swagger.version>
  37.     <spring.version>4.3.5.RELEASE</spring.version>
  38.     <mybatis.version>3.4.0</mybatis.version>
  39.     <!-- version for Maven plugins -->
  40.     <maven-compiler-plugin.version>3.6.1</maven-compiler-plugin.version>
  41.     <maven-site-plugin.version>3.6</maven-site-plugin.version>
  42.     <swagger-maven-plugin.version>3.1.4</swagger-maven-plugin.version>
  43.     <swagger-codegen-maven-plugin.version>2.2.1</swagger-codegen-maven-plugin.version>
  44.     <maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
  45.     <maven-javadoc-plugin.version>2.10.4</maven-javadoc-plugin.version>
  46.     <findbugs-maven-plugin.version>3.0.4</findbugs-maven-plugin.version>
  47.     <maven-checkstyle-plugin.version>2.17</maven-checkstyle-plugin.version>
  48.     <duplicate-finder-maven-plugin.version>1.2.1</duplicate-finder-maven-plugin.version>
  49.     <maven-eclipse-plugin.version>2.10</maven-eclipse-plugin.version>
  50.   </properties>
  51.  
  52.   <repositories>
  53.     <!-- For more repositories, refer https://mvnrepository.com/repos -->
  54.     <repository>
  55.       <id>central1</id>
  56.       <url>http://repo1.maven.org/maven2/</url>
  57.       <releases>
  58.         <updatePolicy>${dependencies.release.updatePolicy}</updatePolicy>
  59.       </releases>
  60.       <snapshots>
  61.         <enabled>false</enabled>
  62.       </snapshots>
  63.     </repository>
  64.     <repository>
  65.       <id>central2</id>
  66.       <url>http://repo2.maven.org/maven2/</url>
  67.       <releases>
  68.         <updatePolicy>${dependencies.release.updatePolicy}</updatePolicy>
  69.       </releases>
  70.       <snapshots>
  71.         <enabled>false</enabled>
  72.       </snapshots>
  73.     </repository>
  74.     <repository>
  75.       <id>java.net.public</id>
  76.       <url>https://maven.java.net/content/groups/public/</url>
  77.       <releases>
  78.         <updatePolicy>${dependencies.release.updatePolicy}</updatePolicy>
  79.       </releases>
  80.       <snapshots>
  81.         <enabled>true</enabled>
  82.       </snapshots>
  83.     </repository>
  84.   </repositories>
  85.  
  86.   <pluginRepositories>
  87.     <pluginRepository>
  88.       <id>central1</id>
  89.       <url>http://repo1.maven.org/maven2/</url>
  90.       <releases>
  91.         <updatePolicy>${dependencies.release.updatePolicy}</updatePolicy>
  92.       </releases>
  93.       <snapshots>
  94.         <enabled>false</enabled>
  95.       </snapshots>
  96.     </pluginRepository>
  97.     <pluginRepository>
  98.       <id>central2</id>
  99.       <url>http://repo2.maven.org/maven2/</url>
  100.       <releases>
  101.         <updatePolicy>${dependencies.release.updatePolicy}</updatePolicy>
  102.       </releases>
  103.       <snapshots>
  104.         <enabled>false</enabled>
  105.       </snapshots>
  106.     </pluginRepository>
  107.     <!-- codehaus.org has been effectively shut down as an artifact repository. -->
  108.     <!-- <pluginRepository> -->
  109.     <!-- <id>mojo-release</id> -->
  110.     <!-- <url>http://repository.codehaus.org/</url> -->
  111.     <!-- <releases> -->
  112.     <!-- <updatePolicy>${dependencies.release.updatePolicy}</updatePolicy> -->
  113.     <!-- </releases> -->
  114.     <!-- <snapshots> -->
  115.     <!-- <enabled>false</enabled> -->
  116.     <!-- </snapshots> -->
  117.     <!-- </pluginRepository> -->
  118.     <!-- <pluginRepository> -->
  119.     <!-- <id>mojo-snapshot</id> -->
  120.     <!-- <url>http://snapshots.repository.codehaus.org/</url> -->
  121.     <!-- <releases> -->
  122.     <!-- <enabled>false</enabled> -->
  123.     <!-- </releases> -->
  124.     <!-- <snapshots> -->
  125.     <!-- <enabled>true</enabled> -->
  126.     <!-- </snapshots> -->
  127.     <!-- </pluginRepository> -->
  128.   </pluginRepositories>
  129.  
  130.   <reporting>
  131.     <plugins>
  132.       <plugin>
  133.         <groupId>org.apache.maven.plugins</groupId>
  134.         <artifactId>maven-project-info-reports-plugin</artifactId>
  135.         <reportSets>
  136.           <reportSet>
  137.             <reports>
  138.               <report>index</report>
  139. <!--               <report>dependencies</report> -->
  140. <!--               <report>project-team</report> -->
  141. <!--               <report>mailing-list</report> -->
  142. <!--               <report>cim</report> -->
  143. <!--               <report>issue-tracking</report> -->
  144. <!--               <report>license</report> -->
  145. <!--               <report>scm</report> -->
  146.             </reports>
  147.           </reportSet>
  148.         </reportSets>
  149.       </plugin>
  150.       <plugin>
  151.         <groupId>org.apache.maven.plugins</groupId>
  152.         <artifactId>maven-jxr-plugin</artifactId>
  153.         <reportSets>
  154.           <reportSet>
  155.             <id>aggregate</id>
  156.             <reports>
  157.               <report>aggregate</report>
  158.               <report>test-aggregate</report>
  159.             </reports>
  160.           </reportSet>
  161.         </reportSets>
  162.       </plugin>
  163.       <plugin>
  164.         <groupId>org.apache.maven.plugins</groupId>
  165.         <artifactId>maven-javadoc-plugin</artifactId>
  166.         <reportSets>
  167.           <reportSet>
  168.             <id>aggregate</id>
  169.             <reports>
  170.               <report>aggregate</report>
  171.             </reports>
  172.           </reportSet>
  173.         </reportSets>
  174.       </plugin>
  175.       <plugin>
  176.         <groupId>org.apache.maven.plugins</groupId>
  177.         <artifactId>maven-pmd-plugin</artifactId>
  178.         <configuration>
  179.           <!-- For more, refer https://maven.apache.org/plugins/maven-pmd-plugin/pmd-mojo.html -->
  180.           <aggregate>true</aggregate>
  181.           <linkXRef>true</linkXRef>
  182.           <includeXmlInSite>true</includeXmlInSite>
  183.           <skipEmptyReport>true</skipEmptyReport>
  184.           <skipPmdError>true</skipPmdError>
  185.         </configuration>
  186.       </plugin>
  187.       <plugin>
  188.         <groupId>org.codehaus.mojo</groupId>
  189.         <artifactId>findbugs-maven-plugin</artifactId>
  190.       </plugin>
  191.     </plugins>
  192.   </reporting>
  193.  
  194.   <build>
  195.     <plugins>
  196.       <plugin>
  197.         <groupId>org.basepom.maven</groupId>
  198.         <artifactId>duplicate-finder-maven-plugin</artifactId>
  199.         <executions>
  200.           <execution>
  201.             <id>find-duplicate-classes</id>
  202.             <phase>prepare-package</phase>
  203.             <goals>
  204.               <goal>check</goal>
  205.             </goals>
  206.           </execution>
  207.         </executions>
  208.         <configuration>
  209.           <!-- For more, refer https://github.com/basepom/duplicate-finder-maven-plugin/wiki -->
  210.           <skip>false</skip>
  211.           <checkCompileClasspath>false</checkCompileClasspath>
  212.           <checkRuntimeClasspath>true</checkRuntimeClasspath>
  213.           <checkTestClasspath>false</checkTestClasspath>
  214.           <ignoredResourcePatterns>
  215.             <ignoredResourcePattern>about.html</ignoredResourcePattern>
  216.           </ignoredResourcePatterns>
  217.           <ignoredDependencies>
  218.             <dependency>
  219.               <groupId>org.slf4j</groupId>
  220.               <artifactId>jcl-over-slf4j</artifactId>
  221.             </dependency>
  222.           </ignoredDependencies>
  223.         </configuration>
  224.       </plugin>
  225.     </plugins>
  226.     <pluginManagement>
  227.       <plugins>
  228.         <!-- core -->
  229.         <plugin>
  230.           <groupId>org.apache.maven.plugins</groupId>
  231.           <artifactId>maven-compiler-plugin</artifactId>
  232.           <version>${maven-compiler-plugin.version}</version>
  233.           <inherited>true</inherited>
  234.           <configuration>
  235.             <source>${java.version}</source>
  236.             <target>${java.version}</target>
  237.           </configuration>
  238.         </plugin>
  239.         <plugin>
  240.           <groupId>org.apache.maven.plugins</groupId>
  241.           <artifactId>maven-site-plugin</artifactId>
  242.           <version>${maven-site-plugin.version}</version>
  243.           <dependencies>
  244.             <dependency>
  245.               <groupId>org.apache.maven.wagon</groupId>
  246.               <artifactId>wagon-ssh</artifactId>
  247.               <version>2.12</version>
  248.             </dependency>
  249.           </dependencies>
  250.         </plugin>
  251.         <!-- sources -->
  252.         <plugin>
  253.           <!-- For more, refer https://github.com/kongchen/swagger-maven-plugin -->
  254.           <groupId>com.github.kongchen</groupId>
  255.           <artifactId>swagger-maven-plugin</artifactId>
  256.           <version>${swagger-maven-plugin.version}</version>
  257.           <executions>
  258.             <execution>
  259.               <id>generate-swagger-api</id>
  260.               <phase>process-classes</phase>
  261.               <goals>
  262.                 <goal>generate</goal>
  263.               </goals>
  264.             </execution>
  265.           </executions>
  266.         </plugin>
  267.         <plugin>
  268.           <!-- For more, refer followings
  269.            https://github.com/swagger-api/swagger-codegen
  270.            https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen-maven-plugin
  271.          -->
  272.           <groupId>io.swagger</groupId>
  273.           <artifactId>swagger-codegen-maven-plugin</artifactId>
  274.           <version>${swagger-codegen-maven-plugin.version}</version>
  275.           <executions>
  276.             <execution>
  277.               <id>generate-rest-api-doc</id>
  278.               <phase>process-classes</phase>
  279.               <goals>
  280.                 <goal>generate</goal>
  281.               </goals>
  282.               <configuration>
  283.                 <inputSpec>${project.build.directory}/swagger.json</inputSpec>
  284.                 <language>html2</language>
  285.                 <output>${project.build.directory}/generated-sources/swagger/html2</output>
  286.               </configuration>
  287.             </execution>
  288.           </executions>
  289.         </plugin>
  290.         <!-- packaging -->
  291.         <plugin>
  292.           <groupId>org.apache.maven.plugins</groupId>
  293.           <artifactId>maven-jar-plugin</artifactId>
  294.           <version>${maven-jar-plugin.version}</version>
  295.           <configuration>
  296.                   <!-- For more on Maven archiver, refer http://maven.apache.org/shared/maven-archiver/index.html -->
  297.             <archive>
  298.               <addMavenDescriptor>false</addMavenDescriptor>
  299.               <forced>true</forced>
  300.               <index>true</index>
  301.               <manifest>
  302.                 <addClasspath>false</addClasspath>
  303.                 <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
  304.                 <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
  305.                 <addExtensions>false</addExtensions>
  306.                 <classpathLayoutType>simple</classpathLayoutType>
  307.               </manifest>
  308.               <manifestEntries>
  309.                 <Source-Revision>${project.svn.revision}</Source-Revision>
  310.               </manifestEntries>
  311.             </archive>
  312.           </configuration>
  313.         </plugin>
  314.         <!-- reporting -->
  315.         <plugin>
  316.           <groupId>org.apache.maven.plugins</groupId>
  317.           <artifactId>maven-javadoc-plugin</artifactId>
  318.           <version>${maven-javadoc-plugin.version}</version>
  319.           <configuration>
  320.             <additionalJOptions>
  321.               <!-- causes error with JDK 8 <additionalJOption>-Xms128m</additionalJOption> -->
  322.             </additionalJOptions>
  323.             <failOnError>false</failOnError>
  324.             <docencoding>${project.reporting.outputEncoding}</docencoding>
  325.             <encoding>${project.build.sourceEncoding}</encoding>
  326.             <doctitle>${project.name} ${project.version} API</doctitle>
  327.             <windowtitle>${project.name} ${project.version} API</windowtitle>
  328.             <links>
  329.               <link>http://docs.oracle.com/javase/8/docs/api/</link>
  330.               <link>http://docs.oracle.com/javaee/6/api/</link>
  331.               <link>http://www.javadoc.io/doc/com.google.code.findbugs/jsr305/3.0.1</link>
  332.               <link>http://docs.jboss.org/hibernate/beanvalidation/spec/1.1/api/</link>
  333.               <link>http://docs.jboss.org/hibernate/validator/5.2/api/</link>
  334.               <link>https://www.slf4j.org/apidocs/</link>
  335.               <link>http://junit.org/junit4/javadoc/${junit.version}/</link>
  336.               <link>http://commons.apache.org/proper/commons-lang/javadocs/api-${commons.lang3.version}/</link>
  337.               <link>http://commons.apache.org/proper/commons-collections/javadocs/api-release/</link>
  338.               <link>http://docs.swagger.io/swagger-core/v1.5.0/apidocs/</link>
  339.               <link>http://docs.spring.io/spring/docs/4.3.x/javadoc-api/</link>
  340.               <link>http://docs.spring.io/spring-boot/docs/1.5.x/api/</link>
  341.             </links>
  342.             <show>protected</show>
  343.             <splitindex>true</splitindex>
  344.           </configuration>
  345.         </plugin>
  346.         <plugin>
  347.           <!-- For more, refer http://gleclaire.github.io/findbugs-maven-plugin/ -->
  348.           <groupId>org.codehaus.mojo</groupId>
  349.           <artifactId>findbugs-maven-plugin</artifactId>
  350.           <version>${findbugs-maven-plugin.version}</version>
  351.           <configuration>
  352.             <effort>Max</effort>
  353.             <threshold>Low</threshold>
  354.             <!-- findbugs-maven-plugin doesn't provide aggregate goal or mode -->
  355.             <includeFilterFile>src/config/findbugs/findbugs-exclude.xml</includeFilterFile>
  356.             <plugins>
  357.               <plugin>
  358.                 <groupId>com.mebigfatguy.fb-contrib</groupId>
  359.                 <artifactId>fb-contrib</artifactId>
  360.                 <version>6.8.3</version>
  361.               </plugin>
  362.             </plugins>
  363.           </configuration>
  364.         </plugin>
  365.         <plugin>
  366.           <groupId>org.apache.maven.plugins</groupId>
  367.           <artifactId>maven-checkstyle-plugin</artifactId>
  368.           <version>${maven-checkstyle-plugin.version}</version>
  369.         </plugin>
  370.         <plugin>
  371.           <groupId>org.basepom.maven</groupId>
  372.           <artifactId>duplicate-finder-maven-plugin</artifactId>
  373.           <version>${duplicate-finder-maven-plugin.version}</version>
  374.         </plugin>
  375.         <!-- tools supporting -->
  376.         <plugin>
  377.           <!-- http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html -->
  378.           <groupId>org.apache.maven.plugins</groupId>
  379.           <artifactId>maven-eclipse-plugin</artifactId>
  380.           <version>${maven-eclipse-plugin.version}</version>
  381.           <configuration>
  382.             <!-- the next two item doesn't work on m2e. m2e has its own confgiruation in Eclipse preferences -->
  383.             <downloadJavadocs>true</downloadJavadocs>
  384.             <downloadSources>true</downloadSources>
  385.             <forceRecheck>false</forceRecheck>
  386.           </configuration>
  387.         </plugin>
  388.         <plugin>
  389.           <groupId>org.eclipse.m2e</groupId>
  390.           <artifactId>lifecycle-mapping</artifactId>
  391.           <version>1.0.0</version>
  392.           <configuration>
  393.             <lifecycleMappingMetadata>
  394.               <pluginExecutions>
  395.                 <pluginExecution>
  396.                   <pluginExecutionFilter>
  397.                     <groupId>org.apache.maven.plugins</groupId>
  398.                     <artifactId>maven-dependency-plugin</artifactId>
  399.                     <versionRange>[1.0.0,)</versionRange>
  400.                     <goals>
  401.                       <goal>copy-dependencies</goal>
  402.                     </goals>
  403.                   </pluginExecutionFilter>
  404.                   <action>
  405.                     <ignore/>
  406.                   </action>
  407.                 </pluginExecution>
  408.                 <pluginExecution>
  409.                   <pluginExecutionFilter>
  410.                     <groupId>org.apache.maven.plugins</groupId>
  411.                     <artifactId>maven-antrun-plugin</artifactId>
  412.                     <versionRange>[1.0.0,)</versionRange>
  413.                     <goals>
  414.                       <goal>run</goal>
  415.                     </goals>
  416.                   </pluginExecutionFilter>
  417.                   <action>
  418.                     <ignore/>
  419.                   </action>
  420.                 </pluginExecution>
  421.                 <pluginExecution>
  422.                   <pluginExecutionFilter>
  423.                     <groupId>org.codehaus.mojo</groupId>
  424.                     <artifactId>aspectj-maven-plugin</artifactId>
  425.                     <versionRange>[1.0.0,)</versionRange>
  426.                     <goals>
  427.                       <goal>compile</goal>
  428.                       <goal>test-compile</goal>
  429.                     </goals>
  430.                   </pluginExecutionFilter>
  431.                   <action>
  432.                     <ignore/>
  433.                   </action>
  434.                 </pluginExecution>
  435.                 <pluginExecution>
  436.                   <pluginExecutionFilter>
  437.                     <groupId>org.codehaus.mojo</groupId>
  438.                     <artifactId>build-helper-maven-plugin</artifactId>
  439.                     <versionRange>[1.0.0,)</versionRange>
  440.                     <goals>
  441.                       <goal>parse-version</goal>
  442.                     </goals>
  443.                   </pluginExecutionFilter>
  444.                   <action>
  445.                     <ignore/>
  446.                   </action>
  447.                 </pluginExecution>
  448.                 <pluginExecution>
  449.                   <pluginExecutionFilter>
  450.                     <groupId>net.alchim31.maven</groupId>
  451.                     <artifactId>scala-maven-plugin</artifactId>
  452.                     <versionRange>[1.0.0,)</versionRange>
  453.                     <goals>
  454.                       <goal>add-source</goal>
  455.                       <goal>compile</goal>
  456.                       <goal>testCompile</goal>
  457.                     </goals>
  458.                   </pluginExecutionFilter>
  459.                   <action>
  460.                     <ignore/>
  461.                   </action>
  462.                 </pluginExecution>
  463.               </pluginExecutions>
  464.             </lifecycleMappingMetadata>
  465.           </configuration>
  466.         </plugin>
  467.       </plugins>
  468.     </pluginManagement>
  469.   </build>
  470.  
  471.   <dependencies>
  472.     <dependency>
  473.       <!-- JSR 305: Annotations for Software Defect Detection (https://jcp.org/en/jsr/detail?id=305) -->
  474.       <groupId>com.google.code.findbugs</groupId>
  475.       <artifactId>jsr305</artifactId>
  476.       <version>${jsr305.version}</version>
  477.     </dependency>
  478.     <dependency>
  479.       <!-- JSR 330: Dependency Injection for Java -->
  480.       <groupId>javax.inject</groupId>
  481.       <artifactId>javax.inject</artifactId>
  482.       <version>1</version>
  483.     </dependency>
  484.     <dependency>
  485.       <!-- JSR 349: Bean Validation 1.1 (https://jcp.org/en/jsr/detail?id=349) -->
  486.       <groupId>javax.validation</groupId>
  487.       <artifactId>validation-api</artifactId>
  488.       <version>1.1.0.Final</version>
  489.     </dependency>
  490.     <dependency>
  491.       <!-- Hibernate Validator -->
  492.       <groupId>org.hibernate</groupId>
  493.       <artifactId>hibernate-validator</artifactId>
  494.       <version>5.2.4.Final</version>
  495.     </dependency>
  496.     <dependency>
  497.       <groupId>org.slf4j</groupId>
  498.       <artifactId>slf4j-api</artifactId>
  499.       <version>${slf4j.version}</version>
  500.     </dependency>
  501.     <dependency>
  502.       <groupId>org.slf4j</groupId>
  503.       <artifactId>jcl-over-slf4j</artifactId>
  504.       <version>${slf4j.version}</version>
  505.       <scope>runtime</scope>
  506.     </dependency>
  507.     <dependency>
  508.       <groupId>org.slf4j</groupId>
  509.       <artifactId>jul-to-slf4j</artifactId>
  510.       <version>${slf4j.version}</version>
  511.     </dependency>
  512.     <dependency>
  513.       <groupId>ch.qos.logback</groupId>
  514.       <artifactId>logback-classic</artifactId>
  515.       <version>${logback.version}</version>
  516.     </dependency>
  517.     <dependency>
  518.       <groupId>org.codehaus.janino</groupId>
  519.       <artifactId>janino</artifactId>
  520.       <version>2.7.8</version>
  521.     </dependency>
  522.     <dependency>
  523.       <groupId>junit</groupId>
  524.       <artifactId>junit</artifactId>
  525.       <version>${junit.version}</version>
  526.       <scope>test</scope>
  527.     </dependency>
  528.     <dependency>
  529.       <groupId>org.testng</groupId>
  530.       <artifactId>testng</artifactId>
  531.       <version>${testng.version}</version>
  532.       <scope>test</scope>
  533.     </dependency>
  534.     <dependency>
  535.       <groupId>org.mockito</groupId>
  536.       <artifactId>mockito-core</artifactId>
  537.       <version>${mockito.version}</version>
  538.       <scope>test</scope>
  539.     </dependency>
  540.     <dependency>
  541.       <groupId>org.apache.commons</groupId>
  542.       <artifactId>commons-lang3</artifactId>
  543.       <version>${commons.lang3.version}</version>
  544.     </dependency>
  545.     <!-- For more typesafe config, refer https://github.com/typesafehub/config -->
  546.     <dependency>
  547.       <groupId>com.typesafe</groupId>
  548.       <artifactId>config</artifactId>
  549.       <version>${typesafe-config.version}</version>
  550.     </dependency>
  551.   </dependencies>
  552. </project>

Referencing Maven project properties of List type

//@todo

This syntax works within pom.xml and Ant build files using Maven Ant plugin. But this doesn't working with resource filtering of Maven. I can't find any explain or reason for this. Is it a bug?

  1.     ...
  2.     <artifact:pom id="this-pom" file="${basedir}/pom.xml"/>
  3.     <xsddoc out="${this-pom.reporting.outputDirectory}/xsddocs"
  4.        verbose="true">
  5.        <fileset dir="${this-pom.build.resources[0].directory}"
  6.           includes="**/*.xsd"/>
  7.     </xsddoc>
  8.     ...

Build Lifecycle, Build Phase, Plugin and Goal

Maven-buildlifecycle


Guidelines for multi-moduled Maven project

  1. Separate parent project from container project.
  2. Define properties in the parent POM file as possible.
  3. Define the following properties explicitly for clearness and control.
    • Encoding related properties whose default value are dependent on platform.
      • project.build.sourceEncoding
      • project.reporting.outputEncoding
    • Properties to skip situationally unnecessary long running goals.
      • skipTests
      • maven.javadoc.skip
      • maven.deploy.skip
      • findbugs.skip
      • checkstyle.skip
    • Properties to run maven more stable way.
    • Paths for executable programs external to Maven
      • graphviz.home
  1. Define all plugins in the <pluginManagement> element of parent POM file.
    • Don't specify version to plugin definitions in child POM files.
  1. Define repositories in the parent POM file as possible.
  2. Define plugins to analyze or diagnose the sources or resources of the project as a reporting plugin as possible.
  3. Start values for path with ${project.basedir}, ${project.build.directory}, ${project.build.outputDirectory} or so on
    • When just specifying relative path such as 'target/classes', the result directory could be different if you build the project from the enclosing project in multi-module case.
    • If you specify the path with leading ${project.build.directory}, the resulting directory always would be one that is calculated with the current POM's project.
  1. Use resources in target/classes not in src/main/resources, considering resource filtering.

Sample of parent POM in action

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  2.  
  3.   <modelVersion>4.0.0</modelVersion>
  4.   <groupId>thridstage</groupId>
  5.   <artifactId>thridstage-framework-parent</artifactId>
  6.   <version>3.0.0-SNAPSHOT</version>
  7.   <packaging>pom</packaging>
  8.  
  9.   <name>Thirdstage Framework</name>
  10.   <url>...</url>
  11.   <inceptionYear>2012</inceptionYear>
  12.   <organization>
  13.     <name>...</name>
  14.     <url>...</url>
  15.   </organization>
  16.  
  17.   <prerequisites>
  18.     <maven>3.0</maven>
  19.   </prerequisites>
  20.  
  21.   <properties>
  22.     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  23.     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  24.     <graphviz.home>${env.GRAPHVIZ_HOME}</graphviz.home>
  25.     <skipTests>false</skipTests>
  26.     <maven.deploy.skip>true</maven.deploy.skip>
  27.     <maven.javadoc.skip>false</maven.javadoc.skip>
  28.     <maven.site.deploy.skip>true</maven.site.deploy.skip>
  29.     <findbugs.skip>true</findbugs.skip>
  30.     <checkstyle.skip>true</checkstyle.skip>
  31.     <dependency.locations.enabled>false</dependency.locations.enabled>
  32.     <antrun.echos.properties>true</antrun.echos.properties>
  33.     <scm.url.base>...</scm.url.base>
  34.   </properties>
  35.  
  36.   <issueManagement>
  37.     <system>Redmine</system>
  38.     <url>.../issues</url>
  39.   </issueManagement>
  40.   <scm>
  41.     <connection>scm:svn:http:...</connection>
  42.     <url>http:...</url>
  43.   </scm>
  44.   <distributionManagement>
  45.     <repository>
  46.       <id>...</id>
  47.       <name>...</name>
  48.       <url>...</url>
  49.     </repository>
  50.     <snapshotRepository>
  51.       <id>...</id>
  52.       <name>...</name>
  53.       <url>...</url>
  54.     </snapshotRepository>
  55.     <site>
  56.       <id>...</id>
  57.       <url>sftp://.../${project.version}</url>
  58.     </site>
  59.   </distributionManagement>
  60.  
  61.   <repositories>
  62.     <repository>
  63.       <snapshots>
  64.         <enabled>false</enabled>
  65.       </snapshots>
  66.       <id>thirdstag-releases</id>
  67.       <url>...</url>
  68.     </repository>
  69.     <repository>
  70.       <releases>
  71.         <enabled>false</enabled>
  72.       </releases>
  73.       <snapshots>
  74.         <enabled>true</enabled>
  75.       </snapshots>
  76.       <id>thirdstage-snapshots</id>
  77.       <url>...</url>
  78.     </repository>
  79.     <repository>
  80.       <snapshots>
  81.         <enabled>false</enabled>
  82.       </snapshots>
  83.       <id>central2</id>
  84.       <url>http://repo2.maven.org/maven2/</url>
  85.     </repository>
  86.     <repository>
  87.       <snapshots>
  88.         <enabled>false</enabled>
  89.       </snapshots>
  90.       <id>maven2-repository.dev.java.net</id>
  91.       <name>Java.net Repository for Maven</name>
  92.       <url>http://download.java.net/maven/2/</url>
  93.     </repository>
  94.     <repository>
  95.       <snapshots>
  96.         <enabled>false</enabled>
  97.       </snapshots>
  98.       <id>thirdparty</id>
  99.       <name>3rd-party Repository</name>
  100.       <url>http://repo.expertvill.net/nexus/content/repositories/thirdparty</url>
  101.     </repository>
  102.     <repository>
  103.       <id>evolvis-3rdparty</id>
  104.       <url>http://maven-repo.evolvis.org/3rdparty</url>
  105.     </repository>
  106.   </repositories>
  107.   <pluginRepositories>
  108.     <pluginRepository>
  109.       <snapshots>
  110.         <enabled>false</enabled>
  111.       </snapshots>
  112.       <id>central2</id>
  113.       <url>http://repo2.maven.org/maven2/</url>
  114.     </pluginRepository>
  115.     <pluginRepository>
  116.       <snapshots>
  117.         <enabled>false</enabled>
  118.       </snapshots>
  119.       <id>spring-beandoc</id>
  120.       <url>http://spring-beandoc.sourceforge.net/repo</url>
  121.     </pluginRepository>
  122.     <pluginRepository>
  123.       <snapshots>
  124.         <enabled>false</enabled>
  125.       </snapshots>
  126.       <id>tmatesoft-releases</id>
  127.       <url>http://maven.tmatesoft.com/content/repositories/releases/</url>
  128.     </pluginRepository>
  129.     <pluginRepository>
  130.       <releases>
  131.         <enabled>false</enabled>
  132.       </releases>
  133.       <id>tmatesoft-snapshots</id>
  134.       <url>http://maven.tmatesoft.com/content/repositories/snapshots/</url>
  135.     </pluginRepository>
  136.     <pluginRepository>
  137.       <id>evolvis-3rdparty</id>
  138.       <url>http://maven-repo.evolvis.org/3rdparty</url>
  139.     </pluginRepository>
  140.     <pluginRepository>
  141.       <snapshots>
  142.         <enabled>false</enabled>
  143.       </snapshots>
  144.       <id>elca-services</id>
  145.       <url>http://el4.elca-services.ch/el4j/maven2repository</url>
  146.     </pluginRepository>
  147.   </pluginRepositories>
  148.  
  149.   <reporting>
  150.     <plugins>
  151.       <plugin>
  152.         <groupId>org.apache.maven.plugins</groupId>
  153.         <artifactId>maven-checkstyle-plugin</artifactId>
  154.         <configuration>
  155.           <configLocation>../thirdstage.framework.parent/src/main/config/checkstyle/checkstyle.xml</configLocation>
  156.           <propertyExpansion>parent.basedir=../thirdstage.framework.parent</propertyExpansion>
  157.           <failsOnError>false</failsOnError>
  158.         </configuration>
  159.       </plugin>
  160.       <plugin>
  161.         <groupId>org.codehaus.mojo</groupId>
  162.         <artifactId>findbugs-maven-plugin</artifactId>
  163.         <version>2.3.2</version>
  164.         <configuration>
  165.           <effort>Max</effort>
  166.           <threshold>Low</threshold>
  167.           <onlyAnalyze>thirdstage.framework.*</onlyAnalyze>
  168.           <excludeFilterFile>../thirdstage.framework.parent/src/main/config/findbugs/findbugs-exclude.xml</excludeFilterFile>
  169.           <fork>true</fork>
  170.           <timeout>600000</timeout>
  171.           <maxHeap>512</maxHeap>
  172.         </configuration>
  173.       </plugin>
  174.     </plugins>
  175.   </reporting>
  176.  
  177.   <build>
  178.     <plugins>
  179.       <plugin>
  180.         <groupId>org.apache.maven.plugins</groupId>
  181.         <artifactId>maven-antrun-plugin</artifactId>
  182.         <executions>
  183.           <execution>
  184.             <id>validate-properties</id>
  185.             <phase>validate</phase>
  186.             <goals>
  187.               <goal>run</goal>
  188.             </goals>
  189.             <configuration>
  190.               <failOnError>true</failOnError>
  191.               <target name="validate-properties">
  192.                 <taskdef name="if" classname="ise.antelope.tasks.IfTask" classpathref="maven.plugin.classpath" />
  193.  
  194.                 <if name="antrun.echos.properties" value="true">
  195.                   <echo>Head revision of the project "${project.artifactId}" is
  196.                     ${project.svn.revision}.</echo>
  197.                   <echo>project.artifactId : ${project.artifactId}</echo>
  198.                   <echo>project.basedir : ${project.basedir}</echo>
  199.                   <echo>project.resources.0.directory : ${project.resources.0.directory}</echo>
  200.                   <echo>project.resources[0].directory : ${project.resources[0].directory}</echo>
  201.                   <echo>project.parent : ${project.parent}</echo>
  202.                   <echo>project.parent.groupId : ${project.parent.groupId}</echo>
  203.                   <echo>project.parent.artifactId : ${project.parent.artifactId}</echo>
  204.                   <echo>project.parent.relativePath :
  205.                     ${project.parent.relativePath}</echo>
  206.  
  207.                   <pathconvert pathsep="${line.separator}" property="classpath.maven.plugin" refid="maven.plugin.classpath" />
  208.  
  209.                   <pathconvert pathsep="${line.separator}" property="classpath.maven.compile" refid="maven.compile.classpath" />
  210.                   <echo />
  211.                   <echo>Compile-time classpath for Maven :</echo>
  212.                   <echo>${classpath.maven.compile}</echo>
  213.  
  214.                   <pathconvert pathsep="${line.separator}" property="classpath.maven.runtime" refid="maven.runtime.classpath" />
  215.                   <echo />
  216.                   <echo>Run-time classpath for Maven :</echo>
  217.                   <echo>${classpath.maven.runtime}</echo>
  218.  
  219.                   <echo>Check Korean output : 한글이 정상적으로 보이나요?</echo>
  220.                  
  221.                   <!-- echo all properties passed to Ant and environment variables prefixed with 'env' -->
  222.                   <echo>All properties given to Ant are : </echo>
  223.                   <property environment="env" />
  224.                   <echoproperties />
  225.                 </if>
  226.               </target>
  227.             </configuration>
  228.           </execution>
  229.         </executions>
  230.         <dependencies>
  231.           <dependency>
  232.             <groupId>ise.antelope</groupId>
  233.             <artifactId>ant-antelope-tasks</artifactId>
  234.             <version>3.5.0</version>
  235.           </dependency>
  236.         </dependencies>
  237.       </plugin>
  238.       <plugin>
  239.         <groupId>org.apache.maven.plugins</groupId>
  240.         <artifactId>maven-release-plugin</artifactId>
  241.         <configuration>
  242.           <!--
  243.          @fixme javaHome doesn't seem to work as is explained.
  244.          You should specify JAVA_HOME env. variable explicitly in your run configuration when running from
  245.          Eclipse.
  246.           -->
  247.           <!--  <javaHome>c:\lang\jdk1.5</javaHome> -->
  248.          
  249.           <!--  <mavenHome>C:\tools\maven-3.0.3</mavenHome> -->
  250.           <tagBase>${scm.url.base}/main/tags</tagBase>
  251.           <tagNameFormat>@{project.version}</tagNameFormat>
  252.           <username>OhSangMoon</username>
  253.           <autoVersionSubmodules>true</autoVersionSubmodules>
  254.           <pomFileName>pom.xml</pomFileName>
  255.           <arguments>-f pom.xml</arguments>
  256.          
  257.           <!--  not supported by release plugin oer 2.2.2
  258.          <generateReleasePoms>true</generateReleasePoms>
  259.          -->
  260.         </configuration>
  261.       </plugin>
  262.  
  263.     </plugins>
  264.     <pluginManagement>
  265.       <plugins>
  266.         <plugin>
  267.           <groupId>org.apache.maven.plugins</groupId>
  268.           <artifactId>maven-compiler-plugin</artifactId>
  269.           <version>2.3.2</version>
  270.           <inherited>true</inherited>
  271.           <configuration>
  272.             <source>1.5</source>
  273.             <target>1.5</target>
  274.           </configuration>
  275.         </plugin>
  276.         <plugin>
  277.           <groupId>org.apache.maven.plugins</groupId>
  278.           <artifactId>maven-site-plugin</artifactId>
  279.           <version>3.0</version>
  280.           <dependencies>
  281.             <dependency>
  282.               <groupId>org.apache.maven.wagon</groupId>
  283.               <artifactId>wagon-ssh</artifactId>
  284.               <version>2.0</version>
  285.             </dependency>
  286.           </dependencies>
  287.         </plugin>
  288.         <plugin>
  289.           <groupId>org.apache.maven.plugins</groupId>
  290.           <artifactId>maven-jar-plugin</artifactId>
  291.           <version>2.3.2</version>
  292.           <configuration>
  293.             <archive>
  294.               <addMavenDescriptor>false</addMavenDescriptor>
  295.               <forced>true</forced>
  296.               <index>true</index>
  297.               <manifest>
  298.                 <addClasspath>false</addClasspath>
  299.                 <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
  300.                 <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
  301.                 <addExtensions>false</addExtensions>
  302.                 <classpathLayoutType>simple</classpathLayoutType>
  303.               </manifest>
  304.               <manifestEntries>
  305.                 <Source-Revision>${project.svn.revision}</Source-Revision>
  306.               </manifestEntries>
  307.             </archive>
  308.           </configuration>
  309.         </plugin>
  310.         <plugin>
  311.           <groupId>org.apache.maven.plugins</groupId>
  312.           <artifactId>maven-assembly-plugin</artifactId>
  313.           <version>2.2.1</version>
  314.         </plugin>
  315.         <plugin>
  316.           <groupId>org.apache.maven.plugins</groupId>
  317.           <artifactId>maven-javadoc-plugin</artifactId>
  318.           <version>2.8</version>
  319.           <configuration>
  320.             <docencoding>${project.reporting.outputEncoding}</docencoding>
  321.             <encoding>${project.build.sourceEncoding}</encoding>
  322.             <links>
  323.               <link>http://download.oracle.com/javase/1.5.0/docs/api/</link>
  324.               <link>http://download.oracle.com/javaee/5/api/</link>
  325.             </links>
  326.             <show>projected</show>
  327.             <splitindex>true</splitindex>
  328.           </configuration>
  329.         </plugin>
  330.         <plugin>
  331.           <groupId>org.apache.maven.plugins</groupId>
  332.           <artifactId>maven-project-info-reports-plugin</artifactId>
  333.           <version>2.4</version>
  334.         </plugin>
  335.         <plugin>
  336.           <groupId>org.apache.maven.plugins</groupId>
  337.           <artifactId>maven-checkstyle-plugin</artifactId>
  338.           <version>2.7</version>
  339.         </plugin>
  340.         <plugin>
  341.           <groupId>org.apache.maven.plugins</groupId>
  342.           <artifactId>maven-antrun-plugin</artifactId>
  343.           <version>1.7</version>
  344.           <dependencies>
  345.             <dependency>
  346.               <groupId>org.apache.ant</groupId>
  347.               <artifactId>ant</artifactId>
  348.               <version>1.8.2</version>
  349.             </dependency>
  350.           </dependencies>
  351.         </plugin>
  352.         <plugin>
  353.           <groupId>org.apache.maven.plugins</groupId>
  354.           <artifactId>maven-release-plugin</artifactId>
  355.           <version>2.2.2</version>
  356.           <configuration>
  357.             <providerImplementations>
  358.               <svn>javasvn</svn>
  359.             </providerImplementations>
  360.           </configuration>
  361.           <dependencies>
  362.             <dependency>
  363.               <groupId>com.google.code.maven-scm-provider-svnjava</groupId>
  364.               <artifactId>maven-scm-provider-svnjava</artifactId>
  365.               <version>1.15</version>
  366.             </dependency>
  367.             <dependency>
  368.               <groupId>org.tmatesoft.svnkit</groupId>
  369.               <artifactId>svnkit</artifactId>
  370.               <version>1.7.0-SNAPSHOT</version>
  371.             </dependency>
  372.           </dependencies>
  373.         </plugin>
  374.         <plugin>
  375.           <groupId>org.apache.maven.plugins</groupId>
  376.           <artifactId>maven-scm-plugin</artifactId>
  377.           <version>1.6</version>
  378.           <configuration>
  379.             <providerImplementations>
  380.               <svn>javasvn</svn>
  381.             </providerImplementations>
  382.           </configuration>
  383.           <dependencies>
  384.             <dependency>
  385.               <groupId>com.google.code.maven-scm-provider-svnjava</groupId>
  386.               <artifactId>maven-scm-provider-svnjava</artifactId>
  387.               <version>1.15</version>
  388.             </dependency>
  389.             <dependency>
  390.               <groupId>org.tmatesoft.svnkit</groupId>
  391.               <artifactId>svnkit</artifactId>
  392.               <version>1.7.0-SNAPSHOT</version>
  393.             </dependency>
  394.           </dependencies>
  395.         </plugin>
  396.  
  397.         <plugin>
  398.           <groupId>org.apache.maven.plugins</groupId>
  399.           <artifactId>maven-dependency-plugin</artifactId>
  400.           <version>2.4</version>
  401.         </plugin>
  402.  
  403.         <plugin>
  404.           <groupId>org.apache.maven.plugins</groupId>
  405.           <artifactId>maven-eclipse-plugin</artifactId>
  406.           <version>2.8</version>
  407.           <configuration>
  408.             <!-- the next two item doesn't work on m2e. m2e has its own confgiruation in Eclipse preferences -->
  409.             <downloadSources>true</downloadSources>
  410.             <downloadJavaDocs>true</downloadJavaDocs>
  411.           </configuration>
  412.         </plugin>
  413.  
  414.         <plugin>
  415.           <groupId>org.codehaus.mojo</groupId>
  416.           <artifactId>properties-maven-plugin</artifactId>
  417.           <version>1.0-alpha-2</version>
  418.         </plugin>
  419.         <plugin>
  420.           <groupId>org.codehaus.mojo</groupId>
  421.           <artifactId>maven-springbeandoc-plugin</artifactId>
  422.           <version>1.0.8-SNAPSHOT</version>
  423.         </plugin>
  424.         <plugin>
  425.           <groupId>com.google.code.maven-svn-revision-number-plugin</groupId>
  426.           <artifactId>maven-svn-revision-number-plugin</artifactId>
  427.           <version>1.7</version>
  428.           <executions>
  429.             <execution>
  430.               <phase>validate</phase>
  431.               <goals>
  432.                 <goal>revision</goal>
  433.               </goals>
  434.               <configuration>
  435.                 <entries>
  436.                   <entry>
  437.                     <path>${project.basedir}</path>
  438.                     <prefix>project.svn</prefix>
  439.                     <depth>infinity</depth>
  440.                     <reportUnversioned>true</reportUnversioned>
  441.                     <reportIgnored>false</reportIgnored>
  442.                     <reportOutOfDate>false</reportOutOfDate>
  443.                   </entry>
  444.                 </entries>
  445.               </configuration>
  446.             </execution>
  447.           </executions>
  448.           <dependencies>
  449.             <dependency>
  450.               <groupId>org.tmatesoft.svnkit</groupId>
  451.               <artifactId>svnkit</artifactId>
  452.               <version>1.7.0-SNAPSHOT</version>
  453.             </dependency>
  454.           </dependencies>
  455.         </plugin>
  456.       </plugins>
  457.     </pluginManagement>
  458.   </build>
  459. </project>

Dependency on local library not in Maven repository and with no POM file

Sometimes your project may have dependency on a JAR file that is not registered to any of Maven repositories and so have no it's own POM file. In this case, you can use <systemPath> element to specify your module's dependency on it.

  1. <dependencies>
  2.   ...
  3.   <dependency>
  4.     <groupId>unknown</groupId>
  5.     <artifactId>abcd</artifactId>
  6.     <version>1.0</version>
  7.     <type>jar</type>
  8.     <scope>system</scope>
  9.     <systemPath>${project.basedir}/lib/abcd.jar</systemPath>
  10.   </dependency>
  11.   ...
  12. </dependencies>

Note that systemPath could be specified only with system scope. You should specify groupId, artifactId, and version 'cause they are mandatory but you can specify any value and don't need pom file.

Escaping expression interpolation

It may necessary not to interpolate Maven expression in resources. In other words, you just want to leave ${some-property} as it is. For this, you can specify the escape string with escapeString parameter of maven-resource-plugin. You can also define maven.resources.escapeString property in your POM file.

For more refer this page : http://maven.apache.org/plugins/maven-resources-plugin/resources-mojo.html#escapeString

Working with Subversion working copy in format of ver. 1.7

The default configuration of Maven release plugin(maven-release-plugin) up to ver. 2.2.2 or Maven scm plugin(maven-scm-plugin) up to ver. 1.6 can't work correctly with Subversion working copy in format of ver. 1.7.
To solve this problem, you should override the configuration of release plugin or scm plugin to use maven-scm-provider-svnjava and svnkit 1.7.

  1. <plugin>
  2.    <groupId>org.apache.maven.plugins</groupId>
  3.    <artifactId>maven-release-plugin</artifactId>
  4.    <version>2.2.2</version>
  5.    <configuration>
  6.       <providerImplementations>
  7.          <svn>javasvn</svn>
  8.       </providerImplementations>
  9.    </configuration>
  10.    <dependencies>
  11.       <dependency>
  12.          <groupId>com.google.code.maven-scm-provider-svnjava</groupId>
  13.          <artifactId>maven-scm-provider-svnjava</artifactId>
  14.          <version>1.15</version>
  15.       </dependency>
  16.       <dependency>
  17.          <groupId>org.tmatesoft.svnkit</groupId>
  18.          <artifactId>svnkit</artifactId>
  19.          <version>1.7.0-SNAPSHOT</version>
  20.       </dependency>                
  21.    </dependencies>
  22. </plugin>
  23. <plugin>
  24.    <groupId>org.apache.maven.plugins</groupId>
  25.    <artifactId>maven-scm-plugin</artifactId>
  26.    <version>1.6</version>
  27.    <configuration>
  28.       <providerImplementations>
  29.          <svn>javasvn</svn>
  30.       </providerImplementations>
  31.    </configuration>
  32.    <dependencies>
  33.       <dependency>
  34.          <groupId>com.google.code.maven-scm-provider-svnjava</groupId>
  35.          <artifactId>maven-scm-provider-svnjava</artifactId>
  36.          <version>1.15</version>
  37.       </dependency>
  38.       <dependency>
  39.          <groupId>org.tmatesoft.svnkit</groupId>
  40.          <artifactId>svnkit</artifactId>
  41.          <version>1.7.0-SNAPSHOT</version>
  42.       </dependency>                
  43.    </dependencies>
  44. </plugin>

For now, svnkit 1.7 has no release and is in snapshot version.

If you let the plugins use svnkit 1.3.x which is default setting as of now, you would meet the exceptions like the following.

Caused by: org.apache.maven.shared.release.scm.ReleaseScmCommandException: Unable to commit files
Provider message:
SVN commit failed.
Command output:
svn: The path ... appears to be part of a Subversion 1.7 or greater working copy.  Please upgrade your Subversion client to use this working copy.
 at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.checkin(AbstractScmCommitPhase.java:168)
 at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.performCheckins(AbstractScmCommitPhase.java:148)
 at org.apache.maven.shared.release.phase.ScmCommitPreparationPhase.runLogic(ScmCommitPreparationPhase.java:75)
 at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.execute(AbstractScmCommitPhase.java:79)
 at org.apache.maven.shared.release.DefaultReleaseManager.rollback(DefaultReleaseManager.java:259)
 at org.apache.maven.shared.release.DefaultReleaseManager.rollback(DefaultReleaseManager.java:238)
 at org.apache.maven.plugins.release.RollbackReleaseMojo.execute(RollbackReleaseMojo.java:56)
 ... 21 more

For more, refer the followings,

Release process

  • overall process
    • prepare-with-pom in dry mode > rollback > prepare > perform


  1. Check whether the free space in file system is enough for the relative servers.
    • server hosting source repository
    • server hosting binary repository
    • server hosting site documentation
  2. Synchronize all project in trunk.
  3. Run release:prepare-with-pom goal in dryRun mode with following options.
    • maven.deploy.skip = false
    • resume = false
    • dryRun = true
    • maven.home = ${env_var:MAVEN_HOME}
  4. Review pom.xml.tag, pom.xml.next, release-pom.xml in each project
    • pom.xml.tag ...
    • pom.xml.next ...
    • release-pom.xml ...
    • fully explicit(with no placeholder) scm information would exist only in pom.xml.tag file of aggregation project and parent project. Url of the scm should end with the name of the project.
  5. Run release:rollback goal with following options.
    • maven.deploy.skip = false
    • <code>resume = false
    • <code>maven.home = ${env_var:MAVEN_HOME}
  6. Check that all pom.xml.tag, pom.xml.next, pom.xml.backup files are deleted.
  7. Run <code>release:prepare goal with following options
    • maven.deploy.skip = false
    • resume = false
    • maven.home = ${env_var:MAVEN_HOME}
  8. Check the new directory for the version and directories for projects under tag directory in source repository.
  9. Run release:perform goal with following options.
    • maven.deploy.skip = false
    • resume = false
    • maven.home = ${env_var:MAVEN_HOME}
  10. Refresh(F5) all projects in Eclipse.
  11. Login on binary repository and check the binaries for projects are uploaded.
  12. Test on the new version

references

Download a specific artifact using mvn command

You can execute dependency plugin even without a pom.xml to download a specific artifact. Note that dependency plugin needs artifact and repoUrl properties specified explicitly.

# mvn org.apache.maven.plugins:maven-dependency-plugin:2.9:get -Dartifact=org.aspectj:aspectjweaver:1.8.1 -DremoteRepositories=central2::::http://repo2.maven.org/maven2/ -Dtransitive=false -Ddest=.

references

Using Maven and Eclipse for Scala/Java mixed project

  • Required tools and plugins
    • Scala IDE
    • m2eclipse-scala
    • scalatest-eclipse-plugin
    • scala-maven-plugin
  • POM
  1.   ...
  2.  
  3.   <properties>
  4.     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  5.     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  6.     <java.version>1.7</java.version>
  7.     <scala.version>2.11</scala.version>
  8.   </properties>
  9.  
  10.   <build>
  11.     <plugins>
  12.       <plugin>
  13.         <groupId>org.apache.maven.plugins</groupId>
  14.         <artifactId>maven-compiler-plugin</artifactId>
  15.       </plugin>
  16.       <plugin>
  17.         <groupId>net.alchim31.maven</groupId>
  18.         <artifactId>scala-maven-plugin</artifactId>
  19.         <executions>
  20.           <execution>
  21.             <id>scala-compile</id>
  22.             <phase>process-resources</phase>
  23.             <goals>
  24.               <goal>add-source</goal>
  25.               <goal>compile</goal>
  26.             </goals>
  27.           </execution>
  28.           <execution>
  29.             <id>scala-test-compile</id>
  30.             <phase>process-test-resources</phase>
  31.             <goals>
  32.               <goal>testCompile</goal>
  33.             </goals>
  34.           </execution>
  35.         </executions>
  36.       </plugin>
  37.     </plugins>
  38.     <pluginManagement>
  39.       <plugins>
  40.         <plugin>
  41.           <groupId>org.apache.maven.plugins</groupId>
  42.           <artifactId>maven-compiler-plugin</artifactId>
  43.           <version>3.5.1</version>
  44.           <configuration>
  45.             <source>${java.version}</source>
  46.             <target>${java.version}</target>
  47.           </configuration>
  48.         </plugin>
  49.         <plugin>
  50.           <groupId>net.alchim31.maven</groupId>
  51.           <artifactId>scala-maven-plugin</artifactId>
  52.           <version>3.2.2</version>
  53.           <configuration>
  54.             <source>${java.version}</source>
  55.             <target>${java.version}</target>
  56.             <scalaVersion>${scala.version}</scalaVersion>
  57.             <sourceDir>${project.build.sourceDirectory}/../scala</sourceDir>
  58.             <testSourceDir>${project.build.testSourceDirectory}/../scala</testSourceDir>
  59.           </configuration>
  60.         </plugin>
  61.         <plugin>
  62.           <groupId>org.eclipse.m2e</groupId>
  63.           <artifactId>lifecycle-mapping</artifactId>
  64.           <version>1.0.0</version>
  65.           <configuration>
  66.             <lifecycleMappingMetadata>
  67.               <pluginExecutions>
  68.                 <pluginExecution>
  69.                   <pluginExecutionFilter>
  70.                     <groupId>net.alchim31.maven</groupId>
  71.                     <artifactId>scala-maven-plugin</artifactId>
  72.                     <versionRange>[1.0.0,)</versionRange>
  73.                     <goals>
  74.                       <goal>add-source</goal>
  75.                       <goal>compile</goal>
  76.                       <goal>testCompile</goal>
  77.                     </goals>
  78.                   </pluginExecutionFilter>
  79.                   <action>
  80.                     <execute>
  81.                       <runOnConfiguration>true</runOnConfiguration>
  82.                       <runOnIncremental>true</runOnIncremental>
  83.                     </execute>
  84.                   </action>
  85.                 </pluginExecution>
  86.               </pluginExecutions>
  87.             </lifecycleMappingMetadata>
  88.           </configuration>
  89.         </plugin>
  90.       </plugins>
  91.     </pluginManagement>
  92.   </build>
  93.  
  94.   <dependencies>
  95.     <dependency>
  96.       <groupId>org.scalactic</groupId>
  97.       <artifactId>scalactic_${scala.version}</artifactId>
  98.       <version>2.2.6</version>
  99.     </dependency>
  100.     <dependency>
  101.       <groupId>org.scalatest</groupId>
  102.       <artifactId>scalatest_${scala.version}</artifactId>
  103.       <version>2.2.6</version>
  104.       <scope>test</scope>
  105.     </dependency>
  106.   </dependencies>
  107.  
  108.   ...

Simple tips and troubleshooting

  • The value of Maven property "project.build.directory" in normal case is ${basedir}/target. You can confirm this using the following command line : "mvn help:evaluate -Dexpression=project.build.directory".
  • Solving "[ERROR Unable to determine if resource ... exists in .." error.]
    Or just add <dependency.locations.enabled>false</dependency.locations.enabled> into the <properties> element of POM file.
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.3.2:jar (default-jar) on project ...: Error assembling JAR
  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
  ...
Caused by: org.apache.maven.plugin.MojoExecutionException: Error assembling JAR
  at org.apache.maven.plugin.jar.AbstractJarMojo.createArchive(AbstractJarMojo.java:223)
  ...
Caused by: org.codehaus.plexus.archiver.ArchiverException: Problem creating jar: ... (Access is denied)
  at org.codehaus.plexus.archiver.AbstractArchiver.createArchive(AbstractArchiver.java:892)
 ...
Caused by: java.io.FileNotFoundException: ... (Access is denied)
  at java.io.RandomAccessFile.open(Native Method)
  at java.io.RandomAccessFile.<init>(RandomAccessFile.java:216)
  at org.codehaus.plexus.archiver.zip.ZipFile.<init>(ZipFile.java:150)