<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>org.alfresco</groupId>
  <artifactId>api-explorer</artifactId>
  <version>7.2.0-M2</version>
  <packaging>war</packaging>
  <name>Alfresco REST API Explorer</name>
  <description>Produces the API Explorer for all API definitions</description>

  <properties>
    <swagger-ui.version>3.38.0</swagger-ui.version>
    <java.version>11</java.version>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <maven.build.sourceVersion>11</maven.build.sourceVersion>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <!-- needed to set the port for "jetty:start-war" run before the integration tests -->
    <jetty.httpPort>8085</jetty.httpPort>
  </properties>

  <scm>
    <connection>scm:git:https://github.com/Alfresco/rest-api-explorer.git</connection>
    <developerConnection>scm:git:https://github.com/Alfresco/rest-api-explorer.git</developerConnection>
    <url>https://github.com/Alfresco/rest-api-explorer</url>
    <tag>7.2.0-M2</tag>
  </scm>

  <licenses>
    <license>
      <name>Apache License 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0</url>
    </license>
  </licenses>

  <dependencies>
    <dependency>
      <groupId>org.webjars</groupId>
      <artifactId>swagger-ui</artifactId>
      <version>${swagger-ui.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>4.5.13</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.8.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.swagger</groupId>
      <artifactId>swagger-parser</artifactId>
      <version>1.0.52</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.30</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>1.7.30</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>api-explorer</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>2.5.3</version>
        <configuration>
          <tagNameFormat>@{project.version}</tagNameFormat>
        </configuration>
      </plugin>
      <!-- skip unit tests as the project only contains integration tests -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.2</version>
        <configuration>
          <skipTests>true</skipTests>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.1.2</version>
        <executions>
          <execution>
            <id>unpack-dependencies</id>
            <phase>validate</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <includes>META-INF/resources/webjars/swagger-ui/${swagger-ui.version}/**/*.*</includes>
              <excludes>**/index.html,**/*.gz,**/*.map</excludes>
              <outputDirectory>${basedir}/src/main/swagger</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <id>generate-json</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>java</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <mainClass>org.alfresco.api.YamlToJson</mainClass>
          <arguments>
            <argument>${basedir}</argument>
          </arguments>
          <classpathScope>test</classpathScope>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
          <filesets>
            <fileset>
              <directory>${basedir}/src/main/swagger</directory>
            </fileset>
          </filesets>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.3.1</version>
        <configuration>
          <webResources>
            <resource>
              <directory>
                src/main/swagger/META-INF/resources/webjars/swagger-ui/${swagger-ui.version}
              </directory>
            </resource>
          </webResources>
          <archive>
            <manifestEntries>
              <Implementation-Version>${project.version}</Implementation-Version>
              <Build-Date>${maven.build.timestamp}</Build-Date>
            </manifestEntries>
            <manifestSections>
              <manifestSection>
                <name>Libraries</name>
                <manifestEntries>
                  <swaggerui-version>${swagger-ui.version}</swaggerui-version>
                </manifestEntries>
              </manifestSection>
            </manifestSections>
            <manifest>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
              <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
            </manifest>
          </archive>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>11.0.0</version>
        <configuration>
          <scan>0</scan>
          <webApp>
            <contextPath>/api-explorer</contextPath>
          </webApp>
          <httpConnector>
            <!-- needed to set the port for the manual "mvn jetty:run-war"-->
            <port>8085</port>
          </httpConnector>
        </configuration>
        <executions>
          <execution>
            <id>start-ephemeral-jetty</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>start-war</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.22.2</version>
        <executions>
          <execution>
            <id>integration-tests</id>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
            <configuration>
              <includes>
                <include>**/*IntegrationTest.java</include>
              </includes>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <distributionManagement>
    <snapshotRepository>
      <id>alfresco-public-snapshots</id>
      <url>https://artifacts.alfresco.com/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>alfresco-public</id>
      <url>https://artifacts.alfresco.com/nexus/content/repositories/releases</url>
    </repository>
  </distributionManagement>
</project>
