├── .gitignore ├── CHANGELOG.md ├── LICENSE.txt ├── README.cn.md ├── README.md ├── app ├── build.gradle └── src │ └── main │ ├── groovy │ └── com │ │ └── jween │ │ └── gradle │ │ └── soexcluder │ │ ├── AppPlugin.groovy │ │ └── Rule.groovy │ └── resources │ └── META-INF │ └── gradle-plugins │ └── android-soexcluder.properties ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── sample-android-app ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── jween │ │ └── soexcluder │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── jween │ │ │ └── soexcluder │ │ │ └── ScrollingActivity.java │ ├── jniLibs │ │ ├── arm64-v8a │ │ │ ├── librealm-jni.so │ │ │ └── libweibosdkcore.so │ │ └── armeabi-v7a │ │ │ ├── librealm-jni.so │ │ │ └── libweibosdkcore.so │ └── res │ │ ├── layout │ │ ├── activity_scrolling.xml │ │ └── content_scrolling.xml │ │ ├── menu │ │ └── menu_scrolling.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ └── styles.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── jween │ └── soexcluder │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | 3 | .DS_Store 4 | /captures 5 | .gradle 6 | .idea 7 | build/ 8 | local.properties -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### 1.1 2 | - change exclude/include behavior 3 | from now on, you can call include and exclude multiple times just like gradle 4 | 5 | 6 | ### 1.0 7 | - First version 8 | 9 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | "THE BEER-WARE LICENSE" (Revision 42): 3 | 4 | wrote this file. As long as you retain this notice 5 | you can do whatever you want with this stuff. If we meet some day, and you think 6 | this stuff is worth it, you can buy me a beer in return. -Jween Lau 7 | -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /README.cn.md: -------------------------------------------------------------------------------- 1 | [Gradle Android so 文件过滤插件](https://github.com/Jween/android-soexcluder) 2 | ============================ 3 | 4 | 此插件可以根据 buildType 或者 flavor 来过滤 so 文件 5 | 6 | 7 | 使用 8 | ----- 9 | 10 | 1. 在 build.gradle 中添加以下脚本 11 | 12 | ```groovy 13 | buildscript { 14 | repositories { 15 | jcenter() 16 | } 17 | 18 | dependencies { 19 | classpath 'com.jween.gradle:android-soexcluder:1.1' 20 | } 21 | } 22 | 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'android-soexcluder' 26 | ``` 27 | **注意**: `android-soexcluder`插件必须和`com.android.application`插件配合使用 28 | 29 | 30 | 配置 31 | ---- 32 | 33 | 1. 根据flavor移除指定so文件 34 | 35 | ```groovy 36 | soexcluder { 37 | // 为flavor1 移除v7a的foo.so与v8a的bar.so文件 38 | flavor1 { 39 | exclude "lib/armeabi-v7a/foo.so", "lib/armeabi-v8a/bar.so" 40 | } 41 | 42 | // 对debug buildType保留v7a和x86 abi的除foo.so之外的所有so文件 43 | debug { 44 | include "lib/armeabi-v7a/*.so" 45 | include "lib/x86/*.so" 46 | exclude "lib/armeabi-v7a/foo.so" 47 | exclude "lib/x86/foo.so" 48 | } 49 | } 50 | ``` 51 | 52 | 2. 与 gradle 的 include/exclude 的Ant路径正则用法完全一致 53 | 54 | ```groovy 55 | soexcluder { 56 | 57 | // 对debug buildType保留除foo.so之外的所有so文件 58 | debug { 59 | include "**/*" 60 | exclude "**/foo.so" 61 | } 62 | } 63 | ``` 64 | 65 | 3. 你甚至可以对buildType以及flavor使用正则表达式! 66 | 67 | ```groovy 68 | soexcluder { 69 | 70 | // 当flavor或者buildType的名字以o结尾的时候, 移除所有so文件 71 | ".*o" { 72 | exclude "**/*" 73 | } 74 | } 75 | ``` 76 | 77 | License 78 | ------- 79 | 80 | "THE BEER-WARE LICENSE" (Revision 42): 81 | 82 | wrote this file. As long as you retain this notice 83 | you can do whatever you want with this stuff. If we meet some day, and you think 84 | this stuff is worth it, you can buy me a beer in return. -Jween Lau 85 | 86 | 87 | [Anti-996 License](https://github.com/996icu/996.ICU/blob/master/LICENSE) 88 | -------- 89 | 90 | - The purpose of this license is to prevent anti-labour-law companies from using the software or codes under the license, and force those companies to weigh their way of working 91 | - See a [full list of projects](https://github.com/996icu/996.ICU/blob/master/awesomelist/README.md) under Anti-996 License 92 | 93 | - This draft is adapted from the MIT license. For more detailed explanation, please see [Wiki](https://github.com/kattgu7/996-License-Draft/wiki). This license is designed to be compatible with all major open source licenses. 94 | - For law professionals or anyone who is willing to contribute to future version directly, please go to [Anti-996-License-1.0](https://github.com/kattgu7/996-License-Draft). Thank you. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [Gradle Android So Excluder Plugin](https://github.com/Jween/android-soexcluder) 2 | ========================================= 3 | 4 | This plugin will help you exclude so files by flavor or buildType 5 | 6 | [中文版本 README](README.cn.md) 7 | 8 | 9 | Usage 10 | ----- 11 | 12 | 1. Add the following scripts to your build.gradle 13 | 14 | ```groovy 15 | buildscript { 16 | repositories { 17 | jcenter() 18 | } 19 | 20 | dependencies { 21 | classpath 'com.jween.gradle:android-soexcluder:1.1' 22 | } 23 | } 24 | 25 | 26 | apply plugin: 'com.android.application' 27 | apply plugin: 'android-soexcluder' 28 | ``` 29 | **Note**: You MUST apply `android-soexcluder` along with `com.android.application` 30 | 31 | 2. Wish we have step 2! 32 | 33 | But that's it, it a quite simple small tool to deal with so files. 34 | 35 | Configuration 36 | ------------- 37 | 38 | 1. Exclude specific so files by flavors 39 | 40 | ```groovy 41 | soexcluder { 42 | // exclude armeabi-v7a/foo.so and armeabi-v8a/bar.so for flavor1 43 | flavor1 { 44 | exclude "lib/armeabi-v7a/foo.so", "lib/armeabi-v8a/bar.so" 45 | } 46 | 47 | // Reserve only v7a and x86 so files except foo.so for debug buildType 48 | debug { 49 | include "lib/armeabi-v7a/*.so" 50 | include "lib/x86/*.so" 51 | exclude "lib/armeabi-v7a/foo.so" 52 | exclude "lib/x86/foo.so" 53 | } 54 | } 55 | ``` 56 | 57 | 2. Exact the same path pattern as gradle include/exclude api 58 | 59 | ```groovy 60 | soexcluder { 61 | 62 | // Reserve all so files for debug buildType except foo.so 63 | debug { 64 | include "**/*" 65 | exclude "**/foo.so" 66 | } 67 | } 68 | ``` 69 | 70 | 3. You can even use regex in flavor/buildType entry! 71 | 72 | ```groovy 73 | soexcluder { 74 | 75 | // Remove all so files if the flavor or buildType name ends with 'o' 76 | ".*o" { 77 | exclude "**/*" 78 | } 79 | } 80 | ``` 81 | 82 | License 83 | ------- 84 | 85 | "THE BEER-WARE LICENSE" (Revision 42): 86 | 87 | wrote this file. As long as you retain this notice 88 | you can do whatever you want with this stuff. If we meet some day, and you think 89 | this stuff is worth it, you can buy me a beer in return. -Jween Lau 90 | 91 | 92 | [Anti-996 License](https://github.com/996icu/996.ICU/blob/master/LICENSE) 93 | -------- 94 | 95 | - The purpose of this license is to prevent anti-labour-law companies from using the software or codes under the license, and force those companies to weigh their way of working 96 | - See a [full list of projects](https://github.com/996icu/996.ICU/blob/master/awesomelist/README.md) under Anti-996 License 97 | 98 | - This draft is adapted from the MIT license. For more detailed explanation, please see [Wiki](https://github.com/kattgu7/996-License-Draft/wiki). This license is designed to be compatible with all major open source licenses. 99 | - For law professionals or anyone who is willing to contribute to future version directly, please go to [Anti-996-License-1.0](https://github.com/kattgu7/996-License-Draft). Thank you. -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6' 7 | classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3' 8 | } 9 | } 10 | apply plugin: 'com.jfrog.bintray' 11 | 12 | 13 | // 14 | // read bintray user and api key form gitignored local.properties file 15 | // 16 | def FILE_LOCAL_PROPERTIES = "local.properties" 17 | Properties localProp = new Properties() 18 | def getFileInDir = { dir -> 19 | File ret = new File("$dir$File.separator$FILE_LOCAL_PROPERTIES") 20 | ret?.exists() ? ret : null 21 | } 22 | 23 | def rootLocalPropFile = getFileInDir(project.rootDir) 24 | if (rootLocalPropFile) { 25 | localProp.load(rootLocalPropFile.newDataInputStream()) 26 | } 27 | 28 | def localPropFile = getFileInDir(project.projectDir) 29 | if (localPropFile) { 30 | Properties tmpProp = new Properties() 31 | tmpProp.load(localPropFile.newDataInputStream()) 32 | localProp.putAll(tmpProp) 33 | } 34 | 35 | def propLocal = { localProp?.get it } 36 | 37 | apply plugin: 'groovy' 38 | apply plugin: 'nebula.provided-base' 39 | apply plugin: 'maven' 40 | apply plugin: 'maven-publish' 41 | 42 | def VERSION = '1.1' 43 | def GROUP = 'com.jween.gradle' 44 | def ARTIFACT_ID = 'android-soexcluder' 45 | group = GROUP 46 | version = VERSION 47 | 48 | def u = "${propLocal 'bintray_user'}" 49 | def k = "${propLocal 'bintray_api_key'}" 50 | 51 | bintray { 52 | user = u 53 | key = k 54 | publications = ['SePublication'] 55 | 56 | pkg { 57 | repo = 'maven' 58 | name = ARTIFACT_ID 59 | // userOrg = u 60 | licenses = ['Copyfree'] // fuck no, I need help to change this license to BEER-WARE 61 | websiteUrl = 'https://github.com/Jween/android-soexcluder' 62 | vcsUrl = 'https://github.com/Jween/android-soexcluder.git' 63 | 64 | version { 65 | name = VERSION 66 | desc = 'This plugin will help you exclude so files by flavor or buildType' 67 | // released = new Date() // bug here 68 | vcsTag = VERSION 69 | attributes = ['gradle-plugin': 'com.jween:com.jween.gradle:android-soexcluder'] 70 | } 71 | } 72 | } 73 | 74 | task sourceJar(type: Jar) { 75 | from sourceSets.main.allSource 76 | classifier = 'sources' 77 | } 78 | 79 | publishing { 80 | publications { 81 | SePublication(MavenPublication) { 82 | from components.java 83 | artifact sourceJar { 84 | classifier "sources" 85 | } 86 | groupId GROUP 87 | artifactId ARTIFACT_ID 88 | version version 89 | } 90 | } 91 | } 92 | 93 | 94 | dependencies { 95 | compile gradleApi() 96 | compile localGroovy() 97 | 98 | provided 'com.android.tools.build:gradle:1.3.1' 99 | } 100 | 101 | repositories { 102 | jcenter() 103 | } 104 | 105 | sourceCompatibility = JavaVersion.VERSION_1_6 106 | targetCompatibility = JavaVersion.VERSION_1_6 -------------------------------------------------------------------------------- /app/src/main/groovy/com/jween/gradle/soexcluder/AppPlugin.groovy: -------------------------------------------------------------------------------- 1 | package com.jween.gradle.soexcluder 2 | 3 | import org.gradle.api.Plugin 4 | import org.gradle.api.Project 5 | import org.gradle.api.file.FileTree 6 | import org.gradle.api.file.FileCollection 7 | 8 | import java.util.Arrays 9 | import java.util.List 10 | 11 | 12 | 13 | /** 14 | * Created with Atom by Jween on 3/14/2016 15 | * 16 | */ 17 | class AppPlugin implements Plugin { 18 | 19 | def /* lateinit */ logger 20 | 21 | @Override 22 | def void apply(Project project) { 23 | logger = project.logger 24 | 25 | def soexcluder = project.container(Rule) 26 | 27 | soexcluder.all { 28 | // do nothing 29 | } 30 | 31 | project.extensions.soexcluder = soexcluder 32 | 33 | project.afterEvaluate { 34 | configPlugin(project, soexcluder) 35 | } 36 | } 37 | 38 | void configPlugin(Project project, def soexcluder) { 39 | 40 | 41 | project.android.applicationVariants.all { variant -> 42 | def excludeList = [] 43 | def includeList = [] 44 | 45 | // 46 | // find all flavors and build type of this variont 47 | // 48 | def flavors = (variant.productFlavors.name).collect() 49 | flavors << variant.buildType.name 50 | 51 | // 52 | // detect all excluding rules for this variant 53 | // 54 | soexcluder.matching { rule -> 55 | flavors.any { flavName -> 56 | flavName.matches(rule.name) 57 | } 58 | }.all { rule -> 59 | excludeList.addAll(rule.excludeList) 60 | includeList.addAll(rule.includeList) 61 | } 62 | 63 | // 64 | // Find and remove excluded so files before package application 65 | // 66 | variant.outputs.each { output -> 67 | output.packageApplication.doFirst { pkgApp -> 68 | boolean dealWithIt = excludeList.size > 0 || includeList.size > 0 69 | 70 | if (dealWithIt) { 71 | 72 | pkgApp.jniFolders.each { dir -> 73 | // 74 | // find all so files needed by this output 75 | // 76 | FileTree reserve = project.fileTree(dir) { fileTree -> 77 | includeList?.each { 78 | fileTree.include it 79 | } 80 | 81 | excludeList?.each { 82 | fileTree.exclude it 83 | } 84 | } 85 | 86 | // 87 | // remove all excluded so files 88 | // 89 | FileCollection remove = project.fileTree(dir).minus(reserve) 90 | 91 | logger.quiet "* Removing for ${output.name}: ${remove.getAsPath()}" 92 | remove.each { 93 | it.delete() 94 | } 95 | } 96 | } 97 | } 98 | } 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /app/src/main/groovy/com/jween/gradle/soexcluder/Rule.groovy: -------------------------------------------------------------------------------- 1 | package com.jween.gradle.soexcluder 2 | 3 | class Rule { 4 | final String name 5 | List excludeList = [] 6 | List includeList = [] 7 | 8 | Rule(String name) { 9 | this.name = name 10 | } 11 | 12 | void exclude(String...args) { 13 | excludeList += Arrays.asList(args) 14 | } 15 | 16 | void include(String...args) { 17 | includeList += Arrays.asList(args) 18 | } 19 | } -------------------------------------------------------------------------------- /app/src/main/resources/META-INF/gradle-plugins/android-soexcluder.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.jween.gradle.soexcluder.AppPlugin -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | jcenter() 4 | } 5 | } 6 | 7 | task clean(type: Delete) { 8 | delete rootProject.buildDir 9 | } 10 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jween/android-soexcluder/4818eff4e82d07b063bb0e58d66f51d037b74006/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /sample-android-app/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:2.2.2' 7 | classpath 'com.jween.gradle:android-soexcluder:1.1' 8 | } 9 | } 10 | 11 | 12 | apply plugin: 'com.android.application' 13 | apply plugin: 'android-soexcluder' 14 | 15 | android { 16 | compileSdkVersion 23 17 | buildToolsVersion "23.0.2" 18 | 19 | defaultConfig { 20 | applicationId "com.jween.soexcluder" 21 | minSdkVersion 19 22 | targetSdkVersion 23 23 | versionCode 1 24 | versionName "1.0" 25 | } 26 | 27 | buildTypes { 28 | release { 29 | minifyEnabled false 30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 31 | } 32 | } 33 | 34 | // 35 | // define test flavors 36 | // 37 | flavorDimensions "foo" 38 | 39 | productFlavors { 40 | xxx { 41 | dimension "foo" 42 | } 43 | 44 | yyy { 45 | dimension "foo" 46 | } 47 | } 48 | } 49 | 50 | 51 | soexcluder { 52 | // exclude all so files with names end with -jni.so for flavor 'xxx' 53 | // 为名为 xxx 的 flavor 移除所有以 -jni.so 结尾的 so 文件 54 | xxx { 55 | exclude "lib/**/*-jni.so" 56 | } 57 | 58 | // exclude all so files for flavor whose name ends with character 'y' 59 | // 当 flavor 名字以 y 结尾时, 移除所有 so 60 | ".*y" { 61 | exclude "**/*" 62 | } 63 | } 64 | 65 | dependencies { 66 | compile fileTree(dir: 'libs', include: ['*.jar']) 67 | testCompile 'junit:junit:4.12' 68 | compile 'com.android.support:appcompat-v7:23.2.1' 69 | compile 'com.android.support:design:23.2.1' 70 | } 71 | -------------------------------------------------------------------------------- /sample-android-app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\dev\android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /sample-android-app/src/androidTest/java/com/jween/soexcluder/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.jween.soexcluder; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /sample-android-app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /sample-android-app/src/main/java/com/jween/soexcluder/ScrollingActivity.java: -------------------------------------------------------------------------------- 1 | package com.jween.soexcluder; 2 | 3 | import android.os.Bundle; 4 | import android.support.design.widget.FloatingActionButton; 5 | import android.support.design.widget.Snackbar; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.support.v7.widget.Toolbar; 8 | import android.view.View; 9 | import android.view.Menu; 10 | import android.view.MenuItem; 11 | 12 | public class ScrollingActivity extends AppCompatActivity { 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_scrolling); 18 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 19 | setSupportActionBar(toolbar); 20 | 21 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 22 | fab.setOnClickListener(new View.OnClickListener() { 23 | @Override 24 | public void onClick(View view) { 25 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 26 | .setAction("Action", null).show(); 27 | } 28 | }); 29 | } 30 | 31 | @Override 32 | public boolean onCreateOptionsMenu(Menu menu) { 33 | // Inflate the menu; this adds items to the action bar if it is present. 34 | getMenuInflater().inflate(R.menu.menu_scrolling, menu); 35 | return true; 36 | } 37 | 38 | @Override 39 | public boolean onOptionsItemSelected(MenuItem item) { 40 | // Handle action bar item clicks here. The action bar will 41 | // automatically handle clicks on the Home/Up button, so long 42 | // as you specify a parent activity in AndroidManifest.xml. 43 | int id = item.getItemId(); 44 | 45 | //noinspection SimplifiableIfStatement 46 | if (id == R.id.action_settings) { 47 | return true; 48 | } 49 | return super.onOptionsItemSelected(item); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /sample-android-app/src/main/jniLibs/arm64-v8a/librealm-jni.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jween/android-soexcluder/4818eff4e82d07b063bb0e58d66f51d037b74006/sample-android-app/src/main/jniLibs/arm64-v8a/librealm-jni.so -------------------------------------------------------------------------------- /sample-android-app/src/main/jniLibs/arm64-v8a/libweibosdkcore.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jween/android-soexcluder/4818eff4e82d07b063bb0e58d66f51d037b74006/sample-android-app/src/main/jniLibs/arm64-v8a/libweibosdkcore.so -------------------------------------------------------------------------------- /sample-android-app/src/main/jniLibs/armeabi-v7a/librealm-jni.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jween/android-soexcluder/4818eff4e82d07b063bb0e58d66f51d037b74006/sample-android-app/src/main/jniLibs/armeabi-v7a/librealm-jni.so -------------------------------------------------------------------------------- /sample-android-app/src/main/jniLibs/armeabi-v7a/libweibosdkcore.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jween/android-soexcluder/4818eff4e82d07b063bb0e58d66f51d037b74006/sample-android-app/src/main/jniLibs/armeabi-v7a/libweibosdkcore.so -------------------------------------------------------------------------------- /sample-android-app/src/main/res/layout/activity_scrolling.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 24 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /sample-android-app/src/main/res/layout/content_scrolling.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /sample-android-app/src/main/res/menu/menu_scrolling.xml: -------------------------------------------------------------------------------- 1 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /sample-android-app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jween/android-soexcluder/4818eff4e82d07b063bb0e58d66f51d037b74006/sample-android-app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample-android-app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jween/android-soexcluder/4818eff4e82d07b063bb0e58d66f51d037b74006/sample-android-app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample-android-app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jween/android-soexcluder/4818eff4e82d07b063bb0e58d66f51d037b74006/sample-android-app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample-android-app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jween/android-soexcluder/4818eff4e82d07b063bb0e58d66f51d037b74006/sample-android-app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample-android-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jween/android-soexcluder/4818eff4e82d07b063bb0e58d66f51d037b74006/sample-android-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample-android-app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /sample-android-app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /sample-android-app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 180dp 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /sample-android-app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Soexcluder 3 | 4 | "Material is the metaphor.\n\n" 5 | 6 | "A material metaphor is the unifying theory of a rationalized space and a system of motion." 7 | "The material is grounded in tactile reality, inspired by the study of paper and ink, yet " 8 | "technologically advanced and open to imagination and magic.\n" 9 | "Surfaces and edges of the material provide visual cues that are grounded in reality. The " 10 | "use of familiar tactile attributes helps users quickly understand affordances. Yet the " 11 | "flexibility of the material creates new affordances that supercede those in the physical " 12 | "world, without breaking the rules of physics.\n" 13 | "The fundamentals of light, surface, and movement are key to conveying how objects move, " 14 | "interact, and exist in space and in relation to each other. Realistic lighting shows " 15 | "seams, divides space, and indicates moving parts.\n\n" 16 | 17 | "Bold, graphic, intentional.\n\n" 18 | 19 | "The foundational elements of print based design typography, grids, space, scale, color, " 20 | "and use of imagery guide visual treatments. These elements do far more than please the " 21 | "eye. They create hierarchy, meaning, and focus. Deliberate color choices, edge to edge " 22 | "imagery, large scale typography, and intentional white space create a bold and graphic " 23 | "interface that immerse the user in the experience.\n" 24 | "An emphasis on user actions makes core functionality immediately apparent and provides " 25 | "waypoints for the user.\n\n" 26 | 27 | "Motion provides meaning.\n\n" 28 | 29 | "Motion respects and reinforces the user as the prime mover. Primary user actions are " 30 | "inflection points that initiate motion, transforming the whole design.\n" 31 | "All action takes place in a single environment. Objects are presented to the user without " 32 | "breaking the continuity of experience even as they transform and reorganize.\n" 33 | "Motion is meaningful and appropriate, serving to focus attention and maintain continuity. " 34 | "Feedback is subtle yet clear. Transitions are efficient yet coherent.\n\n" 35 | 36 | "3D world.\n\n" 37 | 38 | "The material environment is a 3D space, which means all objects have x, y, and z " 39 | "dimensions. The z-axis is perpendicularly aligned to the plane of the display, with the " 40 | "positive z-axis extending towards the viewer. Every sheet of material occupies a single " 41 | "position along the z-axis and has a standard 1dp thickness.\n" 42 | "On the web, the z-axis is used for layering and not for perspective. The 3D world is " 43 | "emulated by manipulating the y-axis.\n\n" 44 | 45 | "Light and shadow.\n\n" 46 | 47 | "Within the material environment, virtual lights illuminate the scene. Key lights create " 48 | "directional shadows, while ambient light creates soft shadows from all angles.\n" 49 | "Shadows in the material environment are cast by these two light sources. In Android " 50 | "development, shadows occur when light sources are blocked by sheets of material at " 51 | "various positions along the z-axis. On the web, shadows are depicted by manipulating the " 52 | "y-axis only. The following example shows the card with a height of 6dp.\n\n" 53 | 54 | "Resting elevation.\n\n" 55 | 56 | "All material objects, regardless of size, have a resting elevation, or default elevation " 57 | "that does not change. If an object changes elevation, it should return to its resting " 58 | "elevation as soon as possible.\n\n" 59 | 60 | "Component elevations.\n\n" 61 | 62 | "The resting elevation for a component type is consistent across apps (e.g., FAB elevation " 63 | "does not vary from 6dp in one app to 16dp in another app).\n" 64 | "Components may have different resting elevations across platforms, depending on the depth " 65 | "of the environment (e.g., TV has a greater depth than mobile or desktop).\n\n" 66 | 67 | "Responsive elevation and dynamic elevation offsets.\n\n" 68 | 69 | "Some component types have responsive elevation, meaning they change elevation in response " 70 | "to user input (e.g., normal, focused, and pressed) or system events. These elevation " 71 | "changes are consistently implemented using dynamic elevation offsets.\n" 72 | "Dynamic elevation offsets are the goal elevation that a component moves towards, relative " 73 | "to the component’s resting state. They ensure that elevation changes are consistent " 74 | "across actions and component types. For example, all components that lift on press have " 75 | "the same elevation change relative to their resting elevation.\n" 76 | "Once the input event is completed or cancelled, the component will return to its resting " 77 | "elevation.\n\n" 78 | 79 | "Avoiding elevation interference.\n\n" 80 | 81 | "Components with responsive elevations may encounter other components as they move between " 82 | "their resting elevations and dynamic elevation offsets. Because material cannot pass " 83 | "through other material, components avoid interfering with one another any number of ways, " 84 | "whether on a per component basis or using the entire app layout.\n" 85 | "On a component level, components can move or be removed before they cause interference. " 86 | "For example, a floating action button (FAB) can disappear or move off screen before a " 87 | "user picks up a card, or it can move if a snackbar appears.\n" 88 | "On the layout level, design your app layout to minimize opportunities for interference. " 89 | "For example, position the FAB to one side of stream of a cards so the FAB won’t interfere " 90 | "when a user tries to pick up one of cards.\n\n" 91 | 92 | Settings 93 | 94 | -------------------------------------------------------------------------------- /sample-android-app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |