<?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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.sonarsource.java</groupId>
    <artifactId>java</artifactId>
    <version>4.2</version>
  </parent>

  <artifactId>java-maven-model</artifactId>

  <name>SonarQube Java :: Maven model generator</name>

  <properties>
    <!-- source: http://maven.apache.org/xsd/maven-4.0.0.xsd -->
    <xsdPath>src/main/resources/maven-4.0.0.xsd</xsdPath>
    <bindingFile>src/main/resources/bindings.xml</bindingFile>
    <javaPackageName>org.sonar.maven.model.maven2</javaPackageName>
    <targetDir>${project.build.directory}/generated-sources</targetDir>
    <!-- exclude generated sources from analysis -->
    <sonar.exclusions>target/generated-sources/**</sonar.exclusions>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.sonarsource.sslr</groupId>
      <artifactId>sslr-core</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.easytesting</groupId>
      <artifactId>fest-assert</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-all</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <excludes>
          <exclude>*.xsd</exclude>
          <exclude>*.xml</exclude>
        </excludes>
        <filtering>false</filtering>
      </resource>
    </resources>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.8</version>
        <executions>
          <execution>
            <id>generate-model</id>
            <phase>generate-sources</phase>
            <configuration>
              <target>
                <mkdir dir="${targetDir}" />
                <exec executable="xjc">
                  <arg line="-extension -b ${bindingFile} -p ${javaPackageName} -d ${targetDir} -encoding UTF-8 ${xsdPath}" />
                </exec>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.10</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-sources/</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
