<?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.javascript</groupId>
    <artifactId>sonar-plugin</artifactId>
    <version>11.4.1.34873</version>
  </parent>

  <artifactId>javascript-checks</artifactId>

  <name>SonarQube JavaScript :: Checks</name>

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.sonarsource.api.plugin</groupId>
      <artifactId>sonar-plugin-api</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
    </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>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.sonarsource.rspec</groupId>
        <artifactId>rspec-maven-plugin</artifactId>
        <version>1.1.0.62</version>
        <executions>
          <execution>
            <id>Generate Javascript/Typescript rules data</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>generate-rule-data</goal>
            </goals>
            <configuration>
              <ruleSubdirectory>javascript</ruleSubdirectory>
              <vcsBranchName>dogfood-automerge</vcsBranchName>
              <targetDirectory>${project.basedir}/../../resources/rule-data/javascript</targetDirectory>
            </configuration>
          </execution>
          <execution>
            <id>Generate CSS rules data</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>generate-rule-data</goal>
            </goals>
            <configuration>
              <ruleSubdirectory>css</ruleSubdirectory>
              <vcsBranchName>dogfood-automerge</vcsBranchName>
              <targetDirectory>${project.basedir}/../../resources/rule-data/css</targetDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.5.1</version>
        <executions>
          <execution>
            <id>Clean the Rule Data</id>
            <phase>clean</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>rm</executable>
              <workingDirectory>../..</workingDirectory>
              <arguments>
                <argument>-rf</argument>
                <argument>resources/rule-data</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>Clean the Generated Classes</id>
            <phase>clean</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>git</executable>
              <arguments>
                <argument>clean</argument>
                <argument>-xdf</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>Deploy the rule data</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>npm</executable>
              <workingDirectory>../..</workingDirectory>
              <arguments>
                <argument>run</argument>
                <argument>deploy-rule-data</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>Generate the Java Check classes</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>npm</executable>
              <workingDirectory>../..</workingDirectory>
              <arguments>
                <argument>run</argument>
                <argument>generate-java-rule-classes</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>Update README with rule counts</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>npm</executable>
              <workingDirectory>../..</workingDirectory>
              <arguments>
                <argument>run</argument>
                <argument>count-rules</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
