I'm using Maven 3.0.3. I'm trying to test reading properties from a properties file (this is part of a larger effort, I wanted to get this part right first). I have this in my pom.xml file ...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>maven-properties-plugin</artifactId>
<version>1.0</version>
<开发者_StackOverflow中文版;configuration>
<files>
<file>${basedir}/build.properties</file>
</files>
</configuration>
</plugin>
But sadly, running "mvn properties:read-project-properties" fails with the error below. How do I need to reconfigure what I'm doing? - Dave
davea-mbp2:socialmediaproxy davea$ mvn properties:read-project-properties
[INFO] Scanning for projects...
[WARNING] The POM for org.codehaus.mojo:maven-properties-plugin:jar:1.0 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.codehaus.mojo:maven-properties-plugin:1.0: Plugin org.codehaus.mojo:maven-properties-plugin:1.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:maven-properties-plugin:jar:1.0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building socialmediaproxy 0.1
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.codehaus.mojo:maven-properties-plugin:jar:1.0 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.codehaus.mojo:maven-properties-plugin:1.0: Plugin org.codehaus.mojo:maven-properties-plugin:1.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:maven-properties-plugin:jar:1.0
[INFO]
[INFO] --- properties-maven-plugin:1.0-alpha-2:read-project-properties (default-cli) @ socialmediaproxy ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.355s
[INFO] Finished at: Fri Apr 15 11:01:31 CDT 2011
[INFO] Final Memory: 11M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:read-project-properties (default-cli) on project socialmediaproxy: The parameters 'files' for goal org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:read-project-properties are missing or invalid -> [Help 1]
[ERROR]
I think you mixed up the plugin artifact setting. The correct artifact identifiers are
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
See: Plugin Homepage
- Update to the current plugin version
1.0-alpha-2
- Make sure the
build.properties
file exists in the${basedir}
- Either:
- specify the goal when calling
mvn
withmvn properties:read-project-properties
- Or add the goal to the
pom.xml
- specify the goal when calling
Example pom.xml
:
<build>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/build.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
Are you sure your build.properties
file is in your ${basedir}
?
The ${basedir}
represents the directory containing pom.xml
You may reference http://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide
精彩评论