<?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>
    <groupId>com.github.shadowsocks</groupId>
    <artifactId>shadowsocks</artifactId>
    <version>1.3.3</version>
    <packaging>apk</packaging>
    <name>Shadowsocks</name>

    <repositories>
        <repository>
            <id>madeye-maven-repository</id>
            <url>http://madeye-maven-repository.googlecode.com/git</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>

        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.1.1.4</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.google.android.analytics</groupId>
            <artifactId>analytics</artifactId>
            <version>V2</version>
        </dependency>

        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.5</version>
        </dependency>

    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <sourceDirectory>src</sourceDirectory>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-jarsigner-plugin</artifactId>
                    <version>1.2</version>
                </plugin>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>3.4.1</version>
                    <extensions>true</extensions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12.4</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.5</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jarsigner-plugin</artifactId>
                <executions>
                    <execution>
                        <id>signing</id>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                        <phase>package</phase>
                        <inherited>true</inherited>
                        <configuration>
                            <archiveDirectory/>
                            <includes>
                                <include>${project.build.directory}/${project.artifactId}.apk</include>
                            </includes>
                            <keystore>${sign.keystore}</keystore>
                            <alias>${sign.alias}</alias>
                            <storepass>${sign.storepass}</storepass>
                            <keypass>${sign.keypass}</keypass>
                            <verbose>true</verbose>
                            <arguments>
                                <argument>-sigalg</argument><argument>MD5withRSA</argument>
                                <argument>-digestalg</argument><argument>SHA1</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>alignApk</id>
                        <phase>install</phase>
                        <goals>
                            <goal>zipalign</goal>
                        </goals>
                    </execution>
                </executions>
                <extensions>true</extensions>
                <configuration>
                    <release>true</release>
                    <sign>
                        <debug>false</debug>
                    </sign>
                    <zipalign>
                        <verbose>true</verbose>
                        <skip>false</skip>
                        <inputApk>${project.build.directory}/${project.artifactId}.apk</inputApk>
                        <outputApk>${project.build.directory}/${project.artifactId}-${project.version}.apk
                        </outputApk>
                    </zipalign>
                    <sdk>
                        <platform>16</platform>
                    </sdk>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>debug-sign</id>
            <activation>
                <file>
                    <missing>${basedir}/local.properties</missing>
                </file>
            </activation>
            <properties>
                <sign.keystore>${basedir}/travis.keystore</sign.keystore>
                <sign.alias>travis</sign.alias>
                <sign.keypass>travis</sign.keypass>
                <sign.storepass>travis</sign.storepass>
            </properties>
        </profile>
        <profile>
            <id>release-sign</id>
            <activation>
                <file>
                    <exists>${basedir}/local.properties</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>properties-maven-plugin</artifactId>
                        <version>1.0-alpha-2</version>
                        <executions>
                            <execution>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>read-project-properties</goal>
                                </goals>
                                <configuration>
                                    <files>
                                        <file>${basedir}/local.properties</file>
                                    </files>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>travis</id>
            <activation>
                <property>
                    <name>TRAVIS</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>deploy-to-sae</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <executable>${basedir}/deploy</executable>
                            <arguments>
                                <argument>${project.build.directory}</argument>
                                <argument>${project.artifactId}-${project.version}.apk</argument>
                            </arguments>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
