【发布时间】:2020-03-22 12:54:03
【问题描述】:
有没有办法从 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
【问题讨论】:
-
@AndyMan - 我正在努力从文本文件中读取文本并将其设置为 maven 属性。
-
你可以试试@AndyMan 推荐的插件。将 bash 脚本更改为
PWD="$(ls -l)" echo "token = $PWD"> temp.properties。然后读取该文件并使用令牌属性。见stackoverflow.com/questions/12619446/… -
我相信,它会起作用的。谢谢。
-
properties-maven-plugin 从此插件的配置文件中读取属性将受到限制,或者可以在整个文件中访问该属性?
标签: java maven maven-antrun-plugin maven-exec-plugin