<?xml version="1.0" encoding="ISO-8859-1"?>
<!--

    Copyright 2006-2022 the original author or authors.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<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 https://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.objenesis</groupId>
    <artifactId>objenesis-parent</artifactId>
    <version>3.5-SNAPSHOT</version>
  </parent>
  <artifactId>objenesis-tck-android</artifactId>
  <name>Objenesis Android TCK</name>
  <description>Objenesis' TCK built for Android devices</description>
  <packaging>apk</packaging>

  <properties>
    <android.home>${env.ANDROID_HOME}</android.home>
    <exec.skip>${skipTests}</exec.skip>
    <maven.deploy.skip>true</maven.deploy.skip>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.objenesis</groupId>
      <artifactId>objenesis</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>objenesis-tck</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.android</groupId>
      <artifactId>android</artifactId>
      <version>4.1.1.4</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.android</groupId>
      <artifactId>android-test</artifactId>
      <version>4.1.1.4</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.simpligility.maven.plugins</groupId>
          <artifactId>android-maven-plugin</artifactId>
          <version>4.6.0</version>
          <extensions>true</extensions>
          <configuration>
            <testFailSafe>false</testFailSafe>
            <test>
              <instrumentationPackage>org.objenesis.tck.android</instrumentationPackage>
              <instrumentationRunner>android.test.InstrumentationTestRunner</instrumentationRunner>
            </test>
          </configuration>
        </plugin>
        <!--This plugin configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                  	<groupId>com.simpligility.maven.plugins</groupId>
          			<artifactId>android-maven-plugin</artifactId>
          			<versionRange>[1.0,)</versionRange>
                    <goals>
                      <goal>emma</goal>
                      <goal>generate-sources</goal>
                      <goal>proguard</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <execute/>
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>

      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <groupId>com.keyboardsamurais.maven</groupId>
        <artifactId>maven-timestamp-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-remote-resources-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>com.simpligility.maven.plugins</groupId>
        <artifactId>android-maven-plugin</artifactId>
        <configuration>
          <sdk>
            <platform>30</platform>
          </sdk>
          <dexArguments>--min-sdk-version=26</dexArguments>
        </configuration>
        <extensions>true</extensions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <inherited>false</inherited>
        <executions>
          <execution>
            <id>execute</id>
            <phase>integration-test</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>${android.home}/platform-tools/adb</executable>
              <arguments>
                <argument>shell</argument>
                <argument>am</argument>
                <argument>instrument</argument>
                <argument>-w</argument>
                <argument>org.objenesis.tck.android/.TckInstrumentation</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>

  </build>

  <profiles>
    <profile>
      <!-- To activate in IntelliJ. This will allow compilation because it seems IntelliJ can't retrieve
           the objenesis classes shaded in the objenesis-tck jar -->
      <id>intellij-specific</id>
      <dependencies>
        <dependency>
          <groupId>${project.groupId}</groupId>
          <artifactId>objenesis</artifactId>
          <version>${project.version}</version>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
</project>
