use of org.gradle.api.tasks.wrapper.Wrapper in project curiostack by curioswitch.
the class CuriostackRootPlugin method apply.
@Override
public void apply(Project rootProject) {
rootProject.getGradle().getTaskGraph().whenReady(tasks -> {
if (!rootProject.getGradle().getGradleVersion().equals(ToolDependencies.getGradleVersion(rootProject)) && !tasks.hasTask(":wrapper")) {
throw new IllegalStateException("Gradle wrapper out-of-date, run ./gradlew :wrapper");
}
});
PluginContainer plugins = rootProject.getPlugins();
// Provides useful tasks like 'clean', 'assemble' to the root project.
plugins.apply(BasePlugin.class);
plugins.apply(AwsSetupPlugin.class);
plugins.apply(CondaBuildEnvPlugin.class);
plugins.apply(CurioGenericCiPlugin.class);
plugins.apply(GcloudPlugin.class);
plugins.apply(IdeaPlugin.class);
plugins.apply(NodePlugin.class);
plugins.apply(ReleasePlugin.class);
plugins.apply(TerraformSetupPlugin.class);
plugins.apply(ToolDownloaderPlugin.class);
var updateGradleWrapper = rootProject.getTasks().register("curioUpdateWrapper", UpdateGradleWrapperTask.class);
rootProject.getTasks().withType(Wrapper.class).configureEach(wrapper -> {
wrapper.setGradleVersion(ToolDependencies.getGradleVersion(rootProject));
wrapper.setDistributionType(DistributionType.ALL);
wrapper.finalizedBy(updateGradleWrapper);
});
rootProject.getTasks().register("setupGitHooks", SetupGitHooks.class);
var updateShellConfig = rootProject.getTasks().register("updateShellConfig", CreateShellConfigTask.class);
DownloadToolUtil.getDownloadTask(rootProject, "miniconda-build").configure(t -> t.finalizedBy(updateShellConfig));
rootProject.getTasks().named("condaInstallPackagesMinicondaBuild", t -> t.mustRunAfter(updateShellConfig));
var updateIntelliJJdks = rootProject.getTasks().register(UpdateIntelliJSdksTask.NAME, UpdateIntelliJSdksTask.class, t -> t.dependsOn(updateGradleWrapper));
var idea = rootProject.getTasks().named("idea");
idea.configure(task -> task.dependsOn(updateIntelliJJdks));
rootProject.getTasks().register("setup", t -> {
t.dependsOn(idea);
t.dependsOn(rootProject.getTasks().named("toolsSetupAll"));
t.dependsOn(updateShellConfig);
});
var updateProjectSettings = rootProject.getTasks().register("updateProjectSettings", UpdateProjectSettingsTask.class);
rootProject.getTasks().register("generateApiServer", GenerateApiServerTask.class, t -> t.finalizedBy(updateProjectSettings));
rootProject.afterEvaluate((p) -> rootProject.getPlugins().withType(IdeaPlugin.class, plugin -> {
var ipr = plugin.getModel().getProject().getIpr();
ipr.whenMerged(unused -> ipr.withXml(provider -> setupProjectXml(rootProject, provider)));
var iws = plugin.getModel().getWorkspace().getIws();
iws.whenMerged(unused -> iws.withXml(provider -> setupWorkspaceXml(rootProject, provider)));
}));
rootProject.allprojects(project -> {
project.getPlugins().withType(JavaPlugin.class, plugin -> setupJavaProject(project, ERROR_PRONE_CHECKS));
project.getPlugins().withType(VersionsPlugin.class, unused -> {
project.getTasks().named("dependencyUpdates", DependencyUpdatesTask.class, task -> {
task.setRevision("release");
task.setCheckConstraints(true);
task.rejectVersionIf(filter -> {
String version = filter.getCandidate().getVersion();
String uppercaseVersion = version.toUpperCase(Locale.ROOT);
if (uppercaseVersion.contains("RELEASE") || uppercaseVersion.contains("FINAL") || uppercaseVersion.contains("GA")) {
return false;
}
if (IS_STABLE_VERSION.matcher(version).matches()) {
return false;
}
if (version.endsWith("-jre")) {
// Guava
return false;
}
return true;
});
});
});
project.getPlugins().withType(GolangPlugin.class, unused -> {
project.getExtensions().getByType(GolangExtension.class).jib(jib -> jib.getCredentialHelper().set(DownloadedToolManager.get(project).getBinDir("gcloud").resolve("docker-credential-gcr")));
project.getTasks().withType(JibTask.class).configureEach(t -> t.dependsOn(project.getRootProject().getTasks().getByName("gcloudSetup")));
});
});
setupDataSources(rootProject);
rootProject.getPlugins().withType(GolangSetupPlugin.class, unused -> rootProject.getPlugins().withType(ToolDownloaderPlugin.class, plugin -> plugin.tools().named("go").configure(tool -> tool.getVersion().set(ToolDependencies.getGolangVersion(rootProject)))));
rootProject.getPlugins().withType(CondaPlugin.class, plugin -> plugin.getCondas().withType(CondaExtension.class).named("miniconda-build").configure(conda -> conda.getVersion().set(ToolDependencies.getMinicondaVersion(rootProject))));
setupSpotless(rootProject);
}
Aggregations