maven-deploy-plugin中多次执行的Maven错误

时间:2009-03-16 11:00:02

标签: java maven-2 build maven-plugin

我找到this nice recipe并希望用它在我们的存储库中部署一些第三方文件

命令行上的调用是

mvn -P deploy-libs

如果我为一个文件执行此操作,它将完全按预期工作

<profiles>
    <profile>
        <id>deploy-libs</id>
        <build>
            <defaultGoal>deploy:deploy-file</defaultGoal>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.4</version>
                    <goals>
                        <goal>deploy-file</goal>
                    </goals>
                    <configuration>
                        <repositoryId>openscada-external</repositoryId>
                        <url>${openscada.distrib.repository}</url>
                        <file>../openscada_opc_dcom/lib/j-interop.jar</file>
                        <pomFile>../openscada_opc_dcom/lib/j-interop.pom</pomFile>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

如果我使用具有多个执行的执行块,则它不起作用。这是一个错误,还是这个预期的行为?

<profiles>
    <profile>
        <id>deploy-libs</id>
        <build>
            <defaultGoal>deploy:deploy-file</defaultGoal>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.4</version>
                    <configuration>
                        <repositoryId>openscada-external</repositoryId>
                        <url>${openscada.distrib.repository}</url>
                    </configuration>
                    <executions>
                        <execution>
                            <id>j-interop</id>
                            <goals>
                                <goal>deploy-file</goal>
                            </goals>
                            <configuration>
                                <file>../openscada_opc_dcom/lib/j-interop.jar</file>
                                <pomFile>../openscada_opc_dcom/lib/j-interop.pom</pomFile>
                            </configuration>
                        </execution>
                        <execution>
                            <id>j-interopdeps</id>
                            <goals>
                                <goal>deploy-file</goal>
                            </goals>
                            <configuration>
                                <file>../openscada_opc_dcom/lib/j-interopdeps.jar</file>
                                <pomFile>../openscada_opc_dcom/lib/j-interopdeps.pom</pomFile>
                            </configuration>
                        </execution>
                        <execution>
                            <id>jcifs</id>
                            <goals>
                                <goal>deploy-file</goal>
                            </goals>
                            <configuration>
                                <file>../openscada_opc_dcom/lib/jcifs-1.2.9.jar</file>
                                <pomFile>../openscada_opc_dcom/lib/jcifs-1.2.9.pom</pomFile>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

我得到的错误是:

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] One or more required plugin parameters are invalid/missing for 'deploy:deploy-file'

[0] Inside the definition for plugin 'maven-deploy-plugin' specify the following:

<configuration>
  ...
  <file>VALUE</file>
</configuration>

-OR-

on the command line, specify: '-Dfile=VALUE'

[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error configuring: org.apache.maven.plugins:maven-deploy-plugin. Reason: Invalid or missing parameters: [Mojo parameter [name: 'file'; alias: 'null']] for mojo: org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:587)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:512)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:482)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:227)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.PluginParameterException: Error configuring: org.apache.maven.plugins:maven-deploy-plugin. Reason: Invalid or missing parameters: [Mojo parameter [name: 'file'; alias: 'null']] for mojo: org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file
    at org.apache.maven.plugin.DefaultPluginManager.checkRequiredParameters(DefaultPluginManager.java:1042)
    at org.apache.maven.plugin.DefaultPluginManager.getConfiguredMojo(DefaultPluginManager.java:659)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:429)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
    ... 16 more

有什么想法吗?

5 个答案:

答案 0 :(得分:6)

发生这种情况的原因是,当您从命令行调用插件时,它就没有与之相关的阶段或执行。这意味着它会获取未命名的执行配置,这是执行块之外的配置。

如果您确实想要运行多个执行,请将它们绑定到某个阶段,然后调用该阶段。在这种情况下,每次执行都将使用自己的配置运行。

这里真正未解决的问题是你使用deploy-file来部署这样的一堆东西的原因?如果它是第三方的东西,你应该得到一个像Nexus这样的回购管理器,并将它们上传到一个存储库,供整个团队使用。

答案 1 :(得分:0)

这有点冗长但可能会有所帮助:

<profiles>
  <profile>
    <id>deploy-j-interop</id>
    <build>
      <defaultGoal>deploy:deploy-file</defaultGoal>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.4</version>
          <configuration>
            <repositoryId>openscada-external</repositoryId>
            <url>${openscada.distrib.repository}</url>
          </configuration>
          <executions>
            <execution>
              <id>j-interop</id>
              <goals>
                <goal>deploy-file</goal>
              </goals>
              <configuration>
                <file>../openscada_opc_dcom/lib/j-interop.jar</file>
                <pomFile>../openscada_opc_dcom/lib/j-interop.pom</pomFile>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
  </profile>

  <profile>
    <id>deploy-j-interopdeps</id>
    <build>
      <defaultGoal>deploy:deploy-file</defaultGoal>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.4</version>
          <configuration>
            <repositoryId>openscada-external</repositoryId>
            <url>${openscada.distrib.repository}</url>
          </configuration>
          <executions>
            <execution>
              <id>j-interopdeps</id>
              <goals>
                <goal>deploy-file</goal>
              </goals>
              <configuration>
                <file>../openscada_opc_dcom/lib/j-interopdeps.jar</file>
                <pomFile>../openscada_opc_dcom/lib/j-interopdeps.pom</pomFile>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
  </profile>

  <profile>
    <id>deploy-jcifs</id>
    <build>
      <defaultGoal>deploy:deploy-file</defaultGoal>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.4</version>
          <configuration>
            <repositoryId>openscada-external</repositoryId>
            <url>${openscada.distrib.repository}</url>
          </configuration>
          <executions>
            <execution>
              <id>jcifs</id>
              <goals>
                <goal>deploy-file</goal>
              </goals>
              <configuration>
                <file>../openscada_opc_dcom/lib/jcifs-1.2.9.jar</file>
                <pomFile>../openscada_opc_dcom/lib/jcifs-1.2.9.pom</pomFile>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

您可以使用以下命令运行它:

mvn -P deploy-j-interop deploy-j-interopdeps deploy-jcifs

答案 2 :(得分:0)

我猜maven还尝试执行默认执行,其中未指定<file>。 在pluginManagement中配置插件通常是个好主意,并将不同的执行显式绑定到特定的阶段。

尝试在默认插件配置中添加明确的''和''元素。您可以将垃圾放入其中,以查看默认执行是否已执行,如果执行,则将其中一个执行作为默认执行。

答案 3 :(得分:0)

要一次完成所有部署(如Boris所述),您可以添加:

  

&LT;型材&GT;
  &LT;型材&GT;
  &LT; ID&GT; MyId1&LT; / ID&GT;
  &LT;活化&GT;&LT;性&gt;&DeployAll LT; /性&gt;&LT; /活化&GT;
  ...
  &LT; /简档&GT;
  &LT;型材&GT;
  &LT; ID&GT; MyId2&LT; / ID&GT;
  &LT;活化&GT;&LT;性&gt;&DeployAll LT; /性&gt;&LT; /活化&GT;
  ......

然后使用

  

mvn -DDeployAll

答案 4 :(得分:0)

Of cource it's a bug. Maven plugin is not supposed to work in this way.