简体   繁体   English

maven scm 插件在每次执行时删除输出文件夹

[英]maven scm plugin deleting output folder in every execution

I need to download from 2 different svn locations to the same output directory.我需要从 2 个不同的 svn 位置下载到同一个输出目录。 So i configured 2 different executions.所以我配置了 2 个不同的执行。 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:这是我的 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</connectionUrl>
              <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</connectionUrl>
              <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} ?有没有办法阻止执行删除文件夹 ${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:我在配置文件中添加了 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?任何的想法?

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.是:将每个 SVN 位置放在一个 Maven 模块(一个子项目)中,然后创建第三个项目,其中包含将两者连接起来的代码。

Background: With Maven, you always have one project per POM.xml.背景:使用 Maven,每个 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".如果你觉得你需要从多个地方连接数据,创建模块,然后使用父 POM 将它们连接到一个“反应器项目”。

To build, invoke Maven in the parent "reactor project".要构建,请在父“反应器项目”中调用 Maven。

I've modified the source of the maven-scm-plugin.我已经修改了 maven-scm-plugin 的源代码。 Added functionality I needed.添加了我需要的功能。

Thanks for your time and help!感谢您的时间和帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM