Skip to content

Commit e5f5101

Browse files
committed
fix
1 parent 1d151ea commit e5f5101

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ public void apply(Project project) {
3131
project.getGradle()
3232
.getSharedServices()
3333
.registerIfAbsent("transportVersionResources", TransportVersionResourcesService.class, spec -> {
34-
Directory transportResources = project.getLayout().getProjectDirectory().dir("src/main/resources/transport");
35-
spec.getParameters().getResourcesDirectory().set(transportResources);
34+
Directory transportResources = project.getLayout().getProjectDirectory().dir("src/main/resources/" + resourceRoot);
35+
spec.getParameters().getTransportResourcesDirectory().set(transportResources);
3636
spec.getParameters().getRootDirectory().set(project.getRootProject().getRootDir());
37-
spec.getParameters().getResourceRoot().set(resourceRoot);
3837
});
3938

4039
DependencyHandler depsHandler = project.getDependencies();

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
package org.elasticsearch.gradle.internal.transport;
1111

1212
import org.gradle.api.file.DirectoryProperty;
13-
import org.gradle.api.provider.Property;
1413
import org.gradle.api.services.BuildService;
1514
import org.gradle.api.services.BuildServiceParameters;
1615
import org.gradle.process.ExecOperations;
@@ -52,11 +51,9 @@
5251
public abstract class TransportVersionResourcesService implements BuildService<TransportVersionResourcesService.Parameters> {
5352

5453
public interface Parameters extends BuildServiceParameters {
55-
DirectoryProperty getResourcesDirectory();
54+
DirectoryProperty getTransportResourcesDirectory();
5655

5756
DirectoryProperty getRootDirectory();
58-
59-
Property<String> getResourceRoot();
6057
}
6158

6259
@Inject
@@ -67,31 +64,31 @@ public interface Parameters extends BuildServiceParameters {
6764
private static final Path UNREFERENCED_DIR = DEFINITIONS_DIR.resolve("unreferenced");
6865
private static final Path LATEST_DIR = Path.of("latest");
6966

70-
private final Path resourcesDir;
67+
private final Path transportResourcesDir;
7168
private final Path rootDir;
7269
private final AtomicReference<Set<String>> mainResources = new AtomicReference<>(null);
7370
private final AtomicReference<Set<String>> changedResources = new AtomicReference<>(null);
7471

7572
@Inject
7673
public TransportVersionResourcesService(Parameters params) {
77-
this.resourcesDir = params.getResourcesDirectory().get().getAsFile().toPath();
74+
this.transportResourcesDir = params.getTransportResourcesDirectory().get().getAsFile().toPath();
7875
this.rootDir = params.getRootDirectory().get().getAsFile().toPath();
7976
}
8077

8178
/**
8279
* Return the directory for this repository which contains transport version resources.
8380
* This should be an input to any tasks reading resources from this service.
8481
*/
85-
Path getResourcesDir() {
86-
return resourcesDir;
82+
Path getTransportResourcesDir() {
83+
return transportResourcesDir;
8784
}
8885

8986
/**
9087
* Return the transport version definitions directory for this repository.
9188
* This should be an input to any tasks that only read definitions from this service.
9289
*/
9390
Path getDefinitionsDir() {
94-
return resourcesDir.resolve(DEFINITIONS_DIR);
91+
return transportResourcesDir.resolve(DEFINITIONS_DIR);
9592
}
9693

9794
// return the path, relative to the resources dir, of a named definition
@@ -104,7 +101,7 @@ Map<String, TransportVersionDefinition> getNamedDefinitions() throws IOException
104101
Map<String, TransportVersionDefinition> definitions = new HashMap<>();
105102
// temporarily include unreferenced in named until validation understands the distinction
106103
for (var dir : List.of(NAMED_DIR, UNREFERENCED_DIR)) {
107-
try (var definitionsStream = Files.list(resourcesDir.resolve(dir))) {
104+
try (var definitionsStream = Files.list(transportResourcesDir.resolve(dir))) {
108105
for (var definitionFile : definitionsStream.toList()) {
109106
String contents = Files.readString(definitionFile, StandardCharsets.UTF_8).strip();
110107
var definition = TransportVersionDefinition.fromString(definitionFile.getFileName().toString(), contents);
@@ -123,18 +120,18 @@ TransportVersionDefinition getNamedDefinitionFromMain(String name) {
123120

124121
/** Test whether the given named definition exists */
125122
boolean namedDefinitionExists(String name) {
126-
return Files.exists(resourcesDir.resolve(getNamedDefinitionRelativePath(name)));
123+
return Files.exists(transportResourcesDir.resolve(getNamedDefinitionRelativePath(name)));
127124
}
128125

129126
/** Return the path within the repository of the given named definition */
130127
Path getRepositoryPath(TransportVersionDefinition definition) {
131-
return rootDir.relativize(resourcesDir.resolve(getNamedDefinitionRelativePath(definition.name())));
128+
return rootDir.relativize(transportResourcesDir.resolve(getNamedDefinitionRelativePath(definition.name())));
132129
}
133130

134131
/** Read all latest files and return them mapped by their release branch */
135132
Map<String, TransportVersionLatest> getLatestByReleaseBranch() throws IOException {
136133
Map<String, TransportVersionLatest> latests = new HashMap<>();
137-
try (var stream = Files.list(resourcesDir.resolve(LATEST_DIR))) {
134+
try (var stream = Files.list(transportResourcesDir.resolve(LATEST_DIR))) {
138135
for (var latestFile : stream.toList()) {
139136
String contents = Files.readString(latestFile, StandardCharsets.UTF_8).strip();
140137
var latest = TransportVersionLatest.fromString(latestFile.getFileName().toString(), contents);
@@ -152,7 +149,7 @@ TransportVersionLatest getLatestFromMain(String releaseBranch) {
152149

153150
/** Return the path within the repository of the given latest */
154151
Path getRepositoryPath(TransportVersionLatest latest) {
155-
return rootDir.relativize(resourcesDir.resolve(getLatestRelativePath(latest.branch())));
152+
return rootDir.relativize(transportResourcesDir.resolve(getLatestRelativePath(latest.branch())));
156153
}
157154

158155
private Path getLatestRelativePath(String releaseBranch) {
@@ -201,7 +198,7 @@ private String gitCommand(String... args) {
201198
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
202199

203200
List<String> command = new ArrayList<>();
204-
Collections.addAll(command, "git", "-C", getResourcesDir().toString());
201+
Collections.addAll(command, "git", "-C", getTransportResourcesDir().toString());
205202
Collections.addAll(command, args);
206203

207204
ExecResult result = getExecOperations().exec(spec -> {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public abstract class ValidateTransportVersionResourcesTask extends DefaultTask
4444
@Optional
4545
@PathSensitive(PathSensitivity.RELATIVE)
4646
public Path getResourcesDir() {
47-
return getResources().get().getResourcesDir();
47+
return getResources().get().getTransportResourcesDir();
4848
}
4949

5050
@InputFiles

0 commit comments

Comments
 (0)