<?xml version="1.0" encoding="UTF-8"?>

<!-- ====================================================================== -->
<!--                                                                        -->
<!--  JBoss, the OpenSource J2EE webOS                                      -->
<!--                                                                        -->
<!--  Distributable under LGPL license.                                     -->
<!--  See terms of license at http://www.gnu.org.                           -->
<!--                                                                        -->
<!-- ====================================================================== -->

<!-- $Id: pom.xml 3010 2008-11-20 08:30:16Z tom.baeyens@jboss.com $ -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <!-- Module Info -->
  <modelVersion>4.0.0</modelVersion>
  <name>jBPM 4 - DB</name>
  <groupId>org.jbpm.jbpm4</groupId>
  <artifactId>jbpm-db</artifactId>
  <packaging>jar</packaging>

  <!-- Parent -->
  <parent>
    <groupId>org.jbpm.jbpm4</groupId>
    <artifactId>jbpm</artifactId>
    <version>4.1</version>
    <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}"/>
                    <property name="database" value="${database}"/>
										<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}/${jbpm.previous.version}</previous.version.directory>
			</properties>
		</profile>
  </profiles>

  <!-- Dependencies -->
  <dependencies>
    <dependency>
      <groupId>org.jbpm.jbpm4</groupId>
      <artifactId>jbpm-jpdl</artifactId>
    </dependency>
    <dependency>
      <groupId>hsqldb</groupId>
      <artifactId>hsqldb</artifactId>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <dependency>
      <groupId>postgresql</groupId>
      <artifactId>postgresql</artifactId>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
          	<id>create-drop-script</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <property name="project.output.dir" value="${project.build.outputDirectory}"/>
                <ant antfile="scripts/antrun-schema.xml" target="create-schema" inheritRefs="yes"/>
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>