<?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>22</version>
  </parent>

  <modelVersion>4.0.0</modelVersion>

  <artifactId>vertx-codegen</artifactId>
  <name>Vert.x Codegen</name>
  <version>4.5.23</version>

  <scm>
    <connection>scm:git:git@github.com:eclipse-vertx/vertx-codegen.git</connection>
    <developerConnection>scm:git:git@github.com:eclipse-vertx/vertx-codegen.git</developerConnection>
    <url>git@github.com:vert-x3/vertx-sockjs-service-proxy.git</url>
  </scm>

  <properties>
    <asciidoc.dir>${project.basedir}/src/main/asciidoc</asciidoc.dir>
    <jar.manifest>${project.basedir}/src/main/resources/META-INF/MANIFEST.MF</jar.manifest>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-dependencies</artifactId>
        <version>${project.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-docgen</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <executions>
            <execution>
              <id>default-clean</id>
              <configuration>
                <filesets>
                  <fileset>
                    <directory>${project.basedir}/src/converters/generated</directory>
                    <directory>${project.basedir}/src/tck/generated</directory>
                  </fileset>
                </filesets>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <executions>
            <execution>
              <id>default-compile</id>
              <configuration>
                <annotationProcessors>
                  <annotationProcessor>io.vertx.docgen.JavaDocGenProcessor</annotationProcessor>
                </annotationProcessors>
                <compilerArgs>
                  <arg>-Adocgen.source=${asciidoc.dir}</arg>
                  <arg>-Adocgen.output=${project.build.directory}/asciidoc/java</arg>
                </compilerArgs>
                <excludes>
                  <exclude>**/TreeTypeInternal.java</exclude>
                </excludes>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <executions>
            <execution>
              <id>default-jar</id>
              <configuration>
                <excludes>
                  <exclude>io/vertx/core/**</exclude>
                  <exclude>io/vertx/codegen/testmodel/**</exclude>
                  <exclude>com/acme/**</exclude>
                  <exclude>examples/**</exclude>
                </excludes>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <configuration>
            <additionalClasspathElements>
              <additionalClasspathElement>${project.build.testSourceDirectory}</additionalClasspathElement>
              <additionalClasspathElement>${project.basedir}/src/test/testgen1</additionalClasspathElement>
              <additionalClasspathElement>${project.basedir}/src/test/testgen2</additionalClasspathElement>
              <additionalClasspathElement>${project.basedir}/src/test/testgen3</additionalClasspathElement>
              <additionalClasspathElement>${project.basedir}/src/test/testgen4</additionalClasspathElement>
              <additionalClasspathElement>${project.basedir}/src/test/testgen5</additionalClasspathElement>
              <additionalClasspathElement>${project.basedir}/src/test/testgen6</additionalClasspathElement>
              <additionalClasspathElement>${project.basedir}/src/test/testgen7</additionalClasspathElement>
            </additionalClasspathElements>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <configuration>
            <excludes>
              <exclude>io/vertx/core/**</exclude>
              <exclude>examples/**</exclude>
            </excludes>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.fasterxml.jackson.core</groupId>
                  <artifactId>jackson-core</artifactId>
                  <type>jar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>junit</groupId>
                  <artifactId>junit</artifactId>
                  <type>jar</type>
                </artifactItem>
              </artifactItems>
              <outputDirectory>${project.build.directory}/test-classpath</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-source</id>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${basedir}/src/examples/java</source>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>add-test-source</id>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${basedir}/src/converters/java</source>
                <source>${basedir}/src/converters/generated</source>
                <source>${basedir}/src/tck/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.bsc.maven</groupId>
        <artifactId>maven-processor-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
          <systemProperties>
            <java.util.logging.SimpleFormatter.format>%4$s: %3$s - %5$s %6$s%n</java.util.logging.SimpleFormatter.format>
          </systemProperties>
        </configuration>
        <executions>
          <!-- Converters -->
          <execution>
            <id>generate-converters-sources</id>
            <goals>
              <goal>process-test</goal>
            </goals>
            <phase>generate-test-sources</phase>
            <configuration>
              <!-- We use this workaround to have a specific json-mappers.properties file for this gen -->
              <classpathElements>
                <classpathElement>${project.build.outputDirectory}</classpathElement>
                <classpathElement>${project.build.directory}/test-classpath</classpathElement>
                <classpathElement>${project.basedir}/src/converters/resources</classpathElement>
              </classpathElements>
              <processors>
                <processor>io.vertx.codegen.CodeGenProcessor</processor>
              </processors>
              <optionMap>
              </optionMap>
              <sourceDirectory>${project.basedir}/src/converters/java</sourceDirectory>
              <outputDirectory>${project.basedir}/src/converters/generated</outputDirectory>
            </configuration>
          </execution>
          <!-- TCK -->
          <execution>
            <id>generate-tck-sources</id>
            <goals>
              <goal>process-test</goal>
            </goals>
            <phase>generate-test-sources</phase>
            <configuration>
              <!-- We use this workaround to have a specific json-mappers.properties file for this gen -->
              <classpathElements>
                <classpathElement>${project.build.outputDirectory}</classpathElement>
                <classpathElement>${project.build.directory}/test-classpath</classpathElement>
                <classpathElement>${project.basedir}/src/tck/resources</classpathElement>
              </classpathElements>
              <processors>
                <processor>io.vertx.codegen.CodeGenProcessor</processor>
              </processors>
              <optionMap>
              </optionMap>
              <sourceDirectory>${project.basedir}/src/tck/java</sourceDirectory>
              <outputDirectory>${project.basedir}/src/tck/generated</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>package</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <attach>true</attach>
              <appendAssemblyId>false</appendAssemblyId>
              <archive>
                <manifestFile>${jar.manifest}</manifestFile>
              </archive>
              <descriptors>
                <descriptor>src/main/assembly/jar.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
          <execution>
            <id>package-others</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <attach>true</attach>
              <descriptors>
                <descriptor>src/main/assembly/processor.xml</descriptor>
                <descriptor>src/main/assembly/tck.xml</descriptor>
                <descriptor>src/main/assembly/tck-sources.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
          <execution>
            <id>package-docs</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <attach>true</attach>
              <descriptors>
                <descriptor>src/main/assembly/docs.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>

    <profile>
      <id>java-8</id>
      <properties>
        <tools.jar>${java.home}/../lib/tools.jar</tools.jar>
      </properties>
      <activation>
        <jdk>1.8</jdk>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <executions>
                <execution>
                  <id>default-compile</id>
                  <configuration>
                    <excludes>
                      <exclude>/whatever</exclude>
                    </excludes>
                  </configuration>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
      <dependencies>
        <dependency>
          <groupId>com.sun</groupId>
          <artifactId>tools</artifactId>
          <version>1.8</version>
          <scope>system</scope>
          <systemPath>${tools.jar}</systemPath>
          <optional>true</optional>
        </dependency>
      </dependencies>
    </profile>

    <!-- Documentation generation : activate with -Pdocs -->
    <profile>
      <id>docs</id>
      <build>
        <plugins>
          <!-- Transform the Asciidoctor to html -->
          <plugin>
            <groupId>org.asciidoctor</groupId>
            <artifactId>asciidoctor-maven-plugin</artifactId>
            <executions>
              <execution>
                <goals>
                  <goal>process-asciidoc</goal>
                </goals>
                <configuration>
                  <sourceDirectory>${project.build.directory}/asciidoc</sourceDirectory>
                </configuration>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>javadoc</goal>
                </goals>
                <configuration>
                  <reportOutputDirectory>${project.build.directory}/docs</reportOutputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
