【问题标题】:properties-maven-plugin: The parameters 'files' for goal ... are missingproperties-maven-plugin:目标的参数“文件”丢失......
【发布时间】:2011-04-15 16:00:40
【问题描述】:

我正在使用 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] 

【问题讨论】:

标签: maven maven-plugin maven-3


【解决方案1】:

我认为您混淆了插件工件设置。正确的工件标识符是

<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>

见:Plugin Homepage

【讨论】:

    【解决方案2】:
    1. 更新到当前插件版本1.0-alpha-2
    2. 确保build.properties 文件存在于${basedir}
    3. 要么:
      • 使用mvn properties:read-project-properties 调用mvn 时指定目标
      • 或将目标添加到pom.xml

    例如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>
    

    【讨论】:

      【解决方案3】:

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

      ${basedir}代表包含pom.xml的目录

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

      【讨论】:

      • 嗨。如果您找到了解决问题的方法,请分享。我有完全相同的问题。