Since you don't want to run your executions as part of your regular build, but as a convenience to your developers, use the default-cli "magic" execution id (see https://maven.apache.org/guides/mini/guide-default-execution-ids.html). So don't include neither phase nor goal in your execution and name it "default-cli". That way, it's configuration is only used during manual call of mvn hibernate3:hbm2ddl sql:execute
:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>3.0</version>
<dependencies>
...
</dependencies>
<executions>
<execution>
<id>default-cli</id>
<configuration>
...
</configuration>
<execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
...
</dependencies>
<configuration>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://localhost/MYDB</url>
<username>root</username>
<password>root</password>
</configuration>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<autocommit>true</autocommit>
<srcFiles>
<srcFile>src/main/resources/sql/init.sql</srcFile>
<srcFile>src/main/resources/sql/insertMessages.sql</srcFile>
</srcFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
That way your "manual" goal's configuration will never interfere with some normal lifecycle configuration.
Just two more points:
- Consider always creating the init.sql as part of your build and attaching them as attached artifact (using the classifier sql) to your project. It will make it easier to retrieve the correct sql to a revision later
- please don't generate your sql into
src/main/resources
. This could lead to unmaching classes and sqls as well as "phantom changes" in your developers' workspaces. Correct place to generate to is somewhere under${project.build.directory}
, usuallytarget/generated-resources/hibernate3
.