Konrad Garus
Konrad Garus

Reputation: 54045

Populating DB with Maven

Let's say that my standard configration in Maven is:

With normal execution path it works just fine (modulo bugs in Maven plugin ordering, besides the point).

Now, I would like to have a single command to only generate and execute the DB schema scripts, and another command to only run the Java program to populate database.

So far I figured I could put install-schema, populate-db and start-jetty in their own profiles, then:

mvn pre-integration-test -Pinstall-schema

This is bad, because it still would run all the preceding phases, and I really don't want to compile, test and package for it.

Is it possible to somehow run those "things" (several plugin executions, a profile) in isolation, ignoring the lifecycle or skipping compile-test-package?

Upvotes: 2

Views: 1275

Answers (1)

rlegendi
rlegendi

Reputation: 10606

Yes, I think you can do that with conditional activation through certain properties for the Maven profiles, e.g.:

<profile>
    <id>install-schema</id>
    <activation>
        <property>doItPlz</property>
    </activation>
</profile>
...

This way the profile is activated only if that given doItPlz property is present -- so you can create one for the build, the db initialization, etc.

The command you have to use is then modified to:

mvn -DdoItPlz ...

Hope that helps something.

Upvotes: 0

Related Questions