1010package org .elasticsearch .gradle .internal .transport ;
1111
1212import org .gradle .api .file .DirectoryProperty ;
13- import org .gradle .api .provider .Property ;
1413import org .gradle .api .services .BuildService ;
1514import org .gradle .api .services .BuildServiceParameters ;
1615import org .gradle .process .ExecOperations ;
5251public 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 -> {
0 commit comments