From 7c3c4ab3b39d8834442a9372632f27d10526fe48 Mon Sep 17 00:00:00 2001 From: Yong Date: Sun, 6 Nov 2016 12:36:27 +0800 Subject: [PATCH] + update 0.8.1 --- freeline_core/version.py | 2 +- gradle/bintray.gradle | 2 +- gradle/build.gradle | 2 +- .../FreelineAnnotationCollector.groovy | 85 +++++++++++++++++++ .../antfortune/freeline/FreelinePlugin.groovy | 2 +- sample/build.gradle | 2 +- sample/gradle.properties | 2 +- 7 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 gradle/src/main/groovy/com/antfortune/freeline/FreelineAnnotationCollector.groovy diff --git a/freeline_core/version.py b/freeline_core/version.py index a94bcca..e5cf336 100755 --- a/freeline_core/version.py +++ b/freeline_core/version.py @@ -3,7 +3,7 @@ import os VERSION_FORMATTER = '{}({})' -FREELINE_VERSION = 'v0.8.0' +FREELINE_VERSION = 'v0.8.1' def get_freeline_version(): diff --git a/gradle/bintray.gradle b/gradle/bintray.gradle index bd1f78d..53afd50 100644 --- a/gradle/bintray.gradle +++ b/gradle/bintray.gradle @@ -15,7 +15,7 @@ def developerEmail = 'yong.hy@alipay.com' def publishedGroupId = 'com.antfortune.freeline' def artifact = 'gradle' def libraryName = 'freeline-gradle' -def publishVersion = '0.8.0' +def publishVersion = '0.8.1' install { repositories { diff --git a/gradle/build.gradle b/gradle/build.gradle index 3c2269c..e4ee0c5 100644 --- a/gradle/build.gradle +++ b/gradle/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'java' apply from: 'bintray.gradle' group 'com.antfortune.freeline' -version '0.8.0' +version '0.8.1' sourceCompatibility = 1.6 targetCompatibility = 1.6 diff --git a/gradle/src/main/groovy/com/antfortune/freeline/FreelineAnnotationCollector.groovy b/gradle/src/main/groovy/com/antfortune/freeline/FreelineAnnotationCollector.groovy new file mode 100644 index 0000000..fb232e2 --- /dev/null +++ b/gradle/src/main/groovy/com/antfortune/freeline/FreelineAnnotationCollector.groovy @@ -0,0 +1,85 @@ +package com.antfortune.freeline + +import groovy.json.JsonBuilder +import org.gradle.api.Project; + +/** + * Created by huangyong on 16/11/3. + */ +class FreelineAnnotationCollector { + + public static final def ANNOTATION_CLASSES = [ + "Landroid/databinding/BindingAdapter;", + "Landroid/databinding/BindingConversion;", + "Landroid/databinding/Bindable;", + ] + + public static final def ANNOTATION_TARGETS = [ + "Landroid/databinding/BindingAdapter;": "BindingAdapter", + "Landroid/databinding/BindingConversion;": "BindingConversion", + "Landroid/databinding/Bindable;": "Bindable" + ] + + private static def sAnnotationCollection = [:] + + public static void addNewAnno(String anno, String path, String className, String entry, boolean isJar) { + String key = ANNOTATION_TARGETS[anno] + if (!sAnnotationCollection.containsKey(key)) { + sAnnotationCollection[key] = [] + } + + sAnnotationCollection[key].add(['path': path, 'className': className, 'entry': entry, 'isJar': isJar]) + } + + public static void saveCollections(Project project, String buildCacheDirPath, Map modules) { + def description = FreelineUtils.readProjectDescription(project) + sAnnotationCollection.keySet().each { key -> + sAnnotationCollection[key].each { value -> + if (value['isJar']) { + modules.each { m, sep -> + if (value['path'].contains(sep)) { + value['module'] = m + value['java_path'] = findJavaPath(description, m as String, value['className'] as String) + return false + } + } + } else { + value['module'] = project.name + value['java_path'] = findJavaPath(description, project.name, value['className'] as String) + } + } + } + + def json = new JsonBuilder(sAnnotationCollection).toPrettyString() + println json + FreelineUtils.saveJson(json, FreelineUtils.joinPath(buildCacheDirPath, "freeline_annotation_info.json"), true) + + sAnnotationCollection.clear() + } + + private static String findJavaPath(def description, String module, String className) { + if (description != null) { + if (description['project_source_sets'].containsKey(module)) { + def relatedPath = className.replace("/", File.separator).replace(".class", ".java") + if (!relatedPath.endsWith(".java")) { + relatedPath = relatedPath + ".java" + } + + def javaPath = null + description['project_source_sets'][module]['main_src_directory'].each { path -> + File file = new File(FreelineUtils.joinPath(path as String, relatedPath)) + if (file.exists()) { + javaPath = file.absolutePath + return false + } + } + + if (javaPath != null) { + return javaPath + } + } + } + return null + } + +} diff --git a/gradle/src/main/groovy/com/antfortune/freeline/FreelinePlugin.groovy b/gradle/src/main/groovy/com/antfortune/freeline/FreelinePlugin.groovy index 458384a..f3335d9 100644 --- a/gradle/src/main/groovy/com/antfortune/freeline/FreelinePlugin.groovy +++ b/gradle/src/main/groovy/com/antfortune/freeline/FreelinePlugin.groovy @@ -15,7 +15,7 @@ import org.gradle.util.VersionNumber */ class FreelinePlugin implements Plugin { - String freelineVersion = "0.8.0" + String freelineVersion = "0.8.1" @Override void apply(Project project) { diff --git a/sample/build.gradle b/sample/build.gradle index e73f914..ddd3720 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -7,7 +7,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:2.2.2' - classpath 'com.antfortune.freeline:gradle:0.8.0' + classpath 'com.antfortune.freeline:gradle:0.8.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' diff --git a/sample/gradle.properties b/sample/gradle.properties index d895308..4d355ac 100644 --- a/sample/gradle.properties +++ b/sample/gradle.properties @@ -16,4 +16,4 @@ # 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 -FREELINE_RELEASE_VERSION=0.8.0 \ No newline at end of file +FREELINE_RELEASE_VERSION=0.8.1 \ No newline at end of file