Skip to content

Commit 2c1a15f

Browse files
committed
protect task for plugins with no source
1 parent 445d3bf commit 2c1a15f

File tree

4 files changed

+35
-10
lines changed

4 files changed

+35
-10
lines changed

build-tools/src/main/java/org/elasticsearch/gradle/plugin/GenerateTestBuildInfoTask.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,18 @@ public ModuleVisitor visitModule(String name, int access, String version) {
184184
writer.write("\",\n");
185185

186186
writer.write(" \"locations\": [\n");
187-
StringBuilder sb = new StringBuilder();
188-
for (Map.Entry<String, String> entry : classesToModules.entrySet()) {
189-
sb.append(" {\n");
190-
sb.append(" \"class\": \"");
191-
sb.append(entry.getKey());
192-
sb.append("\",\n \"module\": \"");
193-
sb.append(entry.getValue());
194-
sb.append("\"\n },\n");
187+
if (classesToModules.isEmpty() == false) {
188+
StringBuilder sb = new StringBuilder();
189+
for (Map.Entry<String, String> entry : classesToModules.entrySet()) {
190+
sb.append(" {\n");
191+
sb.append(" \"class\": \"");
192+
sb.append(entry.getKey());
193+
sb.append("\",\n \"module\": \"");
194+
sb.append(entry.getValue());
195+
sb.append("\"\n },\n");
196+
}
197+
writer.write(sb.substring(0, sb.length() - 2));
195198
}
196-
writer.write(sb.substring(0, sb.length() - 2));
197199
writer.write("\n ]\n}\n");
198200
}
199201
}

build-tools/src/main/java/org/elasticsearch/gradle/plugin/PluginBuildPlugin.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,4 @@ public void apply(final Project project) {
8282
task.into("META-INF", copy -> copy.from(testBuildInfoTask));
8383
});
8484
}
85-
8685
}
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.test;
11+
12+
import org.gradle.api.Plugin;
13+
import org.gradle.api.Project;
14+
15+
public class TestBuildInfoPlugin implements Plugin<Project> {
16+
17+
@Override
18+
public void apply(Project project) {
19+
20+
}
21+
}

server/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ apply plugin: 'elasticsearch.build'
1111
apply plugin: 'elasticsearch.publish'
1212
apply plugin: 'elasticsearch.internal-cluster-test'
1313
apply plugin: 'elasticsearch.internal-test-artifact'
14+
// TODO: apply new plugin
1415

1516
publishing {
1617
publications {
@@ -284,3 +285,5 @@ tasks.named("licenseHeaders").configure {
284285
}
285286

286287
tasks.withType(Checkstyle.class).configureEach { t -> t.getMaxHeapSize().set("2g") }
288+
289+
// TODO: add tasks.named for new task and set server as component

0 commit comments

Comments
 (0)