Skip to content

Commit

Permalink
Add gradle incremental compilation support (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
bejibx authored and grandstaish committed Jun 2, 2019
1 parent 40e7d1d commit ded625e
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 34 deletions.
40 changes: 23 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ subprojects { project ->
version = VERSION_NAME
}

ext.kotlin_version = '1.1.60'
ext.kotlin_version = '1.3.31'

allprojects {
repositories {
Expand All @@ -20,7 +20,7 @@ allprojects {

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'io.realm:realm-gradle-plugin:2.2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
Expand All @@ -38,7 +38,7 @@ ext {
minSdkVersion = 9
targetSdkVersion = 27
compileSdkVersion = 27
buildToolsVersion = '26.0.2'
buildToolsVersion = '28.0.3'
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
targetCompatibilityVersion = JavaVersion.VERSION_1_7
}
Expand All @@ -57,22 +57,28 @@ project.plugins.whenPluginAdded { plugin ->
}

def androidSupportVersion = '27.0.1'
def gradleIncapHelperVersion = '0.2'
def autoserviceVersion = '1.0-rc5'

ext.deps = [
android : 'com.google.android:android:4.1.1.4',
supportAnnotations : "com.android.support:support-annotations:$androidSupportVersion",
appCompat : "com.android.support:appcompat-v7:$androidSupportVersion",
design : "com.android.support:design:$androidSupportVersion",
supportTestRunner : 'com.android.support.test:runner:0.5',
javapoet : 'com.squareup:javapoet:1.8.0',
autovalue : 'com.google.auto.value:auto-value:1.3',
autocommon : 'com.google.auto:auto-common:0.8',
autoservice : 'com.google.auto.service:auto-service:1.0-rc2',
javaFormat : 'com.google.googlejavaformat:google-java-format:1.1',
junit : 'junit:junit:4.12',
truth : 'com.google.truth:truth:0.30',
compiletesting : 'com.google.testing.compile:compile-testing:0.10',
lombok : "org.projectlombok:lombok:1.16.16"
android : 'com.google.android:android:4.1.1.4',
supportAnnotations : "com.android.support:support-annotations:$androidSupportVersion",
appCompat : "com.android.support:appcompat-v7:$androidSupportVersion",
design : "com.android.support:design:$androidSupportVersion",
supportTestRunner : 'com.android.support.test:runner:0.5',
javapoet : 'com.squareup:javapoet:1.8.0',
autovalueProcessor : 'com.google.auto.value:auto-value:1.6.5',
autovalueApi : 'com.google.auto.value:auto-value-annotations:1.6.3',
autocommon : 'com.google.auto:auto-common:0.8',
autoserviceProcessor : "com.google.auto.service:auto-service:$autoserviceVersion",
autoserviceApi : "com.google.auto.service:auto-service-annotations:$autoserviceVersion",
javaFormat : 'com.google.googlejavaformat:google-java-format:1.1',
junit : 'junit:junit:4.12',
truth : 'com.google.truth:truth:0.30',
compiletesting : 'com.google.testing.compile:compile-testing:0.10',
lombok : "org.projectlombok:lombok:1.16.16",
gradleIncapHelperApi : "net.ltgt.gradle.incap:incap:$gradleIncapHelperVersion",
gradleIncapHelperProcessor: "net.ltgt.gradle.incap:incap-processor:$gradleIncapHelperVersion"
]

task clean(type: Delete) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
9 changes: 7 additions & 2 deletions paperparcel-compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ targetCompatibility = rootProject.ext.targetCompatibilityVersion

dependencies {
compile project(':paperparcel-api')
compile deps.autovalue
compile deps.autoservice
compile deps.autovalueApi
compile deps.autovalueProcessor
annotationProcessor deps.autovalueProcessor
compile deps.autoserviceApi
annotationProcessor deps.autoserviceProcessor
compile deps.autocommon
compile deps.javapoet
compile deps.javaFormat
compile deps.gradleIncapHelperApi
annotationProcessor deps.gradleIncapHelperProcessor
}

apply from: rootProject.file('gradle/bintray.gradle')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public class PaperParcelAutoValueExtension extends AutoValueExtension {
private static final TypeName PARCEL = ClassName.get("android.os", "Parcel");
private static final String NULLABLE_ANNOTATION_NAME = "Nullable";

@Override
public IncrementalExtensionType incrementalType(final ProcessingEnvironment processingEnvironment) {
return IncrementalExtensionType.ISOLATING;
}

@Override public boolean applicable(Context context) {
ProcessingEnvironment env = context.processingEnvironment();
Elements elements = env.getElementUtils();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
import com.google.auto.service.AutoService;
import com.google.common.collect.ImmutableList;
import com.google.googlejavaformat.java.filer.FormattingFiler;

import net.ltgt.gradle.incap.IncrementalAnnotationProcessor;
import net.ltgt.gradle.incap.IncrementalAnnotationProcessorType;

import javax.annotation.processing.Filer;
import javax.annotation.processing.Messager;
import javax.annotation.processing.Processor;
Expand All @@ -32,6 +36,7 @@
* implementation.
*/
@AutoService(Processor.class)
@IncrementalAnnotationProcessor(IncrementalAnnotationProcessorType.AGGREGATING)
public class PaperParcelProcessor extends BasicAnnotationProcessor {
@Override public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latestSupported();
Expand Down
4 changes: 2 additions & 2 deletions paperparcel-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ dokka {
}

dependencies {
provided "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

provided project(":paperparcel")
compileOnly project(":paperparcel")
}

apply from: rootProject.file('gradle/bintray.gradle')
Expand Down
25 changes: 14 additions & 11 deletions paperparcel/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.gradle.internal.jvm.Jvm

apply plugin: 'com.android.library'

android {
Expand Down Expand Up @@ -25,20 +27,21 @@ tasks.withType(Test) {
}

dependencies {
compile project(':paperparcel-api')
compile deps.supportAnnotations
api project(':paperparcel-api')
api deps.supportAnnotations

androidTestCompile deps.junit
androidTestCompile deps.truth
androidTestCompile deps.supportTestRunner
androidTestImplementation deps.junit
androidTestImplementation deps.truth
androidTestImplementation deps.supportTestRunner
androidTestAnnotationProcessor project(':paperparcel-compiler')

testCompile deps.junit
testCompile deps.truth
testCompile deps.compiletesting
testCompile files(getRuntimeJar())
testCompile files(org.gradle.internal.jvm.Jvm.current().getToolsJar())
testCompile project(':paperparcel-compiler')
testImplementation deps.junit
testImplementation deps.truth
testImplementation deps.compiletesting
testImplementation files(getRuntimeJar())
testImplementation files(Jvm.current().getToolsJar())
testImplementation project(':paperparcel-compiler')
testAnnotationProcessor project(':paperparcel-compiler')
}

def getRuntimeJar() {
Expand Down
2 changes: 1 addition & 1 deletion paperparcel/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="paperparcel"/>
<manifest package="paperparcel.core"/>

0 comments on commit ded625e

Please sign in to comment.