Skip to content

Commit 422319d

Browse files
committed
Merge remote-tracking branch 'origin/feature-oidc-realm' into oidc-realm-authentication-flows
2 parents b70526a + cc2549b commit 422319d

File tree

405 files changed

+6071
-7403
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

405 files changed

+6071
-7403
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ indent_style = space
88
indent_size = 4
99
trim_trailing_whitespace = true
1010
insert_final_newline = true
11+
12+
[*.bat]
13+
indent_size = 2

buildSrc/build.gradle

-5
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,6 @@ if (project != rootProject) {
235235
exclude '**/ForbiddenPatternsTask.java'
236236
}
237237

238-
namingConventions {
239-
testClass = 'org.elasticsearch.gradle.test.GradleUnitTestCase'
240-
integTestClass = 'org.elasticsearch.gradle.test.GradleIntegrationTestCase'
241-
}
242-
243238
testingConventions {
244239
naming.clear()
245240
naming {

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

+1
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ class BuildPlugin implements Plugin<Project> {
904904
project.tasks.withType(RandomizedTestingTask) {task ->
905905
jvm "${project.runtimeJavaHome}/bin/java"
906906
parallelism System.getProperty('tests.jvms', project.rootProject.ext.defaultParallel)
907+
ifNoTests 'fail'
907908
onNonEmptyWorkDirectory 'wipe'
908909
leaveTemporary true
909910
project.sourceSets.matching { it.name == "test" }.all { test ->

buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy

-5
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ public class PluginBuildPlugin extends BuildPlugin {
7272
if (isModule == false || isXPackModule) {
7373
addNoticeGeneration(project)
7474
}
75-
76-
project.namingConventions {
77-
// Plugins declare integration tests as "Tests" instead of IT.
78-
skipIntegTestInDisguise = true
79-
}
8075
}
8176
project.testingConventions {
8277
naming.clear()

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy

-10
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class PrecommitTasks {
4343
List<Task> precommitTasks = [
4444
configureCheckstyle(project),
4545
configureForbiddenApisCli(project),
46-
configureNamingConventions(project),
4746
project.tasks.create('forbiddenPatterns', ForbiddenPatternsTask.class),
4847
project.tasks.create('licenseHeaders', LicenseHeadersTask.class),
4948
project.tasks.create('filepermissions', FilePermissionsTask.class),
@@ -230,15 +229,6 @@ class PrecommitTasks {
230229
return checkstyleTask
231230
}
232231

233-
private static Task configureNamingConventions(Project project) {
234-
if (project.sourceSets.findByName("test")) {
235-
Task namingConventionsTask = project.tasks.create('namingConventions', NamingConventionsTask)
236-
namingConventionsTask.javaHome = project.compilerJavaHome
237-
return namingConventionsTask
238-
}
239-
return null
240-
}
241-
242232
private static Task configureLoggerUsage(Project project) {
243233
project.configurations.create('loggerUsagePlugin')
244234
project.dependencies.add('loggerUsagePlugin',

buildSrc/src/main/java/org/elasticsearch/gradle/precommit/NamingConventionsTask.java

-167
This file was deleted.

buildSrc/src/main/java/org/elasticsearch/gradle/precommit/TestingConventionsTasks.java

+42-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import org.gradle.api.file.FileTree;
2828
import org.gradle.api.tasks.Input;
2929
import org.gradle.api.tasks.OutputFile;
30+
import org.gradle.api.tasks.SourceSet;
31+
import org.gradle.api.tasks.SourceSetContainer;
3032
import org.gradle.api.tasks.TaskAction;
3133
import org.gradle.api.tasks.testing.Test;
3234
import org.gradle.api.tasks.util.PatternFilterable;
@@ -122,6 +124,23 @@ public void naming(Closure<TestingConventionRule> action) {
122124
naming.configure(action);
123125
}
124126

127+
@Input
128+
public Set<String> getMainClassNamedLikeTests() {
129+
SourceSetContainer javaSourceSets = Boilerplate.getJavaSourceSets(getProject());
130+
if (javaSourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME) == null) {
131+
// some test projects don't have a main source set
132+
return Collections.emptySet();
133+
}
134+
return javaSourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)
135+
.getOutput().getClassesDirs().getAsFileTree()
136+
.getFiles().stream()
137+
.filter(file -> file.getName().endsWith(".class"))
138+
.map(File::getName)
139+
.map(name -> name.substring(0, name.length() - 6))
140+
.filter(this::implementsNamingConvention)
141+
.collect(Collectors.toSet());
142+
}
143+
125144
@TaskAction
126145
public void doCheck() throws IOException {
127146
final String problems;
@@ -235,10 +254,12 @@ public void doCheck() throws IOException {
235254
);
236255
}).sorted()
237256
.collect(Collectors.joining("\n"))
238-
)
257+
),
239258
// TODO: check that the testing tasks are included in the right task based on the name ( from the rule )
240-
// TODO: check to make sure that the main source set doesn't have classes that match
241-
// the naming convention (just the names, don't load classes)
259+
checkNoneExists(
260+
"Classes matching the test naming convention should be in test not main",
261+
getMainClassNamedLikeTests()
262+
)
242263
);
243264
}
244265

@@ -296,6 +317,18 @@ private String checkNoneExists(String message, Stream<? extends Class<?>> stream
296317
}
297318
}
298319

320+
private String checkNoneExists(String message, Set<? extends String> candidates) {
321+
String problem = candidates.stream()
322+
.map(each -> " * " + each)
323+
.sorted()
324+
.collect(Collectors.joining("\n"));
325+
if (problem.isEmpty() == false) {
326+
return message + ":\n" + problem;
327+
} else {
328+
return "";
329+
}
330+
}
331+
299332
private String checkAtLeastOneExists(String message, Stream<? extends Class<?>> stream) {
300333
if (stream.findAny().isPresent()) {
301334
return "";
@@ -337,10 +370,14 @@ private boolean seemsLikeATest(Class<?> clazz) {
337370
}
338371

339372
private boolean implementsNamingConvention(Class<?> clazz) {
373+
return implementsNamingConvention(clazz.getName());
374+
}
375+
376+
private boolean implementsNamingConvention(String className) {
340377
if (naming.stream()
341378
.map(TestingConventionRule::getSuffix)
342-
.anyMatch(suffix -> clazz.getName().endsWith(suffix))) {
343-
getLogger().debug("{} is a test because it matches the naming convention", clazz.getName());
379+
.anyMatch(suffix -> className.endsWith(suffix))) {
380+
getLogger().debug("{} is a test because it matches the naming convention", className);
344381
return true;
345382
}
346383
return false;

buildSrc/src/main/java/org/elasticsearch/gradle/precommit/ThirdPartyAuditTask.java

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import org.gradle.api.tasks.InputFiles;
3434
import org.gradle.api.tasks.Optional;
3535
import org.gradle.api.tasks.OutputDirectory;
36+
import org.gradle.api.tasks.PathSensitive;
37+
import org.gradle.api.tasks.PathSensitivity;
3638
import org.gradle.api.tasks.SkipWhenEmpty;
3739
import org.gradle.api.tasks.TaskAction;
3840
import org.gradle.process.ExecResult;
@@ -86,11 +88,13 @@ public void setTargetCompatibility(JavaVersion targetCompatibility) {
8688
}
8789

8890
@InputFiles
91+
@PathSensitive(PathSensitivity.NAME_ONLY)
8992
public Configuration getForbiddenAPIsConfiguration() {
9093
return getProject().getConfigurations().getByName("forbiddenApisCliJar");
9194
}
9295

9396
@InputFile
97+
@PathSensitive(PathSensitivity.NONE)
9498
public File getSignatureFile() {
9599
return signatureFile;
96100
}
@@ -154,6 +158,7 @@ public Set<String> getMissingClassExcludes() {
154158
}
155159

156160
@InputFiles
161+
@PathSensitive(PathSensitivity.NAME_ONLY)
157162
@SkipWhenEmpty
158163
public Set<File> getJarsToScan() {
159164
// These are SelfResolvingDependency, and some of them backed by file collections, like the Gradle API files,

0 commit comments

Comments
 (0)