Reputation: 1447
I'm having a question related to the maven properties plugin. My question is somewhat related to How to read an external properties file in Maven
Following that article's advice, I have managed to get it to do most of what I want it to do. My config looks like this :
<dependency>
<groupId>org.kuali.maven.plugins</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.8</version>
</dependency>
...
<plugin>
<groupId>org.kuali.maven.plugins</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.8</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/${environment}.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
Now, the problem that I have is as follows : I have configured a simple repository to store stuff in, like this :
<distributionManagement>
<repository>
<id>localRep</id>
<url>file:${localRepositoryLocation}</url>
</repository>
</distributionManagement>
When running mvn deploy
, the ${localRepositoryLocation} does NOT get replaced.
[INFO] --- maven-deploy-plugin:2.5:deploy (default-deploy) @ SomeApp ---
Uploading: file:${localRepositoryLocation}/SomeApp/SomeApp/1.0.0/SomeApp-1.0.0.war
Uploaded: file:${localRepositoryLocation}/SomeApp/SomeApp/1.0.0/SomeApp-1.0.0.war (5754 KB at 18322.3 KB/sec)
Uploading: file:${localRepositoryLocation}/SomeApp/SomeApp/1.0.0/SomeApp-1.0.0.pom
Uploaded: file:${localRepositoryLocation}/SomeApp/SomeApp/1.0.0/SomeApp-1.0.0.pom (7 KB at 2051.1 KB/sec)
Also, I should note that I also used that plugin in the mojo version, and it yields the exact same behavior. So if the same plugin from two different providers have the same results, there must be something I'm doing wrong here.
Is anybody able to help ?
Kind regards, Andrei
Upvotes: 1
Views: 1939
Reputation: 15678
First, both plugins are different. The original codehaus plugin is available in <version>1.0-alpha-2</version>
and the configuration for the goal properties:read-project-properties
requires the files property:
<configuration>
<files>
<file>etc/config/dev.properties</file>
</files>
</configuration>
The kuali-plugin is available in <version>1.1.10</version>
and is an extended version compared to the original plugin, the configuration requires the location property:
<configuration>
<locations>
<location>classpath:META-INF/spring/database.properties</location>
</locations>
</configuration>
Here you can see the improvement, a quote from the plugins code:
Locations where properties files can be found. Any url Spring resource loading can understand is valid. eg classpath:myprops.properties
. Both, .properties and .xml style properties are supported.
The problem in your code is that the sample (from the codehaus documentation) is wrong. The right configuration looks like:
<plugin>
<groupId>org.kuali.maven.plugins</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.1.10</version>
<configuration>
<locations>
<location>classpath:META-INF/spring/database.properties</location>
</locations>
</configuration>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
</execution>
</executions>
</plugin>
As you can see, the configuration tag is not under the execution tag.
Upvotes: 5