This post describes how to make a maven repo for your google code project. I’m a big fan of google code. It’s a tremendous service for those looking for a place to host their open source code. The only thing I lacked was a maven repo. I have to be honest here, while I use maven, it’s still a big mystery to me how things end up in the main maven repo. If Google were to add one new feature, I’d prefer it be a maven repo and hudson build that autodiscovers maven projects and builds them…but we’re not there yet, so the question I’m going to answer is how you can provide a maven repo for your open source customers hosted on google code. The secret is SVN and it’s HTTP support. If you can duplicate the directory stucture of a maven repositoty in your SVN, maven will be perfectly happy to seek dependencies from your project trunk.
Step 1: Install in your local repo
You’ve run mvn install on your project and have a jar file under the target folder. The first step is to install that file locally using the mvn install:install-file command.
mvn install:install-file -Dfile=path-to-your-artifact-jar \
-DgroupId=your.groupId \
-DartifactId=your-artifactId \
-Dversion=version \
-Dpackaging=jar \
-DcreateChecksum=true
Note: the checksum part is important, maven will need that. “your.groupId” is typically a reverse domain, like we use in java package names.
Step 2:
Copy the results to a folder in your SVN tree and commit. Typically, the local repo will be in C:/Documets and Settings/yourid/.m2/repository. On unix it’s most likely under .m2 in your home. From there cd into the directory tree that matches the groupid you provided in step one, following it all the way down you’ll find a directory named after your artifactId containing all the necessary files for maven, including the jar. All you need to do is copy this tree into SVN and commit it back to your google code project.
Step 3
We’ve created a non-standard repo which maven won’t know about. Therefore, it’s necessary to make your build aware of it by including a reference to the repo (actually this can be done in your maven settings too). Here’s an example:
<repositories>
<repository>
<id>Jenabean</id>
<url>http://jenabean.googlecode.com/svn/trunk/repo</url>
</repository>
</repositories>
To summarize, you basically run mvn install locally, and copy the results to a place in your SVN project, and make maven aware of the base http svn path as a new repo. For further reading, Ian Dickenson has also provided a detailed look at using eclipse with Jena.
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=223aa043-7ae3-4857-b675-69cfc2655592)
Have you looked into using wagon-svn [1] for SVN deployment?
If you start using that, please consider commenting-on/voting-for issue 4 [2] so that mime-types can get applied when deploying Maven sites.
Regards,
Luke
[1] https://wagon-svn.dev.java.net/
[2] https://wagon-svn.dev.java.net/issues/show_bug.cgi?id=4