<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.sonatype.oss</groupId>
    <artifactId>oss-parent</artifactId>
    <version>7</version>
  </parent>

  <groupId>com.code54.mojo</groupId>
  <artifactId>buildversion-plugin</artifactId>
  <version>1.0.3</version>
  <packaging>maven-plugin</packaging>

  <name>buildversion-plugin</name>
  <description>
    This is a maven plugin that extracts current build information from git
    projects, including: the latest commit hash, timestamp, most recent tag,
    number of commits since most recent tag. It also implements a "follow first
    parent" flavor of git describe.
  </description>

  <url>https://github.com/code54/buildversion-plugin</url>

  <licenses>
    <license>
      <name>Eclipse Public License</name>
      <url>http://www.eclipse.org/legal/epl-v10.html</url>
    </license>
  </licenses>

  <scm>
    <connection>scm:git:git://github.com/code54/buildversion-plugin.git</connection>
    <developerConnection>scm:git:ssh://git@github.com:code54/buildversion-plugin.git</developerConnection>
    <url>https://github.com/code54/buildversion-plugin</url>
    <tag>v1.0.3</tag>
  </scm>

  <properties>
    <clojureMaven.version>0.3.2</clojureMaven.version>
    <maven.version>3.0.4</maven.version>
  </properties>


  <profiles>
    <profile>
      <id>release-sign-artifacts</id>
      <activation>
        <property>
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>1.1</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>


  <build>
    <sourceDirectory>src/main/clojure</sourceDirectory>
    <resources>
      <resource>
        <directory>src/main/clojure</directory>
        <includes>
          <include>**/*.clj</include>
        </includes>
      </resource>
    </resources>

    <plugins>
      <plugin>
        <!-- extract mojo properties from source -->
        <artifactId>maven-plugin-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>default-descriptor</id>
            <phase>process-classes</phase>
            <goals>
              <goal>descriptor</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <!-- add the Clojure-specific extractor to generate the mojo descriptor -->
            <groupId>org.cloudhoist</groupId>
            <artifactId>clojure-maven-mojo-descriptor-extractor</artifactId>
            <version>${clojureMaven.version}</version>
          </dependency>
        </dependencies>
      </plugin>


      <plugin>
        <artifactId>maven-invoker-plugin</artifactId>
        <version>1.5</version>
        <configuration>
          <projectsDirectory>src/it</projectsDirectory>
          <cloneProjectsTo>${project.build.directory}/it/</cloneProjectsTo>
          <pomIncludes>
            <pomInclude>*/pom.xml</pomInclude>
          </pomIncludes>
          <settingsFile>src/it/settings.xml</settingsFile>
          <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
          <preBuildHookScript>setup.groovy</preBuildHookScript>
          <postBuildHookScript>verify.groovy</postBuildHookScript>
          <debug>true</debug>
          <properties>
            <!-- <clojure.version>${clojure.version}</clojure.version> -->
          </properties>
        </configuration>
        <executions>
          <execution>
            <id>integration-test</id>
            <goals>
              <goal>install</goal>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Run tests in Clojure -->
      <plugin>
        <groupId>org.cloudhoist.plugin</groupId>
        <artifactId>zi</artifactId>
        <version>0.4.5</version>
        <executions>
          <execution>
            <id>test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>

          <!-- <execution> -->
          <!--   <id>default-compile</id> -->
          <!--   <phase>compile</phase> -->

          <!--   <goals> -->
          <!--     <goal>compile</goal> -->
          <!--   </goals> -->
          <!-- </execution> -->

        </executions>
        <configuration>
          <initScript>
            (require 'clojure.string)

            (java.lang.System/setProperty
                       "buildversion.maven-target-dir"
                       "${project.build.directory}" )

            (java.lang.System/setProperty
                       "buildversion.maven-bash-source-dir"
                       (clojure.string/replace "${project.build.testSourceDirectory}"
                           #"/java$" "/bash") )

          </initScript>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <tagNameFormat>v@{project.version}</tagNameFormat>
          <autoVersionSubmodules>true</autoVersionSubmodules>
          <localCheckout>true</localCheckout>
          <pushChanges>false</pushChanges>

        </configuration>
      </plugin>
    </plugins>

  </build>


  <dependencies>
    <dependency>
      <groupId>org.clojure</groupId>
      <artifactId>clojure</artifactId>
      <version>1.3.0</version>
    </dependency>

    <dependency>
      <groupId>org.clojure</groupId>
      <artifactId>tools.trace</artifactId>
      <version>0.7.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.cloudhoist</groupId>
      <artifactId>clojure-maven-mojo</artifactId>
      <version>${clojureMaven.version}</version>
    </dependency>

    <dependency>
      <groupId>org.cloudhoist</groupId>
      <artifactId>clojure-maven-mojo-annotations</artifactId>
      <version>${clojureMaven.version}</version>
    </dependency>
    <dependency>
      <groupId>org.cloudhoist</groupId>
      <artifactId>clojure-maven-plexus-component-factory</artifactId>
      <version>${clojureMaven.version}</version>
      <scope>runtime</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>${maven.version}</version>
    </dependency>

    <dependency>
      <groupId>me.raynes</groupId>
      <artifactId>conch</artifactId>
      <version>0.3.1</version>
    </dependency>
  </dependencies>

</project>
