Skip to content

Commit 00d57ac

Browse files
committed
Update to support the latest version of gradle
1 parent e252193 commit 00d57ac

25 files changed

+233
-99
lines changed

gradle-retrolambda/src/main/groovy/me/tatarka/RetrolambdaExec.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class RetrolambdaExec {
5858
if (!retrolambda.onJava8) {
5959
def java = "${retrolambda.tryGetJdk()}/bin/java"
6060
if (!checkIfExecutableExists(java)) {
61-
throw new ProjectConfigurationException("Cannot find executable: $java", null)
61+
throw new ProjectConfigurationException("Cannot find executable: $java", (Throwable) null)
6262
}
6363
exec.executable java
6464
}

gradle-retrolambda/src/main/groovy/me/tatarka/RetrolambdaExtension.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public class RetrolambdaExtension {
101101
String tryGetJdk() {
102102
String jdk = getJdk()
103103
if (jdk == null) {
104-
throw new ProjectConfigurationException("When running gradle with java 5, 6 or 7, you must set the path to jdk8, either with property retrolambda.jdk or environment variable JAVA8_HOME", null)
104+
throw new ProjectConfigurationException("When running gradle with java 5, 6 or 7, you must set the path to jdk8, either with property retrolambda.jdk or environment variable JAVA8_HOME", (Throwable) null)
105105
}
106106
return jdk
107107
}

gradle-retrolambda/src/main/groovy/me/tatarka/RetrolambdaPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import org.gradle.api.plugins.JavaPlugin
2828

2929
@CompileStatic
3030
public class RetrolambdaPlugin implements Plugin<Project> {
31-
protected static String retrolambdaCompile = "net.orfjackal.retrolambda:retrolambda:2.5.1"
31+
protected static String retrolambdaCompile = "net.orfjackal.retrolambda:retrolambda:2.5.6"
3232

3333
@Override
3434
void apply(Project project) {

gradle-retrolambda/src/main/groovy/me/tatarka/RetrolambdaPluginAndroid.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class RetrolambdaPluginAndroid implements Plugin<Project> {
143143
// Set JDK 8 for the compiler task
144144
def javac = "${retrolambda.tryGetJdk()}/bin/javac"
145145
if (!checkIfExecutableExists(javac)) {
146-
throw new ProjectConfigurationException("Cannot find executable: $javac", null)
146+
throw new ProjectConfigurationException("Cannot find executable: $javac", (Throwable) null)
147147
}
148148
javaCompile.options.fork = true
149149
javaCompile.options.forkOptions.executable = javac
@@ -154,7 +154,7 @@ class RetrolambdaPluginAndroid implements Plugin<Project> {
154154
if (!retrolambda.onJava8) {
155155
def java = "${retrolambda.tryGetJdk()}/bin/java"
156156
if (!checkIfExecutableExists(java)) {
157-
throw new ProjectConfigurationException("Cannot find executable: $java", null)
157+
throw new ProjectConfigurationException("Cannot find executable: $java", (Throwable) null)
158158
}
159159
test.executable java
160160
}

gradle-retrolambda/src/main/groovy/me/tatarka/RetrolambdaPluginGroovy.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class RetrolambdaPluginGroovy implements Plugin<Project> {
3434
if (project.retrolambda.isIncluded(set.name)) {
3535
def name = RetrolambdaUtil.capitalize(set.name)
3636
def taskName = "compileRetrolambdaGroovy$name"
37-
def oldOutputDir = set.output.classesDir
37+
def oldOutputDir = RetrolambdaUtil.groovyOutputDir(set)
3838
def newOutputDir = project.file("$project.buildDir/retrolambda/$set.name")
3939

4040
/* No compileJavaTaskName present, so re-use any modifications applied to compileJava and remap to Groovy */

gradle-retrolambda/src/main/groovy/me/tatarka/RetrolambdaPluginJava.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class RetrolambdaPluginJava implements Plugin<Project> {
4040
if (retrolambda.isIncluded(set.name)) {
4141
def name = RetrolambdaUtil.capitalize(set.name)
4242
def taskName = "compileRetrolambda$name"
43-
def oldOutputDir = set.output.classesDir
43+
def oldOutputDir = RetrolambdaUtil.javaOutputDir(set)
4444
def newOutputDir = project.file("$project.buildDir/retrolambda/$set.name")
4545

4646
def compileJavaTask = project.tasks.getByName(set.compileJavaTaskName) as JavaCompile
@@ -82,7 +82,7 @@ public class RetrolambdaPluginJava implements Plugin<Project> {
8282
if (oldJdkPath != null) {
8383
def oldJava = "$oldJdkPath/bin/java"
8484
if (!checkIfExecutableExists(oldJava)) {
85-
throw new ProjectConfigurationException("Cannot find executable: $oldJava", null)
85+
throw new ProjectConfigurationException("Cannot find executable: $oldJava", (Throwable) null)
8686
}
8787
task.executable oldJava
8888
}

gradle-retrolambda/src/main/groovy/me/tatarka/RetrolambdaTask.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ class RetrolambdaTask extends DefaultTask {
5555
def retrolambda = project.extensions.getByType(RetrolambdaExtension)
5656

5757
List<InputFileDetails> changes = []
58-
inputs.outOfDate { changes += it }
58+
inputs.outOfDate { changes.add(it) }
5959

6060
// Ensure output is cleared if build is not incremental.
6161
if (inputs.incremental && !changes.isEmpty() && !retrolambda.incremental) {
6262
outputDir.eachFile { it.delete() }
6363
} else {
64-
changes.each { InputFileDetails change ->
64+
for (InputFileDetails change : changes) {
6565
if (change.modified) deleteRelated(toOutput(change.file))
6666
}
6767
}
@@ -90,11 +90,11 @@ class RetrolambdaTask extends DefaultTask {
9090
}
9191
}
9292

93-
def File toOutput(File file) {
93+
File toOutput(File file) {
9494
return outputDir.toPath().resolve(inputDir.toPath().relativize(file.toPath())).toFile()
9595
}
9696

97-
def deleteRelated(File file) {
97+
void deleteRelated(File file) {
9898
def className = file.name.replaceFirst(/\.class$/, '')
9999
// Delete any generated Lambda classes
100100
project.logger.debug("Deleting related for " + className + " in " + file.parentFile)

gradle-retrolambda/src/main/groovy/me/tatarka/RetrolambdaTransform.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class RetrolambdaTransform extends Transform {
116116
BaseVariant variant = getVariant(context, outputDir)
117117

118118
if (variant == null) {
119-
throw new ProjectConfigurationException('Missing variant for output dir: ' + outputDir, null)
119+
throw new ProjectConfigurationException('Missing variant for output dir: ' + outputDir, (Throwable) null)
120120
}
121121

122122
FileCollection classpathFiles = variant.javaCompile.classpath
@@ -132,7 +132,7 @@ class RetrolambdaTransform extends Transform {
132132
} else {
133133
// If this is null it means the javaCompile task didn't need to run, however, we still
134134
// need to run but can't without the bootClasspath. Just fail and ask the user to rebuild.
135-
throw new ProjectConfigurationException("Unable to obtain the bootClasspath. This may happen if your javaCompile tasks didn't run but retrolambda did. You must rebuild your project or otherwise force javaCompile to run.", null)
135+
throw new ProjectConfigurationException("Unable to obtain the bootClasspath. This may happen if your javaCompile tasks didn't run but retrolambda did. You must rebuild your project or otherwise force javaCompile to run.", (Throwable) null)
136136
}
137137

138138
return classpathFiles
@@ -161,7 +161,7 @@ class RetrolambdaTransform extends Transform {
161161
// This will no longer be needed when the transform api supports per-variant transforms
162162
String[] parts = outputDir.toURI().path.split('/intermediates/transforms/retrolambda/|/folders/[0-9]+')
163163
if (parts.length < 2) {
164-
throw new ProjectConfigurationException('Could not extract variant from output dir: ' + outputDir, null)
164+
throw new ProjectConfigurationException('Could not extract variant from output dir: ' + outputDir, (Throwable) null)
165165
}
166166
String variantPath = parts[1]
167167
for (BaseVariant variant : variants) {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
package me.tatarka
22

3+
import groovy.transform.TypeChecked
4+
import groovy.transform.TypeCheckingMode
5+
import org.gradle.api.tasks.SourceSet
6+
37
class RetrolambdaUtil {
48
static String capitalize(CharSequence self) {
59
return self.length() == 0 ? "" : "" + Character.toUpperCase(self.charAt(0)) + self.subSequence(1, self.length())
610
}
11+
12+
@TypeChecked(TypeCheckingMode.SKIP)
13+
static File javaOutputDir(SourceSet set) {
14+
try {
15+
return set.java.outputDir
16+
} catch (Exception e) {
17+
return set.output.classesDir
18+
}
19+
}
20+
21+
@TypeChecked(TypeCheckingMode.SKIP)
22+
static File groovyOutputDir(SourceSet set) {
23+
try {
24+
return set.groovy.outputDir
25+
} catch (Exception e) {
26+
return set.output.classesDir
27+
}
28+
}
729
}

gradle-retrolambda/src/test/java/me/tatarka/AndroidAppPluginTest.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
import java.util.Arrays;
1616
import java.util.Collection;
1717

18-
import static me.tatarka.TestHelpers.findFile;
19-
import static me.tatarka.TestHelpers.getPluginClasspath;
20-
import static me.tatarka.TestHelpers.newestSupportedAndroidPluginVersion;
21-
import static me.tatarka.TestHelpers.oldestSupportedAndroidPluginVersion;
22-
import static me.tatarka.TestHelpers.writeFile;
18+
import static me.tatarka.TestHelpers.*;
2319
import static org.assertj.core.api.Assertions.assertThat;
2420

2521
@RunWith(Parameterized.class)
@@ -38,19 +34,22 @@ public static Collection<Object[]> data() {
3834
private final String androidVersion;
3935
private final String gradleVersion;
4036
private final String buildToolsVersion;
37+
private final String kotlinVersion;
4138
private File rootDir;
4239
private File buildFile;
4340

44-
public AndroidAppPluginTest(String androidVersion, String gradleVersion, String buildToolsVersion) {
41+
public AndroidAppPluginTest(String androidVersion, String gradleVersion, String buildToolsVersion, String kotlinVersion) {
4542
this.androidVersion = androidVersion;
4643
this.gradleVersion = gradleVersion;
4744
this.buildToolsVersion = buildToolsVersion;
45+
this.kotlinVersion = kotlinVersion;
4846
}
4947

5048
@Before
5149
public void setup() throws Exception {
5250
rootDir = testProjectDir.getRoot();
5351
buildFile = testProjectDir.newFile("build.gradle");
52+
copyLocalPropertiesIfExists(rootDir);
5453
}
5554

5655
@Test
@@ -75,6 +74,7 @@ public void assembleDebug() throws Exception {
7574
"apply plugin: 'me.tatarka.retrolambda'\n" +
7675
"\n" +
7776
"repositories {\n" +
77+
" maven { url 'https://maven.google.com' }\n" +
7878
" mavenCentral()\n" +
7979
"}\n" +
8080
"\n" +
@@ -92,7 +92,7 @@ public void assembleDebug() throws Exception {
9292

9393
writeFile(manifestFile,
9494
//language="XML"
95-
"<manifest package=\"test\" " +
95+
"<manifest package=\"test.test\" " +
9696
"xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
9797
" <application/>\n" +
9898
"</manifest>");
@@ -147,6 +147,7 @@ public void assembleDebugIncremental() throws Exception {
147147
"apply plugin: 'me.tatarka.retrolambda'\n" +
148148
"\n" +
149149
"repositories {\n" +
150+
" maven { url 'https://maven.google.com' }\n" +
150151
" mavenCentral()\n" +
151152
"}\n" +
152153
"\n" +
@@ -164,7 +165,7 @@ public void assembleDebugIncremental() throws Exception {
164165

165166
writeFile(manifestFile,
166167
//language="XML"
167-
"<manifest package=\"test\" " +
168+
"<manifest package=\"test.test\" " +
168169
"xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
169170
" <application/>\n" +
170171
"</manifest>");
@@ -240,6 +241,7 @@ public void assembleDebugIncrementalShouldntLeak() throws Exception {
240241
"apply plugin: 'me.tatarka.retrolambda'\n" +
241242
"\n" +
242243
"repositories {\n" +
244+
" maven { url 'https://maven.google.com' }\n" +
243245
" mavenCentral()\n" +
244246
"}\n" +
245247
"\n" +
@@ -257,7 +259,7 @@ public void assembleDebugIncrementalShouldntLeak() throws Exception {
257259

258260
writeFile(manifestFile,
259261
//language="XML"
260-
"<manifest package=\"test\" " +
262+
"<manifest package=\"test.test\" " +
261263
"xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
262264
" <application/>\n" +
263265
"</manifest>");
@@ -293,13 +295,15 @@ public void assembleDebugIncrementalShouldntLeak() throws Exception {
293295
assertThat(lambdaClassFile).exists();
294296

295297
// delete the java file
296-
javaFile.delete();
298+
if (!javaFile.delete()) {
299+
throw new Exception("Failed to delete file: " + javaFile);
300+
}
297301

298302
errorOutput = new StringWriter();
299303
result = GradleRunner.create()
300304
.withGradleVersion(gradleVersion)
301305
.withProjectDir(rootDir)
302-
.withArguments("assembleDebug", "--stacktrace", "-Pandroid.enableAapt2=false")
306+
.withArguments("assembleDebug", "--stacktrace", "-Pandroid.enableAapt2=false", "--debug")
303307
.forwardStdError(errorOutput)
304308
.build();
305309

@@ -329,6 +333,7 @@ public void unitTest() throws Exception {
329333
"apply plugin: 'me.tatarka.retrolambda'\n" +
330334
"\n" +
331335
"repositories {\n" +
336+
" maven { url 'https://maven.google.com' }\n" +
332337
" mavenCentral()\n" +
333338
"}\n" +
334339
"\n" +
@@ -350,7 +355,7 @@ public void unitTest() throws Exception {
350355

351356
writeFile(manifestFile,
352357
//language="XML"
353-
"<manifest package=\"test\" " +
358+
"<manifest package=\"test.test\" " +
354359
"xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
355360
" <application/>\n" +
356361
"</manifest>");
@@ -414,6 +419,7 @@ public void androidTest() throws Exception {
414419
"apply plugin: 'me.tatarka.retrolambda'\n" +
415420
"\n" +
416421
"repositories {\n" +
422+
" maven { url 'https://maven.google.com' }\n" +
417423
" mavenCentral()\n" +
418424
"}\n" +
419425
"\n" +
@@ -494,7 +500,7 @@ public void withKotlin() throws Exception {
494500
" dependencies {\n" +
495501
" classpath files(" + getPluginClasspath() + ")\n" +
496502
" classpath 'com.android.tools.build:gradle:" + androidVersion + "'\n" +
497-
" classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0'" +
503+
" classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:" + kotlinVersion + "'" +
498504
" }\n" +
499505
"}\n" +
500506
"\n" +
@@ -503,6 +509,7 @@ public void withKotlin() throws Exception {
503509
"apply plugin: 'kotlin-android'\n" +
504510
"\n" +
505511
"repositories {\n" +
512+
" maven { url 'https://maven.google.com' }\n" +
506513
" mavenCentral()\n" +
507514
"}\n" +
508515
"\n" +
@@ -523,7 +530,7 @@ public void withKotlin() throws Exception {
523530

524531
writeFile(manifestFile,
525532
//language="XML"
526-
"<manifest package=\"test\" " +
533+
"<manifest package=\"test.test\" " +
527534
"xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
528535
" <application/>\n" +
529536
"</manifest>");

0 commit comments

Comments
 (0)