<?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>io.vertx</groupId>
    <artifactId>vertx-parent</artifactId>
    <version>3.0.0-dev_preview1</version>
  </parent>

  <artifactId>vertx-lang-groovy</artifactId>
  <version>3.0.0-dev_preview1</version>

  <name>Vert.x Groovy Language Support</name>

  <properties>
    <vertx.version>3.0.0-dev_preview1</vertx.version>
    <asciidoc.dir>${project.basedir}/src/main/asciidoc</asciidoc.dir>
  </properties>

  <dependencies>

    <!-- What we need at runtime -->
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-core</artifactId>
      <version>${vertx.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <version>2.3.7</version>
    </dependency>

    <!-- Not needed at runtime -->
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-codegen</artifactId>
      <scope>provided</scope>
      <version>${vertx.version}</version>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-docgen</artifactId>
      <version>${vertx.version}</version>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-codetrans</artifactId>
      <version>${vertx.version}</version>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-codegen</artifactId>
      <version>${vertx.version}</version>
      <scope>provided</scope>
      <classifier>sources</classifier>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-core</artifactId>
      <version>${vertx.version}</version>
      <scope>provided</scope>
      <classifier>sources</classifier>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.16</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.6.2</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.mvel</groupId>
      <artifactId>mvel2</artifactId>
      <version>2.2.0.Final</version>
      <scope>provided</scope>
    </dependency>

    <!-- Test dependencies -->
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-core</artifactId>
      <type>test-jar</type>
      <version>${vertx.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <configuration>
            <additionalClasspathElements>
              <additionalClasspathElement>${project.build.testSourceDirectory}</additionalClasspathElement>
              <additionalClasspathElement>${project.basedir}/src/main/resources</additionalClasspathElement>
            </additionalClasspathElements>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <executions>
            <execution>
              <id>default-clean</id>
              <configuration>
                <filesets>
                  <fileset>
                    <directory>src/main/groovy/io/vertx/groovy/core</directory>
                  </fileset>
                  <fileset>
                    <directory>${asciidoc.dir}</directory>
                  </fileset>
                </filesets>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <!-- Unpack vertx-core source code to target/sources/vertx-core -->
          <execution>
            <id>unpack-vertx-core</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>io.vertx</groupId>
                  <artifactId>vertx-core</artifactId>
                  <version>${vertx.version}</version>
                  <classifier>sources</classifier>
                </artifactItem>
              </artifactItems>
              <outputDirectory>${project.build.directory}/sources/vertx-core</outputDirectory>
            </configuration>
          </execution>
          <!-- Unpack codegen source code to target/sources/codegen -->
          <execution>
            <id>unpack-codegen</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>io.vertx</groupId>
                  <artifactId>vertx-codegen</artifactId>
                  <version>${vertx.version}</version>
                  <classifier>sources</classifier>
                </artifactItem>
              </artifactItems>
              <outputDirectory>${project.build.directory}/sources/codegen</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.bsc.maven</groupId>
        <artifactId>maven-processor-plugin</artifactId>
        <version>2.2.4</version>
        <executions>
          <!-- Run the annotation processor on vertx-core and generate the Groovy API -->
          <execution>
            <id>generate-vertx-core</id>
            <goals>
              <goal>process</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
              <systemProperties>
                <java.util.logging.SimpleFormatter.format>%4$s: %3$s - %5$s %6$s%n</java.util.logging.SimpleFormatter.format>
              </systemProperties>
              <processors>
                <processor>io.vertx.codegen.CodeGenProcessor</processor>
                <processor>io.vertx.docgen.DocGenProcessor</processor>
              </processors>
              <optionMap>
                <generators>groovy</generators>
                <outputDirectory>${project.basedir}/src/main</outputDirectory>
                <docgen.output>${asciidoc.dir}</docgen.output>
              </optionMap>
              <sourceDirectory>${project.build.directory}/sources/vertx-core</sourceDirectory>
            </configuration>
          </execution>
          <!-- Run the annotation processor on codegen and generate the codegen API -->
          <execution>
            <id>generate-codegen</id>
            <goals>
              <goal>process</goal>
            </goals>
            <phase>generate-test-sources</phase>
            <configuration>
              <systemProperties>
                <java.util.logging.SimpleFormatter.format>%4$s: %3$s - %5$s %6$s%n</java.util.logging.SimpleFormatter.format>
              </systemProperties>
              <processors>
                <processor>io.vertx.codegen.CodeGenProcessor</processor>
              </processors>
              <optionMap>
                <outputDirectory>${project.basedir}/src/test/</outputDirectory>
              </optionMap>
              <sourceDirectory>${project.build.directory}/sources/codegen</sourceDirectory>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.codehaus.gmavenplus</groupId>
        <artifactId>gmavenplus-plugin</artifactId>
        <version>1.2</version>
        <executions>
          <execution>
            <goals>
              <goal>addSources</goal>
              <goal>addTestSources</goal>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.bluetrainsoftware.maven</groupId>
        <artifactId>groovydoc-maven-plugin</artifactId>
        <version>1.3</version>
        <executions>
          <execution>
            <id>attach-docs</id>
            <phase>package</phase>
            <goals>
              <goal>attach-docs</goal>
            </goals>
            <configuration>
              <destinationDirectory>${project.build.directory}/docs/groovydoc</destinationDirectory>
              <scope>public</scope>
              <skipJavadoc>true</skipJavadoc>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.asciidoctor</groupId>
        <artifactId>asciidoctor-maven-plugin</artifactId>
        <version>1.5.0</version>
        <executions>
          <execution>
            <goals>
              <goal>process-asciidoc</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <sourceDirectory>${asciidoc.dir}</sourceDirectory>
              <sourceDocumentName>index.adoc</sourceDocumentName>
              <outputDirectory>${project.build.directory}/docs</outputDirectory>
              <backend>html</backend>
              <doctype>book</doctype>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-groovy-source</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${basedir}/src/main/groovy</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
