[英]Is there a way to read a text from a text.file and set it to maven property in pom.xml maven?
有没有办法从text.file中读取文本并将其设置为pom.xml maven中的maven属性? 我正在尝试以下代码。 但是,我需要从tmp.txt中读取文本并将其分配给Maven属性“ token”。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<id>generate-random-string</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>bash</executable>
<arguments>
<argument>temp.sh</argument>
</arguments>
<workingDirectory>temp.txt</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
PWD=${openssl rand hex 12}
echo $PWD >> temp.txt
您可以使用properties-maven-plugin: https : //www.mojohaus.org/properties-maven-plugin/
在您的pom.xml中。 将生成的文件的文件路径放在配置部分。
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<!-- your generated file -->
<file>temp.txt</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.