views:

363

answers:

2

Hi all,

I need to download from 2 different svn locations to the same output directory. So i configured 2 different executions. But every time it executes a checkout deletes the output directory so it also deletes the already downloaded projects.

Here is a sample of my pom.xml:

<profile>
  <id>checkout</id>
  <activation>
    <property>
      <name>checkout</name>
      <value>true</value>
    </property>
  </activation>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-scm-plugin</artifactId>
        <version>1.3</version>
        <configuration>
          <username>${svn.username}</username>
          <password>${svn.pass}</password>
          <checkoutDirectory>${path}</checkoutDirectory>
          <skipCheckoutIfExists/>
        </configuration>
        <executions>
          <execution>
            <id>checkout_a</id>
            <configuration>
              <connectionUrl>scm:svn:https://host_n/folder&lt;/connectionUrl&gt;
              <checkoutDirectory>${path}</checkoutDirectory>
            </configuration>
            <phase>process-resources</phase>
            <goals>
              <goal>checkout</goal>
            </goals>
          </execution>
          <execution>
            <id>checkout_b</id>
            <configuration>
              <connectionUrl>scm:svn:https://host_l/anotherfolder&lt;/connectionUrl&gt;
              <checkoutDirectory>${path}</checkoutDirectory>
            </configuration>
            <phase>process-resources</phase>
            <goals>
              <goal>checkout</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>

Is there any way to prevent the executions to delete the folder ${path} ?


I came up with a solution but I cant get it to work:

I added to the profile a execution of maven-clean-plugin:

<profile>
  <id>checkout</id>
  ...
  <plugin>
    <artifactId>maven-clean-plugin</artifactId>
    <executions>
      <execution>
        <id>not-clean</id>
        <configuration>
          <filesets>
            <fileset>
              <directory>${path}</directory>
              <excludes>
                <exclude>*/*</exclude>
              </excludes>
              <followSymlinks>false</followSymlinks>
            </fileset>
          </filesets>
        </configuration>
        <phase>initialize</phase>
        <goals>
          <goal>clean</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

But I cant realize how to exclude everything in folder.

Any Idea?

+2  A: 

Yes: Put each SVN location in a Maven module (a sub-project) and then create a third project which contains the code to join the two.

Background: With Maven, you always have one project per POM.xml. If you feel that you need to join data from several places, create modules and then use a parent POM to join them into one "reactor project".

To build, invoke Maven in the parent "reactor project".

Aaron Digulla
Thanks for your quick replay. But I cant actually modify the structure of the projects (its a multi module project).
Udo Fholl
Then you're already halfway there. I am talking about a multi module project. The fact is that you can't checkout two SCM sources into the same folder since each call will remove everything that can't be found in the source. So you must checkout to two different places *or* you must use a custom ant task. See the antrun plugin.
Aaron Digulla
A: 

I've modified the source of the maven-scm-plugin. Added functionality I needed.

Thanks for your time and help!

Udo Fholl