Maven:属性未被替换
我在项目中使用 install4j 的 Maven 插件,位于此处。该插件允许您使用
部分将变量传递给 install4j。这是我的 pom 的相关部分:
<plugin>
<groupId>com.google.code.maven-install4j</groupId>
<artifactId>maven-install4j-plugin</artifactId>
<version>0.1.1</version>
<configuration>
<executable>${devenv.install4jc}</executable>
<configFile>${basedir}/newinstaller/ehd.install4j</configFile>
<releaseId>${project.version}</releaseId>
<attach>false</attach>
<skipOnMissingExecutable>false</skipOnMissingExecutable>
<compilerVariables>
<property>
<name>m2_home</name>
<value>${settings.localRepository}</value>
</property>
</compilerVariables>
</configuration>
</plugin>
问题是当我运行插件时 ${settings.localRepository} 没有被实际目录替换。这是 install4j 生成的命令行脚本:
[INFO] Running the following command for install4j compile: /bin/sh -c /home/zach/install4j/bin/install4jc --release=9.1-SNAPSHOT --destination="/home/zach/projects/java/ehdtrunk/target/install4j" -D m2_home=${settings.localRepository} /home/zach/projects/java/ehdtrunk/newinstaller/ehd.install4j
这是插件的错误吗?如果是这样,需要进行哪些更改才能实现替换?
I'm using a maven plugin for install4j in my project, located here. That plugin lets you pass variables to install4j using the <compilerVariables>
section. Here's the relevant section of my pom:
<plugin>
<groupId>com.google.code.maven-install4j</groupId>
<artifactId>maven-install4j-plugin</artifactId>
<version>0.1.1</version>
<configuration>
<executable>${devenv.install4jc}</executable>
<configFile>${basedir}/newinstaller/ehd.install4j</configFile>
<releaseId>${project.version}</releaseId>
<attach>false</attach>
<skipOnMissingExecutable>false</skipOnMissingExecutable>
<compilerVariables>
<property>
<name>m2_home</name>
<value>${settings.localRepository}</value>
</property>
</compilerVariables>
</configuration>
</plugin>
The problem is that ${settings.localRepository} is not being substituted with the actual directory when I run the plugin. Here's the command line script that install4j is generating:
[INFO] Running the following command for install4j compile: /bin/sh -c /home/zach/install4j/bin/install4jc --release=9.1-SNAPSHOT --destination="/home/zach/projects/java/ehdtrunk/target/install4j" -D m2_home=${settings.localRepository} /home/zach/projects/java/ehdtrunk/newinstaller/ehd.install4j
Is this the fault of the plugin? If so, what needs to change to allow the substitution to happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下 POM 对我有效(使用 Maven 2.2.1):
运行 mvn process-ressources 会产生以下输出:
以上对您有用吗?你在使用M2Eclipse吗?它可能与 MNGECLIPSE-299 有关吗?
The following POM just works for me (with Maven 2.2.1):
And running mvn process-ressources produces the following output:
Does the above work for you? Are you using M2Eclipse? Could it be related to MNGECLIPSE-299?
该插件接受一个 Properties 实例参数。无论出于何种原因,用于配置 Properties 实例的表达式都不会自动求值。我必须更改插件以使用 org.apache.maven.plugin.PluginParameterExpressionEvaluator 来评估 ${settings.localRepository}。
The plugin in question accepts a parameter which is a Properties instance. For whatever reason, expressions used to configure Properties instances are not automatically evaluated. I had to change the plugin to use a org.apache.maven.plugin.PluginParameterExpressionEvaluator to evaluate ${settings.localRepository}.