[jbpm-commits] JBoss JBPM SVN: r5463 - in jbpm4/trunk/modules/db: scripts and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Aug 11 07:15:14 EDT 2009


Author: alex.guizar at jboss.com
Date: 2009-08-11 07:15:14 -0400 (Tue, 11 Aug 2009)
New Revision: 5463

Added:
   jbpm4/trunk/modules/db/scripts/antrun-upgrade.xml
Modified:
   jbpm4/trunk/modules/db/pom.xml
   jbpm4/trunk/modules/db/scripts/antrun-schema.xml
Log:
[JBPM-1995] build script to calculate jBPM DB differences 
first stab at upgrade buildfile, fails while creating previous schema

Modified: jbpm4/trunk/modules/db/pom.xml
===================================================================
--- jbpm4/trunk/modules/db/pom.xml	2009-08-11 09:29:09 UTC (rev 5462)
+++ jbpm4/trunk/modules/db/pom.xml	2009-08-11 11:15:14 UTC (rev 5463)
@@ -27,6 +27,68 @@
     <relativePath>../../pom.xml</relativePath>
   </parent>
 
+  <profiles>
+		<profile>
+			<id>upgrade</id>
+			<activation>
+				<property>
+					<name>jbpm.previous.version</name>
+				</property>
+			</activation>
+
+			<build>
+				<plugins>
+					<plugin>
+						<artifactId>maven-dependency-plugin</artifactId>
+						<executions>
+							<execution>
+								<id>previous-version</id>
+								<phase>generate-resources</phase>
+								<goals>
+									<goal>unpack</goal>
+								</goals>
+								<configuration>
+								  <artifactItems>
+								  	<artifactItem>
+								  		<groupId>org.jbpm.jbpm4</groupId>
+								  		<artifactId>jbpm-db</artifactId>
+								  		<version>${jbpm.previous.version}</version>
+								  	</artifactItem>
+								  </artifactItems>
+								  <outputDirectory>${previous.version.directory}</outputDirectory>
+								</configuration>
+							</execution>
+						</executions>
+					</plugin>
+	
+					<plugin>
+						<artifactId>maven-antrun-plugin</artifactId>
+						<executions>
+							<execution>
+								<id>upgrade-script</id>
+								<phase>process-resources</phase>
+								<goals>
+									<goal>run</goal>
+								</goals>
+								<configuration>
+								  <tasks>
+										<property name="project.output.dir" value="${project.build.outputDirectory}"/>
+										<property name="previous.version.dir" value="${previous.version.directory}"/>
+										<ant antfile="scripts/antrun-upgrade.xml" target="upgrade-schema" inheritRefs="yes"/>
+									</tasks>
+								</configuration>
+							</execution>
+						</executions>
+					</plugin>
+				</plugins>
+			</build>
+
+			<properties>
+				<previous.version.directory>${project.build.directory}/previous</previous.version.directory>
+			</properties>
+		</profile>
+  </profiles>
+
   <!-- Dependencies -->
   <dependencies>
     <dependency>
@@ -45,10 +107,6 @@
       <groupId>postgresql</groupId>
       <artifactId>postgresql</artifactId>
     </dependency>
-    <dependency>
-      <groupId>net.sourceforge.jtds</groupId>
-      <artifactId>jtds</artifactId>
-    </dependency>
   </dependencies>
 
   <build>
@@ -57,17 +115,15 @@
         <artifactId>maven-antrun-plugin</artifactId>
         <executions>
           <execution>
-            <id>create-db-schemas</id>
-            <phase>process-resources</phase>
+          	<id>create-drop-script</id>
+            <phase>generate-resources</phase>
             <goals>
               <goal>run</goal>
             </goals>
             <configuration>
               <tasks>
-                <property name="maven.runtime.classpath" refid="maven.runtime.classpath"/>
-                <ant antfile="scripts/antrun-schema.xml"
-                     target="create-schema">
-                </ant>
+                <property name="project.output.dir" value="${project.build.outputDirectory}"/>
+                <ant antfile="scripts/antrun-schema.xml" target="create-schema" inheritRefs="yes"/>
               </tasks>
             </configuration>
           </execution>

Modified: jbpm4/trunk/modules/db/scripts/antrun-schema.xml
===================================================================
--- jbpm4/trunk/modules/db/scripts/antrun-schema.xml	2009-08-11 09:29:09 UTC (rev 5462)
+++ jbpm4/trunk/modules/db/scripts/antrun-schema.xml	2009-08-11 11:15:14 UTC (rev 5463)
@@ -15,22 +15,17 @@
   <!-- ================================================================== -->
 
   <target name="create-schema">
-    <echo message="${maven.runtime.classpath}"/>
-
     <taskdef name="schemaexport"
-             classname="org.hibernate.tool.hbm2ddl.SchemaExportTask">
-      <classpath path="${maven.runtime.classpath}"/>
-    </taskdef>
+             classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
+             classpathref="maven.compile.classpath" />
 
-    <mkdir dir="target"/>
-
     <!-- HsqlDB -->
     <create-ddl db="hsqldb"/>
 
     <!-- MySQL -->
     <create-ddl db="mysql"/>
     <!--TODO: https://jira.jboss.org/jira/browse/JBPM-2071 -->
-    <replace file="target/jbpm.mysql.create.sql" token="BLOB_VALUE_ blob" value="BLOB_VALUE_ longblob" />
+    <replace file="${project.output.dir}/jbpm.mysql.create.sql" token="BLOB_VALUE_ blob" value="BLOB_VALUE_ longblob" />
 
     <!-- Oracle -->
     <create-ddl db="oracle"/>
@@ -50,22 +45,20 @@
     <attribute name="db"/>
 
     <sequential>
-      <echo></echo>
       <echo>=====================</echo>
       <echo>Create DDL @{db}</echo>
       
-      <schemaexport output="target/jbpm.@{db}.create.sql"
+      <schemaexport output="${project.output.dir}/jbpm.@{db}.create.sql"
                     create="yes" drop="no"
                     config="src/main/config/@{db}.hibernate.cfg.xml"
                     text="yes" delimiter=";"
                     quiet="yes"/>
-      <schemaexport output="target/jbpm.@{db}.drop.sql"
+      <schemaexport output="${project.output.dir}/jbpm.@{db}.drop.sql"
                     create="no" drop="yes"
                     config="src/main/config/@{db}.hibernate.cfg.xml"
                     text="yes" delimiter=";"
                     quiet="yes"/>
 
-      <echo>Done.</echo>
       <echo>=====================</echo>
     </sequential>
   </macrodef>

Added: jbpm4/trunk/modules/db/scripts/antrun-upgrade.xml
===================================================================
--- jbpm4/trunk/modules/db/scripts/antrun-upgrade.xml	                        (rev 0)
+++ jbpm4/trunk/modules/db/scripts/antrun-upgrade.xml	2009-08-11 11:15:14 UTC (rev 5463)
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+
+	<!-- ============================================ -->
+	<!-- jBPM database schema                         -->
+	<!-- ============================================ -->
+
+	<target name="upgrade-schema">
+		<taskdef name="schemaupdate"
+		         classname="org.hibernate.tool.hbm2ddl.SchemaUpdateTask"
+		         classpathref="maven.compile.classpath" />
+    <taskdef name="schemaexport"
+             classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
+		         classpathref="maven.compile.classpath"/>
+
+    <!-- HSQLDB -->
+    <upgrade-ddl db="hsqldb"/>
+
+    <!-- MySQL -->
+    <upgrade-ddl db="mysql"/>
+
+    <!-- Oracle -->
+    <upgrade-ddl db="oracle"/>
+
+    <!-- PostgreSQL -->
+    <upgrade-ddl db="postgresql"/>
+	</target>
+
+	<!-- ============================================ -->
+	<!-- Macro definitions                            -->
+	<!-- ============================================ -->
+
+	<macrodef name="upgrade-ddl">
+		<attribute name="db" />
+
+		<sequential>
+			<echo>=====================</echo>
+			<echo>Upgrade DDL @{db}</echo>
+
+			<property file="${user.home}/.jbpm4/jdbc/@{db}.properties" prefix="@{db}"/>
+			<echo>driver... ${@{db}.jdbc.driver}</echo>
+			<echo>url...... ${@{db}.jdbc.url}</echo>
+			<echo>username. ${@{db}.jdbc.username}</echo>
+		  <echo>password. ${@{db}.jdbc.password}</echo>
+			<!-- drop current schema if exists -->
+			<sql src="${project.output.dir}/jbpm.@{db}.drop.sql" url="${@{db}.jdbc.url}"
+			     driver="${@{db}.jdbc.driver}" classpathref="maven.compile.classpath"
+			     userid="${@{db}.jdbc.username}" password="${@{db}.jdbc.password}"
+			     autocommit="yes" onerror="continue"/>
+			<!-- create previous version schema -->
+			<sql src="${previous.version.dir}/jbpm.@{db}.create.sql" url="${@{db}.jdbc.url}"
+			     driver="${@{db}.jdbc.driver}" classpathref="maven.compile.classpath"
+			     userid="${@{db}.jdbc.username}" password="${@{db}.jdbc.password}"
+			     autocommit="yes"/>
+			<!-- generate schema upgrade script -->
+			<schemaupdate outputFile="${project.build.dir}/jbpm.@{db}.update.sql"
+			              config="src/main/config/@{db}.hibernate.cfg.xml"
+			              properties="${user.home}/.jbpm4/@{db}.properties"
+			              text="yes" delimiter=";"/>
+			<!-- drop previous version schema -->
+			<sql src="${previous.version.dir}/jbpm.@{db}.drop.sql" url="${@{db}.jdbc.url}"
+			     driver="${@{db}.jdbc.driver}" classpathref="maven.compile.classpath"
+			     userid="${@{db}.jdbc.username}" password="${@{db}.jdbc.password}"
+			     autocommit="yes"/>
+
+			<echo>=====================</echo>
+		</sequential>
+	</macrodef>
+</project>
\ No newline at end of file



More information about the jbpm-commits mailing list