<?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">

  <parent>
    <groupId>io.vertx</groupId>
    <artifactId>vertx-parent</artifactId>
    <version>3.0.0-dev_preview1</version>
  </parent>

  <modelVersion>4.0.0</modelVersion>

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

  <properties>
    <vertx.version>3.0.0-dev_preview1</vertx.version>
    <asciidoc.dir>${project.basedir}/src/main/asciidoc</asciidoc.dir>
    <tools.jar>${java.home}/../lib/tools.jar</tools.jar>
  </properties>

  <dependencies>

    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-codegen</artifactId>
      <version>${vertx.version}</version>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-codegen</artifactId>
      <version>${vertx.version}</version>
      <classifier>sources</classifier>
      <scope>provided</scope>
    </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-core</artifactId>
      <version>${vertx.version}</version>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-core</artifactId>
      <version>${vertx.version}</version>
      <classifier>sources</classifier>
      <scope>provided</scope>
    </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>
    </dependency>
    <dependency>
      <groupId>org.mvel</groupId>
      <artifactId>mvel2</artifactId>
      <version>2.2.0.Final</version>
      <scope>provided</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>
            <systemPropertyVariables>
              <java.util.logging.SimpleFormatter.format>%4$s: %3$s - %5$s %6$s%n</java.util.logging.SimpleFormatter.format>
            </systemPropertyVariables>
            <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>${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/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 js 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>
                <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 js codegen -->
          <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>com.phasebash.jsdoc</groupId>
        <artifactId>jsdoc3-maven-plugin</artifactId>
        <version>1.1.0</version>
        <executions>
          <execution>
            <phase>prepare-package</phase>
            <goals>
              <goal>jsdoc3</goal>
            </goals>
            <configuration>
              <recursive>false</recursive>
              <directoryRoots>
                <directoryRoot>${basedir}/src/main/resources/vertx-js</directoryRoot>
              </directoryRoots>
              <outputDirectory>${project.build.directory}/docs/jsdoc</outputDirectory>
            </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>
    </plugins>
  </build>

</project>
