Skip to content

Commit a8cef2d

Browse files
authored
[Build] Fix checkstyle exclusions on windows (#115185) (#115259)
1 parent 8276986 commit a8cef2d

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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.util;
11+
12+
import java.util.stream.Collectors;
13+
14+
public class PlatformUtils {
15+
16+
public static String normalize(String input) {
17+
return input.lines()
18+
.map(it -> it.replace('\\', '/'))
19+
.map(it -> it.replaceAll("\\d+\\.\\d\\ds", "0.00s"))
20+
.map(it -> it.replace("file:/./", "file:./"))
21+
.collect(Collectors.joining("\n"));
22+
}
23+
}

x-pack/plugin/esql/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import org.elasticsearch.gradle.internal.info.BuildParams
22
import org.elasticsearch.gradle.internal.precommit.CheckForbiddenApisTask;
33
import org.elasticsearch.gradle.internal.util.SourceDirectoryCommandLineArgumentProvider;
4+
import static org.elasticsearch.gradle.util.PlatformUtils.normalize
45

56
apply plugin: 'elasticsearch.internal-es-plugin'
67
apply plugin: 'elasticsearch.internal-cluster-test'
@@ -56,7 +57,7 @@ def generatedSourceDir = projectDirectory.dir("src/main/generated")
5657
tasks.named("compileJava").configure {
5758
options.compilerArgumentProviders.add(new SourceDirectoryCommandLineArgumentProvider(generatedSourceDir))
5859
// IntelliJ sticks generated files here and we can't stop it....
59-
exclude { it.file.toString().contains("src/main/generated-src/generated") }
60+
exclude { normalize(it.file.toString()).contains("src/main/generated-src/generated") }
6061
}
6162

6263
interface Injected {
@@ -262,8 +263,8 @@ tasks.register("regen") {
262263
tasks.named("spotlessJava") { dependsOn stringTemplates }
263264
tasks.named('checkstyleMain').configure {
264265
excludes = [ "**/*.java.st" ]
265-
exclude { it.file.toString().contains("src/main/generated-src/generated") }
266-
exclude { it.file.toString().contains("src/main/generated") }
266+
exclude { normalize(it.file.toString()).contains("src/main/generated-src/generated") }
267+
exclude { normalize(it.file.toString()).contains("src/main/generated") }
267268
}
268269

269270
def prop(Type, type, TYPE, BYTES, Array) {

x-pack/plugin/kql/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.elasticsearch.gradle.internal.info.BuildParams
2+
import static org.elasticsearch.gradle.util.PlatformUtils.normalize
23

34
apply plugin: 'elasticsearch.internal-es-plugin'
45
apply plugin: 'elasticsearch.internal-cluster-test'
@@ -54,7 +55,7 @@ pluginManager.withPlugin('com.diffplug.spotless') {
5455
}
5556
}
5657
tasks.named('checkstyleMain').configure {
57-
exclude { it.file.toString().contains("src/main/java/org/elasticsearch/xpack/kql/parser/KqlBase") }
58+
exclude { normalize(it.file.toString()).contains("src/main/java/org/elasticsearch/xpack/kql/parser/KqlBase") }
5859
}
5960

6061
tasks.register("cleanGenerated", Delete) {

0 commit comments

Comments
 (0)