Skip to content

Commit 95a4788

Browse files
authored
[Gradle] Make CopyCheckStyleConfTask usage cc compatible in serverless (#119249) (#119493)
This ensures we can use gradle configuration cache with elasticsearch serverless build (cherry picked from commit 1d5706e) # Conflicts: # build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/CheckstylePrecommitPlugin.java
1 parent 3c025d7 commit 95a4788

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionArchiveSetupPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ private void registerEmptyDirectoryTasks(Project project) {
132132
});
133133

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

141141
File jvmOptionsDir = new File(project.getBuildDir(), "jvm-options-hack/jvm.options.d");
142-
project.getExtensions().add("jvmOptionsDir", jvmOptionsDir);
142+
project.getExtensions().getExtraProperties().set("jvmOptionsDir", jvmOptionsDir);
143143
project.getTasks().register("createJvmOptionsDir", EmptyDirTask.class, t -> {
144144
t.setDir(jvmOptionsDir);
145145
t.setDirMode(0750);

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/CheckstylePrecommitPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public TaskProvider<? extends Task> createTask(Project project) {
4141
File checkstyleDir = new File(project.getBuildDir(), "checkstyle");
4242
File checkstyleSuppressions = new File(checkstyleDir, "checkstyle_suppressions.xml");
4343
File checkstyleConf = new File(checkstyleDir, "checkstyle.xml");
44-
TaskProvider<Task> copyCheckstyleConf = project.getTasks().register("copyCheckstyleConf");
45-
44+
TaskProvider<CopyCheckStyleConfTask> copyCheckstyleConf = project.getTasks()
45+
.register("copyCheckstyleConf", CopyCheckStyleConfTask.class);
4646
// configure inputs and outputs so up to date works properly
4747
copyCheckstyleConf.configure(t -> t.getOutputs().files(checkstyleSuppressions, checkstyleConf));
4848
if ("jar".equals(checkstyleConfUrl.getProtocol())) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.gradle.internal.precommit;
11+
12+
import org.gradle.api.DefaultTask;
13+
import org.gradle.api.file.FileSystemOperations;
14+
15+
import javax.inject.Inject;
16+
17+
public abstract class CopyCheckStyleConfTask extends DefaultTask {
18+
19+
@Inject
20+
public abstract FileSystemOperations getFs();
21+
}

0 commit comments

Comments
 (0)