且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Maven将整个目录复制到另一个目录?

更新时间:2023-11-27 18:14:46

您可以使用 Maven资源插件.

以他们的文档中的示例为例:

As an example taken from their documentation:

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>copy-resources</id>
            <!-- here the phase you need -->
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${basedir}/target/extra-resources</outputDirectory>
              <resources>          
                <resource>
                  <directory>src/non-packaged-resources</directory>
                  <filtering>true</filtering>
                </resource>
              </resources>              
            </configuration>            
          </execution>
        </executions>
      </plugin>
    </plugins>
    ...
  </build>
  ...
</project>

如果我没记错的话,这会将directory的内容复制到outputDirectory中.

This would copy the content of the directory into the outputDirectory if I'm not mistaken.