Read a file into a Maven property

后端 未结 1 705
一向
一向 2020-12-06 18:16

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 hea

相关标签:
1条回答
  • 2020-12-06 18:56

    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.

    0 讨论(0)
提交回复
热议问题