首页 > 解决方案 > Maven:读取文件并循环内容

问题描述

所以我有 2 个文件,其中包含我想要打包的其他文件的列表。这就是目录的样子

 /mydir   
   |-pom.xml   
   |-a.out   
   |-b.out   
   |-c.out 
   |-d.out  
   |-read1.list  
   |-read2.list

下面是 read1.list 和 read2.list 的内容

read1.list

a.out
b.out

read2.list

c.out

所以我想让 maven 读取 read1.list 和 read2.list 文件,获取文件列表,然后将它们复制到另一个目录。我想我已经阅读了文件部分,但我不知道在那之后该怎么做。

 <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <version>1.0.0</version>
    <executions>
       <execution>
          <id>read property file</id>
          <phase>process-resources</phase>
          <goals>
             <goal>read-project-properties</goal>
          </goals>
          <configuration>
             <files>
                <file>${basedir}/read1.list</file>
                <file>${basedir}/read2.list</file>
             </files>
          </configuration>
       </execution>
    </executions>
 </plugin>

我从这篇文章中得到了这段代码,但我不确定下一步该做什么。 Maven:读取属性文件并复制资源

任何帮助将不胜感激。

标签: mavenpropertiescompilation

解决方案


推荐阅读