sql-maven-plugin按照pom.xml中列出的确切顺序执行文件

时间:2013-01-06 17:01:05

标签: sql maven execution

我想就sql-mvn-plugin提出一些帮助。根据{{​​3}},如果pom.xml文件没有关于文件顺序的任何内容 - orderFile 标记 - 则文件将按照列出的确切顺序执行。但事实并非如此!如果删除 orderFile 标记,则默认情况下将按升序执行文件。

老实说,我想在安装过程中使用此插件创建数据库并导入数据。由于我正在使用超过20个表 - 脚本,表和序列以及约束 - 被分成单独的文件 - 我无法处理没有有意义名称的文件。这将是地狱本身,使用这个插件将毫无价值。另一方面,我不希望在maven外面执行此步骤,因为在我的脑海中,maven是构建,测试和部署我的应用程序以及避免脚本地狱的工具的工具。

正如您在下面的示例中所看到的,未定义执行顺序,尽管在执行期间执行了第一个文件,但执行了* procedures / test_activate_all_partners.sql *,这是文件顺序中的倒数第二个!根据我的理解,第一个执行的文件应该是* tables / datapoint_component_types / table.sql *。

我的pom.xml:

              <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>sql-maven-plugin</artifactId>
                <version>1.5</version>
                <dependencies>
                    <dependency>
                        <groupId>postgresql</groupId>
                        <artifactId>postgresql</artifactId>
                        <version>9.1-901.jdbc4</version>
                    </dependency>            
                </dependencies>
                <configuration>
                    <driver>org.postgresql.Driver</driver>
                    <url>jdbc:postgresql://localhost:5432/database</url>
                    <username>postgres</username>
                    <password>postgres</password>
                </configuration>
                <executions>
                    <execution>
                        <id>default-cli</id>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <delimiter>/</delimiter>
                            <delimiterType>normal</delimiterType>
                            <autocommit>true</autocommit>
                            <fileset>
                                <!-- at home -->
                                <basedir>d:/PRIVAT/Projects/java/bigProject/</basedir>
                                <includes>
                                    <!-- tables -->
                                    <include>tables/datapoint_component_types/table.sql</include>
                                    <include>tables/datapoint_datapoint_components/table.sql</include>
                                    <include>tables/datapoint_java_result_types/table.sql</include>
                                    <include>tables/datapoint_postgres_result_types/table.sql</include>
                                    <include>tables/datapoint_result_types/table.sql</include>
                                    <include>tables/datapoints/table.sql</include>
                                    <include>tables/datatype_descs/table.sql</include>
                                    <include>tables/datatypes/table.sql</include>
                                    <include>tables/disabled_period/table.sql</include>
                                    <include>tables/file_extensions/table.sql</include>
                                    <include>tables/logs/table.sql</include>
                                    <include>tables/partner_datatypes/table.sql</include>
                                    <include>tables/partner_processes/table.sql</include>
                                    <include>tables/partner_protocols/table.sql</include>
                                    <include>tables/partner_protocols_attributes_details/table.sql</include>
                                    <include>tables/partners/table.sql</include>
                                    <include>tables/process_step/table.sql</include>
                                    <include>tables/process_step_actions/table.sql</include>
                                    <include>tables/process_steps_param/table.sql</include>
                                    <include>tables/process_steps_partner_processes/table.sql</include>
                                    <include>tables/processes/table.sql</include>
                                    <include>tables/protocol_attributes/table.sql</include>
                                    <include>tables/protocols/table.sql</include>
                                    <include>tables/result_tables/table.sql</include>
                                    <include>tables/valid_period/table.sql</include>
                                    <!-- constrains -->
                                    <include>tables/datapoint_component_types/sequences.sql</include>
                                    <include>tables/datapoint_datapoint_components/sequences.sql</include>
                                    <include>tables/datapoint_java_result_types/sequences.sql</include>
                                    <include>tables/datapoint_postgres_result_types/sequences.sql</include>
                                    <include>tables/datapoint_result_types/sequences.sql</include>
                                    <include>tables/datapoints/sequences.sql</include>
                                    <include>tables/datatype_descs/sequences.sql</include>
                                    <include>tables/datatypes/sequences.sql</include>
                                    <include>tables/disabled_period/sequences.sql</include>
                                    <include>tables/file_extensions/sequences.sql</include>
                                    <include>tables/logs/sequences.sql</include>
                                    <include>tables/partner_datatypes/sequences.sql</include>
                                    <include>tables/partner_processes/sequences.sql</include>
                                    <include>tables/partner_protocols/sequences.sql</include>
                                    <include>tables/partner_protocols_attributes_details/sequences.sql</include>
                                    <include>tables/partners/sequences.sql</include>
                                    <include>tables/process_step/sequences.sql</include>
                                    <include>tables/process_step_actions/sequences.sql</include>
                                    <include>tables/process_steps_param/sequences.sql</include>
                                    <include>tables/process_steps_partner_processes/sequences.sql</include>
                                    <include>tables/processes/sequences.sql</include>
                                    <include>tables/protocol_attributes/sequences.sql</include>
                                    <include>tables/protocols/sequences.sql</include>
                                    <include>tables/result_tables/sequences.sql</include>
                                    <include>tables/valid_period/sequences.sql</include>
                                    <!-- sequences -->
                                    <include>tables/datapoint_component_types/constraints.sql</include>
                                    <include>tables/datapoint_datapoint_components/constraints.sql</include>
                                    <include>tables/datapoint_java_result_types/constraints.sql</include>
                                    <include>tables/datapoint_postgres_result_types/constraints.sql</include>
                                    <include>tables/datapoint_result_types/constraints.sql</include>
                                    <include>tables/datapoints/constraints.sql</include>
                                    <include>tables/datatype_descs/constraints.sql</include>
                                    <include>tables/datatypes/constraints.sql</include>
                                    <include>tables/disabled_period/constraints.sql</include>
                                    <include>tables/file_extensions/constraints.sql</include>
                                    <include>tables/logs/constraints.sql</include>
                                    <include>tables/partner_datatypes/constraints.sql</include>
                                    <include>tables/partner_processes/constraints.sql</include>
                                    <include>tables/partner_protocols/constraints.sql</include>
                                    <include>tables/partner_protocols_attributes_details/constraints.sql</include>
                                    <include>tables/partners/constraints.sql</include>
                                    <include>tables/process_step/constraints.sql</include>
                                    <include>tables/process_step_actions/constraints.sql</include>
                                    <include>tables/process_steps_param/constraints.sql</include>
                                    <include>tables/process_steps_partner_processes/constraints.sql</include>
                                    <include>tables/processes/constraints.sql</include>
                                    <include>tables/protocol_attributes/constraints.sql</include>
                                    <include>tables/protocols/constraints.sql</include>
                                    <include>tables/result_tables/constraints.sql</include>
                                    <include>tables/valid_period/constraints.sql</include>
                                    <!-- procedures -->
                                    <include>procedures/test_activate_all_partners.sql</include>
                                    <!-- testdata -->
                                    <include>testdata/data.sql</include>
                                </includes>
                            </fileset>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

输出:

d:/PRIVAT/Projects/java/bigProject>mvn sql:execute
[INFO] Scanning for projects...
...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building EJB 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sql-maven-plugin:1.5:execute (default-cli) @ DiLibCoreEJB ---
[INFO] Executing file: sql\procedures\test_activate_all_partners.sql
[INFO] Executing file: sql\tables\datapoints\constraints.sql
[ERROR] Failed to execute:
 ALTER TABLE
 datapoints
 ADD
 CONSTRAINT datapoints_pkey PRIMARY KEY (datapoint_id );

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.503s
[INFO] Finished at: Sun Jan 06 17:49:40 CET 2013
[INFO] Final Memory: 4M/77M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:sql-maven-plugin:1.5:execute (default-cli) on project DiLibCoreEJB: ERROR: relation "datapoints" does not exist -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
d:/PRIVAT/Projects/java/bigProject>

提前感谢您的帮助!

0 个答案:

没有答案