diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/pom.xml b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/pom.xml index c6a09fd722..d90ae32ddb 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/pom.xml +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/pom.xml @@ -16,6 +16,7 @@ ./gradlew build false + 1.2.10 diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit/GradleBuild.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit/GradleBuild.java index de66141ccf..0d7996c424 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit/GradleBuild.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit/GradleBuild.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.regex.Pattern; -import java.util.stream.Collectors; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpression; @@ -35,6 +34,11 @@ import io.spring.gradle.dependencymanagement.DependencyManagementPlugin; import org.apache.commons.compress.archivers.ArchiveEntry; import org.gradle.testkit.runner.BuildResult; import org.gradle.testkit.runner.GradleRunner; +import org.jetbrains.kotlin.cli.common.PropertiesKt; +import org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner; +import org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin; +import org.jetbrains.kotlin.gradle.plugin.KotlinPlugin; +import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper; import org.junit.rules.TemporaryFolder; import org.junit.rules.TestRule; import org.junit.runner.Description; @@ -121,14 +125,14 @@ public class GradleBuild implements TestRule { new File(pathOfJarContaining(LaunchScript.class)), new File(pathOfJarContaining(ClassVisitor.class)), new File(pathOfJarContaining(DependencyManagementPlugin.class)), + new File(pathOfJarContaining(KotlinPluginWrapper.class)), + new File(pathOfJarContaining(PropertiesKt.class)), + new File(pathOfJarContaining(KotlinCompilerRunner.class)), + new File(pathOfJarContaining(KotlinPlugin.class)), + new File(pathOfJarContaining(KotlinGradleSubplugin.class)), new File(pathOfJarContaining(ArchiveEntry.class))); } - private String pluginClasspathAsString() { - return pluginClasspath().stream().map(File::getAbsolutePath) - .collect(Collectors.joining(",")); - } - private String pathOfJarContaining(Class type) { return type.getProtectionDomain().getCodeSource().getLocation().getPath(); } @@ -170,20 +174,6 @@ public class GradleBuild implements TestRule { List allArguments = new ArrayList<>(); allArguments.add("-PbootVersion=" + getBootVersion()); allArguments.add("--stacktrace"); - - // this is necessary for the tests checking that we react correctly to the Kotlin - // plugin. - // Indeed, when using the plugins block to load the Boot plugin under test, - // relying on the plugin - // classpath set by withPluginClasspath(pluginClasspath()), the Boot plugin and - // the Kotlin plugin - // are loaded using two separate classloaders, and the Boot plugin thus doesn't - // see the Kotlin plugin - // class and can't react to it. To circumvent this test kit limitation, we set the - // classpath - // from the buildscript block of the build script, thanks to this pluginClasspath - // property - allArguments.add("-PpluginClasspath=" + pluginClasspathAsString()); allArguments.addAll(Arrays.asList(arguments)); return gradleRunner.withArguments(allArguments); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-kotlinCompileTasksCanOverrideDefaultJavaParametersFlag.gradle b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-kotlinCompileTasksCanOverrideDefaultJavaParametersFlag.gradle index 20fd64b938..d2c6c2dfbf 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-kotlinCompileTasksCanOverrideDefaultJavaParametersFlag.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-kotlinCompileTasksCanOverrideDefaultJavaParametersFlag.gradle @@ -1,19 +1,8 @@ -// this is necessary for the tests checking that we react correctly to the Kotlin plugin. -// Indeed, when using the plugins block to load the Boot plugin under test, relying on the plugin -// classpath set by the test kit gradle runner, the Boot plugin and the Kotlin plugin -// are loaded using two separate classloaders, and the Boot plugin thus doesn't see the Kotlin plugin -// class and can't react to it. To circumvent this test kit limitation, we set the classpath here. -buildscript { - dependencies { - classpath files(pluginClasspath.split(',')) - } -} - plugins { - id 'org.jetbrains.kotlin.jvm' version '1.2.10' + id 'org.springframework.boot' version '{version}' } -apply plugin: 'org.springframework.boot' +apply plugin: 'org.jetbrains.kotlin.jvm' import org.jetbrains.kotlin.gradle.dsl.KotlinCompile diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-kotlinCompileTasksUseJavaParametersFlagByDefault.gradle b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-kotlinCompileTasksUseJavaParametersFlagByDefault.gradle index 9cf052978d..cb6e5f8967 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-kotlinCompileTasksUseJavaParametersFlagByDefault.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-kotlinCompileTasksUseJavaParametersFlagByDefault.gradle @@ -1,19 +1,8 @@ -// this is necessary for the tests checking that we react correctly to the Kotlin plugin. -// Indeed, when using the plugins block to load the Boot plugin under test, relying on the plugin -// classpath set by the test kit gradle runner, the Boot plugin and the Kotlin plugin -// are loaded using two separate classloaders, and the Boot plugin thus doesn't see the Kotlin plugin -// class and can't react to it. To circumvent this test kit limitation, we set the classpath here. -buildscript { - dependencies { - classpath files(pluginClasspath.split(',')) - } -} - plugins { - id 'org.jetbrains.kotlin.jvm' version '1.2.10' + id 'org.springframework.boot' version '{version}' } -apply plugin: 'org.springframework.boot' +apply plugin: 'org.jetbrains.kotlin.jvm' import org.jetbrains.kotlin.gradle.dsl.KotlinCompile diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-kotlinVersionMatchesKotlinPluginVersion.gradle b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-kotlinVersionMatchesKotlinPluginVersion.gradle index ee9c05852a..4f67100c60 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-kotlinVersionMatchesKotlinPluginVersion.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-kotlinVersionMatchesKotlinPluginVersion.gradle @@ -1,21 +1,9 @@ -// this is necessary for the tests checking that we react correctly to the Kotlin plugin. -// Indeed, when using the plugins block to load the Boot plugin under test, relying on the plugin -// classpath set by the test kit gradle runner, the Boot plugin and the Kotlin plugin -// are loaded using two separate classloaders, and the Boot plugin thus doesn't see the Kotlin plugin -// class and can't react to it. To circumvent this test kit limitation, we set the classpath here. -buildscript { - dependencies { - classpath files(pluginClasspath.split(',')) - } -} - plugins { - id 'org.jetbrains.kotlin.jvm' version '1.2.10' + id 'org.springframework.boot' version '{version}' } - -apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' +apply plugin: 'org.jetbrains.kotlin.jvm' dependencyManagement { resolutionStrategy { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-noKotlinVersionPropertyWithoutKotlinPlugin.gradle b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-noKotlinVersionPropertyWithoutKotlinPlugin.gradle index 9a528c6501..b32c7306da 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-noKotlinVersionPropertyWithoutKotlinPlugin.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/KotlinPluginActionIntegrationTests-noKotlinVersionPropertyWithoutKotlinPlugin.gradle @@ -1,16 +1,7 @@ -// this is necessary for the tests checking that we react correctly to the Kotlin plugin. -// Indeed, when using the plugins block to load the Boot plugin under test, relying on the plugin -// classpath set by the test kit gradle runner, the Boot plugin and the Kotlin plugin -// are loaded using two separate classloaders, and the Boot plugin thus doesn't see the Kotlin plugin -// class and can't react to it. To circumvent this test kit limitation, we set the classpath here. -buildscript { - dependencies { - classpath files(pluginClasspath.split(',')) - } +plugins { + id 'org.springframework.boot' version '{version}' } -apply plugin: 'org.springframework.boot' - task kotlinVersion { doLast { def kotlinVersion = project.hasProperty('kotlin.version') ? project.getProperty('kotlin.version') : 'none'