是否可以读取文件并将整个内容存储到Maven属性中?
我正在尝试生成一些自定义JavaDoc,并且他们可以选择设置标头,但它必须是字符串,而不是文件名(出于某种原因).我显然不想把一堆HTML放到我的pom.xml中,所以我需要一种方法来读取我header.html的Maven属性.
这可能吗?我无法找到标准方式,但看起来像Maven插件可能会这样做.
显然Ant有我想要的东西,但我更喜欢比Ant任务更重的东西.
And*_*nov 13
在SO上看到这个问题.这里是properties-maven-plugin.
如果您不想使用.properties文件,我可以建议使用Groovy插件和我编写的小脚本:
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<properties>
<header_file>header.html</header_file>
</properties>
<source>
def file = new File(project.properties.header_file)
project.properties.header_content = file.getText()
</source>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
执行此插件后,您应该能够引用${header_content}包含header.html文件内容的属性.
| 归档时间: |
|
| 查看次数: |
5818 次 |
| 最近记录: |