<!--
  ~ Copyright (c) Microsoft. All rights reserved.
  ~ Licensed under the MIT license. See License.txt in the project root.
  -->

<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>com.microsoft.alm</groupId>
    <artifactId>oauth2-useragent-parent</artifactId>
    <version>0.11.3</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <artifactId>oauth2-useragent</artifactId>
  <packaging>jar</packaging>

  <name>Microsoft OAuth 2.0 User Agent library for Java</name>
  <description>Provides classes to facilitate the implementation of "4.1. Authorization Code Grant" from RFC 6749, specifically by auto-detecting a suitable user-agent (and informing the user if any system requirements are unmet and preventing the use of a user-agent), launching the user-agent and directing it to the authorization endpoint, waiting for the results and returning either the authorization code or the reason for failure.</description>

  <build>
    <resources>
      <resource>
        <directory>${project.basedir}/..</directory>
        <targetPath>./</targetPath>
        <filtering>true</filtering>
        <includes>
          <include>License.txt</include>
        </includes>
      </resource>
      <resource>
        <directory>${project.basedir}/..</directory>
        <targetPath>${project.build.directory}</targetPath>
        <filtering>false</filtering>
        <includes>
          <include>*.md</include>
        </includes>
      </resource>
      <resource>
        <directory>${project.basedir}/../templates</directory>
        <targetPath>${project.build.directory}</targetPath>
        <filtering>true</filtering>
        <includes>
          <!-- Templates: Every file here must be matched under the release profile -->
          <include>ReadMe.md</include>
        </includes>
      </resource>
      <!-- The following are implicit dependencies bundled in our JAR,
      with the side-effect that our consumers won't have more dependencies. -->
      <resource>
        <directory>${project.basedir}/../oauth2-useragent-core/target/classes</directory>
        <targetPath>./</targetPath>
        <includes>
          <include>**</include>
        </includes>
      </resource>
      <resource>
        <directory>${project.basedir}/../oauth2-useragent-javafx/target/classes</directory>
        <targetPath>./</targetPath>
        <includes>
          <include>**</include>
        </includes>
      </resource>
      <resource>
        <directory>${project.basedir}/../oauth2-useragent-swt/target/classes</directory>
        <targetPath>./</targetPath>
        <includes>
          <include>**</include>
        </includes>
      </resource>
    </resources>

    <plugins>
      <plugin>
        <groupId>org.sonatype.plugins</groupId>
        <artifactId>nexus-staging-maven-plugin</artifactId>
        <!-- The only artifacts we need are from the aggregator project, oauth2-useragent,
         and the parent POM, so enable deployment here -->
        <configuration>
          <skipNexusStagingDeployMojo>false</skipNexusStagingDeployMojo>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-install-plugin</artifactId>
        <!-- The only artifacts we need are from the aggregator project, oauth2-useragent,
         and the parent POM, so enable installation here -->
        <configuration>
          <skip>false</skip>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <!-- https://stackoverflow.com/a/6773868/ -->
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            </manifest>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
          <goals>deploy</goals>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.ruleoftech</groupId>
        <artifactId>markdown-page-generator-plugin</artifactId>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <inputDirectory>${project.build.directory}</inputDirectory>
          <outputDirectory>${project.build.outputDirectory}</outputDirectory>
          <pegdownExtensions>AUTOLINKS,FENCED_CODE_BLOCKS</pegdownExtensions>
          <headerHtmlFile>${project.basedir}/src/main/resources/markdown/html/header.html</headerHtmlFile>
          <footerHtmlFile>${project.basedir}/src/main/resources/markdown/html/footer.html</footerHtmlFile>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <descriptors>
                <descriptor>src/assembly/sources.xml</descriptor>
              </descriptors>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <configuration>
              <additionalparam>-quiet</additionalparam>
              <attach>true</attach>
              <skip>false</skip>
              <sourcepath>${project.basedir}/../oauth2-useragent-core/src/main/java;${project.basedir}/../oauth2-useragent-javafx/src/main/java;${project.basedir}/../oauth2-useragent-swt/src/main/java</sourcepath>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-gpg-plugin</artifactId>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
        <resources>
          <resource>
            <directory>${project.build.directory}</directory>
            <targetPath>${project.basedir}/..</targetPath>
            <filtering>false</filtering>
            <includes>
              <!-- Every file here must be matched under Templates -->
              <include>ReadMe.md</include>
            </includes>
          </resource>
        </resources>
      </build>
    </profile>
  </profiles>

</project>
