|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2017 the original author or authors. |
| 2 | + * Copyright 2012-2018 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
25 | 25 | import java.util.Arrays;
|
26 | 26 | import java.util.List;
|
27 | 27 | import java.util.regex.Pattern;
|
28 |
| -import java.util.stream.Collectors; |
29 | 28 |
|
30 | 29 | import javax.xml.xpath.XPath;
|
31 | 30 | import javax.xml.xpath.XPathExpression;
|
|
35 | 34 | import org.apache.commons.compress.archivers.ArchiveEntry;
|
36 | 35 | import org.gradle.testkit.runner.BuildResult;
|
37 | 36 | import org.gradle.testkit.runner.GradleRunner;
|
| 37 | +import org.jetbrains.kotlin.cli.common.PropertiesKt; |
| 38 | +import org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner; |
| 39 | +import org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin; |
| 40 | +import org.jetbrains.kotlin.gradle.plugin.KotlinPlugin; |
| 41 | +import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper; |
38 | 42 | import org.junit.rules.TemporaryFolder;
|
39 | 43 | import org.junit.rules.TestRule;
|
40 | 44 | import org.junit.runner.Description;
|
@@ -121,14 +125,14 @@ private List<File> pluginClasspath() {
|
121 | 125 | new File(pathOfJarContaining(LaunchScript.class)),
|
122 | 126 | new File(pathOfJarContaining(ClassVisitor.class)),
|
123 | 127 | new File(pathOfJarContaining(DependencyManagementPlugin.class)),
|
| 128 | + new File(pathOfJarContaining(KotlinPluginWrapper.class)), |
| 129 | + new File(pathOfJarContaining(PropertiesKt.class)), |
| 130 | + new File(pathOfJarContaining(KotlinCompilerRunner.class)), |
| 131 | + new File(pathOfJarContaining(KotlinPlugin.class)), |
| 132 | + new File(pathOfJarContaining(KotlinGradleSubplugin.class)), |
124 | 133 | new File(pathOfJarContaining(ArchiveEntry.class)));
|
125 | 134 | }
|
126 | 135 |
|
127 |
| - private String pluginClasspathAsString() { |
128 |
| - return pluginClasspath().stream().map(File::getAbsolutePath) |
129 |
| - .collect(Collectors.joining(",")); |
130 |
| - } |
131 |
| - |
132 | 136 | private String pathOfJarContaining(Class<?> type) {
|
133 | 137 | return type.getProtectionDomain().getCodeSource().getLocation().getPath();
|
134 | 138 | }
|
@@ -170,20 +174,6 @@ public GradleRunner prepareRunner(String... arguments) throws IOException {
|
170 | 174 | List<String> allArguments = new ArrayList<>();
|
171 | 175 | allArguments.add("-PbootVersion=" + getBootVersion());
|
172 | 176 | allArguments.add("--stacktrace");
|
173 |
| - |
174 |
| - // this is necessary for the tests checking that we react correctly to the Kotlin |
175 |
| - // plugin. |
176 |
| - // Indeed, when using the plugins block to load the Boot plugin under test, |
177 |
| - // relying on the plugin |
178 |
| - // classpath set by withPluginClasspath(pluginClasspath()), the Boot plugin and |
179 |
| - // the Kotlin plugin |
180 |
| - // are loaded using two separate classloaders, and the Boot plugin thus doesn't |
181 |
| - // see the Kotlin plugin |
182 |
| - // class and can't react to it. To circumvent this test kit limitation, we set the |
183 |
| - // classpath |
184 |
| - // from the buildscript block of the build script, thanks to this pluginClasspath |
185 |
| - // property |
186 |
| - allArguments.add("-PpluginClasspath=" + pluginClasspathAsString()); |
187 | 177 | allArguments.addAll(Arrays.asList(arguments));
|
188 | 178 | return gradleRunner.withArguments(allArguments);
|
189 | 179 | }
|
|
0 commit comments