Tag: sourceedit |
(→misc) Tag: sourceedit |
||
Line 297: | Line 297: | ||
* [http://stackoverflow.com/questions/9115171/why-must-i-always-add-spring-project-nature-after-maven-update-project-config Why must I always “Add Spring project Nature” after Maven “Update Project Configuration” in Eclipse?] (Feb 2 '12) |
* [http://stackoverflow.com/questions/9115171/why-must-i-always-add-spring-project-nature-after-maven-update-project-config Why must I always “Add Spring project Nature” after Maven “Update Project Configuration” in Eclipse?] (Feb 2 '12) |
||
* [http://maven.apache.org/plugins/maven-eclipse-plugin/examples/ajdt-projects.html Including AJDT Projects into Workspace] |
* [http://maven.apache.org/plugins/maven-eclipse-plugin/examples/ajdt-projects.html Including AJDT Projects into Workspace] |
||
+ | * [http://stackoverflow.com/questions/9932923/why-cant-maven-find-an-osgi-bundle-dependency Why can't maven find an osgi bundle dependency?](Mar 29 '12) |
||
==HOWTOs== |
==HOWTOs== |
Revision as of 06:53, 6 March 2015
Overview
- Maven Getting Started Guide
- POM Reference
- Maven Build Lifecycle
- Maven Plugin List
- Maven Shared Components
- mvn Command Line Options
- Maven Properties Guide
- Maven Project Properties
- XML Schema and description for Maven POM file(maven-4.0.0.xsd).
- Maven Model 3.0 API
- Maven Core 3.0 API
- API of MavenProject class
- The mvn Command
- Version Range Specification
- Depedencies
- Dependency Mediation and Conflict Resolution
- How Scope Affects Transitive Dependencies
- Maven for C/C++
- Maven for JavaScript
- Maven for Python
- Maven for Scala
Maven Repositories
- Central Repository : http://search.maven.org/#browse
- Main Repositories : http://mvnrepository.com/
- Apache Maven Repository :
- JBoss Maven Repository
- Maven Repository
- JBoss Maven Snapshot Repositories
- JBoss Maven repsoitories include hibernate releases and snapshots.
- SUN Jars Repository
- Maven Repository of eclipse.org
- DocBook Repository
- http://docbook.sourceforge.net/maven/repository/
- About configuring pom.xml, refer http://wiki.docbook.org/topic/Maven.
Maven Plug-ins
Utilities
- Resource Plugin
- Build Helper Plugin
- Build Number Plugin
- http://mojo.codehaus.org/buildnumber-maven-plugin/
- Designed to get a unique build number for each time you build your project.
- Versions Plugin
- http://mojo.codehaus.org/versions-maven-plugin/
- Manages the versions of artifacts in a project's POM.
- Timestamp Plugin
- http://code.google.com/p/maven-timestamp-plugin/
- Provides formatted timestamps for maven builds.
- Properties Plugin
- http://mojo.codehaus.org/properties-maven-plugin/
- Provides goals to read and write properties from and to files.
- Properties Plugin
- http://site.kuali.org/maven/plugins/properties-maven-plugin/1.3.2/plugin-info.html
- Provides goals to read and write properties from files.
- Replacer Plugin
- http://code.google.com/p/maven-replacer-plugin/
- Replace tokens within a file with a given value and fully supports regular expressions.
- Expression Plugin
- https://github.com/jdcasey/expression-maven-plugin
- Allow users to resolve expressions interactively.
Code analysis tools plug-in
- FindBugs Plugin
- 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.
- Checkstyle Plugin
- http://maven.apache.org/plugins/maven-checkstyle-plugin/
- Generates a report regarding the code style used by the developers.
- JavaNCSS Plugin
- http://mojo.codehaus.org/javancss-maven-plugin/
- provides the capability to run the JavaNCSS tool on your Maven 2 project sources and produce an html report.
- JDepend Plugin
- http://mojo.codehaus.org/jdepend-maven-plugin/
- produces a nicely formatted metrics report based on your project.
- Dependency Graph Plugin
- http://el4j.sourceforge.net/plugins/maven-depgraph-plugin/
- Draws a dependency graph of the project the mojo is executed in.
- Sonar Plugin
- http://mojo.codehaus.org/sonar-maven-plugin/
- Enables to analyze and report metrics on source code.
- Rat Plugin
- http://creadur.apache.org/rat/apache-rat-plugin/
- verifies, whether your source code matches standards like the ASF Source Header and Copyright Notice Policy
Collaboration tools plug-in
- Confluence Plugin
- http://code.google.com/p/maven-confluence-plugin/
- Documents a project (using maven site style) and send result to a live confluence site.
Source configuration management tools plug-in
- SVN Revision Number Plugin
- http://code.google.com/p/maven-svn-revision-number-plugin/
- Retrieves the revision number and the status of the Subversion working copy directory and sets project properties that can be used later in the build process.
- To work with working copy of SVN 1.7 or higher, you should setup dependencies for this plugin to use svnkit 1.7.0-SNAPSHOT.
Continuous integration tools plug-in
- Jenkins-maven-plugin
- http://evgeny-goldin.com/wiki/Jenkins-maven-plugin
- allows to generate Jenkins jobs, one "config.xml" per job, from a simple Maven POM.
Packaging tools support
- IzPack Plugin
- RPM Maven Plugin
- http://mojo.codehaus.org/rpm-maven-plugin/
- allows artifacts from one or more projects to be packaged in an RPM for distribution.
Programming languages support
- Native Maven Plugin
- http://mojo.codehaus.org/maven-native/native-maven-plugin/index.html
- Use this plugin to compile c and c++ source under Maven 2 with compilers such as gcc, msvc, gcj etc ...
- Maven NAR Plugin
- http://duns.github.com/maven-nar-plugin/
- allows you to compile native code (c++, c and fortran) on a number of different architectures (Linux, Windows, MacOSX, Solaris, ...) and with a number of different compilers/linkers (g++, Microsoft Visual C++, CC, ...).
- Scala Maven Plugin
- http://davidb.github.io/scala-maven-plugin/
- used for compiling/testing/running/documenting scala code in maven
- Maven Scala Plugin
- http://scala-tools.org/mvnsites/maven-scala-plugin/
- used for compiling/testing/running/documenting scala code in maven.
Application frameworks support
- AspectJ Plugin
- Spring BeanDoc Plugin
- http://mojo.codehaus.org/maven-springbeandoc-plugin/
- Generates pretty reports for Spring configuration files.
- FreeMarker Pre Processor(FMPP) Plugin
- http://code.google.com/p/freemarkerpp-maven-plugin/
- Allows to process FreeMarker templates, inject data into those templates in order to produce code, artifacts, reports or anything desired.
Application servers support
- JBoss Plugin
- Jetty Plugin
- http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin
- Configuring the Jetty Maven Plugin (for Jetty 9 or higher)
Eclipse support
- Eclipse Plugin
- Tycho
- a set of Maven plugins and extensions for building Eclipse plugins and OSGi bundles with Maven.
- http://www.eclipse.org/tycho/
- http://www.eclipse.org/tycho/sitedocs/
- Tycho/Reference Card
- Tycho/Packaging Types
- Tycho/FAQ
- P2 Plugin
- https://github.com/reficio/p2-maven-plugin
- responsible for the automation of dependency management in the Eclipse RCP environment.
misc
- Graphviz Plugin
- http://graphviz-maven-plugin.bryon.us/
- Uses the Graphviz library to render .dot files into images.
Maven Skins
- Fluido skin
- http://code.google.com/p/fluido-skin/
- rounded corners and code syntax highlight
Readings
Sonatype books
- Maven the Complete Reference
- Developing with Eclipse and Maven
- Maven by Example
- Maven Cookbook
- Repository Management with Nexus
Multi module project
- Guide to Working with Multiple Modules
- Multiple Module Projects with Eclipse
- Running Maven Checkstyle plugin safely with multi module project.
- Using just propertyExpansion much simpler than http://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html
- Maven Modules + Building a Single Specific Module (Jul 11 '09)
- Maven Tips and Tricks: Advanced Reactor Options (October 6, 2009)
Reporting
- Aggregate Reports
- Aggregating Javadocs For Multi-Projects
- Maven FindBugs Plugin/Multimodule Configuration
Maven assemblies
- Guide to creating assemblies
- Maven Assembly Descriptor Reference
- Maven the Complete Reference/Maven Assemblies
Maven snapshot repositories
- Repository - SNAPSHOT Handling
- Maven Concepts Repositories
- Guide to deploying 3rd party JARs to remote repository
- Setting Up a Maven Repository
Deployment process and security
- <servers> element in settings.xml
- Password encryption
- Maven Wagon
- Uploading a directory using sftp with Maven
Site process
- Creating a site
- XML Schema Reference for the site descriptor
- Configuring the site descriptor
- Maven Project Info Reports Plugin
- Customizing Site Appearance
- Doxia Modules Guide
- doxia-module-markdown
- How to use confluence format? (in Maven site generation)
Release process
- Using the Maven Release plugin: Things to know
- Archiva Release Process (Real-world sample of Maven release plugin)
- Deploying same version overwrites existing release
Property and Interpolation
misc
- Set plugin’s version on the command line in maven 2
- Attach Library Sources and Javadocs
- Guides to download sources and javadocs of artifacts
- Defining custom Maven build command for any project.
- Specify ${project_loc} at 'Base directory' field and select 'Run' item at 'Display in favorites menu' field in 'Common' tab.
- reportPlugins doesn't inherit more information from pluginManagement.
- Naked Objects' Sister Projects 1.0: Developers Guide
- How do I get m2eclipse to recognize $M2_OPTS?
- Maven project versions
- How to deploy SNAPSHOT with sources and JavaDoc?
- A little bit strange but it really works. But how about the release ?
- ANTLR3 Maven Plugin - Eclipse Setup
- Why must I always “Add Spring project Nature” after Maven “Update Project Configuration” in Eclipse? (Feb 2 '12)
- Including AJDT Projects into Workspace
- Why can't maven find an osgi bundle dependency?(Mar 29 '12)
HOWTOs
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?
...
<artifact:pom id="this-pom" file="${basedir}/pom.xml"/>
<xsddoc out="${this-pom.reporting.outputDirectory}/xsddocs"
verbose="true">
<fileset dir="${this-pom.build.resources[0].directory}"
includes="**/*.xsd"/>
</xsddoc>
...
Build Lifecycle, Build Phase, Plugin and Goal
Guidelines for multi-moduled Maven project
- Separate parent project from container project.
- Define properties in the parent POM file as possible.
- 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.
dependency.locations.enabled
: refer If your maven site build is too slow
- Paths for executable programs external to Maven
graphviz.home
- Encoding related properties whose default value are dependent on platform.
- Define all plugins in the <pluginManagement> element of parent POM file.
- Don't specify version to plugin definitions in child POM files.
- Define repositories in the parent POM file as possible.
- Define plugins to analyze or diagnose the sources or resources of the project as a reporting plugin as possible.
- 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.
- Use resources in target/classes not in src/main/resources, considering resource filtering.
Sample of parent POM in action
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>thridstage</groupId>
<artifactId>thridstage-framework-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Thirdstage Framework</name>
<url>...</url>
<inceptionYear>2012</inceptionYear>
<organization>
<name>...</name>
<url>...</url>
</organization>
<prerequisites>
<maven>3.0</maven>
</prerequisites>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<graphviz.home>${env.GRAPHVIZ_HOME}</graphviz.home>
<skipTests>false</skipTests>
<maven.deploy.skip>true</maven.deploy.skip>
<maven.javadoc.skip>false</maven.javadoc.skip>
<maven.site.deploy.skip>true</maven.site.deploy.skip>
<findbugs.skip>true</findbugs.skip>
<checkstyle.skip>true</checkstyle.skip>
<dependency.locations.enabled>false</dependency.locations.enabled>
<antrun.echos.properties>true</antrun.echos.properties>
<scm.url.base>...</scm.url.base>
</properties>
<issueManagement>
<system>Redmine</system>
<url>.../issues</url>
</issueManagement>
<scm>
<connection>scm:svn:http:...</connection>
<url>http:...</url>
</scm>
<distributionManagement>
<repository>
<id>...</id>
<name>...</name>
<url>...</url>
</repository>
<snapshotRepository>
<id>...</id>
<name>...</name>
<url>...</url>
</snapshotRepository>
<site>
<id>...</id>
<url>sftp://.../${project.version}</url>
</site>
</distributionManagement>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>thirdstag-releases</id>
<url>...</url>
</repository>
<repository>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>thirdstage-snapshots</id>
<url>...</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central2</id>
<url>http://repo2.maven.org/maven2/</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>thirdparty</id>
<name>3rd-party Repository</name>
<url>http://repo.expertvill.net/nexus/content/repositories/thirdparty</url>
</repository>
<repository>
<id>evolvis-3rdparty</id>
<url>http://maven-repo.evolvis.org/3rdparty</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central2</id>
<url>http://repo2.maven.org/maven2/</url>
</pluginRepository>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>mojo-release</id>
<url>http://repository.codehaus.org/</url>
</pluginRepository>
<pluginRepository>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>mojo-snapshot</id>
<url>http://snapshots.repository.codehaus.org/</url>
</pluginRepository>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>spring-beandoc</id>
<url>http://spring-beandoc.sourceforge.net/repo</url>
</pluginRepository>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>tmatesoft-releases</id>
<url>http://maven.tmatesoft.com/content/repositories/releases/</url>
</pluginRepository>
<pluginRepository>
<releases>
<enabled>false</enabled>
</releases>
<id>tmatesoft-snapshots</id>
<url>http://maven.tmatesoft.com/content/repositories/snapshots/</url>
</pluginRepository>
<pluginRepository>
<id>evolvis-3rdparty</id>
<url>http://maven-repo.evolvis.org/3rdparty</url>
</pluginRepository>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>elca-services</id>
<url>http://el4.elca-services.ch/el4j/maven2repository</url>
</pluginRepository>
</pluginRepositories>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>../thirdstage.framework.parent/src/main/config/checkstyle/checkstyle.xml</configLocation>
<propertyExpansion>parent.basedir=../thirdstage.framework.parent</propertyExpansion>
<failsOnError>false</failsOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<onlyAnalyze>thirdstage.framework.*</onlyAnalyze>
<excludeFilterFile>../thirdstage.framework.parent/src/main/config/findbugs/findbugs-exclude.xml</excludeFilterFile>
<fork>true</fork>
<timeout>600000</timeout>
<maxHeap>512</maxHeap>
</configuration>
</plugin>
</plugins>
</reporting>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>validate-properties</id>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<failOnError>true</failOnError>
<target name="validate-properties">
<taskdef name="if" classname="ise.antelope.tasks.IfTask" classpathref="maven.plugin.classpath" />
<if name="antrun.echos.properties" value="true">
<echo>Head revision of the project "${project.artifactId}" is
${project.svn.revision}.</echo>
<echo>project.artifactId : ${project.artifactId}</echo>
<echo>project.basedir : ${project.basedir}</echo>
<echo>project.resources.0.directory : ${project.resources.0.directory}</echo>
<echo>project.resources[0].directory : ${project.resources[0].directory}</echo>
<echo>project.parent : ${project.parent}</echo>
<echo>project.parent.groupId : ${project.parent.groupId}</echo>
<echo>project.parent.artifactId : ${project.parent.artifactId}</echo>
<echo>project.parent.relativePath :
${project.parent.relativePath}</echo>
<pathconvert pathsep="${line.separator}" property="classpath.maven.plugin" refid="maven.plugin.classpath" />
<pathconvert pathsep="${line.separator}" property="classpath.maven.compile" refid="maven.compile.classpath" />
<echo />
<echo>Compile-time classpath for Maven :</echo>
<echo>${classpath.maven.compile}</echo>
<pathconvert pathsep="${line.separator}" property="classpath.maven.runtime" refid="maven.runtime.classpath" />
<echo />
<echo>Run-time classpath for Maven :</echo>
<echo>${classpath.maven.runtime}</echo>
<echo>Check Korean output : 한글이 정상적으로 보이나요?</echo>
<!-- echo all properties passed to Ant and environment variables prefixed with 'env' -->
<echo>All properties given to Ant are : </echo>
<property environment="env" />
<echoproperties />
</if>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ise.antelope</groupId>
<artifactId>ant-antelope-tasks</artifactId>
<version>3.5.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<!--
@fixme javaHome doesn't seem to work as is explained.
You should specify JAVA_HOME env. variable explicitly in your run configuration when running from
Eclipse.
-->
<!-- <javaHome>c:\lang\jdk1.5</javaHome> -->
<!-- <mavenHome>C:\tools\maven-3.0.3</mavenHome> -->
<tagBase>${scm.url.base}/main/tags</tagBase>
<tagNameFormat>@{project.version}</tagNameFormat>
<username>OhSangMoon</username>
<autoVersionSubmodules>true</autoVersionSubmodules>
<pomFileName>pom.xml</pomFileName>
<arguments>-f pom.xml</arguments>
<!-- not supported by release plugin oer 2.2.2
<generateReleasePoms>true</generateReleasePoms>
-->
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<inherited>true</inherited>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
<forced>true</forced>
<index>true</index>
<manifest>
<addClasspath>false</addClasspath>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<addExtensions>false</addExtensions>
<classpathLayoutType>simple</classpathLayoutType>
</manifest>
<manifestEntries>
<Source-Revision>${project.svn.revision}</Source-Revision>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<configuration>
<docencoding>${project.reporting.outputEncoding}</docencoding>
<encoding>${project.build.sourceEncoding}</encoding>
<links>
<link>http://download.oracle.com/javase/1.5.0/docs/api/</link>
<link>http://download.oracle.com/javaee/5/api/</link>
</links>
<show>projected</show>
<splitindex>true</splitindex>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.8.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<providerImplementations>
<svn>javasvn</svn>
</providerImplementations>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.code.maven-scm-provider-svnjava</groupId>
<artifactId>maven-scm-provider-svnjava</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.7.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.6</version>
<configuration>
<providerImplementations>
<svn>javasvn</svn>
</providerImplementations>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.code.maven-scm-provider-svnjava</groupId>
<artifactId>maven-scm-provider-svnjava</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.7.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<!-- the next two item doesn't work on m2e. m2e has its own confgiruation in Eclipse preferences -->
<downloadSources>true</downloadSources>
<downloadJavaDocs>true</downloadJavaDocs>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>maven-springbeandoc-plugin</artifactId>
<version>1.0.8-SNAPSHOT</version>
</plugin>
<plugin>
<groupId>com.google.code.maven-svn-revision-number-plugin</groupId>
<artifactId>maven-svn-revision-number-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>revision</goal>
</goals>
<configuration>
<entries>
<entry>
<path>${project.basedir}</path>
<prefix>project.svn</prefix>
<depth>infinity</depth>
<reportUnversioned>true</reportUnversioned>
<reportIgnored>false</reportIgnored>
<reportOutOfDate>false</reportOutOfDate>
</entry>
</entries>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.7.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</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.
<dependencies>
...
<dependency>
<groupId>unknown</groupId>
<artifactId>abcd</artifactId>
<version>1.0</version>
<type>jar</type>
<scope>system</scope>
<systemPath>${project.basedir}/lib/abcd.jar</systemPath>
</dependency>
...
</dependencies>
Note that systemPath could be specified only with system scope. You should specify groupId, artifactId, and version 'cause they are mandatory but you can specify any value and don't need pom file.
Escaping expression interpolation
It may necessary not to interpolate Maven expression in resources. In other words, you just want to leave ${some-property} as it is. For this, you can specify the escape string with escapeString parameter of maven-resource-plugin. You can also define maven.resources.escapeString property in your POM file.
For more refer this page : http://maven.apache.org/plugins/maven-resources-plugin/resources-mojo.html#escapeString
Working with Subversion working copy in format of ver. 1.7
The default configuration of Maven release plugin(maven-release-plugin) up to ver. 2.2.2 or Maven scm plugin(maven-scm-plugin) up to ver. 1.6 can't work correctly with Subversion working copy in format of ver. 1.7.
To solve this problem, you should override the configuration of release plugin or scm plugin to use maven-scm-provider-svnjava and svnkit 1.7.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<providerImplementations>
<svn>javasvn</svn>
</providerImplementations>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.code.maven-scm-provider-svnjava</groupId>
<artifactId>maven-scm-provider-svnjava</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.7.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.6</version>
<configuration>
<providerImplementations>
<svn>javasvn</svn>
</providerImplementations>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.code.maven-scm-provider-svnjava</groupId>
<artifactId>maven-scm-provider-svnjava</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.7.0-SNAPSHOT</version>
</dependency>
</dependencies>
</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
- 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
- Synchronize all project in trunk.
- 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}
- Review
pom.xml.tag, pom.xml.next, release-pom.xml
in each projectpom.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.
- Run release:rollback goal with following options.
maven.deploy.skip = false
resume = false
maven.home = ${env_var:MAVEN_HOME}
- Check that all pom.xml.tag, pom.xml.next, pom.xml.backup files are deleted.
- Run
release:prepare
goal with following optionsmaven.deploy.skip = false
resume = false
maven.home = ${env_var:MAVEN_HOME}
- Check the new directory for the version and directories for projects under tag directory in source repository.
- Run
release:perform
goal with following options.maven.deploy.skip = false
resume = false
maven.home = ${env_var:MAVEN_HOME}
- Refresh(F5) all projects in Eclipse.
- Login on binary repository and check the binaries for projects are uploaded.
- 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
references
- How can I download a specific Maven artifact in one command line? (Dec 13 '09)
- Maven Dependency plugin >
dependency:get
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 "org.apache.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 60" exception when running site:site goal
Simply add a dependency on a newer version(eg. 3.8) of icu4j
- 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.
- Using <addClasspath> when you have no dependencies fails with FileNotFoundException
Configuring to add classpath to MANIFEST file can cause unreasonable exception when running maven-jar-plugin without compile or run-time scope dependency. If you run package with -X option, you can identify exception whose stack goes like this.
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)