Скопируйте все файлы из папки в другую, сравнив файлы в ней
Как мы можем скопировать все файлы из одной папки в другую, сравнив все файлы в этой папке, если содержимое файлов изменилось, то скопировать файл в другое место проекта в противном случае нет.
Любое предположение, что какой плагин я должен попробовать?
Я пытаюсь использовать maven-antrun-plugin
(версия 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>
1 ответ
Решение
Я смог сделать с помощью maven-antrun-plugin
<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>
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>