<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>

  <groupId>name.kevinlocke.appveyor</groupId>
  <artifactId>appveyor-swagger</artifactId>
  <version>0.1.0</version>
  <packaging>jar</packaging>

  <name>AppVeyor REST API Client (from Swagger)</name>
  <description>
    AppVeyor REST API Client generated from the unofficial Swagger API
    definition in Java.
  </description>
  <url>https://kevinoid.github.io/appveyor-swagger-java</url>

  <licenses>
    <license>
      <name>MIT License</name>
      <url>https://opensource.org/licenses/mit-license</url>
    </license>
    <license>
      <name>Apache License Version 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>kevinoid</id>
      <name>Kevin Locke</name>
      <email>kevin@kevinlocke.name</email>
      <url>https://kevinlocke.name</url>
    </developer>
  </developers>

  <distributionManagement>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
    <site>
      <id>site</id>
      <url>scm:git:git@github.com:kevinoid/appveyor-swagger-java.git</url>
    </site>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
  </distributionManagement>

  <issueManagement>
    <system>GitHub</system>
    <url>https://github.com/kevinoid/appveyor-swagger-java/issues</url>
  </issueManagement>

  <scm>
    <url>https://github.com/kevinoid/appveyor-swagger-java</url>
    <connection>scm:git:git://github.com/kevinoid/appveyor-swagger-java.git</connection>
    <developerConnection>scm:git:git@github.com:kevinoid/appveyor-swagger-java.git</developerConnection>
    <tag>v0.1.0</tag>
  </scm>

  <properties>
    <java.version>1.8</java.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <site.path>/</site.path>

    <appveyor-swagger-version>v0.20170308.0</appveyor-swagger-version>
    <build-helper-maven-plugin-version>1.12</build-helper-maven-plugin-version>
    <bval-version>1.1.2</bval-version>
    <copy-rename-maven-plugin-version>1.0.1</copy-rename-maven-plugin-version>
    <geronimo-validation-version>1.0</geronimo-validation-version>
    <gson-version>2.8.0</gson-version>
    <jodatime-version>2.9.7</jodatime-version>
    <jsonassert-version>1.4.0</jsonassert-version>
    <maven-gpg-plugin-version>1.6</maven-gpg-plugin-version>
    <maven-javadoc-plugin-version>2.10.4</maven-javadoc-plugin-version>
    <maven-project-info-reports-plugin-version>2.9</maven-project-info-reports-plugin-version>
    <maven-release-plugin-version>2.5.3</maven-release-plugin-version>
    <maven-replacer-plugin-version>1.5.3</maven-replacer-plugin-version>
    <maven-resources-plugin-version>3.0.2</maven-resources-plugin-version>
    <maven-scm-publish-plugin-version>1.1</maven-scm-publish-plugin-version>
    <maven-site-plugin-version>3.6</maven-site-plugin-version>
    <maven-source-plugin-version>3.0.1</maven-source-plugin-version>
    <maven-surefire-plugin-version>2.19.1</maven-surefire-plugin-version>
    <migbase64-version>2.2</migbase64-version>
    <nexus-staging-maven-plugin-version>1.6.8</nexus-staging-maven-plugin-version>
    <okhttp-version>2.7.5</okhttp-version>
    <swagger-annotations-version>1.5.12</swagger-annotations-version>
    <swagger-codegen-maven-plugin-version>2.2.2</swagger-codegen-maven-plugin-version>
    <swagger-request-validator-version>1.0.10</swagger-request-validator-version>
    <!-- After updating testng, check JDK 7 support and enable CI testing.
         See https://github.com/cbeust/testng/commit/132a807 -->
    <testng-version>6.11</testng-version>
  </properties>

  <profiles>
    <profile>
      <id>release</id>
      <properties>
        <site.path>${project.version}</site.path>
        <!-- Skip tests during release:perform, not release:prepare
             https://stackoverflow.com/q/22391347/503410 -->
        <skipTests>true</skipTests>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>${maven-source-plugin-version}</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>${maven-javadoc-plugin-version}</version>
            <configuration>
              <links>
                <link>https://square.github.io/okhttp/2.x/okhttp/</link>
                <link>http://www.joda.org/joda-time/apidocs/</link>
                <link>https://www.javadoc.io/doc/com.google.code.gson/gson/${gson-version}</link>
                <link>http://docs.swagger.io/swagger-core/apidocs/</link>
              </links>
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>${maven-gpg-plugin-version}</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>${nexus-staging-maven-plugin-version}</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <dependencies>
    <dependency>
      <groupId>io.swagger</groupId>
      <artifactId>swagger-annotations</artifactId>
      <version>${swagger-annotations-version}</version>
    </dependency>

    <dependency>
      <groupId>com.squareup.okhttp</groupId>
      <artifactId>okhttp</artifactId>
      <version>${okhttp-version}</version>
    </dependency>
    <dependency>
      <groupId>com.squareup.okhttp</groupId>
      <artifactId>logging-interceptor</artifactId>
      <version>${okhttp-version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>${gson-version}</version>
    </dependency>
    <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
      <version>${jodatime-version}</version>
    </dependency>
    <dependency>
      <groupId>com.brsanthu</groupId>
      <artifactId>migbase64</artifactId>
      <version>${migbase64-version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.geronimo.specs</groupId>
      <artifactId>geronimo-validation_1.1_spec</artifactId>
      <version>${geronimo-validation-version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.bval</groupId>
      <artifactId>org.apache.bval.bundle</artifactId>
      <version>${bval-version}</version>
    </dependency>

    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>${testng-version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.oai</groupId>
      <artifactId>swagger-request-validator-core</artifactId>
      <version>${swagger-request-validator-version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.skyscreamer</groupId>
      <artifactId>jsonassert</artifactId>
      <version>${jsonassert-version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>com.googlecode.maven-download-plugin</groupId>
        <artifactId>download-maven-plugin</artifactId>
        <version>1.3.0</version>
        <executions>
          <execution>
            <id>get-appveyor-swagger</id>
            <!-- Note: Although this is a resource, it needs to run in
                 generate-sources rather than generate-resources because
                 swagger-codegen (in generate-sources) depends on it. -->
            <phase>generate-sources</phase>
            <goals>
              <goal>wget</goal>
            </goals>
            <configuration>
              <url>https://github.com/kevinoid/appveyor-swagger/raw/${appveyor-swagger-version}/swagger.yaml</url>
              <outputDirectory>${project.build.directory}/generated-resources</outputDirectory>
              <skipCache>true</skipCache>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>io.swagger</groupId>
        <artifactId>swagger-codegen-maven-plugin</artifactId>
        <version>${swagger-codegen-maven-plugin-version}</version>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${project.build.directory}/generated-resources/swagger.yaml</inputSpec>
              <invokerPackage>${project.groupId}</invokerPackage>
              <apiPackage>${project.groupId}.api</apiPackage>
              <modelPackage>${project.groupId}.model</modelPackage>
              <language>java</language>
              <library>okhttp-gson</library>
              <configOptions>
                <dateLibrary>joda</dateLibrary>
                <ensureUniqueParams>false</ensureUniqueParams>
                <useBeanValidation>true</useBeanValidation>
                <performBeanValidation>true</performBeanValidation>
              </configOptions>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- Only required if addCompileSourceRoot is set false for codegen-maven
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>${build-helper-maven-plugin-version}</version>
        <executions>
          <execution>
            <id>add-generated-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-sources/swagger/main/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin-version}</version>
        <configuration>
          <properties>
            <property>
              <name>surefire.testng.verbose</name>
              <value>2</value>
            </property>
          </properties>
          <suiteXmlFiles>
            <suiteXmlFile>${basedir}/src/test/resources/testng.xml</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.coderplus.maven.plugins</groupId>
        <artifactId>copy-rename-maven-plugin</artifactId>
        <version>${copy-rename-maven-plugin-version}</version>
        <executions>
          <!-- Use README.md as index.html in generated site -->
          <execution>
            <id>copy-readme-to-site-index</id>
            <phase>pre-site</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <sourceFile>${basedir}/README.md</sourceFile>
              <destinationFile>${project.build.directory}/generated-site/markdown/index.md</destinationFile>
            </configuration>
          </execution>
          <!-- Use Swagger README.md as index.html in swaggerdocs -->
          <execution>
            <id>copy-readme-to-swaggerdocs-index</id>
            <phase>pre-site</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <sourceFile>${project.build.directory}/generated-sources/swagger/README.md</sourceFile>
              <destinationFile>${project.build.directory}/generated-site/markdown/swaggerdocs/index.md</destinationFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>${maven-resources-plugin-version}</version>
        <executions>
          <execution>
            <!-- Include swagger-generated docs in generated site. -->
            <id>copy-docs</id>
            <phase>pre-site</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <!-- Must match site configuration generatedSiteDirectory -->
              <outputDirectory>${project.build.directory}/generated-site/markdown/swaggerdocs/docs</outputDirectory>
              <resources>
                <resource>
                  <directory>${project.build.directory}/generated-sources/swagger/docs</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- Included to silence warning https://stackoverflow.com/a/18734846 -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>${maven-project-info-reports-plugin-version}</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>${maven-release-plugin-version}</version>
        <configuration>
          <completionGoals>replacer:replace</completionGoals>
          <localCheckout>true</localCheckout>
          <!-- Can't push changes when not releasing from a branch.  Result:
               An error is occurred in the checkin process:
               Exception while executing SCM command.
               Detecting the current branch failed:
               fatal: ref HEAD is not a symbolic ref -->
          <pushChanges>false</pushChanges>
          <releaseProfiles>release</releaseProfiles>
          <tagNameFormat>v@{project.version}</tagNameFormat>
          <useReleaseProfile>false</useReleaseProfile>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.google.code.maven-replacer-plugin</groupId>
        <artifactId>replacer</artifactId>
        <version>${maven-replacer-plugin-version}</version>
        <executions>
          <!-- Change links in swaggerdocs to point to .html files -->
          <execution>
            <id>fix-swaggerdocs-links</id>
            <phase>site</phase>
            <goals>
              <goal>replace</goal>
            </goals>
            <configuration>
              <file>${project.build.directory}/site/swaggerdocs/index.html</file>
              <replacements>
                <replacement>
                  <token>\.md</token>
                  <value>.html</value>
                </replacement>
              </replacements>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>${maven-site-plugin-version}</version>
        <configuration>
          <!-- Let maven-scm-publish-plugin do the deployment.
               It is possible to deploy using wagon as documented at
               https://maven.apache.org/wagon/wagon-providers/wagon-scm/usage.html
               But the limitations noted on that page (no removal of obsolete
               files, one commit per file) are unacceptable. -->
          <skipDeploy>true</skipDeploy>
        </configuration>
        <executions>
          <execution>
            <id>stage-for-scm-publish</id>
            <phase>post-site</phase>
            <goals>
              <goal>stage</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-scm-publish-plugin</artifactId>
        <version>${maven-scm-publish-plugin-version}</version>
        <configuration>
          <scmBranch>gh-pages</scmBranch>
          <tryUpdate>true</tryUpdate>
        </configuration>
        <executions>
          <execution>
            <id>scm-publish</id>
            <phase>site-deploy</phase>
            <goals>
              <goal>publish-scm</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>

    <resources>
      <resource>
        <directory>${project.build.directory}/generated-resources</directory>
        <includes>
          <include>**/*.yaml</include>
        </includes>
      </resource>
    </resources>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${maven-javadoc-plugin-version}</version>
        <configuration>
          <links>
            <link>https://square.github.io/okhttp/2.x/okhttp/</link>
            <link>http://www.joda.org/joda-time/apidocs/</link>
            <link>https://www.javadoc.io/doc/com.google.code.gson/gson/${gson-version}</link>
            <link>http://docs.swagger.io/swagger-core/apidocs/</link>
          </links>
        </configuration>
        <!-- Prevent duplicate execution of generate-sources
             https://maven.apache.org/plugins/maven-javadoc-plugin/examples/javadoc-nofork.html -->
        <reportSets>
          <reportSet>
            <reports>
              <report>javadoc-no-fork</report>
              <report>test-javadoc-no-fork</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>
</project>
