mvn test works, but sql:execute does not work

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

mvn test works, but sql:execute does not work

신상재


I set up sql-maven-plugin like this:

 

<build>

<plugins>

<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>${mysql.version}</version>

</dependency>

</dependencies>

<configuration>

<driver>com.mysql.jdbc.Driver</driver>

<url>jdbc:mysql://localhost:3306/test</url>

<username>scott</username>

<password>tiger</password>

</configuration>

<executions>

<execution>

<id>drop-table</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>create-table</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>insert-data</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

</executions>

</plugin>

</plugins>

</build>

 

 

When I execute 'mvn test', sql executed like this:

 

[INFO] --- sql-maven-plugin:1.5:execute (drop-table) @ pte-webapp-prototype ---

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-bonus-table.1339142444sql

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-salgrade-table.182961079sql

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-dept-table.1442040038sql

[ERROR] Failed to execute:  ALTER TABLE DEPT DROP PRIMARY KEY

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'PRIMARY'; check that column/key exists

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-emp-table.1792844234sql

[ERROR] Failed to execute:  ALTER TABLE EMP DROP FOREIGN KEY FK_DEPTNO

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'FK_DEPTNO'; check that column/key exists

[ERROR] Failed to execute:

 ALTER TABLE EMP DROP PRIMARY KEY

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'PRIMARY'; check that column/key exists

[ERROR] Failed to execute:

 DROP INDEX PK_EMP ON EMP

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'PK_EMP'; check that column/key exists

[INFO] 5 of 9 SQL statements executed successfully

.....

 

 

But when I execute 'mvn sql:execute', sql does not work at all:

 

[INFO] ------------------------------------------------------------------------

[INFO] Building pte-webapp-prototype Maven Webapp 1.1.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] --- sql-maven-plugin:1.5:execute (default-cli) @ pte-webapp-prototype ---

[INFO] 0 of 0 SQL statements executed successfully

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 1.598 s

 

 

 

Why 'mvn test' is ok but 'mvn sql:execute' is not?

Which part of my configuration is wrong?

 

 

Reply | Threaded
Open this post in threaded view
|

Re: mvn test works, but sql:execute does not work

Anders Hammar
It's because you don't have any configuration set for "mvn sql:execute". You need to move any configuration you want for maven execution outside the build lifecycle to the pluginManagement section (build/pluginManagement/plugins/plugin/configuration instead of build/plugins/plugin/configuration).
 
/Anders

On Mon, Feb 2, 2015 at 2:05 PM, 신상재 <[hidden email]> wrote:


I set up sql-maven-plugin like this:

 

<build>

<plugins>

<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>${mysql.version}</version>

</dependency>

</dependencies>

<configuration>

<driver>com.mysql.jdbc.Driver</driver>

<url>jdbc:mysql://localhost:3306/test</url>

<username>scott</username>

<password>tiger</password>

</configuration>

<executions>

<execution>

<id>drop-table</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>create-table</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>insert-data</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

</executions>

</plugin>

</plugins>

</build>

 

 

When I execute 'mvn test', sql executed like this:

 

[INFO] --- sql-maven-plugin:1.5:execute (drop-table) @ pte-webapp-prototype ---

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-bonus-table.1339142444sql

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-salgrade-table.182961079sql

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-dept-table.1442040038sql

[ERROR] Failed to execute:  ALTER TABLE DEPT DROP PRIMARY KEY

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'PRIMARY'; check that column/key exists

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-emp-table.1792844234sql

[ERROR] Failed to execute:  ALTER TABLE EMP DROP FOREIGN KEY FK_DEPTNO

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'FK_DEPTNO'; check that column/key exists

[ERROR] Failed to execute:

 ALTER TABLE EMP DROP PRIMARY KEY

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'PRIMARY'; check that column/key exists

[ERROR] Failed to execute:

 DROP INDEX PK_EMP ON EMP

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'PK_EMP'; check that column/key exists

[INFO] 5 of 9 SQL statements executed successfully

.....

 

 

But when I execute 'mvn sql:execute', sql does not work at all:

 

[INFO] ------------------------------------------------------------------------

[INFO] Building pte-webapp-prototype Maven Webapp 1.1.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] --- sql-maven-plugin:1.5:execute (default-cli) @ pte-webapp-prototype ---

[INFO] 0 of 0 SQL statements executed successfully

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 1.598 s

 

 

 

Why 'mvn test' is ok but 'mvn sql:execute' is not?

Which part of my configuration is wrong?

 

 


Reply | Threaded
Open this post in threaded view
|

Re: mvn test works, but sql:execute does not work

신상재

 

Thanks for advice.

I copy sql-maven-plugin configuration under <pluginManagement>

and remove <phrase> block like this: 

 

<build>

<pluginManagement>

<plugins>

<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>${mysql.version}</version>

</dependency>

</dependencies>

<configuration>

<driver>com.mysql.jdbc.Driver</driver>

<url>jdbc:mysql://localhost:3306/test</url>

<username>scott</username>

<password>tiger</password>

</configuration>

<executions>

<execution>

<id>drop-table</id>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>create-table</id>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>insert-data</id>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

</executions>

</plugin>

</plugins>

</pluginManagement>

<plugins>

<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>${mysql.version}</version>

</dependency>

</dependencies>

<configuration>

<driver>com.mysql.jdbc.Driver</driver>

<url>jdbc:mysql://localhost:3306/test</url>

<username>scott</username>

<password>tiger</password>

</configuration>

<executions>

<execution>

<id>drop-table</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>create-table</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>insert-data</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

</executions>

</plugin>

</plugins>

</build>

 

But, this does not work.

 

I read and read usage page.

- http://mojo.codehaus.org/sql-maven-plugin/usage.html

- http://mojo.codehaus.org/sql-maven-plugin/plugin-info.html 

These pages are contain "...", so these can't help me.

 

Where can I find complete example pom.xml file?

 


  


-----Original Message-----
From: "Anders Hammar"<[hidden email]>
To: "Mojo Users List"<[hidden email]>;
Cc:
Sent: 2015-02-02 (월) 22:08:38
Subject: Re: [mojo-user] mvn test works, but sql:execute does not work
 

It's because you don't have any configuration set for "mvn sql:execute". You need to move any configuration you want for maven execution outside the build lifecycle to the pluginManagement section (build/pluginManagement/plugins/plugin/configuration instead of build/plugins/plugin/configuration).
/Anders

On Mon, Feb 2, 2015 at 2:05 PM, 신상재 <[hidden email]> wrote:


I set up sql-maven-plugin like this:

<build>

<plugins>

<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>${mysql.version}</version>

</dependency>

</dependencies>

<configuration>

<driver>com.mysql.jdbc.Driver</driver>

<url>jdbc:mysql://localhost:3306/test</url>

<username>scott</username>

<password>tiger</password>

</configuration>

<executions>

<execution>

<id>drop-table</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>create-table</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>insert-data</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

</executions>

</plugin>

</plugins>

</build>

When I execute 'mvn test', sql executed like this:

[INFO] --- sql-maven-plugin:1.5:execute (drop-table) @ pte-webapp-prototype ---

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-bonus-table.1339142444sql

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-salgrade-table.182961079sql

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-dept-table.1442040038sql

[ERROR] Failed to execute: ALTER TABLE DEPT DROP PRIMARY KEY

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'PRIMARY'; check that column/key exists

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-emp-table.1792844234sql

[ERROR] Failed to execute: ALTER TABLE EMP DROP FOREIGN KEY FK_DEPTNO

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'FK_DEPTNO'; check that column/key exists

[ERROR] Failed to execute:

ALTER TABLE EMP DROP PRIMARY KEY

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'PRIMARY'; check that column/key exists

[ERROR] Failed to execute:

DROP INDEX PK_EMP ON EMP

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'PK_EMP'; check that column/key exists

[INFO] 5 of 9 SQL statements executed successfully

.....

But when I execute 'mvn sql:execute', sql does not work at all:

[INFO] ------------------------------------------------------------------------

[INFO] Building pte-webapp-prototype Maven Webapp 1.1.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] --- sql-maven-plugin:1.5:execute (default-cli) @ pte-webapp-prototype ---

[INFO] 0 of 0 SQL statements executed successfully

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 1.598 s

Why 'mvn test' is ok but 'mvn sql:execute' is not?

Which part of my configuration is wrong?

 
Reply | Threaded
Open this post in threaded view
|

Re: mvn test works, but sql:execute does not work

Anders Hammar
Don't copy the executions to pluginManagement. If there is any config from an execution that you need for CLI, then you should put that within the plugin config of pluginMangement.
 
/Anders

On Mon, Feb 2, 2015 at 2:25 PM, 신상재 <[hidden email]> wrote:

 

Thanks for advice.

I copy sql-maven-plugin configuration under <pluginManagement>

and remove <phrase> block like this: 

 

<build>

<pluginManagement>

<plugins>

<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>${mysql.version}</version>

</dependency>

</dependencies>

<configuration>

<driver>com.mysql.jdbc.Driver</driver>

<url>jdbc:mysql://localhost:3306/test</url>

<username>scott</username>

<password>tiger</password>

</configuration>

<executions>

<execution>

<id>drop-table</id>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>create-table</id>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>insert-data</id>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

</executions>

</plugin>

</plugins>

</pluginManagement>

<plugins>

<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>${mysql.version}</version>

</dependency>

</dependencies>

<configuration>

<driver>com.mysql.jdbc.Driver</driver>

<url>jdbc:mysql://localhost:3306/test</url>

<username>scott</username>

<password>tiger</password>

</configuration>

<executions>

<execution>

<id>drop-table</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>create-table</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>insert-data</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

</executions>

</plugin>

</plugins>

</build>

 

But, this does not work.

 

I read and read usage page.

- http://mojo.codehaus.org/sql-maven-plugin/usage.html

- http://mojo.codehaus.org/sql-maven-plugin/plugin-info.html 

These pages are contain "...", so these can't help me.

 

Where can I find complete example pom.xml file?

 


  


-----Original Message-----
From: "Anders Hammar"<[hidden email]>
To: "Mojo Users List"<[hidden email]>;
Cc:
Sent: 2015-02-02 (월) 22:08:38
Subject: Re: [mojo-user] mvn test works, but sql:execute does not work
 

It's because you don't have any configuration set for "mvn sql:execute". You need to move any configuration you want for maven execution outside the build lifecycle to the pluginManagement section (build/pluginManagement/plugins/plugin/configuration instead of build/plugins/plugin/configuration).
/Anders

On Mon, Feb 2, 2015 at 2:05 PM, 신상재 <[hidden email]> wrote:


I set up sql-maven-plugin like this:

<build>

<plugins>

<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>${mysql.version}</version>

</dependency>

</dependencies>

<configuration>

<driver>com.mysql.jdbc.Driver</driver>

<url>jdbc:mysql://localhost:3306/test</url>

<username>scott</username>

<password>tiger</password>

</configuration>

<executions>

<execution>

<id>drop-table</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/drop-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>create-table</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/ddl/create-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

<execution>

<id>insert-data</id>

<phase>process-test-resources</phase>

<goals>

<goal>execute</goal>

</goals>

<configuration>

<autocommit>true</autocommit>

<srcFiles>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-bonus-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-salgrade-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-dept-table.sql</srcFile>

<srcFile>${basedir}/src/test/sql/mysql/example/dml/insert-emp-table.sql</srcFile>

</srcFiles>

<onError>continue</onError>

</configuration>

</execution>

</executions>

</plugin>

</plugins>

</build>

When I execute 'mvn test', sql executed like this:

[INFO] --- sql-maven-plugin:1.5:execute (drop-table) @ pte-webapp-prototype ---

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-bonus-table.1339142444sql

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-salgrade-table.182961079sql

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-dept-table.1442040038sql

[ERROR] Failed to execute: ALTER TABLE DEPT DROP PRIMARY KEY

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'PRIMARY'; check that column/key exists

[INFO] Executing file: C:\Users\bomber\AppData\Local\Temp\drop-emp-table.1792844234sql

[ERROR] Failed to execute: ALTER TABLE EMP DROP FOREIGN KEY FK_DEPTNO

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'FK_DEPTNO'; check that column/key exists

[ERROR] Failed to execute:

ALTER TABLE EMP DROP PRIMARY KEY

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'PRIMARY'; check that column/key exists

[ERROR] Failed to execute:

DROP INDEX PK_EMP ON EMP

[ERROR] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Can't DROP 'PK_EMP'; check that column/key exists

[INFO] 5 of 9 SQL statements executed successfully

.....

But when I execute 'mvn sql:execute', sql does not work at all:

[INFO] ------------------------------------------------------------------------

[INFO] Building pte-webapp-prototype Maven Webapp 1.1.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] --- sql-maven-plugin:1.5:execute (default-cli) @ pte-webapp-prototype ---

[INFO] 0 of 0 SQL statements executed successfully

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 1.598 s

Why 'mvn test' is ok but 'mvn sql:execute' is not?

Which part of my configuration is wrong?