Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Commit 23b78bc

Browse files
hdeadmanbclozel
authored andcommitted
Prepend aot jar to classpath for bootJar and bootRun
1 parent b19e11e commit 23b78bc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

spring-aot-gradle-plugin/src/main/java/org/springframework/aot/gradle/SpringAotGradlePlugin.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,14 @@ public void apply(final Project project) {
134134
// Generated+compiled sources must be used by 'bootRun' and packaged by 'bootJar'
135135
project.getPlugins().withType(SpringBootPlugin.class, springBootPlugin -> {
136136
Provider<RegularFile> generatedSources = generatedSourcesJar.getArchiveFile();
137-
project.getTasks().named(SpringBootPlugin.BOOT_JAR_TASK_NAME, BootJar.class, (bootJar) ->
138-
bootJar.classpath(generatedSources));
139-
project.getTasks().named("bootRun", BootRun.class, (bootRun) ->
140-
bootRun.classpath(generatedSources));
137+
project.getTasks().named(SpringBootPlugin.BOOT_JAR_TASK_NAME, BootJar.class, (bootJar) -> {
138+
FileCollection existingClasspath = bootJar.getClasspath();
139+
bootJar.setClasspath(bootJar.getProject().files(generatedSources, new Object[]{existingClasspath != null ? existingClasspath : Collections.emptyList()}));
140+
});
141+
project.getTasks().named("bootRun", BootRun.class, (bootRun) -> {
142+
FileCollection existingClasspath = bootRun.getClasspath();
143+
bootRun.setClasspath(bootRun.getProject().files(generatedSources, new Object[]{existingClasspath != null ? existingClasspath : Collections.emptyList()}));
144+
});
141145
});
142146

143147
// Create a detached configuration that holds dependencies for AOT test generation

0 commit comments

Comments
 (0)