有没有办法从text.file中读取文本并将其设置为pom.xml maven中的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>

temp.sh

PWD=${openssl rand hex 12}
echo $PWD >> temp.txt

您可以使用属性-maven-plugin: https://www.mojohaus.org/properties-maven-plugin/

在你的绒球.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>

最新更新