evant / gradle-retrolambda

A gradle plugin for getting java lambda support in java 6, 7 and android
Apache License 2.0
5.3k stars 449 forks source link

Adds support for the Android Feature plugin #253

Closed josh-burton closed 7 years ago

josh-burton commented 7 years ago

The feature plugin is a new plugin type used in Instant Apps.

evant commented 7 years ago

Looks good, can we get a test for this? See https://github.com/evant/gradle-retrolambda/blob/master/gradle-retrolambda/src/test/java/me/tatarka/AndroidLibPluginTest.java for an example.

josh-burton commented 7 years ago

Hey Evan, I've added tests but they are currently failing.

The UI tests (or the sample projects) are failing due to issues with flavor selection in the latest AGP plugin: https://issuetracker.google.com/issues/62170415

I'm unsure why the unit tests are failing. I am getting the following error: lambda expressions are not supported in -source 1.7

Perhaps an environment setup issue?

evant commented 7 years ago

Hm, yep I'm getting the same error. Adding

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

seems to cause I new error

com.sun.tools.javac.code.Symbol$CompletionFailure: class file for java.lang.invoke.MethodType not found

I'm getting that error running trying to run the sample app too.

evant commented 7 years ago

Figured it out, apprently features have a feature varaint and a library variant. Adding

android.libraryVariants.all { BaseVariant variant ->
    configureCompileJavaTask(project, variant, transform)
}

seems to fix it.

josh-burton commented 7 years ago

Did you add the compile options to the test projects? I'm still getting a myriad of errors with both changes 😕

evant commented 7 years ago

The remaining tests I see failing don't seem to be related to this change. If this is the case you are seeing, I can merge this and make a sepreate pr for the tests.

josh-burton commented 7 years ago

ah ok I think that may be the case. I'm happy for this to be merged.