<?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.python</groupId>
    <artifactId>python</artifactId>
    <version>5.29.0.35837</version>
  </parent>

  <artifactId>python-checks</artifactId>

  <name>Python :: Checks</name>

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>python-frontend</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.sonarsource.api.plugin</groupId>
      <artifactId>sonar-plugin-api</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-text</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
    </dependency>
    
    <!-- test dependencies -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.sonarsource.python</groupId>
      <artifactId>python-checks-testkit</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.sonarsource.analyzer-commons</groupId>
      <artifactId>sonar-analyzer-commons</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>updateRule</id>
      <activation>
        <property>
          <name>rule.id</name>
        </property>
      </activation>
      <properties>
        <rule.branch>master</rule.branch>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>download-rule-api</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>copy</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>com.sonarsource.rule-api</groupId>
                      <artifactId>rule-api</artifactId>
                      <version>${rule.api.version}</version>
                      <type>jar</type>
                      <outputDirectory>${project.build.directory}</outputDirectory>
                      <destFileName>rule-api.jar</destFileName>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>run-rule-api</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <executable>java</executable>
                  <workingDirectory>${project.basedir}/..</workingDirectory>
                  <arguments>
                    <argument>-jar</argument>
                    <argument>${project.build.directory}/rule-api.jar</argument>
                    <argument>generate</argument>
                    <argument>-rule</argument>
                    <argument>${rule.id}</argument>
                    <argument>-branch</argument>
                    <argument>${rule.branch}</argument>
                  </arguments>
                  <environmentVariables>
                    <GITHUB_TOKEN>${env.RULE_API_GH_TOKEN}</GITHUB_TOKEN>
                  </environmentVariables>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>updateAllRules</id>
      <activation>
        <property>
          <name>update.rules</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>download-rule-api-all</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>copy</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>com.sonarsource.rule-api</groupId>
                      <artifactId>rule-api</artifactId>
                      <version>${rule.api.version}</version>
                      <type>jar</type>
                      <outputDirectory>${project.build.directory}</outputDirectory>
                      <destFileName>rule-api.jar</destFileName>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>run-rule-api-all</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <executable>java</executable>
                  <workingDirectory>${project.basedir}/..</workingDirectory>
                  <arguments>
                    <argument>-jar</argument>
                    <argument>${project.build.directory}/rule-api.jar</argument>
                    <argument>update</argument>
                  </arguments>
                  <environmentVariables>
                    <GITHUB_TOKEN>${env.RULE_API_GH_TOKEN}</GITHUB_TOKEN>
                  </environmentVariables>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
