Skip to content

Commit

Permalink
[Gradle] Make CopyCheckStyleConfTask usage cc compatible in serverless (
Browse files Browse the repository at this point in the history
elastic#119249)

This ensures we can use gradle configuration cache with elasticsearch serverless build
  • Loading branch information
breskeby authored Jan 2, 2025
1 parent 03fd89a commit 1d5706e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ private void registerEmptyDirectoryTasks(Project project) {
});

File pluginsDir = new File(project.getBuildDir(), "plugins-hack/plugins");
project.getExtensions().add("pluginsDir", pluginsDir);
project.getExtensions().getExtraProperties().set("pluginsDir", pluginsDir);
project.getTasks().register("createPluginsDir", EmptyDirTask.class, t -> {
t.setDir(pluginsDir);
t.setDirMode(0755);
});

File jvmOptionsDir = new File(project.getBuildDir(), "jvm-options-hack/jvm.options.d");
project.getExtensions().add("jvmOptionsDir", jvmOptionsDir);
project.getExtensions().getExtraProperties().set("jvmOptionsDir", jvmOptionsDir);
project.getTasks().register("createJvmOptionsDir", EmptyDirTask.class, t -> {
t.setDir(jvmOptionsDir);
t.setDirMode(0750);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public TaskProvider<? extends Task> createTask(Project project) {
File checkstyleDir = new File(project.getBuildDir(), "checkstyle");
File checkstyleSuppressions = new File(checkstyleDir, "checkstyle_suppressions.xml");
File checkstyleConf = new File(checkstyleDir, "checkstyle.xml");
TaskProvider<Task> copyCheckstyleConf = project.getTasks().register("copyCheckstyleConf");
TaskProvider<CopyCheckStyleConfTask> copyCheckstyleConf = project.getTasks()
.register("copyCheckstyleConf", CopyCheckStyleConfTask.class);
// configure inputs and outputs so up to date works properly
copyCheckstyleConf.configure(t -> t.getOutputs().files(checkstyleSuppressions, checkstyleConf));
if ("jar".equals(checkstyleConfUrl.getProtocol())) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

package org.elasticsearch.gradle.internal.precommit;

import org.gradle.api.DefaultTask;
import org.gradle.api.file.FileSystemOperations;

import javax.inject.Inject;

public abstract class CopyCheckStyleConfTask extends DefaultTask {

@Inject
public abstract FileSystemOperations getFs();
}

0 comments on commit 1d5706e

Please sign in to comment.