weiguo 7 years ago
commit
d209c021e7
41 changed files with 886 additions and 0 deletions
  1. 7 0
      .gitignore
  2. 1 0
      app/.gitignore
  3. 42 0
      app/build.gradle
  4. BIN
      app/libs/bcel.jar
  5. 17 0
      app/proguard-rules.pro
  6. 32 0
      app/src/main/AndroidManifest.xml
  7. 31 0
      app/src/main/java/com/uddream/plugin/MainActivity.java
  8. 14 0
      app/src/main/java/com/uddream/plugin/MainApplication.java
  9. 35 0
      app/src/main/res/layout/activity_main.xml
  10. 27 0
      app/src/main/res/layout/content_main.xml
  11. 10 0
      app/src/main/res/menu/menu_main.xml
  12. BIN
      app/src/main/res/mipmap-hdpi/ic_launcher.png
  13. BIN
      app/src/main/res/mipmap-mdpi/ic_launcher.png
  14. BIN
      app/src/main/res/mipmap-xhdpi/ic_launcher.png
  15. BIN
      app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  16. BIN
      app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  17. 9 0
      app/src/main/res/values-v21/styles.xml
  18. 6 0
      app/src/main/res/values-w820dp/dimens.xml
  19. 6 0
      app/src/main/res/values/colors.xml
  20. 6 0
      app/src/main/res/values/dimens.xml
  21. 4 0
      app/src/main/res/values/strings.xml
  22. 20 0
      app/src/main/res/values/styles.xml
  23. 20 0
      build.gradle
  24. 12 0
      buildSrc/build.gradle
  25. 17 0
      buildSrc/src/main/groovy/com/gradle/AresPlugin.groovy
  26. 64 0
      buildSrc/src/main/groovy/com/gradle/JarZipUtil.groovy
  27. 154 0
      buildSrc/src/main/groovy/com/gradle/ModifyClassTransform.groovy
  28. 1 0
      buildSrc/src/main/resources/META-INF/gradle-plugins/com.android.ares-agent.properties
  29. 12 0
      buildSrc/src/test/groovy/com/gradle/test/MainTest.groovy
  30. 18 0
      gradle.properties
  31. BIN
      gradle/wrapper/gradle-wrapper.jar
  32. 6 0
      gradle/wrapper/gradle-wrapper.properties
  33. 160 0
      gradlew
  34. 90 0
      gradlew.bat
  35. 1 0
      mylibrary/.gitignore
  36. 24 0
      mylibrary/build.gradle
  37. 17 0
      mylibrary/proguard-rules.pro
  38. 8 0
      mylibrary/src/main/AndroidManifest.xml
  39. 10 0
      mylibrary/src/main/java/com/uddream/library/Test.java
  40. 3 0
      mylibrary/src/main/res/values/strings.xml
  41. 2 0
      settings.gradle

+ 7 - 0
.gitignore

@@ -0,0 +1,7 @@
+*.iml
+.gradle
+/.idea
+local.properties
+.DS_Store
+build
+/captures

+ 1 - 0
app/.gitignore

@@ -0,0 +1 @@
+/build

+ 42 - 0
app/build.gradle

@@ -0,0 +1,42 @@
+apply plugin: 'com.android.application'
+apply plugin: com.gradle.AresPlugin
+
+android {
+    compileSdkVersion 23
+    buildToolsVersion "23.0.1"
+
+    defaultConfig {
+        applicationId "com.uddream.gradle"
+        minSdkVersion 19
+        targetSdkVersion 23
+        versionCode 1
+        versionName "1.0"
+    }
+
+    packagingOptions {
+        exclude 'META-INF/DEPENDENCIES.txt'
+        exclude 'META-INF/LICENSE.txt'
+        exclude 'META-INF/NOTICE.txt'
+        exclude 'META-INF/NOTICE'
+        exclude 'META-INF/LICENSE'
+        exclude 'META-INF/DEPENDENCIES'
+        exclude 'META-INF/notice.txt'
+        exclude 'META-INF/license.txt'
+        exclude 'META-INF/dependencies.txt'
+        exclude 'META-INF/LGPL2.1'
+    }
+
+    lintOptions {
+        abortOnError false
+    }
+}
+
+dependencies {
+    compile fileTree(include: ['*.jar'], dir: 'libs')
+    compile 'com.android.support:design:23.0.1'
+    compile 'com.android.support:appcompat-v7:23.0.1'
+    compile 'com.android.support:cardview-v7:23.0.1'
+    compile 'com.android.support:palette-v7:23.0.1'
+    compile 'com.github.bumptech.glide:glide:3.7.0'
+    compile project(':mylibrary')
+}

BIN
app/libs/bcel.jar


+ 17 - 0
app/proguard-rules.pro

@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in D:\DevTools\AndroidSdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}

+ 32 - 0
app/src/main/AndroidManifest.xml

@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.uddream.plugin">
+
+    <application
+        android:name=".MainApplication"
+        android:allowBackup="true"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/app_name"
+        android:supportsRtl="true"
+        android:theme="@style/AppTheme">
+        <activity
+            android:name=".MainActivity"
+            android:label="@string/app_name"
+            android:theme="@style/AppTheme.NoActionBar">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+
+            <intent-filter>
+                <data android:scheme="growing.cd08c9debb67ad1b" />
+                <action android:name="android.intent.action.VIEW" />
+
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.BROWSABLE" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>

+ 31 - 0
app/src/main/java/com/uddream/plugin/MainActivity.java

@@ -0,0 +1,31 @@
+package com.uddream.plugin;
+
+import android.os.Bundle;
+import android.support.design.widget.FloatingActionButton;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.View;
+import android.widget.Toast;
+
+import com.bumptech.glide.Glide;
+
+public class MainActivity extends AppCompatActivity {
+
+    private View.OnClickListener listener = new View.OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            Toast.makeText(MainActivity.this, "field listener", Toast.LENGTH_LONG).show();
+        }
+    };
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_main);
+        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+        setSupportActionBar(toolbar);
+        Glide.with(this);
+        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
+        fab.setOnClickListener(listener);
+    }
+}

+ 14 - 0
app/src/main/java/com/uddream/plugin/MainApplication.java

@@ -0,0 +1,14 @@
+package com.uddream.plugin;
+
+import android.app.Application;
+
+/**
+ * Created by Glen on 2016/8/30.
+ */
+public class MainApplication extends Application {
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+    }
+}

+ 35 - 0
app/src/main/res/layout/activity_main.xml

@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.design.widget.CoordinatorLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:fitsSystemWindows="true"
+    tools:context="com.uddream.plugin.MainActivity">
+
+    <android.support.design.widget.AppBarLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:theme="@style/AppTheme.AppBarOverlay">
+
+        <android.support.v7.widget.Toolbar
+            android:id="@+id/toolbar"
+            android:layout_width="match_parent"
+            android:layout_height="?attr/actionBarSize"
+            android:background="?attr/colorPrimary"
+            app:popupTheme="@style/AppTheme.PopupOverlay"/>
+
+    </android.support.design.widget.AppBarLayout>
+
+    <include layout="@layout/content_main"/>
+
+    <android.support.design.widget.FloatingActionButton
+        android:id="@+id/fab"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="bottom|end"
+        android:layout_margin="@dimen/fab_margin"
+        android:src="@android:drawable/ic_dialog_email"/>
+
+</android.support.design.widget.CoordinatorLayout>

+ 27 - 0
app/src/main/res/layout/content_main.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    app:layout_behavior="@string/appbar_scrolling_view_behavior"
+    tools:context="com.uddream.plugin.MainActivity"
+    tools:showIn="@layout/activity_main">
+
+    <TextView
+        android:id="@+id/test"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:clickable="true"
+        android:text="Hello World!"/>
+
+    <FrameLayout
+        android:id="@+id/container"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"></FrameLayout>
+</RelativeLayout>

+ 10 - 0
app/src/main/res/menu/menu_main.xml

@@ -0,0 +1,10 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:app="http://schemas.android.com/apk/res-auto"
+      xmlns:tools="http://schemas.android.com/tools"
+      tools:context="com.uddream.plugin.MainActivity">
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:title="@string/action_settings"
+        app:showAsAction="never"/>
+</menu>

BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png


+ 9 - 0
app/src/main/res/values-v21/styles.xml

@@ -0,0 +1,9 @@
+<resources>
+
+    <style name="AppTheme.NoActionBar">
+        <item name="windowActionBar">false</item>
+        <item name="windowNoTitle">true</item>
+        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
+        <item name="android:statusBarColor">@android:color/transparent</item>
+    </style>
+</resources>

+ 6 - 0
app/src/main/res/values-w820dp/dimens.xml

@@ -0,0 +1,6 @@
+<resources>
+    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+         (such as screen margins) for screens with more than 820dp of available width. This
+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+    <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>

+ 6 - 0
app/src/main/res/values/colors.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="colorPrimary">#3F51B5</color>
+    <color name="colorPrimaryDark">#303F9F</color>
+    <color name="colorAccent">#FF4081</color>
+</resources>

+ 6 - 0
app/src/main/res/values/dimens.xml

@@ -0,0 +1,6 @@
+<resources>
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="activity_horizontal_margin">16dp</dimen>
+    <dimen name="activity_vertical_margin">16dp</dimen>
+    <dimen name="fab_margin">16dp</dimen>
+</resources>

+ 4 - 0
app/src/main/res/values/strings.xml

@@ -0,0 +1,4 @@
+<resources>
+    <string name="app_name">AndGradlePlugin</string>
+    <string name="action_settings">Settings</string>
+</resources>

+ 20 - 0
app/src/main/res/values/styles.xml

@@ -0,0 +1,20 @@
+<resources>
+
+    <!-- Base application theme. -->
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+        <!-- Customize your theme here. -->
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+        <item name="colorAccent">@color/colorAccent</item>
+    </style>
+
+    <style name="AppTheme.NoActionBar">
+        <item name="windowActionBar">false</item>
+        <item name="windowNoTitle">true</item>
+    </style>
+
+    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
+
+    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
+
+</resources>

+ 20 - 0
build.gradle

@@ -0,0 +1,20 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+    repositories {
+        jcenter()
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:2.1.0'
+    }
+}
+
+allprojects {
+    repositories {
+        jcenter()
+    }
+}
+
+task clean(type: Delete) {
+    delete rootProject.buildDir
+}

+ 12 - 0
buildSrc/build.gradle

@@ -0,0 +1,12 @@
+apply plugin: 'groovy'
+apply plugin: 'maven'
+
+repositories {
+    mavenCentral()
+}
+
+dependencies {
+    compile gradleApi()
+    compile localGroovy()
+    compile 'com.android.tools.build:gradle:2.1.0'
+}

+ 17 - 0
buildSrc/src/main/groovy/com/gradle/AresPlugin.groovy

@@ -0,0 +1,17 @@
+package com.gradle
+
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+
+/**
+ * Created by Glen on 2016/9/2.
+ * modify by glen
+ */
+public class AresPlugin implements Plugin<Project> {
+
+    @Override
+    void apply(Project project) {
+        project.logger.error("start and gradle plugin")
+        project.android.registerTransform(new ModifyClassTransform(project))
+    }
+}

+ 64 - 0
buildSrc/src/main/groovy/com/gradle/JarZipUtil.groovy

@@ -0,0 +1,64 @@
+package com.gradle
+
+import java.util.jar.JarEntry
+import java.util.jar.JarFile
+import java.util.jar.JarOutputStream
+
+/**
+ * Created by glen on 2016/9/2.
+ * modify by glen
+ */
+public class JarZipUtil {
+
+    /**
+     * 将该jar包解压到指定目录
+     * @param jarPath jar包的绝对路径
+     * @param destDirPath jar包解压后的保存路径
+     */
+    public static void unzipJar(File jar, String destDirPath) {
+        JarFile jarFile = new JarFile(jar.absolutePath)
+        Enumeration<JarEntry> jarEntryIterator = jarFile.entries()
+        while (jarEntryIterator.hasMoreElements()) {
+            JarEntry jarEntry = jarEntryIterator.nextElement()
+            if (jarEntry.directory) {
+                continue
+            }
+            String outFileName = destDirPath + "/" + jarEntry.getName()
+            File outFile = new File(outFileName)
+            outFile.getParentFile().mkdirs()
+            InputStream inputStream = jarFile.getInputStream(jarEntry)
+            FileOutputStream fileOutputStream = new FileOutputStream(outFile)
+            fileOutputStream << inputStream
+            fileOutputStream.close()
+            inputStream.close()
+        }
+        jarFile.close()
+    }
+
+    /**
+     * 重新打包jar
+     * @param packagePath 将这个目录下的所有文件打包成jar
+     * @param destPath 打包好的jar包的绝对路径
+     */
+    public static void zipJar(String packagePath, File jar) {
+        jar.deleteOnExit()
+        JarOutputStream zos = new JarOutputStream(new FileOutputStream(jar.absolutePath))
+        zipFile(new File(packagePath), zos, "")
+        zos.close()
+    }
+
+    private static void zipFile(File inFile, JarOutputStream out, String dir) {
+        if (inFile.isDirectory()) {
+            File[] fl = inFile.listFiles()
+            out.putNextEntry(new JarEntry(dir + "/"))
+            dir = dir.length() == 0 ? "" : dir + "/"
+            for (int i = 0; i < fl.length; i++)
+                zipFile(fl[i], out, dir + fl[i].getName())
+        } else {
+            out.putNextEntry(new JarEntry(dir))
+            FileInputStream ins = new FileInputStream(inFile)
+            out << ins
+            ins.close()
+        }
+    }
+}

+ 154 - 0
buildSrc/src/main/groovy/com/gradle/ModifyClassTransform.groovy

@@ -0,0 +1,154 @@
+package com.gradle
+
+import com.android.build.api.transform.*
+import com.google.common.collect.ImmutableSet
+import org.apache.commons.codec.digest.DigestUtils
+import org.apache.commons.io.FileUtils
+import org.gradle.api.Project
+import org.gradle.api.logging.Logger
+import org.gradle.api.logging.Logging
+
+/**
+ * Created by Glen on 2017/2/7.
+ */
+
+public class ModifyClassTransform extends Transform {
+    Project project;
+    Logger logger;
+
+    public ModifyClassTransform(Project project) {
+        this.project = project;
+        this.logger = Logging.getLogger(ModifyClassTransform.class);
+    }
+
+    @Override
+    public String getName() {
+        return "Modify"
+    }
+
+    @Override
+    public Set<QualifiedContent.ContentType> getInputTypes() {
+        return ImmutableSet.of(QualifiedContent.DefaultContentType.CLASSES)
+    }
+
+    @Override
+    public Set<QualifiedContent.Scope> getScopes() {
+        return ImmutableSet.of(
+                QualifiedContent.Scope.PROJECT,// app class
+                QualifiedContent.Scope.PROJECT_LOCAL_DEPS,// app libs local jar
+                QualifiedContent.Scope.SUB_PROJECTS,//sub lib class
+                QualifiedContent.Scope.SUB_PROJECTS_LOCAL_DEPS,//sub lib libs local jar
+                QualifiedContent.Scope.EXTERNAL_LIBRARIES//compile dependencies
+        )
+    }
+
+    @Override
+    public boolean isIncremental() {
+        return true
+    }
+
+    @Override
+    void transform(TransformInvocation transformInvocation) throws TransformException, InterruptedException, IOException {
+        //delete all
+        transformInvocation.outputProvider.deleteAll()
+
+        // Collecting inputs.
+        transformInvocation.inputs.each { input ->
+            input.directoryInputs.each { dirInput ->
+                if (transformInvocation.incremental) {
+                    dirInput.changedFiles.each { changedFile ->
+                        handleChangedFile(changedFile.key)
+                    }
+                } else {
+                    dirInput.file.eachFileRecurse { File file ->
+                        handleChangedFile(file)
+                    }
+                }
+
+                //output modify class file
+                File file = transformInvocation.outputProvider.getContentLocation(dirInput.file.name, dirInput.contentTypes, dirInput.scopes, Format.DIRECTORY)
+                FileUtils.copyDirectory(dirInput.file, file)
+            }
+            input.jarInputs.each { jarInput ->
+                switch (jarInput.status) {
+                    case Status.NOTCHANGED:
+                        if (transformInvocation.incremental) break
+                    case Status.ADDED:
+                    case Status.CHANGED:
+                        handleChangedFile(jarInput.file)
+                }
+
+                //output modify jar file
+                File file = transformInvocation.outputProvider.getContentLocation(getUniqueHashName(jarInput.file), jarInput.contentTypes, jarInput.scopes, Format.JAR)
+                FileUtils.copyFile(jarInput.file, file)
+            }
+        }
+    }
+
+    /**
+     * 增量文件
+     * @param input
+     */
+    private void handleChangedFile(File input) {
+        String path = input.absolutePath.replace("/", "\\")
+        if (input.isFile()) {
+            debug("changed:" + input.absolutePath)
+            if (path.endsWith(".class")) {
+                modifyClass(input)
+            } else if (path.endsWith(".jar")) {
+                if (path.contains("exploded-aar")) {
+                    if (!path.contains("com.android.support")) {
+                        //需要处理的jar包
+                        File tmp = new File(input.getParent() + File.separator + "tmp")
+                        tmp.deleteOnExit()
+
+                        boolean modify = false
+                        if (!modify) JarZipUtil.unzipJar(input, tmp.absolutePath)
+                        tmp.eachFileRecurse { File file ->
+                            if (file.isFile()) {
+                                if (modifyClass(file)) {
+                                    modify = true
+                                }
+                            }
+                        }
+                        if (modify) JarZipUtil.zipJar(tmp.absolutePath, input)
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 修改类文件
+     * @param clazz
+     * @return
+     */
+    private boolean modifyClass(File clazz) {
+        debug("modify:" + clazz.absolutePath)
+
+
+        return false
+    }
+
+    /**
+     * 生成唯一文件名
+     * @param fileInput
+     * @return
+     */
+    private String getUniqueHashName(File fileInput) {
+        final String fileInputName = fileInput.getName()
+        if (fileInput.isDirectory()) {
+            return fileInputName
+        }
+        final String parentDirPath = fileInput.getParentFile().getAbsolutePath()
+        final String pathMD5 = DigestUtils.md5Hex(parentDirPath.getBytes()).substring(0, 6)
+        final int extSepPos = fileInputName.lastIndexOf('.')
+        final String fileInputNamePrefix =
+                (extSepPos >= 0 ? fileInputName.substring(0, extSepPos) : fileInputName)
+        return fileInputNamePrefix + '_' + pathMD5
+    }
+
+    private void debug(def msg) {
+        this.logger.lifecycle(":" + this.project.name + ":" + msg)
+    }
+}

+ 1 - 0
buildSrc/src/main/resources/META-INF/gradle-plugins/com.android.ares-agent.properties

@@ -0,0 +1 @@
+implementation-class=com.gradle.AresPlugin

+ 12 - 0
buildSrc/src/test/groovy/com/gradle/test/MainTest.groovy

@@ -0,0 +1,12 @@
+package com.gradle.test;
+
+/**
+ * Created by Glen on 2017/2/7.
+ */
+
+public class MainTest {
+
+    public static void main(String[] args) {
+        System.out.printf('hello world')
+    }
+}

+ 18 - 0
gradle.properties

@@ -0,0 +1,18 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true

BIN
gradle/wrapper/gradle-wrapper.jar


+ 6 - 0
gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,6 @@
+#Tue Feb 07 11:38:29 CST 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

+ 160 - 0
gradlew

@@ -0,0 +1,160 @@
+#!/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
+
+# 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\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+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"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # 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 "$@"

+ 90 - 0
gradlew.bat

@@ -0,0 +1,90 @@
+@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

+ 1 - 0
mylibrary/.gitignore

@@ -0,0 +1 @@
+/build

+ 24 - 0
mylibrary/build.gradle

@@ -0,0 +1,24 @@
+apply plugin: 'com.android.library'
+
+android {
+    compileSdkVersion 23
+    buildToolsVersion "23.0.1"
+
+    defaultConfig {
+        minSdkVersion 19
+        targetSdkVersion 23
+        versionCode 1
+        versionName "1.0"
+    }
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+}
+
+dependencies {
+    compile fileTree(dir: 'libs', include: ['*.jar'])
+    compile 'com.android.support:appcompat-v7:23.0.1'
+}

+ 17 - 0
mylibrary/proguard-rules.pro

@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in D:\DevTools\AndroidSdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}

+ 8 - 0
mylibrary/src/main/AndroidManifest.xml

@@ -0,0 +1,8 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.uddream.library">
+
+    <application android:allowBackup="true" android:label="@string/app_name"
+        android:supportsRtl="true">
+
+    </application>
+
+</manifest>

+ 10 - 0
mylibrary/src/main/java/com/uddream/library/Test.java

@@ -0,0 +1,10 @@
+package com.uddream.library;
+
+/**
+ * Created by Glen on 2017/2/7.
+ */
+
+public class Test {
+    public void log() {
+    }
+}

+ 3 - 0
mylibrary/src/main/res/values/strings.xml

@@ -0,0 +1,3 @@
+<resources>
+    <string name="app_name">My Library</string>
+</resources>

+ 2 - 0
settings.gradle

@@ -0,0 +1,2 @@
+include ':app', ':mylibrary'
+include ':buildSrc'