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

Examples

Tips and Tricks

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

Typical POM for Spring Boot Project

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2.  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  3.  
  4.   <modelVersion>4.0.0</modelVersion>
  5.   <!-- POM for Spring Boot 2.1 : https://docs.spring.io/spring-boot/docs/2.1.x/reference/htmlsingle/#getting-started-maven-installation -->
  6.   <parent>
  7.     <groupId>org.springframework.boot</groupId>
  8.     <artifactId>spring-boot-starter-parent</artifactId>
  9.     <version>2.1.6.RELEASE</version>
  10.   </parent>
  11.   <groupId>mygroup</groupId>
  12.   <artifactId>mygroup.myproject</artifactId>
  13.   <version>0.0.1-SNAPSHOT</version>
  14.  
  15.   <name>myproject</name>
  16.   <description>...</description>
  17.  
  18.   <prerequisites>
  19.     <maven>3.0</maven>
  20.   </prerequisites>
  21.  
  22.   <properties>
  23.     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  24.     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  25.     <!-- control build behavior -->
  26.     <skipTests>false</skipTests>
  27.     <maven.deploy.skip>true</maven.deploy.skip>
  28.     <maven.site.skip>false</maven.site.skip> <!-- consumed by maven-site-plugin -->
  29.     <maven.site.deploy.skip>true</maven.site.deploy.skip> <!-- consumed by maven-site-plugin -->
  30.     <generateProjectInfo>false</generateProjectInfo> <!-- consumed by maven-site-plugin -->
  31.     <generateReports>true</generateReports> <!-- consumed by maven-site-plugin -->
  32.     <maven.javadoc.skip>false</maven.javadoc.skip>
  33.     <maven.javadoc.failOnWarnings>false</maven.javadoc.failOnWarnings>
  34.     <doclint>none</doclint> <!-- http://maven.apache.org/plugins/maven-javadoc-plugin/javadoc-mojo.html#doclint -->
  35.     <findbugs.skip>true</findbugs.skip>
  36.     <checkstyle.skip>true</checkstyle.skip>
  37.     <dependencies.release.updatePolicy>never</dependencies.release.updatePolicy>
  38.     <!-- versions for Java SDK and dependencies -->
  39.     <java.version>1.9</java.version>
  40.     <jsr305.version>3.0.2</jsr305.version> <!-- https://mvnrepository.com/artifact/com.google.code.findbugs/jsr305 -->
  41.     <validation-api.version>2.0.1.Final</validation-api.version> <!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
  42.     <hibernate-validator.version>6.1.2.Final</hibernate-validator.version> <!-- https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator -->
  43.     <slf4j.version>1.7.30</slf4j.version> <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
  44.     <logback.version>1.2.3</logback.version> <!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
  45.     <janino.version>3.1.0</janino.version> <!-- https://mvnrepository.com/artifact/org.codehaus.janino/janino -->
  46.     <junit.version>4.12</junit.version>
  47.     <junit5.version>5.6.1</junit5.version> <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
  48.     <testng.version>6.9.10</testng.version>
  49.     <mockito.version>3.1.0</mockito.version> <!-- affect the dependency version of spring-starter-test module -->
  50.     <commons-lang3.version>3.9</commons-lang3.version> <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
  51.     <commons-validator.version>1.6</commons-validator.version> <!-- https://mvnrepository.com/artifact/commons-validator/commons-validator -->
  52.     <commons-collections4.version>4.4</commons-collections4.version> <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 -->
  53.     <typesafe-config.version>1.3.1</typesafe-config.version>
  54.     <swagger.version>2.0.8</swagger.version> <!-- https://mvnrepository.com/artifact/io.swagger.core.v3 -->
  55.     <springfox-swagger2.version>2.9.2</springfox-swagger2.version> <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
  56.     <mybatis.version>3.5.1</mybatis.version> <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
  57.     <jjwt.version>0.10.7</jjwt.version> <!-- https://mvnrepository.com/artifact/io.jsonwebtoken -->
  58.     <web3j.version>4.5.17</web3j.version> <!-- https://mvnrepository.com/artifact/org.web3j -->
  59.     <!-- version for Maven plugins -->
  60.     <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
  61.     <maven-site-plugin.version>3.9.0</maven-site-plugin.version> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-site-plugin -->
  62.     <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-jar-plugin -->
  63.     <maven-javadoc-plugin.version>3.2.0</maven-javadoc-plugin.version> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-javadoc-plugin -->
  64.     <findbugs-maven-plugin.version>3.0.5</findbugs-maven-plugin.version> <!-- https://mvnrepository.com/artifact/org.codehaus.mojo/findbugs-maven-plugin -->
  65.     <maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-checkstyle-plugin -->
  66.     <duplicate-finder-maven-plugin.version>1.4.0</duplicate-finder-maven-plugin.version> <!-- https://mvnrepository.com/artifact/org.basepom.maven/duplicate-finder-maven-plugin -->
  67.     <maven-eclipse-plugin.version>2.10</maven-eclipse-plugin.version> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-eclipse-plugin -->
  68.     <swagger-maven-plugin.version>3.1.8</swagger-maven-plugin.version> <!-- https://github.com/kongchen/swagger-maven-plugin -->
  69.     <swagger-codegen-maven-plugin.version>3.0.0-rc1</swagger-codegen-maven-plugin.version> <!-- https://mvnrepository.com/artifact/io.swagger/swagger-codegen-maven-plugin -->
  70.     <swagger-codegen-maven-plugin.v3.version>3.0.10</swagger-codegen-maven-plugin.v3.version> <!-- https://mvnrepository.com/artifact/io.swagger.codegen.v3/swagger-codegen-maven-plugin -->
  71.     <web3j-maven-plugin.version>4.5.11</web3j-maven-plugin.version> <!-- https://mvnrepository.com/artifact/org.web3j/web3j-maven-plugin -->
  72.     <exec-maven-plugin>1.6.0</exec-maven-plugin>
  73.     <maven.compiler.source>${java.version}</maven.compiler.source>
  74.     <maven.compiler.target>${java.version}</maven.compiler.target>
  75.   </properties>
  76.  
  77.   <repositories>
  78.     <!-- For more repositories, refer https://mvnrepository.com/repos -->
  79.     <repository>
  80.       <id>central1</id>
  81.       <url>http://repo1.maven.org/maven2/</url>
  82.       <releases>
  83.         <updatePolicy>${dependencies.release.updatePolicy}</updatePolicy>
  84.       </releases>
  85.       <snapshots>
  86.         <enabled>false</enabled>
  87.       </snapshots>
  88.     </repository>
  89.     <repository>
  90.       <id>central2</id>
  91.       <url>http://repo2.maven.org/maven2/</url>
  92.       <releases>
  93.         <updatePolicy>${dependencies.release.updatePolicy}</updatePolicy>
  94.       </releases>
  95.       <snapshots>
  96.         <enabled>false</enabled>
  97.       </snapshots>
  98.     </repository>
  99.     <repository>
  100.       <id>java.net.public</id>
  101.       <url>https://maven.java.net/content/groups/public/</url>
  102.       <releases>
  103.         <updatePolicy>${dependencies.release.updatePolicy}</updatePolicy>
  104.       </releases>
  105.       <snapshots>
  106.         <enabled>true</enabled>
  107.       </snapshots>
  108.     </repository>
  109.     <repository>
  110.       <id>jcenter-snapshots</id>
  111.       <name>jcenter</name>
  112.       <url>https://jcenter.bintray.com/</url>
  113.     </repository>
  114.   </repositories>
  115.  
  116.   <pluginRepositories>
  117.     <pluginRepository>
  118.       <id>central1</id>
  119.       <url>http://repo1.maven.org/maven2/</url>
  120.       <releases>
  121.         <updatePolicy>${dependencies.release.updatePolicy}</updatePolicy>
  122.       </releases>
  123.       <snapshots>
  124.         <enabled>false</enabled>
  125.       </snapshots>
  126.     </pluginRepository>
  127.     <pluginRepository>
  128.       <id>central2</id>
  129.       <url>http://repo2.maven.org/maven2/</url>
  130.       <releases>
  131.         <updatePolicy>${dependencies.release.updatePolicy}</updatePolicy>
  132.       </releases>
  133.       <snapshots>
  134.         <enabled>false</enabled>
  135.       </snapshots>
  136.     </pluginRepository>
  137.   </pluginRepositories>
  138.  
  139.   <reporting>
  140.     <plugins>
  141.       <plugin>
  142.         <groupId>org.apache.maven.plugins</groupId>
  143.         <artifactId>maven-project-info-reports-plugin</artifactId>
  144.         <reportSets>
  145.           <reportSet>
  146.             <reports>
  147.               <report>index</report>
  148.               <!-- <report>dependencies</report> -->
  149.               <!-- <report>project-team</report> -->
  150.               <!-- <report>mailing-list</report> -->
  151.               <!-- <report>cim</report> -->
  152.               <!-- <report>issue-tracking</report> -->
  153.               <!-- <report>license</report> -->
  154.               <!-- <report>scm</report> -->
  155.             </reports>
  156.           </reportSet>
  157.         </reportSets>
  158.       </plugin>
  159.       <plugin>
  160.         <groupId>org.apache.maven.plugins</groupId>
  161.         <artifactId>maven-jxr-plugin</artifactId>
  162.         <reportSets>
  163.           <reportSet>
  164.             <id>aggregate</id>
  165.             <reports>
  166.               <report>aggregate</report>
  167.               <report>test-aggregate</report>
  168.             </reports>
  169.           </reportSet>
  170.         </reportSets>
  171.       </plugin>
  172.       <plugin>
  173.         <groupId>org.apache.maven.plugins</groupId>
  174.         <artifactId>maven-javadoc-plugin</artifactId>
  175.         <reportSets>
  176.           <reportSet>
  177.             <id>aggregate</id>
  178.             <reports>
  179.               <report>aggregate</report>
  180.             </reports>
  181.           </reportSet>
  182.         </reportSets>
  183.       </plugin>
  184.       <plugin>
  185.         <groupId>org.apache.maven.plugins</groupId>
  186.         <artifactId>maven-pmd-plugin</artifactId>
  187.         <configuration>
  188.           <!-- For more, refer https://maven.apache.org/plugins/maven-pmd-plugin/pmd-mojo.html -->
  189.           <aggregate>true</aggregate>
  190.           <linkXRef>true</linkXRef>
  191.           <includeXmlInSite>true</includeXmlInSite>
  192.           <skipEmptyReport>true</skipEmptyReport>
  193.           <skipPmdError>true</skipPmdError>
  194.         </configuration>
  195.       </plugin>
  196.       <plugin>
  197.         <groupId>org.codehaus.mojo</groupId>
  198.         <artifactId>findbugs-maven-plugin</artifactId>
  199.       </plugin>
  200.     </plugins>
  201.   </reporting>
  202.  
  203.   <build>
  204.     <plugins>
  205.       <plugin>
  206.         <groupId>org.springframework.boot</groupId>
  207.         <artifactId>spring-boot-maven-plugin</artifactId>
  208.       </plugin>
  209.       <plugin>
  210.         <groupId>org.basepom.maven</groupId>
  211.         <artifactId>duplicate-finder-maven-plugin</artifactId>
  212.         <version>${duplicate-finder-maven-plugin.version}</version>
  213.         <executions>
  214.           <execution>
  215.             <id>find-duplicate-classes</id>
  216.             <phase>prepare-package</phase>
  217.             <goals>
  218.               <goal>check</goal>
  219.             </goals>
  220.           </execution>
  221.         </executions>
  222.         <configuration>
  223.           <!-- For more, refer https://github.com/basepom/duplicate-finder-maven-plugin/wiki -->
  224.           <skip>false</skip>
  225.           <checkCompileClasspath>false</checkCompileClasspath>
  226.           <checkRuntimeClasspath>true</checkRuntimeClasspath>
  227.           <checkTestClasspath>false</checkTestClasspath>
  228.           <ignoredResourcePatterns>
  229.             <ignoredResourcePattern>about\.html</ignoredResourcePattern>
  230.           </ignoredResourcePatterns>
  231.           <ignoredClassPatterns>
  232.             <ignoredClassPattern>META-INF\.versions\.9\.module-info</ignoredClassPattern>
  233.           </ignoredClassPatterns>
  234.           <ignoredDependencies>
  235.             <dependency>
  236.               <groupId>org.slf4j</groupId>
  237.               <artifactId>jcl-over-slf4j</artifactId>
  238.             </dependency>
  239.           </ignoredDependencies>
  240.         </configuration>
  241.       </plugin>
  242.       <plugin>
  243.         <groupId>com.github.kongchen</groupId>
  244.         <artifactId>swagger-maven-plugin</artifactId>
  245.         <version>${swagger-maven-plugin.version}</version>
  246.         <executions>
  247.           <execution>
  248.             <phase>compile</phase>
  249.             <goals>
  250.               <goal>generate</goal>
  251.             </goals>
  252.             <configuration>
  253.               <apiSources>
  254.                 <apiSource>
  255.                   <springmvc>true</springmvc>
  256.                   <locations>
  257.                     <location>myprogram.controllers</location>
  258.                   </locations>
  259.                   <schemes>
  260.                     <scheme>http</scheme>
  261.                   </schemes>
  262.                   <host>localhost:8080</host>
  263.                   <basePath>/myappl/v1</basePath>
  264.                   <info>
  265.                     <title>REST API of My Program</title>
  266.                     <version>v1</version>
  267.                     <description>
  268.                     ...
  269.                     </description>
  270.                   </info>
  271.                   <swaggerDirectory>${project.build.directory}/generated/swagger</swaggerDirectory>
  272.                   <swaggerFileName>api</swaggerFileName>
  273.                   <outputFormats>json,yaml</outputFormats>
  274.                   <!-- <templatePath>${basedir}/src/templates/swagger/strapdown.html.hbs</templatePath> -->
  275.                   <!-- <outputPath>${project.build.directory}/generated/swagger/api.html</outputPath> -->
  276.                   <!-- <attachSwaggerArtifact>true</attachSwaggerArtifact> -->
  277.                   <modelConverters>io.swagger.validator.BeanValidator</modelConverters>
  278.                 </apiSource>
  279.               </apiSources>
  280.             </configuration>
  281.           </execution>
  282.         </executions>
  283.       </plugin>
  284.       <plugin>
  285.         <!-- For more, refer followings
  286.            https://github.com/swagger-api/swagger-codegen/tree/3.0.0
  287.            https://github.com/swagger-api/swagger-codegen/tree/3.0.0/modules/swagger-codegen-maven-plugin
  288.        -->
  289.         <groupId>io.swagger.codegen.v3</groupId>
  290.         <artifactId>swagger-codegen-maven-plugin</artifactId>
  291.         <version>${swagger-codegen-maven-plugin.v3.version}</version>
  292.         <executions>
  293.           <execution>
  294.             <id>generate-rest-api-doc-v3</id>
  295.             <phase>process-classes</phase>
  296.             <goals>
  297.               <goal>generate</goal>
  298.             </goals>
  299.             <configuration>
  300.               <inputSpec>${project.build.directory}/generated/swagger/api.json</inputSpec>
  301.               <language>html2</language>
  302.               <output>${project.build.directory}/generated/swagger/html2</output>
  303.               <generateApis>true</generateApis>
  304.             </configuration>
  305.           </execution>
  306.         </executions>
  307.       </plugin>
  308.       <plugin>
  309.         <groupId>org.web3j</groupId>
  310.         <artifactId>web3j-maven-plugin</artifactId>
  311.         <version>${web3j-maven-plugin.version}</version>
  312.       </plugin>
  313.     </plugins>
  314.     <pluginManagement>
  315.       <plugins>
  316.         <!-- core -->
  317.         <plugin>
  318.           <groupId>org.apache.maven.plugins</groupId>
  319.           <artifactId>maven-compiler-plugin</artifactId>
  320.           <version>${maven-compiler-plugin.version}</version>
  321.           <inherited>true</inherited>
  322.           <configuration>
  323.             <source>${java.version}</source>
  324.             <target>${java.version}</target>
  325.           </configuration>
  326.         </plugin>
  327.         <plugin>
  328.           <groupId>org.apache.maven.plugins</groupId>
  329.           <artifactId>maven-site-plugin</artifactId>
  330.           <version>${maven-site-plugin.version}</version>
  331.           <dependencies>
  332.             <dependency>
  333.               <groupId>org.apache.maven.wagon</groupId>
  334.               <artifactId>wagon-ssh</artifactId>
  335.               <version>2.12</version>
  336.             </dependency>
  337.           </dependencies>
  338.         </plugin>
  339.         <!-- sources -->
  340.         <plugin>
  341.           <!-- For more, refer followings
  342.            https://github.com/swagger-api/swagger-codegen
  343.            https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen-maven-plugin
  344.          -->
  345.           <groupId>io.swagger</groupId>
  346.           <artifactId>swagger-codegen-maven-plugin</artifactId>
  347.           <version>${swagger-codegen-maven-plugin.version}</version>
  348.         </plugin>
  349.         <!-- packaging -->
  350.         <plugin>
  351.           <groupId>org.apache.maven.plugins</groupId>
  352.           <artifactId>maven-jar-plugin</artifactId>
  353.           <version>${maven-jar-plugin.version}</version>
  354.           <configuration>
  355.             <!-- For more on Maven archiver, refer http://maven.apache.org/shared/maven-archiver/index.html -->
  356.             <archive>
  357.               <addMavenDescriptor>false</addMavenDescriptor>
  358.               <forced>true</forced>
  359.               <index>true</index>
  360.               <manifest>
  361.                 <addClasspath>false</addClasspath>
  362.                 <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
  363.                 <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
  364.                 <addExtensions>false</addExtensions>
  365.                 <classpathLayoutType>simple</classpathLayoutType>
  366.               </manifest>
  367.               <manifestEntries>
  368.                 <Source-Revision>${project.svn.revision}</Source-Revision>
  369.               </manifestEntries>
  370.             </archive>
  371.           </configuration>
  372.         </plugin>
  373.         <!-- reporting -->
  374.         <plugin>
  375.           <groupId>org.apache.maven.plugins</groupId>
  376.           <artifactId>maven-javadoc-plugin</artifactId>
  377.           <version>${maven-javadoc-plugin.version}</version>
  378.           <configuration>
  379.             <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
  380.             <!--  <javadocVersion>${java.version}</javadocVersion> -->
  381.             <source>${java.version}</source>
  382.             <maxmemory>256m</maxmemory>
  383.             <!-- causes error with JDK 8 <additionalJOption>-Xms128m</additionalJOption> -->
  384.             <additionalJOptions>--frames</additionalJOptions>
  385.             <failOnError>false</failOnError>
  386.             <attach>true</attach> <!-- for `javadoc:jar`, refer https://maven.apache.org/plugins/maven-javadoc-plugin/jar-mojo.html#attach -->
  387.             <docencoding>${project.reporting.outputEncoding}</docencoding>
  388.             <encoding>${project.build.sourceEncoding}</encoding>
  389.             <doctitle>${project.name} ${project.version} API</doctitle>
  390.             <windowtitle>${project.name} ${project.version} API</windowtitle>
  391.             <links>
  392.               <link>https://docs.oracle.com/javase/8/docs/api/</link>
  393.               <link>https://docs.oracle.com/javaee/7/api/</link>
  394.               <link>https://docs.spring.io/spring/docs/5.1.x/javadoc-api/</link>
  395.               <link>https://docs.spring.io/spring-boot/docs/2.1.x/api/</link>
  396.               <link>http://www.javadoc.io/doc/com.google.code.findbugs/jsr305/${jsr305.version}</link>
  397.               <link>http://docs.jboss.org/hibernate/beanvalidation/spec/2.0/api/</link>
  398.               <link>http://docs.jboss.org/hibernate/validator/6.1/api/</link>
  399.               <link>http://www.javadoc.io/doc/org.slf4j/slf4j-api/${slf4j.version}/</link>
  400.               <link>https://junit.org/junit5/docs/${junit5.version}/api/</link>
  401.               <link>http://commons.apache.org/proper/commons-lang/javadocs/api-${commons-lang3.version}/</link>
  402.               <link>http://commons.apache.org/proper/commons-collections/javadocs/api-${commons-collections4.version}/</link>
  403.               <link>https://javadoc.io/doc/org.web3j/core/${web3j.version}</link>
  404.               <link>https://javadoc.io/doc/org.web3j/abi/${web3j.version}</link>
  405.               <link>https://javadoc.io/doc/org.web3j/crypto/${web3j.version}</link>
  406.               <link>https://javadoc.io/doc/org.web3j/utils/${web3j.version}</link>
  407.             </links>
  408.             <show>protected</show>
  409.             <splitindex>true</splitindex>
  410.             <stylesheet>java</stylesheet> <!-- 'java' (default) or 'maven' -->
  411.           </configuration>
  412.           <executions>
  413.             <execution>
  414.               <id>javadoc-jar</id>
  415.               <phase>prepare-package</phase> <!-- or 'package' -->
  416.               <goals>
  417.                 <goal>jar</goal>
  418.               </goals>
  419.             </execution>
  420.           </executions>
  421.         </plugin>
  422.         <plugin>
  423.           <!-- For more, refer http://gleclaire.github.io/findbugs-maven-plugin/ -->
  424.           <groupId>org.codehaus.mojo</groupId>
  425.           <artifactId>findbugs-maven-plugin</artifactId>
  426.           <version>${findbugs-maven-plugin.version}</version>
  427.           <configuration>
  428.             <effort>Max</effort>
  429.             <threshold>Low</threshold>
  430.             <!-- findbugs-maven-plugin doesn't provide aggregate goal or mode -->
  431.             <includeFilterFile>src/config/findbugs/findbugs-exclude.xml</includeFilterFile>
  432.             <plugins>
  433.               <plugin>
  434.                 <groupId>com.mebigfatguy.fb-contrib</groupId>
  435.                 <artifactId>fb-contrib</artifactId>
  436.                 <version>6.8.3</version>
  437.               </plugin>
  438.             </plugins>
  439.           </configuration>
  440.         </plugin>
  441.         <plugin>
  442.           <groupId>org.apache.maven.plugins</groupId>
  443.           <artifactId>maven-checkstyle-plugin</artifactId>
  444.           <version>${maven-checkstyle-plugin.version}</version>
  445.         </plugin>
  446.         <!-- tools supporting -->
  447.         <plugin>
  448.           <!-- http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html -->
  449.           <groupId>org.apache.maven.plugins</groupId>
  450.           <artifactId>maven-eclipse-plugin</artifactId>
  451.           <version>${maven-eclipse-plugin.version}</version>
  452.           <configuration>
  453.             <!-- the next two item doesn't work on m2e. m2e has its own confgiruation in Eclipse preferences -->
  454.             <downloadJavadocs>true</downloadJavadocs>
  455.             <downloadSources>true</downloadSources>
  456.             <forceRecheck>false</forceRecheck>
  457.           </configuration>
  458.         </plugin>
  459.         <plugin>
  460.           <groupId>org.eclipse.m2e</groupId>
  461.           <artifactId>lifecycle-mapping</artifactId>
  462.           <version>1.0.0</version>
  463.           <configuration>
  464.             <lifecycleMappingMetadata>
  465.               <pluginExecutions>
  466.                 <pluginExecution>
  467.                   <pluginExecutionFilter>
  468.                     <groupId>org.apache.maven.plugins</groupId>
  469.                     <artifactId>maven-dependency-plugin</artifactId>
  470.                     <versionRange>[1.0.0,)</versionRange>
  471.                     <goals>
  472.                       <goal>copy-dependencies</goal>
  473.                     </goals>
  474.                   </pluginExecutionFilter>
  475.                   <action>
  476.                     <ignore />
  477.                   </action>
  478.                 </pluginExecution>
  479.                 <pluginExecution>
  480.                   <pluginExecutionFilter>
  481.                     <groupId>org.apache.maven.plugins</groupId>
  482.                     <artifactId>maven-antrun-plugin</artifactId>
  483.                     <versionRange>[1.0.0,)</versionRange>
  484.                     <goals>
  485.                       <goal>run</goal>
  486.                     </goals>
  487.                   </pluginExecutionFilter>
  488.                   <action>
  489.                     <ignore />
  490.                   </action>
  491.                 </pluginExecution>
  492.                 <pluginExecution>
  493.                   <pluginExecutionFilter>
  494.                     <groupId>org.codehaus.mojo</groupId>
  495.                     <artifactId>aspectj-maven-plugin</artifactId>
  496.                     <versionRange>[1.0.0,)</versionRange>
  497.                     <goals>
  498.                       <goal>compile</goal>
  499.                       <goal>test-compile</goal>
  500.                     </goals>
  501.                   </pluginExecutionFilter>
  502.                   <action>
  503.                     <ignore />
  504.                   </action>
  505.                 </pluginExecution>
  506.                 <pluginExecution>
  507.                   <pluginExecutionFilter>
  508.                     <groupId>org.codehaus.mojo</groupId>
  509.                     <artifactId>build-helper-maven-plugin</artifactId>
  510.                     <versionRange>[1.0.0,)</versionRange>
  511.                     <goals>
  512.                       <goal>parse-version</goal>
  513.                     </goals>
  514.                   </pluginExecutionFilter>
  515.                   <action>
  516.                     <ignore />
  517.                   </action>
  518.                 </pluginExecution>
  519.                 <pluginExecution>
  520.                   <pluginExecutionFilter>
  521.                     <groupId>net.alchim31.maven</groupId>
  522.                     <artifactId>scala-maven-plugin</artifactId>
  523.                     <versionRange>[1.0.0,)</versionRange>
  524.                     <goals>
  525.                       <goal>add-source</goal>
  526.                       <goal>compile</goal>
  527.                       <goal>testCompile</goal>
  528.                     </goals>
  529.                   </pluginExecutionFilter>
  530.                   <action>
  531.                     <ignore />
  532.                   </action>
  533.                 </pluginExecution>
  534.                 <pluginExecution>
  535.                   <pluginExecutionFilter>
  536.                     <groupId>io.swagger.core.v3</groupId>
  537.                     <artifactId>swagger-maven-plugin</artifactId>
  538.                     <versionRange>[1.0.0,)</versionRange>
  539.                     <goals>
  540.                       <goal>resolve</goal>
  541.                     </goals>
  542.                   </pluginExecutionFilter>
  543.                   <action>
  544.                     <ignore>
  545.                       <message>swagger-maven-plugin (goal "resolve") is ignored by m2e.</message>
  546.                     </ignore>
  547.                   </action>
  548.                 </pluginExecution>
  549.                 <pluginExecution>
  550.                   <pluginExecutionFilter>
  551.                     <groupId>io.swagger.codegen.v3</groupId>
  552.                     <artifactId>swagger-codegen-maven-plugin</artifactId>
  553.                     <versionRange>[1.0.0,)</versionRange>
  554.                     <goals>
  555.                       <goal>generate</goal>
  556.                     </goals>
  557.                   </pluginExecutionFilter>
  558.                   <action>
  559.                     <ignore>
  560.                       <message>swagger-codegen-maven-plugin (goal "generate") is ignored by m2e.</message>
  561.                     </ignore>
  562.                   </action>
  563.                 </pluginExecution>
  564.                 <pluginExecution>
  565.                   <pluginExecutionFilter>
  566.                     <groupId>com.github.kongchen</groupId>
  567.                     <artifactId>swagger-maven-plugin</artifactId>
  568.                     <versionRange>[1.0.0,)</versionRange>
  569.                     <goals>
  570.                       <goal>generate</goal>
  571.                     </goals>
  572.                   </pluginExecutionFilter>
  573.                   <action>
  574.                     <ignore>
  575.                       <message>wagger-maven-plugin (goal "generate") is ignored by m2e.</message>
  576.                     </ignore>
  577.                   </action>
  578.                 </pluginExecution>
  579.               </pluginExecutions>
  580.             </lifecycleMappingMetadata>
  581.           </configuration>
  582.         </plugin>
  583.       </plugins>
  584.     </pluginManagement>
  585.   </build>
  586.  
  587.   <dependencies>
  588.     <dependency>
  589.       <!-- JSR 305: Annotations for Software Defect Detection (https://jcp.org/en/jsr/detail?id=305) -->
  590.       <groupId>com.google.code.findbugs</groupId>
  591.       <artifactId>jsr305</artifactId>
  592.       <version>${jsr305.version}</version>
  593.     </dependency>
  594.     <dependency>
  595.       <!-- JSR 330: Dependency Injection for Java -->
  596.       <groupId>javax.inject</groupId>
  597.       <artifactId>javax.inject</artifactId>
  598.       <version>1</version>
  599.     </dependency>
  600.     <dependency>
  601.       <!-- JSR 349: Bean Validation 1.1 (https://jcp.org/en/jsr/detail?id=349) -->
  602.       <groupId>javax.validation</groupId>
  603.       <artifactId>validation-api</artifactId>
  604.       <version>${validation-api.version}</version>
  605.     </dependency>
  606.     <dependency>
  607.       <!-- Hibernate Validator -->
  608.       <groupId>org.hibernate.validator</groupId>
  609.       <artifactId>hibernate-validator</artifactId>
  610.       <version>${hibernate-validator.version}</version>
  611.     </dependency>
  612.     <dependency>
  613.       <groupId>org.slf4j</groupId>
  614.       <artifactId>slf4j-api</artifactId>
  615.       <version>${slf4j.version}</version>
  616.     </dependency>
  617.     <dependency>
  618.       <groupId>org.slf4j</groupId>
  619.       <artifactId>jcl-over-slf4j</artifactId>
  620.       <version>${slf4j.version}</version>
  621.       <scope>runtime</scope>
  622.     </dependency>
  623.     <dependency>
  624.       <groupId>org.slf4j</groupId>
  625.       <artifactId>jul-to-slf4j</artifactId>
  626.       <version>${slf4j.version}</version>
  627.     </dependency>
  628.     <dependency>
  629.       <groupId>ch.qos.logback</groupId>
  630.       <artifactId>logback-classic</artifactId>
  631.       <version>${logback.version}</version>
  632.     </dependency>
  633.     <dependency>
  634.       <!-- to support conditional processing of Logback config. : https://logback.qos.ch/setup.html#janino -->
  635.       <groupId>org.codehaus.janino</groupId>
  636.       <artifactId>janino</artifactId>
  637.       <version>${janino.version}</version>
  638.     </dependency>
  639.     <dependency>
  640.       <!-- https://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven -->
  641.       <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine/5.5.1 -->
  642.       <!-- 'junit-jupiter-engine' depends on 'junit-jupiter-api' -->
  643.       <groupId>org.junit.jupiter</groupId>
  644.       <artifactId>junit-jupiter-engine</artifactId>
  645.       <version>${junit5.version}</version>
  646.       <scope>test</scope>
  647.     </dependency>
  648.     <dependency>
  649.       <groupId>org.testng</groupId>
  650.       <artifactId>testng</artifactId>
  651.       <version>${testng.version}</version>
  652.       <scope>test</scope>
  653.     </dependency>
  654.     <dependency>
  655.       <groupId>org.mockito</groupId>
  656.       <artifactId>mockito-core</artifactId>
  657.       <version>${mockito.version}</version>
  658.       <scope>test</scope>
  659.     </dependency>
  660.     <dependency>
  661.       <groupId>org.apache.commons</groupId>
  662.       <artifactId>commons-lang3</artifactId>
  663.       <version>${commons-lang3.version}</version>
  664.     </dependency>
  665.     <dependency>
  666.       <groupId>org.apache.commons</groupId>
  667.       <artifactId>commons-collections4</artifactId>
  668.       <version>${commons-collections4.version}</version>
  669.     </dependency>
  670.     <dependency>
  671.       <!-- For more typesafe config, refer https://github.com/typesafehub/config -->
  672.       <groupId>com.typesafe</groupId>
  673.       <artifactId>config</artifactId>
  674.       <version>${typesafe-config.version}</version>
  675.     </dependency>
  676.     <!-- Either web or webflux -->
  677.     <dependency>
  678.       <groupId>org.springframework.boot</groupId>
  679.       <artifactId>spring-boot-starter-web</artifactId>
  680.     </dependency>
  681. <!--     <dependency> -->
  682. <!--       <groupId>org.springframework.boot</groupId> -->
  683. <!--       <artifactId>spring-boot-starter-webflux</artifactId> -->
  684. <!--     </dependency> -->
  685.     <dependency>
  686.       <groupId>org.springframework.boot</groupId>
  687.       <artifactId>spring-boot-starter-actuator</artifactId>
  688.     </dependency>
  689.     <dependency>
  690.       <groupId>org.springframework.boot</groupId>
  691.       <artifactId>spring-boot-starter-security</artifactId>
  692.     </dependency>
  693.     <dependency>
  694.       <groupId>org.springframework.boot</groupId>
  695.       <artifactId>spring-boot-devtools</artifactId>
  696.       <scope>runtime</scope>
  697.     </dependency>
  698.     <dependency>
  699.       <!-- https://docs.spring.io/spring-boot/docs/2.1.x/reference/htmlsingle/#boot-features-testing -->
  700.       <groupId>org.springframework.boot</groupId>
  701.       <artifactId>spring-boot-starter-test</artifactId>
  702.       <scope>test</scope>
  703.       <exclusions>
  704.         <exclusion>
  705.           <groupId>junit</groupId>
  706.           <artifactId>junit</artifactId>
  707.         </exclusion>
  708.       </exclusions>
  709.     </dependency>
  710.     <dependency>
  711.       <groupId>io.swagger.core.v3</groupId>
  712.       <artifactId>swagger-core</artifactId>
  713.       <version>${swagger.version}</version>
  714.     </dependency>
  715.     <dependency>
  716.       <groupId>javax.ws.rs</groupId>
  717.       <artifactId>javax.ws.rs-api</artifactId>
  718.       <version>2.1</version>
  719.     </dependency>
  720.     <dependency>
  721.       <groupId>io.swagger</groupId>
  722.       <artifactId>swagger-hibernate-validations</artifactId>
  723.       <version>1.5.22</version>
  724.     </dependency>
  725.     <dependency>
  726.       <groupId>io.springfox</groupId>
  727.       <artifactId>springfox-swagger2</artifactId>
  728.       <version>${springfox-swagger2.version}</version>
  729.     </dependency>
  730.     <dependency>
  731.       <groupId>io.springfox</groupId>
  732.       <artifactId>springfox-swagger-ui</artifactId>
  733.       <version>${springfox-swagger2.version}</version>
  734.     </dependency>
  735.     <dependency>
  736.       <!-- Springfox Support for JSR-303 : https://springfox.github.io/springfox/docs/2.9.2/#springfox-support-for-jsr-303 -->
  737.       <groupId>io.springfox</groupId>
  738.       <artifactId>springfox-bean-validators</artifactId>
  739.       <version>${springfox-swagger2.version}</version>
  740.     </dependency>
  741.     <dependency>
  742.       <groupId>org.web3j</groupId>
  743.       <artifactId>core</artifactId>
  744.       <version>${web3j.version}</version>
  745.     </dependency>
  746.     <dependency>
  747.       <groupId>org.web3j</groupId>
  748.       <artifactId>codegen</artifactId>
  749.       <version>${web3j.version}</version>
  750.     </dependency>
  751.     <dependency>
  752.       <groupId>org.web3j</groupId>
  753.       <artifactId>pantheon</artifactId>
  754.       <version>4.5.1</version>
  755.     </dependency>
  756.   </dependencies>
  757. </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

Deploying Javadoc JAR file along with

Add configuration for Maven deploy plugin including target repository and path to JAR file.

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>${maven-deploy-plugin.version}</version>
        <configuration>
          <file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
          <!-- specify credentials to access the following repoisoty into settings file ('~/.m2/settings.xml') -->
          <repositoryId>skcc-bc-release</repositoryId>
          <url>https://bcrepo.skcc.com/repository/sk-maven-releases</url>
          <pomFile>${project.basedir}/pom.xml</pomFile>
          <javadoc>${project.build.directory}/${project.artifactId}-${project.version}-javadoc.jar</javadoc>
        </configuration>
      </plugin>


Execute 'javadoc:jar' goal first and execute 'deploy:deploy-file' goal instead of 'deploy'.

$ mvn javadoc:jar

...

$ mvn deploy:deploy-file

...

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)
Community content is available under CC-BY-SA unless otherwise noted.