作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在 maven 阶段测试期间将文件从 src 目录复制到 test/resource 目录,当且仅当文件不存在于 test/resource 目录中时。有人知道我们如何实现这个吗?提前致谢
最佳答案
这是在 Maven3 上为我工作的@Saif Asif 答案的更新版本:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>test</phase>
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="maven.dependency.classpath" />
<if>
<available file="/path/to/your/file "/>
<then>
<!-- Do something with it -->
<copy file="/your/file" tofile="/some/destination/path" />
</then>
</if>
</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>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
</plugin>
感谢https://stackoverflow.com/a/13701310/1410035对于“向插件添加依赖项”解决方案。
此示例中值得注意的更改是:
关于jakarta-ee - Maven 3 :How to copy a file to test directory , 当文件不存在时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22319089/
我是一名优秀的程序员,十分优秀!