<?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.sonarsource.sonarqube</groupId>
    <artifactId>sonarqube</artifactId>
    <version>6.3-SNAPSHOT</version>
  </parent>

  <artifactId>sonar-plugin-api</artifactId>
  <packaging>jar</packaging>

  <name>SonarQube :: Plugin API</name>

  <properties>
    <project.version.3digits>${project.version}</project.version.3digits>
  </properties>

  <dependencies>

    <!--
    The following artifacts are shaded and relocated in an internal package.
    They are not visible by plugins
    -->
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
    </dependency>

    <!--
    The following artifacts are shaded but not relocated. They
    are provided at runtime, so plugins can use them but
    can not change their version.
    Long-term target is to remove them from API. They should be
    embedded by plugins.
    -->
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>sonar-check-api</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>sonar-colorizer</artifactId>
      <version>${project.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>sonar-duplications</artifactId>
      <version>${project.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <!-- to be kept for backward-compatibility of org.sonar.api.design.Dependency -->
      <groupId>org.codehaus.sonar</groupId>
      <artifactId>sonar-graph</artifactId>
    </dependency>


    <!--
      Transitive dependencies available at runtime. They are not shaded with API
      as they are not managed by SonarSource. Versions should not be
      overridden by plugins though.
    -->
    <dependency>
      <groupId>org.codehaus.woodstox</groupId>
      <artifactId>woodstox-core-lgpl</artifactId>
      <exclusions>
        <exclusion>
          <groupId>stax</groupId>
          <artifactId>stax-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.codehaus.woodstox</groupId>
      <artifactId>stax2-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.codehaus.staxmate</groupId>
      <artifactId>staxmate</artifactId>
    </dependency>

    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <optional>true</optional>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>xpp3</groupId>
      <artifactId>xpp3</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.0.1</version>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-core</artifactId>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>

    <!-- unit tests -->
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>sonar-testing-harness</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>xmlunit</groupId>
      <artifactId>xmlunit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.dbunit</groupId>
      <artifactId>dbunit</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <!-- can't minimize dependencies because of some classes of sonar-duplications
              that required by sonar-batch -->
              <minimizeJar>false</minimizeJar>
              <createDependencyReducedPom>true</createDependencyReducedPom>
              <artifactSet>
                <excludes>
                  <exclude>org.codehaus.woodstox:woodstox-core-lgpl</exclude>
                  <exclude>org.codehaus.woodstox:stax2-api</exclude>
                  <exclude>org.codehaus.staxmate:staxmate</exclude>
                </excludes>
              </artifactSet>
              <relocations>
                <relocation>
                  <pattern>com.google</pattern>
                  <shadedPattern>org.sonar.api.internal.google</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>org.apache.commons</pattern>
                  <shadedPattern>org.sonar.api.internal.apachecommons</shadedPattern>
                </relocation>
              </relocations>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>test-jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
         <groupId>org.codehaus.gmaven</groupId>
         <artifactId>groovy-maven-plugin</artifactId>
         <executions>
           <execution>
             <id>compute-3digits-version</id>
             <phase>generate-resources</phase>
             <goals>
               <goal>execute</goal>
             </goals>
             <configuration>
               <source><![CDATA[
                 if (! "${project.version}".endsWith("-SNAPSHOT")) {
                   String apiVersion
                   // example: "6.3.0.1234". To be backward-compatible with scanners, only "6.3.0" must be kept
                   String[] fields = "${project.version}".tokenize('.')
                   if (fields.length > 3) {
                     apiVersion = fields[0..2].join('.')
                   } else {
                     apiVersion = fields.join('.')
                   }
                   project.properties['project.version.3digits'] = apiVersion
                 }
                 ]]>
               </source>
             </configuration>
           </execution>
         </executions>
      </plugin>
    </plugins>

    <resources>
      <resource>
        <!-- Used to resolve variables in files sq-version.txt and sonar-api-version.txt -->
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
  </build>

</project>