views:

149

answers:

2

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?

+1  A: 

The following POM just works for me (with Maven 2.2.1):

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.stackoverflow</groupId>
  <artifactId>Q2828732</artifactId>
  <version>1.0-SNAPSHOT</version>
  <dependencies>
    ...
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>validate</phase>
            <configuration>
              <tasks>
                <echo>${settings.localRepository}</echo>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

And running mvn process-ressources produces the following output:

$ mvn validate
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Q2828732
[INFO]    task-segment: [validate]
[INFO] ------------------------------------------------------------------------
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
     [echo] /home/pascal/.m2/repository
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Thu May 13 19:28:38 CEST 2010
[INFO] Final Memory: 3M/54M
[INFO] ------------------------------------------------------------------------

Does the above work for you? Are you using M2Eclipse? Could it be related to MNGECLIPSE-299?

Pascal Thivent
This is straight command line Maven 2. And yes, I get the correct output when using that property in the antrun plugin. It appears that it might be a problem with the plugin. I'll see if I find out what the antrun plugin does with property inputs like that and see if I can apply it to this other plugin.
jobrahms
@jobrahms *It appears that it might be a problem with the plugin* yes, I think so.
Pascal Thivent
@jobrahms I've tested the property outside antrun with `mvn help:evaluate` and confirm it's properly resolved.
Pascal Thivent
@Pascal Thivent I just tried a different property ${basedir}, and that was substituted correctly. Is there something weird about using properties that have dots in their names?
jobrahms
@jobrahms Not to my knowledge (and if there is I would consider this as a bug). Try with `${project.version}` to confirm (it should definitely work).
Pascal Thivent
@Pascal Thivent yes, ${project.version} works.
jobrahms
A: 

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}.

jobrahms