This guide will walk you through
- downloading the latest source code from the trunk of a plugin
- building the plugin
- creating JIRA issues
- modifying the plugin source code
- deploying the plugin to an internal repository for use within your company
- creating patches and attaching to JIRA
- applying patches retrieved from JIRA
See http://www.nabble.com/forum/ViewPost.jtp?post=7884079&framed=y&skin=177, a single artifact can not be available on multiple repositories.
The workaround is to install mvnproxy and include in the configuration all internal repositories.
This way mvnproxy will aggregate all the configured repositories regardless of what actual repository was requested. That is, even though an artifact from central was requested, mvnproxy will return any matching files found for all the repositories that are configured within mvnproxy.
The previous workaround was to suffix "-i" to the artifactId, which is a broken workaround as this makes a duplicate copy of the artifact with a different name and will cause two potentially incompatible libraries to be on the classpath. If you see any references to this workaround in this document please make corrections.
Downloading the latest source code from the trunk of a plugin
Maven uses Subversion as it's source control repository. The base subversion repository is located at http://svn.apache.org/repos/asf/maven. Within this structure there are a number of different directories of useful files:
- http://svn.apache.org/repos/asf/maven/plugins/trunk - all maven plugins
- http://svn.apache.org/repos/asf/maven/sandbox/plugins - sandboxed maven plugins (ones that have not been promoted into common use)
- http://svn.apache.org/repos/asf/maven/components/trunk - the maven core itself
- http://svn.apache.org/repos/asf/maven/shared/trunk - shared components (e.g. maven-archiver)
- codehaus plugins - see their respective web pages for their location, the general format is svn.codehaus.org/project/trunk
Using your favourite subversion tool, check out the plugin you want (e.g. http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-assembly-plugin)
Building the plugin
Maven developers try to ensure that the trunk always builds and to build your own copy use
However because the plugin may be using snapshot versions of other plugins, you will need to ensure you have setup your environment correctly to obtain any dependencies from the snapshot repositories. See the Maven Development Procedures for more details on how to configure your environment. You may also want to read Guide to Testing Development Versions of Plugin and
Guide to Plugin Snapshot Repositories (this guide contains the codehaus snapshot repository setup)
Here are the profiles in use from following the advice above:
Creating JIRA issues
Find the project for the maven plugin at http://jira.codehaus.org/secure/BrowseProjects.jspa.
Before you create a new JIRA issue you should confirm that there is no existing issue already available.
If one already exists, check what other people have suggested for a suitable solution. If there is a patch already, try using that before making your own modifications.
Modifying the plugin source code
The first step should be to create a unit test.
After the unit test has been created modify the code to pass the unit test.
Once the unit test is passing you can then build the plugin and attempt to use it locally via
mvn install. You should check that the plugin works as expected in your project.
Creating patches and attaching to JIRA
In the root directory of the plugin you have been modifying use
svn diff > ../JIRA COMPONENT-JIRA ID-patch.txt e.g.
svn diff > ../MASSEMBLY-118-patch.txt.
Find the JIRA issue you previously created and click the
Attach file link on the left side under the
Operations links. In the comment text area provide a brief description of the patch contents and anything of interest that should be pointed out.
Applying patches retrieved from JIRA
In the root directoy of the plugin run
patch -p0 < PATCH FILE e.g.
patch -p0 < ../MASSEMBLY-118-patch.txt. The
-p0 says to patch that there are no leading paths that need to be stripped from the patch file. In general you won't need to modify this, but if you do look at the
patch file for lines like
Index: FILE and work out how many path elements should be stripped and use that number as the option to
Deploying the plugin to an internal repository for use within your company
If you have an internal repository that is used by your company then you will want to deploy your patched versions to this repository until your patches have been applied to the plugin. If you don't have an internal repository you should consider setting one up, see Using Maven in a corporate environment for more details.
Before you start, ensure that your pom file does not depend upon any
SNAPSHOT versions, if it does then for each
SNAPSHOT version you will need to checkout the trunk for that artifact, build it and then follow the steps below to promote it to an internal release, otherwise you won't have any control over the build process.
Make the following changes to the
pom.xml file after making a backup copy.
- Set the version to be
-INTERNAL-r<svn version>-p<num>-p<num>instead of
-SNAPSHOT. See Better Builds with Maven (June 2006) page 61 for an explanation of how version numbers are compared. e.g. if the version is
2.2-SNAPSHOTand the subversion repository when you checked out the plugin was at r485327 then set it to
2.2-INTERNAL-r485327. If you are have applied any patches then also include the patch numbers in the version id, e.g. the patches for bugs MECLIPSE-206 and MECLIPSE-31 have been applied then use -INTERNAL-r485327-pMECLIPSE-206-pMECLIPSE-31. Note: When the plugin is officially released as
2.2the released version will be considered newer than your patched version and supersede it. You will need to check if your patches have been applied in the release and if not then follow these instructions again. By including the patch numbers in the version id it will help you identify immediately what needs to get checked.
- Modify the description to include exactly what revision of the version repository the build is from and also if any patches (include links) that have been applied. You will need this information later when you try to work out what was in your internal release and when new releases occur what you need to do to back port and get a working internal release again. e.g:
- Add a distributionManagement section (or overwrite the existing section). As this is an internal release it will go to your internal_plugins repository, if you forget to do this you will be attempting to release into the maven repositories which you don't have access to.
- Include the maven-source-plugin so that the source jars get created as part of deployment, there appears to be no profile available in the parent hierarchy to enable this.
- Remove any snapshot repository definitions. These are in the
repositoriessection and contain an enabled
SNAPSHOT dependencies need to be internally released by following the above instructions. The dependency version is then changed from
-INTERNAL. This can be quite a long process of chasing the dragon's tail.
You will need to also chase parent definitions that are a
SNAPSHOT version. Since you only need the pom definition use
mvn -N to avoid recursing into the module directories (which you don't care about and don't need to checkout). Parent poms are located one directory above the current pom, unless there is a
Each dependency and parent pom that is promoted to
INTERNAL needs to be deployed to your internal repository via
mvn deploy, you must do this depth first so that the pom you are deploying has no
Once all dependencies and parents have been deployed you can now deploy your changes to the plugin to your internal repository via