From d52c0323c3b52dfdb13b1c3f90dc413649f01367 Mon Sep 17 00:00:00 2001 From: Can Elmas Date: Sun, 11 Feb 2018 14:34:46 +0300 Subject: [PATCH] Add Instant App Support Update copyright Set version to 1.0.0-beta2 Rename DelayedTasks to ScheduledTasks Separate app and library scopes for transformation --- CHANGELOG.md | 9 ++- build.gradle | 8 +-- gradle.properties | 2 +- let-annotations/build.gradle | 2 +- let-annotations/gradle.properties | 4 +- .../java/com/canelmas/let/AskPermission.java | 2 +- let-plugin/build.gradle | 2 +- let-plugin/gradle.properties | 4 +- .../groovy/com/canelmas/let/LetPlugin.groovy | 25 +++++--- .../com/canelmas/let/LetTransform.groovy | 18 ++++-- .../META-INF/gradle-plugins/let.properties | 2 +- let-runtime/build.gradle | 42 +----------- let-runtime/gradle.properties | 4 +- .../com/canelmas/let/ApplicationTest.java | 2 +- let-runtime/src/main/AndroidManifest.xml | 2 +- .../com/canelmas/let/DeniedPermission.java | 2 +- .../src/main/java/com/canelmas/let/Let.java | 4 +- .../main/java/com/canelmas/let/LetAspect.java | 2 +- .../java/com/canelmas/let/LetContext.java | 2 +- .../java/com/canelmas/let/LetException.java | 2 +- .../let/RuntimePermissionListener.java | 2 +- .../let/RuntimePermissionRequest.java | 4 +- ...{DelayedTasks.java => ScheduledTasks.java} | 6 +- let-runtime/src/main/res/values/strings.xml | 2 +- .../permissioncompat/ExampleUnitTest.java | 16 +++++ let-sample-library/.gitignore | 1 + let-sample-library/build.gradle | 64 +++++++++++++++++++ let-sample-library/proguard-rules.pro | 25 ++++++++ .../ExampleInstrumentedTest.java | 42 ++++++++++++ .../src/main/AndroidManifest.xml | 18 ++++++ .../canelmas/let/sample/library/LibTest.java | 27 ++++++++ .../src/main/res/values/strings.xml | 19 ++++++ .../let_sample_library/ExampleUnitTest.java | 33 ++++++++++ let-sample/build.gradle | 10 ++- .../com/canelmas/let/ApplicationTest.java | 2 +- let-sample/src/main/AndroidManifest.xml | 2 +- .../canelmas/let/sample/ContactsActivity.java | 2 +- .../canelmas/let/sample/SampleActivity.java | 2 +- .../canelmas/let/sample/SampleFragment.java | 2 +- .../let/sample/SampleFragmentActivity.java | 2 +- .../canelmas/let/sample/SampleV4Fragment.java | 2 +- .../let/sample/SampleV4FragmentActivity.java | 2 +- .../src/main/res/layout/activity_fragment.xml | 2 +- .../src/main/res/layout/activity_sample.xml | 2 +- let-sample/src/main/res/layout/fragment.xml | 2 +- .../src/main/res/layout/fragment_contacts.xml | 2 +- let-sample/src/main/res/menu/menu_.xml | 2 +- let-sample/src/main/res/menu/menu_sample.xml | 2 +- let-sample/src/main/res/values-v21/styles.xml | 2 +- .../src/main/res/values-w820dp/dimens.xml | 2 +- let-sample/src/main/res/values/dimens.xml | 2 +- let-sample/src/main/res/values/strings.xml | 2 +- let-sample/src/main/res/values/styles.xml | 2 +- .../permissioncompat/ExampleUnitTest.java | 16 +++++ settings.gradle | 2 +- 55 files changed, 356 insertions(+), 109 deletions(-) rename let-runtime/src/main/java/com/canelmas/let/{DelayedTasks.java => ScheduledTasks.java} (95%) create mode 100644 let-sample-library/.gitignore create mode 100644 let-sample-library/build.gradle create mode 100644 let-sample-library/proguard-rules.pro create mode 100644 let-sample-library/src/androidTest/java/com/cnlms/let_sample_library/ExampleInstrumentedTest.java create mode 100644 let-sample-library/src/main/AndroidManifest.xml create mode 100644 let-sample-library/src/main/java/com/canelmas/let/sample/library/LibTest.java create mode 100644 let-sample-library/src/main/res/values/strings.xml create mode 100644 let-sample-library/src/test/java/com/cnlms/let_sample_library/ExampleUnitTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c4cd2b..1c970a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ Change Log ========== +Version 1.0.0-beta2 *(2018-02-11)* +---------------------------------- +* Add `FeaturePlugin` and `InstantAppPlugin` support [#28](https://github.com/canelmas/let/issues/28) +* Rename `Delayed Tasks` to `ScheduledTasks` +* Update copyright + Version 1.0.0-beta1 *(2017-09-04)* ---------------------------------- * Use Transform API for weaving [#23](https://github.com/canelmas/let/issues/23) @@ -18,5 +24,4 @@ Version 0.1.10 *(2016-03-20)* Version 0.1.9 *(2015-11-12)* ---------------------------- - -initial release \ No newline at end of file +* initial release \ No newline at end of file diff --git a/build.gradle b/build.gradle index f2fb66b..5609200 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,14 @@ buildscript { ext.versions = [ - compileSdkVersion : 26, - buildToolsVersion : '26.0.1', + compileSdkVersion : 27, + buildToolsVersion : '27.0.3', minSdkVersion : 14, - targetSdkVersion : 26, + targetSdkVersion : 27, supportLibrary : '26.0.1', aspectjrt : '1.8.9', aspectjtools : '1.8.9', - androidPlugin : '3.0.0-beta4', + androidPlugin : '3.0.1', androidMavenPlugin: '1.2' ] diff --git a/gradle.properties b/gradle.properties index 2dcc5cd..d09f089 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ # org.gradle.parallel=true #Tue Sep 22 16:15:19 EEST 2015 -VERSION_NAME=1.0.0-beta1 +VERSION_NAME=1.0.0-beta2 GROUP=com.canelmas.let POM_DESCRIPTION=Annotation based simple API flavoured with AOP to handle new Android runtime permission model diff --git a/let-annotations/build.gradle b/let-annotations/build.gradle index 681561a..5565faf 100644 --- a/let-annotations/build.gradle +++ b/let-annotations/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Can Elmas + * Copyright (C) 2018 Can Elmas * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/let-annotations/gradle.properties b/let-annotations/gradle.properties index 63cf88f..2c318b4 100644 --- a/let-annotations/gradle.properties +++ b/let-annotations/gradle.properties @@ -1,10 +1,10 @@ # -# Copyright (C) 2015 Can Elmas +# Copyright (C) 2018 Can Elmas # # 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 diff --git a/let-annotations/src/main/java/com/canelmas/let/AskPermission.java b/let-annotations/src/main/java/com/canelmas/let/AskPermission.java index ed14177..edc81d7 100644 --- a/let-annotations/src/main/java/com/canelmas/let/AskPermission.java +++ b/let-annotations/src/main/java/com/canelmas/let/AskPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Can Elmas + * Copyright (C) 2018 Can Elmas * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/let-plugin/build.gradle b/let-plugin/build.gradle index 788f5a1..8df0764 100644 --- a/let-plugin/build.gradle +++ b/let-plugin/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Can Elmas + * Copyright (C) 2018 Can Elmas * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/let-plugin/gradle.properties b/let-plugin/gradle.properties index 05e0a88..d6e06aa 100644 --- a/let-plugin/gradle.properties +++ b/let-plugin/gradle.properties @@ -1,10 +1,10 @@ # -# Copyright (C) 2015 Can Elmas +# Copyright (C) 2018 Can Elmas # # 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 diff --git a/let-plugin/src/main/groovy/com/canelmas/let/LetPlugin.groovy b/let-plugin/src/main/groovy/com/canelmas/let/LetPlugin.groovy index c8a8ad2..86a307d 100644 --- a/let-plugin/src/main/groovy/com/canelmas/let/LetPlugin.groovy +++ b/let-plugin/src/main/groovy/com/canelmas/let/LetPlugin.groovy @@ -1,11 +1,11 @@ /* - * Copyright (C) 2017 Can Elmas + * Copyright (C) 2018 Can Elmas * * 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 + * 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, @@ -17,6 +17,8 @@ package com.canelmas.let import com.android.build.gradle.AppPlugin +import com.android.build.gradle.FeaturePlugin +import com.android.build.gradle.InstantAppPlugin import com.android.build.gradle.LibraryPlugin import org.gradle.api.Plugin import org.gradle.api.Project @@ -26,23 +28,26 @@ class LetPlugin implements Plugin { @Override void apply(Project project) { - makeSureProjectIsAndroidAppOrLib(project) + makeSureProjectIsCompatible(project) project.android.registerTransform(new LetTransform(project)) project.dependencies { implementation 'org.aspectj:aspectjrt:1.8.9' - implementation 'com.canelmas.let:let-runtime:1.0.0-beta1' - implementation 'com.canelmas.let:let-annotations:1.0.0-beta1' + implementation 'com.canelmas.let:let-runtime:1.0.0-beta2' + implementation 'com.canelmas.let:let-annotations:1.0.0-beta2' } } - private void makeSureProjectIsAndroidAppOrLib(Project project) { - def hasApp = project.plugins.withType(AppPlugin) - def hasLib = project.plugins.withType(LibraryPlugin) + private void makeSureProjectIsCompatible(Project project) { + def hasAppPlugin = project.plugins.withType(AppPlugin) + def hasLibPlugin = project.plugins.withType(LibraryPlugin) + def hasFeaturePlugin = project.plugins.withType(FeaturePlugin) + def hasInstantAppPlugin = project.plugins.withType(InstantAppPlugin) - if (!hasApp && !hasLib) { - throw new IllegalStateException("'android' or 'android-library' plugin required.") + if (!hasAppPlugin && !hasLibPlugin && !hasFeaturePlugin && !hasInstantAppPlugin) { + throw new IllegalStateException("Project must have one the following plugins applied " + + ": 'android', 'android-library', 'feature', 'instantapp'") } } diff --git a/let-plugin/src/main/groovy/com/canelmas/let/LetTransform.groovy b/let-plugin/src/main/groovy/com/canelmas/let/LetTransform.groovy index d664380..349c6c6 100644 --- a/let-plugin/src/main/groovy/com/canelmas/let/LetTransform.groovy +++ b/let-plugin/src/main/groovy/com/canelmas/let/LetTransform.groovy @@ -1,11 +1,11 @@ /* - * Copyright (C) 2017 Can Elmas + * Copyright (C) 2018 Can Elmas * * 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 + * 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, @@ -18,6 +18,7 @@ package com.canelmas.let import com.android.annotations.NonNull import com.android.build.api.transform.* +import com.android.build.gradle.LibraryPlugin import com.google.common.base.Joiner import com.google.common.base.Strings import com.google.common.collect.Lists @@ -32,9 +33,19 @@ import org.gradle.api.logging.Logger class LetTransform extends Transform { private Project project + private boolean isLibrary + + private static final Set LIBRARY_SCOPE = Sets.immutableEnumSet( + QualifiedContent.Scope.PROJECT) + + private static final Set APP_SCOPE = Sets.immutableEnumSet( + QualifiedContent.Scope.PROJECT, + QualifiedContent.Scope.SUB_PROJECTS, + QualifiedContent.Scope.EXTERNAL_LIBRARIES) LetTransform(Project project) { this.project = project + this.isLibrary = project.plugins.hasPlugin(LibraryPlugin) } @Override @@ -129,8 +140,7 @@ class LetTransform extends Transform { @NonNull @Override Set getScopes() { - return Sets.immutableEnumSet(QualifiedContent.Scope.PROJECT, - QualifiedContent.Scope.EXTERNAL_LIBRARIES) + return isLibrary ? LIBRARY_SCOPE : APP_SCOPE } @Override diff --git a/let-plugin/src/main/resources/META-INF/gradle-plugins/let.properties b/let-plugin/src/main/resources/META-INF/gradle-plugins/let.properties index 26ffb9a..466be26 100644 --- a/let-plugin/src/main/resources/META-INF/gradle-plugins/let.properties +++ b/let-plugin/src/main/resources/META-INF/gradle-plugins/let.properties @@ -1,5 +1,5 @@ # -# Copyright (C) 2015 Can Elmas +# Copyright (C) 2018 Can Elmas # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/let-runtime/build.gradle b/let-runtime/build.gradle index c7640da..1f8c319 100644 --- a/let-runtime/build.gradle +++ b/let-runtime/build.gradle @@ -1,9 +1,5 @@ -import org.aspectj.bridge.IMessage -import org.aspectj.bridge.MessageHandler -import org.aspectj.tools.ajc.Main - /* - * Copyright (C) 2015 Can Elmas + * Copyright (C) 2018 Can Elmas * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,40 +50,4 @@ android { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } -} - -android.libraryVariants.all { variant -> - JavaCompile javaCompile = variant.javaCompile - javaCompile.doLast { - String[] args = [ - "-showWeaveInfo", - "-1.5", - "-inpath", javaCompile.destinationDir.toString(), - "-aspectpath", javaCompile.classpath.asPath, - "-d", javaCompile.destinationDir.toString(), - "-classpath", javaCompile.classpath.asPath, - "-bootclasspath", android.bootClasspath.join(File.pathSeparator) - ] - - MessageHandler handler = new MessageHandler(true); - new Main().run(args, handler) - - def log = project.logger - for (IMessage message : handler.getMessages(null, true)) { - switch (message.getKind()) { - case IMessage.ABORT: - case IMessage.ERROR: - case IMessage.FAIL: - log.error message.message, message.thrown - break; - case IMessage.WARNING: - case IMessage.INFO: - log.info message.message, message.thrown - break; - case IMessage.DEBUG: - log.debug message.message, message.thrown - break; - } - } - } } \ No newline at end of file diff --git a/let-runtime/gradle.properties b/let-runtime/gradle.properties index af29580..fbcee9f 100644 --- a/let-runtime/gradle.properties +++ b/let-runtime/gradle.properties @@ -1,10 +1,10 @@ # -# Copyright (C) 2015 Can Elmas +# Copyright (C) 2018 Can Elmas # # 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 diff --git a/let-runtime/src/androidTest/java/com/canelmas/let/ApplicationTest.java b/let-runtime/src/androidTest/java/com/canelmas/let/ApplicationTest.java index 86807ba..5361e5d 100644 --- a/let-runtime/src/androidTest/java/com/canelmas/let/ApplicationTest.java +++ b/let-runtime/src/androidTest/java/com/canelmas/let/ApplicationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Can Elmas + * Copyright (C) 2018 Can Elmas * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/let-runtime/src/main/AndroidManifest.xml b/let-runtime/src/main/AndroidManifest.xml index bff1716..9705c2c 100644 --- a/let-runtime/src/main/AndroidManifest.xml +++ b/let-runtime/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + + diff --git a/let-sample-library/src/main/java/com/canelmas/let/sample/library/LibTest.java b/let-sample-library/src/main/java/com/canelmas/let/sample/library/LibTest.java new file mode 100644 index 0000000..56727ec --- /dev/null +++ b/let-sample-library/src/main/java/com/canelmas/let/sample/library/LibTest.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2018 Can Elmas + * + * 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.canelmas.let.sample.library; + +import com.canelmas.let.AskPermission; + +public class LibTest { + + @AskPermission + public void test(){ + + } +} diff --git a/let-sample-library/src/main/res/values/strings.xml b/let-sample-library/src/main/res/values/strings.xml new file mode 100644 index 0000000..7692d12 --- /dev/null +++ b/let-sample-library/src/main/res/values/strings.xml @@ -0,0 +1,19 @@ + + + + let-sample-library + diff --git a/let-sample-library/src/test/java/com/cnlms/let_sample_library/ExampleUnitTest.java b/let-sample-library/src/test/java/com/cnlms/let_sample_library/ExampleUnitTest.java new file mode 100644 index 0000000..f566e36 --- /dev/null +++ b/let-sample-library/src/test/java/com/cnlms/let_sample_library/ExampleUnitTest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2018 Can Elmas + * + * 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.cnlms.let_sample_library; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/let-sample/build.gradle b/let-sample/build.gradle index 46b434b..d6ce67f 100644 --- a/let-sample/build.gradle +++ b/let-sample/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Can Elmas + * Copyright (C) 2018 Can Elmas * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,12 +18,17 @@ buildscript { repositories { jcenter() google() + mavenLocal() } dependencies { - classpath 'com.canelmas.let:let-plugin:1.0.0-beta1' + classpath 'com.canelmas.let:let-plugin:1.0.0-beta2' } } +repositories { + mavenLocal() +} + apply plugin: 'com.android.application' apply plugin: 'let' @@ -50,6 +55,7 @@ android { abortOnError false } + buildToolsVersion versions.buildToolsVersion } dependencies { diff --git a/let-sample/src/androidTest/java/com/canelmas/let/ApplicationTest.java b/let-sample/src/androidTest/java/com/canelmas/let/ApplicationTest.java index 86807ba..5361e5d 100644 --- a/let-sample/src/androidTest/java/com/canelmas/let/ApplicationTest.java +++ b/let-sample/src/androidTest/java/com/canelmas/let/ApplicationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Can Elmas + * Copyright (C) 2018 Can Elmas * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/let-sample/src/main/AndroidManifest.xml b/let-sample/src/main/AndroidManifest.xml index d6f7814..324a91e 100644 --- a/let-sample/src/main/AndroidManifest.xml +++ b/let-sample/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@