Is it possible to read a file and store the entire contents into a Maven property?
I'm trying to generate some custom JavaDocs, and they have an option to set a header, but it has to be a string, not a file name (for some reason). I obviously don't want to put a bunch of HTML into my pom.xml, so I need a way to read my header.html
as a Maven property.
Is this possible? I'm not able to find a standard way, but it seems like a Maven plugin might do this.
Apparently Ant has what I want, but I'd prefer something lighter weight than the Ant task.
See this question on SO. And here is the properties-maven-plugin.
If you'd like not to use .properties file, than I can suggest to use the Groovy plugin and a small script that I've written:
<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>
After execution of this plugin, you should be able to refer to ${header_content}
property that contains header.html
file contents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With