properties-maven-plugin:缺少目标的参数'files'

时间:2011-04-15 16:00:40

标签: maven maven-plugin maven-3

我正在使用Maven 3.0.3。我正在尝试从属性文件中测试读取属性(这是更大努力的一部分,我希望首先使这部分正确)。我在我的pom.xml文件中有这个...

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>maven-properties-plugin</artifactId>
    <version>1.0</version>
    <configuration>
      <files>
        <file>${basedir}/build.properties</file>
      </files>
    </configuration>
  </plugin>

但遗憾的是,运行“mvn properties:read-project-properties”会失败并显示以下错误。我如何重新配置​​我正在做的事情? - 戴夫

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] 

3 个答案:

答案 0 :(得分:2)

我认为你混淆了插件工件设置。

是正确的工件标识符
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>

请参阅:Plugin Homepage

答案 1 :(得分:1)

  1. 更新到当前插件版本1.0-alpha-2
  2. 确保build.properties
  3. 中存在${basedir}文件
  4. 或者:
    • 使用mvn
    • 调用mvn properties:read-project-properties时指定目标
    • 或将目标添加到pom.xml
  5. 示例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>
    

答案 2 :(得分:0)

您确定build.properties文件在${basedir}吗?

${basedir}代表包含pom.xml

的目录

您可以参考http://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide