views:

27

answers:

1

I thought I was an experienced Maven user, but I am having a mental block on how to do this!

I've been able to use the Maven sql plugin to drop, create, and install a schema in a database via plugin executions I've defined and bound to the pre-integration-test phase.

However, now I'd like to use that same sql plugin to insert some sample data whenever I want from the command line -- that is, not bound to any lifecycle goal. There are a few different sets of sample data, so I'd like to define a few different executions.

But is there a way to run one of these executions from the command line by using the execution ID perhaps?

+2  A: 

But is there a way to run one of these executions from the command line by using the execution ID perhaps?

No, not possible. What is possible though is to define "a" configuration to be used when the plugin is invoked from the command line using the "special" default-cli execution id:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>sql-maven-plugin</artifactId>
  <version>1.4</version>
  ...
  <executions>
    <execution>
      <id>default-cli</id>
      <configuration>
        ...
      </configuration>
    </execution>
    ...
  </executions>
</plugin>

And simply call mvn sql:execute.

See below for the details (from the Maven 2.2.0 Release Notes):

  • MNG-3401 - Starting in Maven 2.2.0, goals invoked directly from the command line can be configured in the POM separately from other plugin invocations using a special executionId called default-cli. Where previously, all configurations for command-line goals had to go in the plugin-level configuration, Maven 2.2.0 allows command-line-specific configurations to be separated into their own <execution>. For more information, see the Guide to Default Execution IDs.
Pascal Thivent
@Pascal -- our paths crossed and I edited the question slightly to make it more clear exactly when you provided this answer. Is it possible to define a few of these and invoke them from the command line?
HDave
@HDave Answer slightly modified to reflect the changes in the question :)
Pascal Thivent
@Pascal - thanks again for another helpful answer
HDave