Maven SVN checkout example

maven-2svn

Concerning my previous question -> Is there a SVN Maven? , I went trough usage page -> http://maven.apache.org/scm/maven-scm-plugin/usage.html didn't found quite what I was looking for, here what I would like to do :

  • Checkout list of projects which I specify for ex :

http://mysvnurl/myprojectname where I could parametrize the project name

Then lets say if there is 3-4 or n number of sub-projects(modules)(for which I can specify the names as well) that I want to checkout, and that I could specify branch(trunk) and revision. To simplify :

  • Checkout certain sub-projects(modules) trunk of myprojectname

Ex :

http://mysvnurl/myprojectname/project1/trunk/* // get everything
http://mysvnurl/myprojectname/project2/trunk/* // get everything

How would I do that with maven, can someone with more expirience explain how to do this or point me to somewhere where I can read how to, I've googled nothing specific to my needs.

Thank you

Best Answer

The Maven SCM Plugin that I mentioned in your previous question is an alternative to SvnAnt task in the sense that it allows to interact with a Subversion repository (amongst others) from Maven or plugins (like the release plugin). But I think I missed what you want to do exactly.

So let's go back to this question, here is how you could use scm:checkout on the CLI:

mvn scm:checkout -DconnectionUrl=scm:svn:https://svn.dev.java.net/svn/glassfish-svn/trunk/v3 -DcheckoutDirectory=v3

And we could imagine putting all this in a POM and declaring these parameters in the configuration of the plugin (or in several execution if you need to handle several URLs). And optionally, you could even play with some excludes or includes (which are honored now, see SCM-526).

...
<execution>  
  <id>perform-checkout</id>  
  <configuration>  
    <connectionUrl>myUrl</connectionUrl>  
    <checkoutDirectory>myDirectory</checkoutDirectory>  
    <excludes>folder1/*,folder2/*</excludes>
  </configuration>  
  <phase><!-- some phase --></phase>  
  <goals>  
     <goal>checkout</goal>  
  </goals>  
</execution>
...

But I've never used it like this. Just in case, maybe have a look at scm:bootstrap that you can use to bootstrap a project from a minimal POM (see Bootstrapping a Project Using a POM) instead. But in both cases, I'm not 100% sure these goals are meant to provide the level of automation you're looking for.

And the more I look at your question, the more I think that svn:externals (i.e. a Subversion feature) is what you're after. That's what I use to do checkouts of complex projects with multiple trunk in a single command.