sql-maven-pluginを使用して、いくつかのデータベースでいくつかのMySQLスクリプトを実行しています。同じSQLスクリプトで、テーブル、データ、トリガー、イベント、およびストアドプロシージャを展開したいと思います。
INSERTまたはCREATEの場合はを使用するため、行区切り文字に問題がありますが、トリガーの場合は、たとえば、で;
区切り文字を変更する必要があります。DELIMITER //
プラグインで区切り文字を変更できることは知っていますが、すべてのスクリプトに適用できます。一意のスクリプトの一部についてのみ区切り文字を変更したいと思います。
これは私のMaven構成です:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
</dependencies>
<configuration>
<driver>com.mysql.jdbc.Driver</driver>
<username>${db.user}</username>
<password>${db.passwd}</password>
<encoding>UTF-8</encoding>
<orderFile>ascending</orderFile>
<keepFormat>true</keepFormat>
<driverProperties>characterEncoding=utf8,
connectionCollation=utf8_general_ci,
sql_mode=STRICT_TRANS_TABLES</driverProperties>
</configuration>
<executions>
<execution>
<id>execution-mysql</id>
<phase>prepare-package</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<url>jdbc:mysql://${db.url}:${db.port}</url
<delimiterType>normal</delimiterType>
<fileset>
<basedir>${project.build.directory}/sql/</basedir>
<includes>
<include>${file.sql}</include>
</includes>
</fileset>
</configuration>
</execution>
</executions>
</plugin>