1

I want to read a maven variable for configure a build plugin from a properties file. It's not needed in and further project files e.g. context files.

1) made a profile (it works, can use mvn ... -P private)

<profile>
 <id>private</id>
  <properties>
   <env>private</env>
  </properties>
</profile>

2) created the filter file with this content (it works) foo.path=/home/foo/path

3) try to configure the plugin (does not work)

<build>
 <plugin>
   <groupId>org.codehaus.mojo</groupId>
    <artifactId>foo-plugin</artifactId>
    <version>${foo-plugin.version}</version>
    <configuration>
     <!--<fooPath>home/foo/path></fooPath> that works -->
     <fooPath>${foo.path}</fooPath> <!--works not -->
    </configuration>
...
</build>

Thx a lot

Sammy_Oliv
  • 11
  • 2

2 Answers2

0

The name of your property is 'env' but you don't use env anywhere in your configuration.

bmargulies
  • 97,814
  • 39
  • 186
  • 310
  • env is for profile: mvn -P private or further mvn -P default. The filter file is called filter-private.properties. It's ok, I can start the several profiles. – Sammy_Oliv Jul 22 '12 at 12:47
0

When Maven docs mention "filter files" they usually mean a file used when processing resources (i.e. copying resources from /src/main/resources to target/classes). As far as I know the properties in those files aren't used for plugin configuration out-of-the-box. I have used the Codehaus properties-maven-plugin:read-project-properties goal do do what you are attempting. Make sure you bind the goal to the lifecycle before any plugins that need the properties for config.

Also, see this answer; you may load properties used to configure other plugins, but not to configure core Maven project elements.

Community
  • 1
  • 1
user944849
  • 14,524
  • 2
  • 61
  • 83