Maven 通过比较文件夹中的文件,将文件夹中的所有文件复制到另一个文件夹中

Maven 通过比较文件夹中的文件,将文件夹中的所有文件复制到另一个文件夹中,maven,ant,maven-antrun-plugin,Maven,Ant,Maven Antrun Plugin,如何通过比较该文件夹中的所有文件将所有文件从一个文件夹复制到另一个文件夹中,如果文件内容已更改,则将文件复制到另一个项目位置,否则不会 有没有关于我应该使用哪个插件的建议 我正在尝试使用maven antrun插件(1.7版),但还没有成功 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artif

如何通过比较该文件夹中的所有文件将所有文件从一个文件夹复制到另一个文件夹中,如果文件内容已更改,则将文件复制到另一个项目位置,否则不会

有没有关于我应该使用哪个插件的建议

我正在尝试使用maven antrun插件(1.7版),但还没有成功

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-antrun-plugin</artifactId>
       <executions>
        <execution>
            <phase>initialize</phase>
                <configuration>
                    <target name="main">
                        <ant antfile="/build.xml" target="main" />
                     </target>
                </configuration>
                    <goals>
                         <goal>run</goal>
                     </goals>
         </execution>
       </executions>
   <dependency>
       <groupId>ant-contrib</groupId>
      <artifactId>ant-contrib</artifactId>
     <version>1.0b3</version>
 </dependency>

</plugin>

org.apache.maven.plugins
maven antrun插件
初始化
跑
抗辩人
抗辩人
1.0b3

我可以使用maven antrun插件

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <configuration>
                            <target name="build">
                                <ant antfile="build.xml"
                                    target="build" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
          <dependency>
            <groupId>ant-contrib</groupId>
            <artifactId>ant-contrib</artifactId>
            <version>1.0b3</version>
            <exclusions>
              <exclusion>
                <artifactId>ant</artifactId>
                <groupId>ant</groupId>
              </exclusion>
            </exclusions>
          </dependency>
        </dependencies>
            </plugin>

org.apache.maven.plugins
maven antrun插件
初始化
跑
抗辩人
抗辩人
1.0b3
蚂蚁
蚂蚁
build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="prospector" basedir="/" default="main">
<target name="main" depends="etc"/>

<target name="etc">

        <for param="file">
            <path>
                <fileset
                    dir="etc"
                    includes="**/**" />
            </path>
            <sequential>
                <var name="name" unset="true" />
                <basename file="@{file}" property="name" />
                <if>
                    <filesmatch file1="@{file}" file2="etc/${name}" /> 
                    <then>
                        <echo message="There is no change in ${name}" />
                    </then>
                    <else>
                        <echo message="There are some changes in ${name}" />
                        <copy
                            file="@{file}"
                            tofile="etc/${name}" overwrite="true"/> 
                    </else>
                </if>


            </sequential>
        </for>
    </target>


您犯了一个基本错误
ApacheMaven AntRun插件
不符合您的目的。阅读参考文档:该插件提供了从Maven内部运行Ant任务的能力。您甚至可以将Ant脚本嵌入POM中!有没有使用其他插件的建议?我不知道你为什么同时处理两个项目。一般来说,构建工具一次只能使用一个项目。即使在同一个项目中,我们如何才能做到这一点?我和我的同事通常不会这样做。