master e16eab6b92d1 cached
24 files
45.6 KB
12.7k tokens
2 symbols
1 requests
Download .txt
Repository: nhachicha/android-native-dependencies
Branch: master
Commit: e16eab6b92d1
Files: 24
Total size: 45.6 KB

Directory structure:
gitextract_f9n_ymw9/

├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── README.md
├── build.gradle
├── gradle/
│   └── wrapper/
│       └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src/
    ├── main/
    │   ├── groovy/
    │   │   └── com/
    │   │       └── nabilhachicha/
    │   │           └── nativedependencies/
    │   │               ├── NativeDependenciesPlugin.groovy
    │   │               ├── extension/
    │   │               │   ├── NativeDep.groovy
    │   │               │   └── NativeDependenciesExtension.groovy
    │   │               └── task/
    │   │                   └── NativeDependenciesResolverTask.groovy
    │   └── resources/
    │       └── META-INF/
    │           └── gradle-plugins/
    │               └── android-native-dependencies.properties
    └── test/
        ├── gradle_project_template/
        │   ├── build.gradle
        │   └── src/
        │       └── main/
        │           └── AndroidManifest.xml
        ├── gradle_project_template_custom_jni_dir/
        │   ├── AndroidManifest.xml
        │   ├── build.gradle
        │   └── src/
        │       └── main/
        │           └── native_libs/
        │               └── .empty
        └── groovy/
            └── com/
                └── nabilhachicha/
                    └── nativedependencies/
                        ├── BasicPluginTest.groovy
                        ├── DependenciesResolverTest.groovy
                        └── utils/
                            ├── AccessibleErrorCollector.java
                            ├── Artifacts.java
                            ├── ConfPath.groovy
                            └── TempGradleProject.groovy

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
.DS_Store
.gradle
build/

# Package Files #
*.jar
*.class

# Ignore Gradle GUI config
gradle-app.setting
gradle.properties

================================================
FILE: .travis.yml
================================================
branches:
  only:
    - master
    - dev

language: java

install: 
  - "./gradlew assemble install test"

env:
  global:
    - TERM=dumb

#debug task (dump gradle test report)
after_failure: 
  - "cat /home/travis/build/nhachicha/android-native-dependencies/build/reports/tests/index.html"
  - "cat /home/travis/build/nhachicha/android-native-dependencies/build/reports/tests/classes/com.nabilhachicha.nativedependencies.DependenciesResolverTest.html"
  - "cat /home/travis/build/nhachicha/android-native-dependencies/build/reports/tests/classes/com.nabilhachicha.nativedependencies.BasicPluginTest.html"
  - "cat /home/travis/build/nhachicha/android-native-dependencies/build/reports/tests/classes/com.nabilhachicha.nativedependencies.DependenciesResolverTest.html"


================================================
FILE: CHANGELOG.md
================================================
Version 0.1.2 *(2015-05-12)*
----------------------------
- Add support for 64bit ABI

Version 0.1.1 *(2014-08-17)*
----------------------------

- Add a DSL (addLibPrefixToArtifact=true|false) to disable prefixing the resolved artifact with 'lib'

Version 0.1.0 *(2014-05-25)*
----------------------------

- Initial version for the 0.1.x Android native dependencies plugin.


================================================
FILE: README.md
================================================
Overview
========
This Gradle plugin allows you to automatically *resolve and add* your native dependencies to `jniLibs` directory.

![screen shot 2014-04-10 at 15 29 40](https://cloud.githubusercontent.com/assets/1793238/2668930/6969020e-c0bd-11e3-9116-ae879991e356.png)

Usage
=====
Apply the plugin in your `build.gradle` after the regular `android` plugin, then declare the list of your native dependencies.
```groovy
buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:1.0.0'
    classpath 'com.nabilhachicha:android-native-dependencies:0.1.2'
  }
}

apply plugin: 'android'
apply plugin: 'android-native-dependencies'

native_dependencies {
    artifact 'com.snappydb:snappydb-native:0.2.+:armeabi'
    artifact 'com.snappydb:snappydb-native:0.2.+:x86'
}

dependencies {
    //regular Jar dependencies ...
}

```

Convention
==========

> The artifact DSL follows the naming convention for Maven artifacts.
> thus, you can use one of the following syntax:

- abbreviated *group:name:version[:classifier]*

```groovy
//adding x86 classifier will resolve only intel's (.so) lib
native_dependencies {
    artifact 'com.snappydb:snappydb-native:0.2+:x86'
}

//omit the classifier will resolve all supported architectures
native_dependencies {
    artifact 'com.snappydb:snappydb-native:0.2+'
}
```

- map-style notation


```groovy
//adding x86 classifier will resolve only intel's (.so) lib
native_dependencies {
    artifact group: 'com.snappydb', name: 'snappydb-native', version: '0.2+', classifier: 'x86'
}

//omit the classifier will resolve all supported architectures
native_dependencies {
    artifact group: 'com.snappydb', name: 'snappydb-native', version: '0.2+'
}
```
    
In both notations, *classifier* is optional. this means that when omitted, the plugin try to resolve the artifact for *all* architectures: `armeabi`, `armeabi-v7a`, `x86` and `mips`.

- Disable `lib` prefix:

You may want to disable the plugin from prefixing the resolved artifact with `lib`  (when copying into **jniLibs** directory) 
```groovy
native_dependencies {
    artifact ('com.snappydb:snappydb-native:0.2.+:armeabi') {
           addLibPrefixToArtifact=false
    }
}
```
in this example the ARM dependency will have the name `snappydb-native.so` rather than `libsnappydb-native.so`

Tasks
=====

The plugin adds the `resolveNativeDependencies` task to your project, this task runs automatically whenever you build your project. 
##### Note: #####
The plugin uses [Gradle incremental task](http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.incremental.IncrementalTaskInputs.html) system to run faster if the configuration didn't change since the last build.

License
=======

    Copyright 2014 Nabil Hachicha

    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.

[![Build Status](https://travis-ci.org/nhachicha/android-native-dependencies.svg?branch=master)](https://travis-ci.org/nhachicha/android-native-dependencies)




================================================
FILE: build.gradle
================================================
import org.gradle.api.artifacts.maven.MavenDeployment

buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://jcenter.bintray.com' }
    }

    dependencies {
        classpath 'org.gradle.api.plugins:gradle-nexus-plugin:0.3'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
    }
}

apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'nexus'

dependencies {
    compile gradleApi()
    compile localGroovy()
    compile 'com.android.tools.build:gradle:1.1.0'
    compile 'commons-io:commons-io:2.4'
    testCompile 'org.easytesting:fest-assert-core:2.0M10'
}

repositories {
    mavenCentral()
}

group = 'com.nabilhachicha'
version = '0.1.2'

modifyPom {
    project {
        name 'Android Native Dependencies'
        description 'Gradle plugin for resolving and downloading Android native dependencies (.so)'
        url 'https://github.com/nhachicha/android-native-dependencies'
        inceptionYear '2014'

        scm {
            url 'https://github.com/nhachicha/android-native-dependencies'
            connection 'scm:git:git://github.com/nhachicha/android-native-dependencies.git'
            developerConnection 'scm:git:ssh://git@github.com/nhachicha/android-native-dependencies.git'
        }

        licenses {
            license {
                name 'The Apache Software License, Version 2.0'
                url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                distribution 'repo'
            }
        }

        developers {
            developer {
                id 'nhachicha'
                name 'Nabil Hachicha'
                email 'nabil.hachicha@gmail.com'
            }
        }
    }
}

task srcJar(type: Jar) {
    classifier 'sources'
    from sourceSets.main.allSource
}

task gdocJar(type: Jar, dependsOn: groovydoc) {
    classifier 'groovydoc'
    from groovydoc.destinationDir
}

artifacts {
    archives srcJar
    archives gdocJar
    archives javadocJar
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java

            artifact srcJar
            artifact gdocJar
            artifact javadocJar

            pom.withXml {
                def root = asNode()
                root.appendNode('name', 'Android Native Dependencies')
                root.appendNode('url', 'https://github.com/nhachicha/android-native-dependencies')
                root.appendNode('description', 'Gradle plugin for resolving and downloading Android native dependencies (.so)')
                root.appendNode('inceptionYear', '2014')

                def scm = root.appendNode('scm')
                scm.appendNode('url', 'https://github.com/nhachicha/android-native-dependencies')
                scm.appendNode('connection', 'scm:git:git://github.com/nhachicha/android-native-dependencies.git')
                scm.appendNode('developerConnection', 'scm:git:ssh://git@github.com/nhachicha/android-native-dependencies.git')

                def license = root.appendNode('licenses').appendNode('license')
                license.appendNode('name', 'The Apache Software License, Version 2.0')
                license.appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt')
                license.appendNode('distribution', 'repo')

                def developers = root.appendNode('developers')
                def nabil = developers.appendNode('developer')
                nabil.appendNode('id', 'nhachicha')
                nabil.appendNode('name', 'Nabil Hachicha')
                nabil.appendNode('email', 'nabil.hachicha@gmail.com')
            }
        }
    }
}

bintray {
    key = project.hasProperty('bintray_apikey') ? project.getProperty('bintray_apikey') : null
    user = project.hasProperty('bintray_user') ? project.getProperty('bintray_user') : null
    publications = ['mavenJava']

    pkg {
        repo = 'gradle-plugins'
        name = 'android-native-dependencies'
        licenses = ['Apache-2.0']
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.2'
}


================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Sat May 09 23:02:18 BST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-bin.zip


================================================
FILE: gradlew
================================================
#!/usr/bin/env bash

##############################################################################
##
##  Gradle start up script for UN*X
##
##############################################################################

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
    echo "$*"
}

die ( ) {
    echo
    echo "$*"
    echo
    exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
  CYGWIN* )
    cygwin=true
    ;;
  Darwin* )
    darwin=true
    ;;
  MINGW* )
    msys=true
    ;;
esac

# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> \(.*\)$'`
    if expr "$link" : '/.*' > /dev/null; then
        PRG="$link"
    else
        PRG=`dirname "$PRG"`"/$link"
    fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
        # IBM's JDK on AIX uses strange locations for the executables
        JAVACMD="$JAVA_HOME/jre/sh/java"
    else
        JAVACMD="$JAVA_HOME/bin/java"
    fi
    if [ ! -x "$JAVACMD" ] ; then
        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
    fi
else
    JAVACMD="java"
    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
    MAX_FD_LIMIT=`ulimit -H -n`
    if [ $? -eq 0 ] ; then
        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
            MAX_FD="$MAX_FD_LIMIT"
        fi
        ulimit -n $MAX_FD
        if [ $? -ne 0 ] ; then
            warn "Could not set maximum file descriptor limit: $MAX_FD"
        fi
    else
        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
    fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

    # We build the pattern for arguments to be converted via cygpath
    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
    SEP=""
    for dir in $ROOTDIRSRAW ; do
        ROOTDIRS="$ROOTDIRS$SEP$dir"
        SEP="|"
    done
    OURCYGPATTERN="(^($ROOTDIRS))"
    # Add a user-defined pattern to the cygpath arguments
    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
    fi
    # Now convert the arguments - kludge to limit ourselves to /bin/sh
    i=0
    for arg in "$@" ; do
        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option

        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
        else
            eval `echo args$i`="\"$arg\""
        fi
        i=$((i+1))
    done
    case $i in
        (0) set -- ;;
        (1) set -- "$args0" ;;
        (2) set -- "$args0" "$args1" ;;
        (3) set -- "$args0" "$args1" "$args2" ;;
        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
    esac
fi

# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
    JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"


================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem  Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windowz variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega


================================================
FILE: src/main/groovy/com/nabilhachicha/nativedependencies/NativeDependenciesPlugin.groovy
================================================
/*
 * Copyright (C) 2014 Nabil HACHICHA.
 *
 * 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.
 */

package com.nabilhachicha.nativedependencies

import org.gradle.api.Project
import com.android.build.gradle.AppPlugin
import com.android.build.gradle.LibraryPlugin
import org.gradle.api.Task
import org.gradle.api.tasks.TaskInstantiationException
import org.gradle.api.Plugin
import com.nabilhachicha.nativedependencies.extension.NativeDependenciesExtension
import com.nabilhachicha.nativedependencies.task.NativeDependenciesResolverTask

class NativeDependenciesPlugin implements Plugin<Project> {
    final static PLUGIN_NAME = "native_dependencies"
    final static TASK_NAME = "resolveNativeDependencies"
    final static TASK_GROUP = "Android"
    final static TASK_DESCRIPTION = "Resolve native dependencies (.so)"
    final static TASK_ATTACH_TO_LIFECYCLE = "preBuild"

    def void apply(Project project) {
        verifyRequiredPlugins project

        project.configure(project) {
            extensions.create(PLUGIN_NAME, NativeDependenciesExtension)
        }

        project.afterEvaluate { evaluateResult ->
            if (null == evaluateResult.state.getFailure()) {
                Task task = project.task(TASK_NAME, type: NativeDependenciesResolverTask)
                task.setDescription(TASK_DESCRIPTION)
                task.setGroup(TASK_GROUP)
                task.
                	dependencies = project.native_dependencies.dependencies

                project.tasks.findByName(TASK_ATTACH_TO_LIFECYCLE).dependsOn task
            }
        }
    }

    private static void verifyRequiredPlugins(Project project) {
        if (!project.plugins.hasPlugin(AppPlugin) && !project.plugins.hasPlugin(LibraryPlugin)) {
            throw new TaskInstantiationException("'android' or 'android-library' plugin has to be applied before")
        }
    }
}


================================================
FILE: src/main/groovy/com/nabilhachicha/nativedependencies/extension/NativeDep.groovy
================================================
/*
 * Copyright (C) 2014 Nabil HACHICHA.
 *
 * 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.
 */

package com.nabilhachicha.nativedependencies.extension
import groovy.transform.Canonical

/**
 * POGO that represents an artifact to resolve by the Plugin
 */
@Canonical class NativeDep implements Serializable {
    String dependency
    boolean shouldPrefixWithLib = true
}

================================================
FILE: src/main/groovy/com/nabilhachicha/nativedependencies/extension/NativeDependenciesExtension.groovy
================================================
/*
 * Copyright (C) 2014 Nabil HACHICHA.
 *
 * 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.
 */

package com.nabilhachicha.nativedependencies.extension
import org.gradle.api.tasks.StopExecutionException
import org.gradle.util.ConfigureUtil

class NativeDependenciesExtension {
    final String CONFIGURATION_SEPARATOR = ":"
    final def classifiers = ['armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64', 'mips', 'mips64']
    def dependencies = []
    /**
     * set by a closure to let the user choose if he/she wants to disable
     * prefixing the artifact with 'lib'
     */
    boolean addLibPrefixToArtifact = true

    /**
     * add {@code dep} to the list of dependencies to retrieve
     *
     * @param dep
     * handle String notation ex: artifact com.snappydb:snappydb-native:0.2.+
     */
    def artifact (String dep, Closure... enablePrefixClosure) {
        if (enablePrefixClosure?.size()>0) {
            ConfigureUtil.configure(enablePrefixClosure[0], this);

        } else {// reset to default
            addLibPrefixToArtifact = true;
        }

        def dependency = dep.tokenize(CONFIGURATION_SEPARATOR)
        if (dependency.size() < 3 || dependency.size()>4) {
            throw new StopExecutionException('please specify group:name:version')

        } else if (dependency.size() == 3) {//add classifier
            classifiers.each {
                dependencies << new NativeDep (dependency: dep + CONFIGURATION_SEPARATOR + it, shouldPrefixWithLib: addLibPrefixToArtifact)
            }

        } else {
            dependencies << new NativeDep (dependency: dep, shouldPrefixWithLib: addLibPrefixToArtifact)
        }
    }

    /**
     * add {@code dep} to the list of dependencies to retrieve
     *
     * @param dep
     * artifact group: 'com.snappydb', name: 'snappydb-native', version: '0.2.0'
     *
     * Note: if the user doesn't specify the optional 'classifier', this method will add
     * all the supported architectures to this dependencies ('armeabi', 'armeabi-v7a', 'x86' and 'mips')
     */
    def artifact (Map m, Closure... enablePrefixClosure) {
        if (enablePrefixClosure?.size()>0) {
            ConfigureUtil.configure(enablePrefixClosure[0], this);

        } else {// reset to default
            addLibPrefixToArtifact = true;
        }

        String temp = m['group'] + CONFIGURATION_SEPARATOR + m['name'] + CONFIGURATION_SEPARATOR + m['version']

        if(!m.containsKey('classifier')) {
            classifiers.each {
                dependencies << new NativeDep (dependency: temp + CONFIGURATION_SEPARATOR + it, shouldPrefixWithLib: addLibPrefixToArtifact)
            }
        } else {
            dependencies << new NativeDep (dependency: temp + CONFIGURATION_SEPARATOR + m['classifier'], shouldPrefixWithLib: addLibPrefixToArtifact)
        }
    }
}


================================================
FILE: src/main/groovy/com/nabilhachicha/nativedependencies/task/NativeDependenciesResolverTask.groovy
================================================
/*
 * Copyright (C) 2014 Nabil HACHICHA.
 *
 * 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.
 */

package com.nabilhachicha.nativedependencies.task

import com.nabilhachicha.nativedependencies.extension.NativeDep
import org.gradle.api.DefaultTask
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.ResolveException
import org.gradle.api.logging.Logger
import org.gradle.api.logging.Logging
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.incremental.IncrementalTaskInputs

class NativeDependenciesResolverTask extends DefaultTask {
    def @Input
            dependencies
    def @OutputDirectory
            jniLibs = project.android.sourceSets.main.jniLibs.srcDirs.first()

    final String X86_FILTER = "x86"
    final String X86_64_FILTER = "x86_64"
    final String MIPS_FILTER = "mips"
    final String MIPS_64_FILTER = "mips64"
    final String ARM_FILTER = "armeabi"
    final String ARMV7A_FILTER = "armeabi-v7a"
    final String ARM64_FILTER = "arm64-v8a"
    final String DEPENDENCY_SUFFIX = "@so"
    final String ARTIFACT_FILE_EXT = ".so"

    final Logger log = Logging.getLogger NativeDependenciesResolverTask

    @TaskAction
    def exec(IncrementalTaskInputs inputs) {
        project.delete { jniLibs }
        log.lifecycle "Executing NativeDependenciesResolverTask"
        dependencies.each { artifact ->
            log.info "Processing artifact: '$artifact.dependency'"
            copyToJniLibs artifact
        }
    }

    def copyToJniLibs(NativeDep artifact) {
        String filter

        if (artifact.dependency.endsWith(X86_FILTER)) {
            filter = X86_FILTER

        } else if (artifact.dependency.endsWith(X86_64_FILTER)) {
            filter = X86_64_FILTER

        } else if (artifact.dependency.endsWith(MIPS_FILTER)) {
            filter = MIPS_FILTER

        } else if (artifact.dependency.endsWith(MIPS_64_FILTER)) {
            filter = MIPS_64_FILTER

        } else if (artifact.dependency.endsWith(ARM_FILTER)) {
            filter = ARM_FILTER

        } else if (artifact.dependency.endsWith(ARMV7A_FILTER)) {
            filter = ARMV7A_FILTER

        } else if (artifact.dependency.endsWith(ARM64_FILTER)) {
            filter = ARM64_FILTER

        } else {
            throw new IllegalArgumentException("Unsupported architecture for artifact '${artifact.dependency}'.")
        }

        try {
            def map = downloadDep(artifact.dependency)
            if (!map.isEmpty()) {
                copyToTarget(map.depFile, filter, map.depName, artifact.shouldPrefixWithLib)

            } else {
                log.warn("Failed to retrieve artifcat '$artifact'")
            }

        } catch (ResolveException e) {
            log.warn("Could not resolve artifcat '$artifact'", e)
        }
    }

    /**
     * Download (or use gradle cache) the artifact from the user's defined repositories
     *
     * @param artifact
     * The dependency notation, in one of the accepted notations:
     *
     * native_dependencies {
     *   //the string notation, e.g. group:name:version
     *   artifact com.snappydb:snappydb-native:0.2.+
     *
     *   //map notation:
     *   artifact group: 'com.snappydb', name: 'snappydb-native', version: '0.2.0'
     *
     *   //optional, you can specify the 'classifier' in order to restrict the desired architecture(s)
     *   artifact group: 'com.snappydb', name: 'snappydb-native', version: '0.2.0', classifier: 'armeabi'
     *   //or
     *   artifact com.snappydb:snappydb-native:0.2.+:armeabi
     *}*
     * @return
     * the dependency {@link java.io.File} or null
     */
    def downloadDep(String artifact) {
        log.info "Trying to resolve artifact '$artifact' using defined repositories"

        def map = [:]
        Dependency dependency = project.dependencies.create(artifact + DEPENDENCY_SUFFIX)
        Configuration configuration = project.configurations.detachedConfiguration(dependency)
        configuration.setTransitive(false)

        configuration.files.each { file ->
            if (file.isFile() && file.name.endsWith(ARTIFACT_FILE_EXT)) {
                map['depFile'] = file
                map['depName'] = dependency.getName()
            } else {
                log.info "Could not find the file corresponding to the artifact '$artifact'"
            }
        }
        return map
    }

    /**
     * Copy the artifact file from gradle cache to the project appropriate jniLibs directory
     *
     * @param depFile
     * {@link java.io.File} to copy
     *
     * @param architecture
     * supported jniLibs architecture ("x86", "x86_64", "mips", "mips64", "armeabi", "armeabi-v7a" or "arm64-v8a")
     *
     * @param shouldPrefixWithLib
     * enable or disable the standard 'lib' prefix to an artifact name
     */
    def copyToTarget(File depFile, String architecture, String depName, boolean shouldPrefixWithLib) {
        project.copy {
            from depFile
            into "$jniLibs" + File.separator + "$architecture"

            rename { fileName ->
                if (shouldPrefixWithLib) {
                    "lib" + depName + ".so"
                } else {
                    depName + ".so"
                }
            }
        }
    }
}


================================================
FILE: src/main/resources/META-INF/gradle-plugins/android-native-dependencies.properties
================================================
implementation-class=com.nabilhachicha.nativedependencies.NativeDependenciesPlugin

================================================
FILE: src/test/gradle_project_template/build.gradle
================================================
buildscript {
    repositories {
        mavenCentral()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath group: 'com.nabilhachicha', name: 'android-native-dependencies', version: '0.1.2'
        classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.10.1'
    }
}

apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'android-native-dependencies'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"
}




================================================
FILE: src/test/gradle_project_template/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>

<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionCode="1"
    android:versionName="1.0"
    package="com.example.nativedependencies">
    <uses-sdk android:minSdkVersion="9" />
</manifest>

================================================
FILE: src/test/gradle_project_template_custom_jni_dir/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>

<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionCode="1"
    android:versionName="1.0"
    package="com.example.nativedependencies"
    />


================================================
FILE: src/test/gradle_project_template_custom_jni_dir/build.gradle
================================================
buildscript {
    repositories {
        mavenCentral()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath group: 'com.nabilhachicha', name: 'android-native-dependencies', version: '0.1.2'
        classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.10.1'
    }
}

apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'android-native-dependencies'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['src/main/native_libs']
        }
    }
}





================================================
FILE: src/test/gradle_project_template_custom_jni_dir/src/main/native_libs/.empty
================================================


================================================
FILE: src/test/groovy/com/nabilhachicha/nativedependencies/BasicPluginTest.groovy
================================================
/*
 * Copyright (C) 2014 Nabil HACHICHA.
 *
 * 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.
 */

package com.nabilhachicha.nativedependencies
import com.nabilhachicha.nativedependencies.task.NativeDependenciesResolverTask
import org.gradle.api.Project
import org.gradle.testfixtures.ProjectBuilder
import org.junit.Test
import org.gradle.api.internal.plugins.PluginApplicationException
import static org.junit.Assert.assertTrue

class BasicPluginTest {

    @Test(expected = PluginApplicationException.class)
    public void testShouldApplyAndroidPluginBefore() {
        Project project = ProjectBuilder.builder().build()
        project.apply plugin: 'android-native-dependencies'
    }

    @Test
    public void testTaskCreation() {
        Project project = ProjectBuilder.builder().build()
        project.apply plugin: 'com.android.application'
        project.apply plugin: 'android-native-dependencies'
        def task = project.task('resolveNativeDependencies', type: NativeDependenciesResolverTask)

        assertTrue(task instanceof NativeDependenciesResolverTask)
    }

}

================================================
FILE: src/test/groovy/com/nabilhachicha/nativedependencies/DependenciesResolverTest.groovy
================================================
/*
 * Copyright (C) 2014 Nabil HACHICHA.
 *
 * 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.
 */

package com.nabilhachicha.nativedependencies

import com.nabilhachicha.nativedependencies.utils.Artifacts
import com.nabilhachicha.nativedependencies.utils.ConfPath
import com.nabilhachicha.nativedependencies.utils.TempGradleProject
import org.gradle.tooling.BuildLauncher
import org.gradle.tooling.GradleConnector
import org.gradle.tooling.ProjectConnection
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test

import static org.fest.assertions.api.Assertions.assertThat

class DependenciesResolverTest {
    @Rule
    public TempGradleProject gradleProject = new TempGradleProject(
            new ConfPath(path: "src${File.separator}test${File.separator}gradle_project_template",
                    jniLibsLocation: "${File.separator}src${File.separator}main${File.separator}jniLibs"),
            new ConfPath(path: "src${File.separator}test${File.separator}gradle_project_template_custom_jni_dir",
                    jniLibsLocation: "${File.separator}src${File.separator}main${File.separator}native_libs"))

    ProjectConnection mConnection

    @Before
    public void setUp() {
        try {
            GradleConnector connector = GradleConnector.newConnector();

            //append DSL to this build
            gradleProject.gradleFile.append "native_dependencies { " + gradleProject.artifacts.join('\n') + " }"

            connector.forProjectDirectory(gradleProject.root);
            mConnection = connector.connect();

            // Configure the build
            BuildLauncher launcher = mConnection.newBuild();
            launcher.forTasks("resolveNativeDependencies");
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            launcher.setStandardOutput(outputStream);
            launcher.setStandardError(outputStream);

            // Run the build
            launcher.run();
        } catch (Exception exception) {
            exception.printStackTrace()
        }
    }

    @After
    public void tearDown() {
        mConnection?.close();
    }

    @Artifacts("artifact 'com.snappydb:snappydb-native:0.2.0'")
    @Test
    public void testDSLResolveWithStringNotationAllArch() {
        assertThat(gradleProject.mJniLibs).exists()

        assertThat(gradleProject.mMipsDepFile).exists()
        assertThat(gradleProject.mX86Dir).exists()
        assertThat(gradleProject.mArmDir).exists()
        assertThat(gradleProject.mArmv7aDir).exists()

        assertThat(gradleProject.mMipsDepFile).exists()
        assertThat(gradleProject.mX86DepFile).exists()
        assertThat(gradleProject.mArmDepFile).exists()
        assertThat(gradleProject.mArmv7aDepFile).exists()
    }

    @Artifacts("artifact group: 'com.snappydb', name: 'snappydb-native', version: '0.2.0'")
    @Test
    public void testDSLResolveWithMappingNotationAllArch() {
        assertThat(gradleProject.mJniLibs).exists()

        assertThat(gradleProject.mMipsDir).exists()
        assertThat(gradleProject.mX86Dir).exists()
        assertThat(gradleProject.mArmDir).exists()
        assertThat(gradleProject.mArmv7aDir).exists()

        assertThat(gradleProject.mMipsDepFile).exists()
        assertThat(gradleProject.mX86DepFile).exists()
        assertThat(gradleProject.mArmDepFile).exists()
        assertThat(gradleProject.mArmv7aDepFile).exists()
    }

    @Artifacts(["artifact 'com.snappydb:snappydb-native:0.2.0:mips'",
            "artifact 'com.snappydb:snappydb-native:0.2.0:x86'"])
    @Test
    public void testDSLResolveWithStringNotationFilterByArch() {
        assertThat(gradleProject.mJniLibs).exists()

        assertThat(gradleProject.mMipsDepFile).exists()
        assertThat(gradleProject.mX86Dir).exists()

        assertThat(gradleProject.mMipsDepFile).exists()
        assertThat(gradleProject.mX86DepFile).exists()
    }

    @Artifacts(["artifact group: 'com.snappydb', name: 'snappydb-native', version: '0.2.0', classifier: 'armeabi'",
            "artifact group: 'com.snappydb', name: 'snappydb-native', version: '0.2.0', classifier: 'armeabi-v7a'"])
    @Test
    public void testDSLResolveWithMappingNotationFilterByArch() {
        assertThat(gradleProject.mJniLibs).exists()

        assertThat(gradleProject.mArmDir).exists()
        assertThat(gradleProject.mArmv7aDir).exists()

        assertThat(gradleProject.mArmDepFile).exists()
        assertThat(gradleProject.mArmv7aDepFile).exists()
    }

    @Artifacts("artifact group: 'com.snappydb', name: 'snappydb-native', version: '0.2.+', classifier: 'armeabi'")
    @Test
    public void testRangeNotationResolveWithMapping() {
        assertThat(gradleProject.mJniLibs).exists()

        assertThat(gradleProject.mArmDir).exists()

        assertThat(gradleProject.mArmDepFile).exists()
    }

    @Artifacts("artifact 'com.snappydb:snappydb-native:0.2.+:x86'")
    @Test
    public void testRangeNotationResolveWithStringNotation() {
        assertThat(gradleProject.mJniLibs).exists()

        assertThat(gradleProject.mX86Dir).exists()

        assertThat(gradleProject.mX86DepFile).exists()
    }

    // Testing addLibPrefixToArtifact closure

    @Artifacts("artifact (group: 'com.snappydb', name: 'snappydb-native', version: '0.2.0', classifier: 'mips') { addLibPrefixToArtifact=false }")
    @Test
    public void testDisableLibPrefixStringNotation() {
        assertThat(gradleProject.mJniLibs).exists()
        assertThat(gradleProject.mMipsDir).exists()
        assertThat(gradleProject.mMipsDepFileNoLibPrefix).exists()
    }

    @Artifacts("artifact (group: 'com.snappydb', name: 'snappydb-native', version: '0.2.0', classifier: 'mips') { addLibPrefixToArtifact=true }")
    @Test
    public void testEnableLibPrefixStringNotation() {
        assertThat(gradleProject.mJniLibs).exists()
        assertThat(gradleProject.mMipsDir).exists()
        assertThat(gradleProject.mMipsDepFile).exists()
    }

    @Artifacts(["artifact ('com.snappydb:snappydb-native:0.2.0:mips') { addLibPrefixToArtifact = false } ",
            "artifact 'com.snappydb:snappydb-native:0.2.0:x86'",
            "artifact ('com.snappydb:snappydb-native:0.2.0:armeabi') { addLibPrefixToArtifact = false } ",
            "artifact 'com.snappydb:snappydb-native:0.2.0:armeabi-v7a'"])
    @Test
    public void testLibPrefixMixStringNotation() {
        assertThat(gradleProject.mJniLibs).exists()
        assertThat(gradleProject.mMipsDir).exists()
        assertThat(gradleProject.mX86Dir).exists()
        assertThat(gradleProject.mArmDir).exists()
        assertThat(gradleProject.mArmv7aDir).exists()

        assertThat(gradleProject.mMipsDepFileNoLibPrefix).exists()
        assertThat(gradleProject.mX86DepFile).exists()
        assertThat(gradleProject.mArmDepFileNoLibPrefix).exists()
        assertThat(gradleProject.mArmv7aDepFile).exists()
    }

    @Artifacts(["artifact (group: 'com.snappydb', name: 'snappydb-native', version: '0.2.0', classifier: 'mips') {}",
            "artifact (group: 'com.snappydb', name: 'snappydb-native', version: '0.2.0', classifier: 'x86') { addLibPrefixToArtifact=false }",
            "artifact (group: 'com.snappydb', name: 'snappydb-native', version: '0.2.0', classifier: 'armeabi')",
            "artifact (group: 'com.snappydb', name: 'snappydb-native', version: '0.2.0', classifier: 'armeabi-v7a') { addLibPrefixToArtifact=false }"])
    @Test
    public void testLibPrefixMixMappingNotation() {
        assertThat(gradleProject.mJniLibs).exists()
        assertThat(gradleProject.mMipsDir).exists()
        assertThat(gradleProject.mX86Dir).exists()
        assertThat(gradleProject.mArmDir).exists()
        assertThat(gradleProject.mArmv7aDir).exists()

        assertThat(gradleProject.mMipsDepFile).exists()
        assertThat(gradleProject.mX86DepFileNoLibPrefix).exists()
        assertThat(gradleProject.mArmDepFile).exists()
        assertThat(gradleProject.mArmv7aDepFileNoLibPrefix).exists()
    }
}

================================================
FILE: src/test/groovy/com/nabilhachicha/nativedependencies/utils/AccessibleErrorCollector.java
================================================
package com.nabilhachicha.nativedependencies.utils;

import org.junit.rules.ErrorCollector;

/**
 * Created by Nabil on 12/05/15.
 * Expose {@link ErrorCollector#verify()} method as public
 */
public class AccessibleErrorCollector extends ErrorCollector {
    @Override
    public void verify() throws Throwable {
        super.verify();
    }
}

================================================
FILE: src/test/groovy/com/nabilhachicha/nativedependencies/utils/Artifacts.java
================================================
/*
 * Copyright (C) 2014 Nabil HACHICHA.
 *
 * 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.
 */

package com.nabilhachicha.nativedependencies.utils;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;


@Target(METHOD) @Retention(RUNTIME)
public @interface Artifacts {
    String[] value ();
}

================================================
FILE: src/test/groovy/com/nabilhachicha/nativedependencies/utils/ConfPath.groovy
================================================
package com.nabilhachicha.nativedependencies.utils;

/**
 * Created by Nabil on 12/05/15.
 */
public class ConfPath {
    String path
    String jniLibsLocation
}


================================================
FILE: src/test/groovy/com/nabilhachicha/nativedependencies/utils/TempGradleProject.groovy
================================================
/*
 * Copyright (C) 2014 Nabil HACHICHA.
 *
 * 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.
 */

package com.nabilhachicha.nativedependencies.utils

import org.apache.commons.io.FileUtils
import org.junit.rules.TemporaryFolder
import org.junit.runner.Description
import org.junit.runners.model.Statement

public class TempGradleProject extends TemporaryFolder {
    final ConfPath[] gradleTemplateDir
    final String GRADLE_BUILD_FILE = "build.gradle"
    File gradleFile
    String[] artifacts
    ConfPath currentDir;

    // Param
    File mJniLibs

    File mMipsDir
    File mX86Dir
    File mArmDir
    File mArmv7aDir

    File mMipsDepFile
    File mX86DepFile
    File mArmDepFile
    File mArmv7aDepFile

    File mMipsDepFileNoLibPrefix
    File mX86DepFileNoLibPrefix
    File mArmDepFileNoLibPrefix
    File mArmv7aDepFileNoLibPrefix

    public TempGradleProject(ConfPath... templateDir) {
        gradleTemplateDir = templateDir
    }

    @Override
    protected void before() throws Throwable {
        super.before();

        File templateDir = new File(currentDir.path)

        def root = getRoot()
        FileUtils.copyDirectory(templateDir, root)

        gradleFile = new File(root, GRADLE_BUILD_FILE)

        mJniLibs = new File(root.absolutePath + currentDir.jniLibsLocation)

        mMipsDir = new File(mJniLibs, 'mips')
        mX86Dir = new File(mJniLibs, 'x86')
        mArmDir = new File(mJniLibs, 'armeabi')
        mArmv7aDir = new File(mJniLibs, 'armeabi-v7a')

        mMipsDepFile = new File(mMipsDir, 'libsnappydb-native.so')
        mX86DepFile = new File(mX86Dir, 'libsnappydb-native.so')
        mArmDepFile = new File(mArmDir, 'libsnappydb-native.so')
        mArmv7aDepFile = new File(mArmv7aDir, 'libsnappydb-native.so')

        mMipsDepFileNoLibPrefix = new File(mMipsDir, 'snappydb-native.so')
        mX86DepFileNoLibPrefix = new File(mX86Dir, 'snappydb-native.so')
        mArmDepFileNoLibPrefix = new File(mArmDir, 'snappydb-native.so')
        mArmv7aDepFileNoLibPrefix = new File(mArmv7aDir, 'snappydb-native.so')

    }

    @Override
    public Statement apply(Statement base, Description description) {
        Artifacts annotation = description.getAnnotation(Artifacts.class);
        if (annotation == null) {
            throw new IllegalStateException(String.format("Test '%s' missing @Artifacts annotation.",
                    description.getDisplayName()));
        }
        artifacts = annotation.value();
        return new RepeatedStatement(base, gradleTemplateDir);
    }


    class RepeatedStatement extends Statement {
        final ConfPath[] dirPaths;
        final Statement test;
        final AccessibleErrorCollector errorCollector;

        public RepeatedStatement(Statement test, ConfPath[] dirPaths) {
            this.dirPaths = dirPaths;
            this.test = test;
            this.errorCollector = new AccessibleErrorCollector();
        }


        @Override
        public void evaluate() throws Throwable {
            for (ConfPath path : dirPaths) {
                currentDir = path;
                before();

                try {
                    test.evaluate();
                } catch (Throwable t) {
                    errorCollector.addError(new AssertionError("For dir: " + currentDir.path, t));
                } finally {
                    after();
                }
            }

            errorCollector.verify();
        }
    }
}
Download .txt
gitextract_f9n_ymw9/

├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── README.md
├── build.gradle
├── gradle/
│   └── wrapper/
│       └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src/
    ├── main/
    │   ├── groovy/
    │   │   └── com/
    │   │       └── nabilhachicha/
    │   │           └── nativedependencies/
    │   │               ├── NativeDependenciesPlugin.groovy
    │   │               ├── extension/
    │   │               │   ├── NativeDep.groovy
    │   │               │   └── NativeDependenciesExtension.groovy
    │   │               └── task/
    │   │                   └── NativeDependenciesResolverTask.groovy
    │   └── resources/
    │       └── META-INF/
    │           └── gradle-plugins/
    │               └── android-native-dependencies.properties
    └── test/
        ├── gradle_project_template/
        │   ├── build.gradle
        │   └── src/
        │       └── main/
        │           └── AndroidManifest.xml
        ├── gradle_project_template_custom_jni_dir/
        │   ├── AndroidManifest.xml
        │   ├── build.gradle
        │   └── src/
        │       └── main/
        │           └── native_libs/
        │               └── .empty
        └── groovy/
            └── com/
                └── nabilhachicha/
                    └── nativedependencies/
                        ├── BasicPluginTest.groovy
                        ├── DependenciesResolverTest.groovy
                        └── utils/
                            ├── AccessibleErrorCollector.java
                            ├── Artifacts.java
                            ├── ConfPath.groovy
                            └── TempGradleProject.groovy
Download .txt
SYMBOL INDEX (2 symbols across 1 files)

FILE: src/test/groovy/com/nabilhachicha/nativedependencies/utils/AccessibleErrorCollector.java
  class AccessibleErrorCollector (line 9) | public class AccessibleErrorCollector extends ErrorCollector {
    method verify (line 10) | @Override
Condensed preview — 24 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (51K chars).
[
  {
    "path": ".gitignore",
    "chars": 122,
    "preview": ".DS_Store\n.gradle\nbuild/\n\n# Package Files #\n*.jar\n*.class\n\n# Ignore Gradle GUI config\ngradle-app.setting\ngradle.properti"
  },
  {
    "path": ".travis.yml",
    "chars": 768,
    "preview": "branches:\n  only:\n    - master\n    - dev\n\nlanguage: java\n\ninstall: \n  - \"./gradlew assemble install test\"\n\nenv:\n  global"
  },
  {
    "path": "CHANGELOG.md",
    "chars": 376,
    "preview": "Version 0.1.2 *(2015-05-12)*\n----------------------------\n- Add support for 64bit ABI\n\nVersion 0.1.1 *(2014-08-17)*\n----"
  },
  {
    "path": "README.md",
    "chars": 3504,
    "preview": "Overview\n========\nThis Gradle plugin allows you to automatically *resolve and add* your native dependencies to `jniLibs`"
  },
  {
    "path": "build.gradle",
    "chars": 4127,
    "preview": "import org.gradle.api.artifacts.maven.MavenDeployment\n\nbuildscript {\n    repositories {\n        mavenCentral()\n        m"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "chars": 230,
    "preview": "#Sat May 09 23:02:18 BST 2015\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
  },
  {
    "path": "gradlew",
    "chars": 5080,
    "preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start "
  },
  {
    "path": "gradlew.bat",
    "chars": 2404,
    "preview": "@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@r"
  },
  {
    "path": "src/main/groovy/com/nabilhachicha/nativedependencies/NativeDependenciesPlugin.groovy",
    "chars": 2380,
    "preview": "/*\n * Copyright (C) 2014 Nabil HACHICHA.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
  },
  {
    "path": "src/main/groovy/com/nabilhachicha/nativedependencies/extension/NativeDep.groovy",
    "chars": 879,
    "preview": "/*\n * Copyright (C) 2014 Nabil HACHICHA.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
  },
  {
    "path": "src/main/groovy/com/nabilhachicha/nativedependencies/extension/NativeDependenciesExtension.groovy",
    "chars": 3351,
    "preview": "/*\n * Copyright (C) 2014 Nabil HACHICHA.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
  },
  {
    "path": "src/main/groovy/com/nabilhachicha/nativedependencies/task/NativeDependenciesResolverTask.groovy",
    "chars": 5899,
    "preview": "/*\n * Copyright (C) 2014 Nabil HACHICHA.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
  },
  {
    "path": "src/main/resources/META-INF/gradle-plugins/android-native-dependencies.properties",
    "chars": 82,
    "preview": "implementation-class=com.nabilhachicha.nativedependencies.NativeDependenciesPlugin"
  },
  {
    "path": "src/test/gradle_project_template/build.gradle",
    "chars": 564,
    "preview": "buildscript {\n    repositories {\n        mavenCentral()\n        mavenLocal()\n    }\n    dependencies {\n        classpath "
  },
  {
    "path": "src/test/gradle_project_template/src/main/AndroidManifest.xml",
    "chars": 271,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<manifest\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    and"
  },
  {
    "path": "src/test/gradle_project_template_custom_jni_dir/AndroidManifest.xml",
    "chars": 223,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<manifest\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    and"
  },
  {
    "path": "src/test/gradle_project_template_custom_jni_dir/build.gradle",
    "chars": 869,
    "preview": "buildscript {\n    repositories {\n        mavenCentral()\n        mavenLocal()\n    }\n    dependencies {\n        classpath "
  },
  {
    "path": "src/test/gradle_project_template_custom_jni_dir/src/main/native_libs/.empty",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "src/test/groovy/com/nabilhachicha/nativedependencies/BasicPluginTest.groovy",
    "chars": 1595,
    "preview": "/*\n * Copyright (C) 2014 Nabil HACHICHA.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
  },
  {
    "path": "src/test/groovy/com/nabilhachicha/nativedependencies/DependenciesResolverTest.groovy",
    "chars": 8524,
    "preview": "/*\n * Copyright (C) 2014 Nabil HACHICHA.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
  },
  {
    "path": "src/test/groovy/com/nabilhachicha/nativedependencies/utils/AccessibleErrorCollector.java",
    "chars": 345,
    "preview": "package com.nabilhachicha.nativedependencies.utils;\n\nimport org.junit.rules.ErrorCollector;\n\n/**\n * Created by Nabil on "
  },
  {
    "path": "src/test/groovy/com/nabilhachicha/nativedependencies/utils/Artifacts.java",
    "chars": 941,
    "preview": "/*\n * Copyright (C) 2014 Nabil HACHICHA.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
  },
  {
    "path": "src/test/groovy/com/nabilhachicha/nativedependencies/utils/ConfPath.groovy",
    "chars": 163,
    "preview": "package com.nabilhachicha.nativedependencies.utils;\n\n/**\n * Created by Nabil on 12/05/15.\n */\npublic class ConfPath {\n  "
  },
  {
    "path": "src/test/groovy/com/nabilhachicha/nativedependencies/utils/TempGradleProject.groovy",
    "chars": 3957,
    "preview": "/*\n * Copyright (C) 2014 Nabil HACHICHA.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
  }
]

About this extraction

This page contains the full source code of the nhachicha/android-native-dependencies GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 24 files (45.6 KB), approximately 12.7k tokens, and a symbol index with 2 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!