【发布时间】:2016-04-11 12:35:38
【问题描述】:
当我使用 maven 的时间戳属性时,我无法创建文件夹。 我已经分享了 pom 详细信息和生成的错误消息,但是我可以手动创建文件夹。
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<timestamp>${maven.build.timestamp}</timestamp>
<outputFolder>C:/AutomationTestReports/${project.name}/Execution_(${timestamp})</outputFolder>
</properties>
当我使用上述代码时,在maven的pom文件中。
虽然报告了以下错误,但作为构建的一部分:
[TestNG] Reporter org.uncommons.reportng.JUnitXMLReporter@3d8c7aca failed
org.uncommons.reportng.ReportNGException: Failed generating JUnit XML report.
at org.uncommons.reportng.JUnitXMLReporter.generateReport(JUnitXMLReporter.java:83)
at org.testng.TestNG.generateReports(TestNG.java:1115)
at org.testng.TestNG.run(TestNG.java:1074)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:293)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:84)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:91)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: java.io.FileNotFoundException: C:\AutomationTestReports\Demo\Execution_(2016-04-11T12:13:35Z)\xml\Script.Demo.AppTest_results.xml (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
at java.io.FileWriter.<init>(FileWriter.java:90)
at org.uncommons.reportng.AbstractReporter.generateFile(AbstractReporter.java:10
但是,如果我删除时间戳,则文件夹创建工作正常。
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<timestamp>${maven.build.timestamp}</timestamp>
<outputFolder>C:/AutomationTestReports/${project.name}</outputFolder>
</properties>
问题:如何在 Maven 中为创建的文件添加时间戳?
【问题讨论】:
-
这种手冲文件夹的目的是什么?