views:

3188

answers:

4

I found this nice recipe and want to use it to deploy some 3rd-party files in our repository

The call on the command line is

mvn -P deploy-libs

If I do this for one file it works exactly as intended

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

If I use an execution block with multiple executions, it doesn't work. Is this a bug, or is this intended behavior?

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

The error I get is:

[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

Any ideas?

A: 

This is a bit verbose but may help:

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

You would run it using the command:

mvn -P deploy-j-interop deploy-j-interopdeps deploy-jcifs
Boris Pavlović
I guess that would work, but I want to specify just one profile and not each one separately.
Mauli
What about trying to write your own plugin which will deal with multiple files?
Boris Pavlović
A: 

I guess maven tries to also execute the default execution, where <file> is not specified. It's usually a good idea to configure the plugins in pluginManagement, and explicitly bind the the different executions to specific phases.

Try to put an explicit '' and '' elements in the default plugin configuration. You can put garbage inside, to see if the default execution get executed, and if it does, make one of the executions a default.

siddhadev
+2  A: 

The reason why this happens is that when a plugin is invoked from the command line like you've done, it has no phase or execution associated with it. This means it picks up the unnamed execution configuration, which is the config outside the execution block.

If you really want to run multiple executions, bind them to a phase and then invoke that phase. In this case each execution will run with its own configuration.

The real unasked question here is why you are using deploy-file to deploy a bunch of stuff like this? If it's 3rd party stuff, you should get a repo manager like Nexus and upload them once to a repository for your whole team to use.

Brian Fox
A: 

To do all the deploys at once (as described by Boris) you can add:

<profile>
  <profiles>
    <id>MyId1</id>
    <activation><property>DeployAll</property></activation>
    ...
</profiles>
<profile>
  <id>MyId2</id>
  <activation><property>DeployAll</property></activation>
  ...

And then use

mvn -DDeployAll

Steven Christenson