|
7 | 7 | import java.nio.file.Paths;
|
8 | 8 | import java.util.LinkedHashSet;
|
9 | 9 | import java.util.List;
|
10 |
| -import java.util.Map; |
11 |
| -import java.util.Objects; |
12 | 10 | import java.util.Set;
|
13 |
| -import java.util.StringJoiner; |
14 |
| -import java.util.stream.Collectors; |
15 | 11 |
|
16 | 12 | import javax.annotation.Nullable;
|
17 | 13 |
|
|
27 | 23 | import org.gradle.api.provider.Provider;
|
28 | 24 | import org.gradle.api.tasks.SourceSet;
|
29 | 25 | import org.gradle.api.tasks.SourceSetContainer;
|
30 |
| -import org.gradle.api.tasks.testing.Test; |
31 | 26 | import org.gradle.jvm.tasks.Jar;
|
32 | 27 | import org.gradle.process.JavaForkOptions;
|
33 | 28 |
|
34 |
| -import io.quarkus.bootstrap.BootstrapConstants; |
35 | 29 | import io.quarkus.bootstrap.model.ApplicationModel;
|
36 | 30 | import io.quarkus.bootstrap.resolver.AppModelResolver;
|
37 | 31 | import io.quarkus.gradle.AppModelGradleResolver;
|
38 |
| -import io.quarkus.gradle.QuarkusPlugin; |
39 | 32 | import io.quarkus.gradle.dsl.Manifest;
|
40 | 33 | import io.quarkus.gradle.tasks.AbstractQuarkusExtension;
|
41 |
| -import io.quarkus.gradle.tasks.QuarkusBuild; |
42 | 34 | import io.quarkus.gradle.tasks.QuarkusGradleUtils;
|
43 | 35 | import io.quarkus.gradle.tooling.ToolingUtils;
|
44 | 36 | import io.quarkus.runtime.LaunchMode;
|
45 |
| -import io.smallrye.config.SmallRyeConfig; |
46 | 37 |
|
47 | 38 | public abstract class QuarkusPluginExtension extends AbstractQuarkusExtension {
|
48 | 39 | // TODO dynamically load generation provider, or make them write code directly in quarkus-generated-sources
|
@@ -79,56 +70,6 @@ public void manifest(Action<Manifest> action) {
|
79 | 70 | action.execute(this.getManifest());
|
80 | 71 | }
|
81 | 72 |
|
82 |
| - public void beforeTest(Test task) { |
83 |
| - try { |
84 |
| - Map<String, Object> props = task.getSystemProperties(); |
85 |
| - ApplicationModel appModel = getApplicationModel(TEST); |
86 |
| - |
87 |
| - SmallRyeConfig config = buildEffectiveConfiguration(appModel) |
88 |
| - .getConfig(); |
89 |
| - config.getOptionalValue(TEST.getProfileKey(), String.class) |
90 |
| - .ifPresent(value -> props.put(TEST.getProfileKey(), value)); |
91 |
| - |
92 |
| - Path serializedModel = ToolingUtils.serializeAppModel(appModel, task, true); |
93 |
| - props.put(BootstrapConstants.SERIALIZED_TEST_APP_MODEL, serializedModel.toString()); |
94 |
| - |
95 |
| - StringJoiner outputSourcesDir = new StringJoiner(","); |
96 |
| - for (File outputSourceDir : combinedOutputSourceDirs()) { |
97 |
| - outputSourcesDir.add(outputSourceDir.getAbsolutePath()); |
98 |
| - } |
99 |
| - props.put(BootstrapConstants.OUTPUT_SOURCES_DIR, outputSourcesDir.toString()); |
100 |
| - |
101 |
| - SourceSetContainer sourceSets = getSourceSets(); |
102 |
| - SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); |
103 |
| - |
104 |
| - File outputDirectoryAsFile = getLastFile(mainSourceSet.getOutput().getClassesDirs()); |
105 |
| - |
106 |
| - Path projectDirPath = projectDir.toPath(); |
107 |
| - |
108 |
| - // Identify the folder containing the sources associated with this test task |
109 |
| - String fileList = sourceSets.stream() |
110 |
| - .filter(sourceSet -> Objects.equals( |
111 |
| - task.getTestClassesDirs().getAsPath(), |
112 |
| - sourceSet.getOutput().getClassesDirs().getAsPath())) |
113 |
| - .flatMap(sourceSet -> sourceSet.getOutput().getClassesDirs().getFiles().stream()) |
114 |
| - .filter(File::exists) |
115 |
| - .distinct() |
116 |
| - .map(testSrcDir -> String.format("%s:%s", |
117 |
| - projectDirPath.relativize(testSrcDir.toPath()), |
118 |
| - projectDirPath.relativize(outputDirectoryAsFile.toPath()))) |
119 |
| - .collect(Collectors.joining(",")); |
120 |
| - task.environment(BootstrapConstants.TEST_TO_MAIN_MAPPINGS, fileList); |
121 |
| - task.getLogger().debug("test dir mapping - {}", fileList); |
122 |
| - |
123 |
| - QuarkusBuild quarkusBuild = project.getTasks().named(QuarkusPlugin.QUARKUS_BUILD_TASK_NAME, QuarkusBuild.class) |
124 |
| - .get(); |
125 |
| - String nativeRunner = quarkusBuild.getNativeRunner().toPath().toAbsolutePath().toString(); |
126 |
| - props.put("native.image.path", nativeRunner); |
127 |
| - } catch (Exception e) { |
128 |
| - throw new IllegalStateException("Failed to resolve deployment classpath", e); |
129 |
| - } |
130 |
| - } |
131 |
| - |
132 | 73 | public Property<String> getFinalName() {
|
133 | 74 | return finalName;
|
134 | 75 | }
|
|
0 commit comments