<?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>
  <name>Tink Cryptography Library for Android</name>
  <description>Tink is a small cryptographic library that provides a safe, simple, agile and fast way to accomplish some common cryptographic tasks. It is written by a group of cryptographers and security engineers at Google, but it is not an official Google product.
  </description>

  <parent>
    <groupId>com.google.crypto.tink</groupId>
    <artifactId>parentpom</artifactId>
    <version>1.0.0</version>
  </parent>
  <artifactId>tink-android</artifactId>
  <packaging>jar</packaging>

  <dependencies>
    <dependency>
      <groupId>com.google.android</groupId>
      <artifactId>android</artifactId>
      <version>${android-sdk.version}</version>
      <scope>system</scope>
      <systemPath>
        ${env.ANDROID_HOME}/platforms/android-${android-sdk.version}/android.jar
      </systemPath>
    </dependency>

    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
    </dependency>

    <dependency>
      <groupId>com.google.errorprone</groupId>
      <artifactId>error_prone_annotations</artifactId>
    </dependency>

    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
    </dependency>

    <dependency>
      <groupId>org.json</groupId>
      <artifactId>json</artifactId>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.google.truth</groupId>
      <artifactId>truth</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <excludes>
            <exclude>**/AwsKmsAead.java</exclude>
            <exclude>**/AwsKmsClient.java</exclude>
            <exclude>**/GcpKmsAead.java</exclude>
            <exclude>**/GcpKmsClient.java</exclude>
          </excludes>
          <testExcludes>
            <exclude>**/AwsKmsAeadTest.java</exclude>
            <exclude>**/KmsAeadKeyManagerTest.java</exclude>
            <exclude>**/KmsEnvelopeAeadKeyManagerTest.java</exclude>
            <!-- these tests depend on JsonFormat which does not work with protobuf lite -->
            <exclude>**/JsonKeysetReaderTest.java</exclude>
            <exclude>**/JsonKeysetWriterTest.java</exclude>
            <!-- TODO: add Maven support for Wycheproof which these tests depend on -->
            <exclude>**/AesGcmJceTest.java</exclude>
          </testExcludes>

        </configuration>
      </plugin>

      <!-- generate and build lite protos -->
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>${maven-antrun-plugin.version}</version>
        <executions>
          <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
              <target>
                <property
                    name="protoc.filename"
                    value="protoc-${protobuf.version}-${os.detected.classifier}.exe"/>
                <property
                    name="protoc.filepath"
                    value="${project.build.directory}/${protoc.filename}"/>

                <chmod file="${protoc.filepath}" perm="ugo+rx"/>

                <property
                    name="protoc-plugin.filename"
                    value="protoc-gen-javalite-${protoc-gen-javalite.version}-${os.detected.classifier}.exe"/>
                <property
                    name="protoc-plugin.filepath"
                    value="${project.build.directory}/${protoc-plugin.filename}"/>
                <chmod file="${protoc-plugin.filepath}" perm="ugo+rx"/>

                <mkdir dir="${protobuf.output.dir}" />

                <path id="protobuf.input.filepaths.path">
                  <fileset dir="${tink.basedir}/proto">
                    <include name="**/*.proto"/>
                  </fileset>
                </path>

                <pathconvert
                    pathsep=" "
                    property="protobuf.input.filepaths"
                    refid="protobuf.input.filepaths.path"/>

                <exec executable="${protoc.filepath}" failonerror="true">
                  <arg value="--proto_path=${tink.basedir}"/>
                  <arg value="--plugin=protoc-gen-javalite=${protoc-plugin.filepath}" />
                  <arg value="--javalite_out=${protobuf.output.dir}" />
                  <arg line="${protobuf.input.filepaths}"/>
                </exec>
              </target>
              <sourceRoot>${protobuf.output.dir}</sourceRoot>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
