<?xml version="1.0"?>
<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">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.quartz-scheduler</groupId>
    <artifactId>quartz-parent</artifactId>
    <version>2.3.2</version>
  </parent>

  <artifactId>quartz-kit</artifactId>
  <packaging>pom</packaging>
  <name>quartz-kit</name>

  <properties>
    <productName>quartz</productName>
    <kitFolder>${productName}-${project.version}</kitFolder>
    <tarballName>${kitFolder}-distribution</tarballName>
    <root.dir>${project.build.directory}/${kitFolder}</root.dir>
    <gmaven-plugin.version>1.3</gmaven-plugin.version>
    <skipJavadoc>true</skipJavadoc>
    <skipSources>true</skipSources>
  </properties>
  
  <modules>
    <module>examples</module>
  </modules>

  <dependencies>
    <dependency>
      <groupId>org.quartz-scheduler</groupId>
      <artifactId>quartz</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.quartz-scheduler</groupId>
      <artifactId>quartz-jobs</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>    
    <dependency>
      <groupId>com.mchange</groupId>
      <artifactId>c3p0</artifactId>
      <version>${c3p0.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>${slf4j.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>${log4j.version}</version>
      <scope>provided</scope>
    </dependency>  
  </dependencies>

  <profiles>
    <profile>
      <id>includeJavadoc</id>
      <activation>
        <property>
          <name>!skipJavadoc</name>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>org.quartz-scheduler</groupId>
          <artifactId>quartz</artifactId>
          <version>${project.version}</version>
          <classifier>javadoc</classifier>
          <scope>provided</scope>
        </dependency> 
      </dependencies>
    </profile>
  </profiles>
  
  <build>
    <plugins>
      <plugin>
        <groupId>com.github.goldin</groupId>
        <artifactId>copy-maven-plugin</artifactId>
        <version>0.2.3.8</version>
        <configuration>
          <verbose>false</verbose>
          <resources>
            <!-- clean up -->
            <resource>
              <runIf>{{ new File( project.build.directory, "${kitFolder}" ).isDirectory() }}</runIf>
              <directory>${root.dir}</directory>
              <includes>
                <include>**/**</include>
              </includes>
              <clean>true</clean>
              <cleanEmptyDirectories>true</cleanEmptyDirectories>
            </resource>
            <!-- skeleton -->                
            <resource>
              <targetPath>${root.dir}</targetPath>
              <directory>${basedir}/src/main/assembly/root</directory>
              <preservePath>true</preservePath>
            </resource>
            <!-- lib -->                
            <resource>
              <targetPath>${root.dir}/lib</targetPath>
              <dependencies>
                <dependency>
                  <groupId>org.quartz-scheduler</groupId>
                  <artifactId>quartz</artifactId>
                </dependency>
                <dependency>
                  <groupId>org.quartz-scheduler</groupId>
                  <artifactId>quartz-jobs</artifactId>
                </dependency>                
                <dependency>
                  <groupId>com.mchange</groupId>
                  <artifactId>c3p0</artifactId>
                </dependency>                
                <dependency>
                  <groupId>org.slf4j</groupId>
                  <artifactId>slf4j-log4j12</artifactId>
                </dependency>
                <dependency>
                  <groupId>org.slf4j</groupId>
                  <artifactId>slf4j-api</artifactId>
                </dependency>
                <depedency>
                  <groupId>log4j</groupId>
                  <artifactId>log4j</artifactId>
                </depedency>
              </dependencies>
            </resource>
            <!-- src -->
            <resource>
              <targetPath>${root.dir}/src</targetPath>
              <dependency>
                <groupId>org.quartz-scheduler</groupId>
                <artifactId>quartz</artifactId>
                <classifier>sources</classifier>
              </dependency>
              <unpack>true</unpack>
            </resource>
            <!-- javadoc -->
            <resource>
              <failIfNotFound>false</failIfNotFound>
              <targetPath>${root.dir}/javadoc</targetPath>
              <dependency>
                <groupId>org.quartz-scheduler</groupId>
                <artifactId>quartz</artifactId>
                <classifier>javadoc</classifier>
              </dependency>
              <unpack>true</unpack>
            </resource>
            <!-- examples -->
            <resource>
              <targetPath>${root.dir}/examples/lib</targetPath>
              <dependencies>
                <dependency>
                  <groupId>org.quartz-scheduler</groupId>
                  <artifactId>quartz-examples</artifactId>
                  <version>${project.version}</version>
                </dependency>
                <!-- non public dependency necessary for running example 10 without adding jta.jar in examples/lib -->
                <dependency>
                  <groupId>gf-3122</groupId>
                  <artifactId>gf.javax.transaction</artifactId>
                  <version>1.1</version>
                  <optional>true</optional>
                </dependency>
              </dependencies>
            </resource>
            <!-- examples src -->
            <resource>
              <targetPath>${root.dir}/examples/src</targetPath>
              <directory>${project.basedir}/examples/src/main/java</directory>
              <preservePath>true</preservePath>
            </resource>
          </resources>
        </configuration>
        <executions>
          <execution>
            <id>package-with-no-tc</id>
            <phase>package</phase>
            <goals>
              <goal>copy</goal>
            </goals>
          </execution>
        </executions>            
      </plugin>
      <plugin>
        <groupId>org.codehaus.gmaven</groupId>
        <artifactId>gmaven-plugin</artifactId>
        <version>${gmaven-plugin.version}</version>
        <executions>
          <execution>
            <id>create-tarball</id>
            <phase>package</phase>
            <goals>
              <goal>execute</goal>
            </goals>
            <configuration>         
              <source>
                def srcdir = new File(project.basedir, "target/${kitFolder}") 
                def destFile = new File(project.basedir, "target/${tarballName}.tar.gz") 
                ant.tar(destfile: "${destFile}", longfile: "gnu", compression: "gzip") {
                  tarfileset(dir: "${srcdir}", prefix: "${kitFolder}", excludes: "**/.placeholder,**/bin/**,**/lib/**,**/*.sh,**/*.bat")
                  tarfileset(dir: "${srcdir}", prefix: "${kitFolder}", includes: "**/bin/**,**/lib/**,**/*.sh,**/*.bat", filemode: "755")
                } 
              </source>
            </configuration>
          </execution>              
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.5</version>
        <executions>
          <execution>
            <id>attach-distribution</id>
            <phase>package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <artifacts>
                <artifact>
                  <file>${project.build.directory}/${tarballName}.tar.gz</file>
                  <type>tar.gz</type>
                  <classifier>distribution</classifier>
                </artifact>                
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>      
    </plugins>
  </build>

  <repositories>
    <repository>
      <id>terracotta-snapshots</id>
      <url>http://www.terracotta.org/download/reflector/snapshots</url>
    </repository>
    <repository>
      <id>terracotta-releases</id>
      <url>http://www.terracotta.org/download/reflector/releases</url>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>terracotta-snapshots</id>
      <url>http://www.terracotta.org/download/reflector/snapshots</url>
    </pluginRepository>
    <pluginRepository>
      <id>terracotta-releases</id>
      <url>http://www.terracotta.org/download/reflector/releases</url>
    </pluginRepository>
    <pluginRepository>
      <id>evgenyg.artifactoryonline.com</id>
      <url>http://evgenyg.artifactoryonline.com/evgenyg/repo/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </pluginRepository>    
  </pluginRepositories>

</project>
