Skip to content

Commit

Permalink
Merge branch '3.3.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Jan 17, 2025
2 parents de11362 + 262ad9f commit fd693c9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2024 the original author or authors.
* Copyright 2022-2025 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.
Expand Down Expand Up @@ -60,6 +60,7 @@
import org.springframework.aot.gradle.tasks.StartJvmApplication;
import org.springframework.aot.gradle.tasks.StartNativeApplication;
import org.springframework.aot.gradle.tasks.StopApplication;
import org.springframework.aot.gradle.tasks.WarmCaches;
import org.springframework.boot.gradle.plugin.SpringBootAotPlugin;
import org.springframework.boot.gradle.plugin.SpringBootPlugin;
import org.springframework.boot.gradle.tasks.bundling.BootJar;
Expand Down Expand Up @@ -156,6 +157,20 @@ private void configureBootJavaProject(Project project) {
DependencyHandler dependencies = project.getRootProject().getDependencies();
dependencies.add(smokeTests.getName(),
dependencies.project(Map.of("path", project.getPath(), "configuration", smokeTests.getName())));
project.getTasks().register("warmCaches", WarmCaches.class, (warmCaches) -> {
sourceSets
.matching((sourceSet) -> List
.of(SourceSet.MAIN_SOURCE_SET_NAME, SourceSet.TEST_SOURCE_SET_NAME, APP_TEST_SOURCE_SET_NAME)
.contains(sourceSet.getName()))
.all((sourceSet) -> {
warmCaches.addDependencies(
project.getConfigurations().getByName(sourceSet.getAnnotationProcessorConfigurationName()));
warmCaches.addDependencies(
project.getConfigurations().getByName(sourceSet.getCompileClasspathConfigurationName()));
warmCaches.addDependencies(
project.getConfigurations().getByName(sourceSet.getRuntimeClasspathConfigurationName()));
});
});
}

private void enableJavaCompileLinting(Project project, SourceSetContainer sourceSets) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2022-2025 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.aot.gradle.tasks;

import org.gradle.api.DefaultTask;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.FileCollection;
import org.gradle.api.tasks.Classpath;
import org.gradle.api.tasks.TaskAction;

/**
* Task to warm Gradle's caches by downloading the configured dependencies.
*
* @author Andy Wilkinson
*/
public class WarmCaches extends DefaultTask {

private final ConfigurableFileCollection dependencies;

public WarmCaches() {
this.dependencies = getProject().getObjects().fileCollection();
}

public void addDependencies(FileCollection dependencies) {
this.dependencies.from(dependencies);
}

@TaskAction
void execute() {
this.dependencies.getFiles();
}

@Classpath
FileCollection getDependencies() {
return this.dependencies;
}

}

0 comments on commit fd693c9

Please sign in to comment.