Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven SVN checkout example

Tags:

maven-2

svn

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

like image 532
ant Avatar asked May 12 '10 11:05

ant


3 Answers

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.

like image 151
Pascal Thivent Avatar answered Nov 09 '22 09:11

Pascal Thivent


A multi-module build normally requires that the child modules be contained inside the directory of the parent module. But there does not seem to be a way for Hudson/Jenkins to create that sort of structure unless all the modules are in a single tree in SCM. For my project, that's not the case. Many of the children are in separate scm trees (on github). It would be very helpful if maven could create the structure. It needs to be able to do that given only the parent pom, because the children are not visible until they have been fetched from scm.

like image 40
GrampaJohn Avatar answered Nov 09 '22 11:11

GrampaJohn


Is your project organized like the following?

 root (pom.xml)
   +--- Module1 (pom.xml)
   +--- Module2 (pom.xml)

Do you have a multimodule build?

The first thing is, why would you like to checkout via Maven? Let Build servers do this work or your IDE...

like image 23
khmarbaise Avatar answered Nov 09 '22 09:11

khmarbaise