Commit graph

73 commits

Author SHA1 Message Date
Mark Vieira
a59c182f9f
Add AGPLv3 as a supported license 2024-09-13 15:29:46 -07:00
Rene Groeschke
8ac3e3dd90
Update Gradle wrapper to 8.8 (#108021)
Fix incompatibility with 8.8 and our internal api usages

- Update ospackage to a version that contains a fix we provided
- Tweak build logic to avoid deprecation warnings
- Use newer permission api
- Use custom shadowplugin
- Rework ElasticsearchDistribution dependencies resolution
- Update Gradle wrapper to 8.8
2024-06-04 12:43:02 +02:00
Slobodan Adamović
b643abab3b
Harden usage of XML document builder in build-conventions (#106874)
While `LicenseHeadersTask` only uses `DocumentBuilderFactory` internally
to parse `rat.xml` files (which are the output of running Apache RAT on
Elasticsearch codebase files), it is a good practice to disable XXE
features even if it's part of checks that are run on developers
machines.
2024-03-31 19:41:52 -04:00
Armin Braun
3f8bc36788
Fix Gradle File leaks (#105597)
Fixing a couple of file leaks (and cleaning up one missing
try-with-resources). The directory descriptor leaks in particular
were leaking massively on every precommit run, to the point where it
slows down the whole system and/or we're running into descriptor limits.
2024-02-18 17:56:22 +01:00
Dmitry Cherniachenko
e21a4874ab
Use String.replace() instead of replaceAll() for non-regexp replacements (#105127)
* Use String.replace() instead of replaceAll() for non-regexp replacements

When arguments do not make use of regexp features replace() is a more efficient option, especially the char-variant.
2024-02-12 13:11:15 -05:00
Mark Vieira
6c4e55e714
Fix file path when looking for docker exclusions file (#105304) 2024-02-08 12:27:09 -08:00
Rene Groeschke
209b655d0c
Avoid eager task realization (#103343)
* Avoid eager task realization in esql qa projects
* Fix eager task realization in PomValidationPrecommitPlugin
* Make loadCsvSpecData task lazy created
* Fix test task reference
2024-01-25 14:27:03 +01:00
Mark Vieira
a9546a07f2
Disable incremental compilation in CI environments (#103346) 2023-12-12 13:10:27 -08:00
Rene Groeschke
b8627079b4
Update Gradle Wrapper to 8.2 (#96686)
- Convention usage has been deprecated and was fixed in our build files
- Fix test dependencies and deprecation
2023-07-04 15:35:15 +02:00
Armin Braun
63e64ae61b
Cleanup Stream usage in various spots (#97306)
Lots of spots where we did weird things around streams like redundant stream creation, redundant collecting
before adding all the collected elements to another collection or so, redundant streams for joining strings
and using less efficient `Collectors.toList` and in a few cases also incorrectly relying on the result being mutable.
2023-07-03 14:24:57 +02:00
Rene Groeschke
a45370e6dd
Update spotless gradle plugin (#95999) 2023-05-11 12:06:03 +02:00
Rene Groeschke
4e2f852c08
Resolve runtime java via Gradle tool chain provider (#95319)
Using gradle toolchain support in gradle requires refactoring how the composite build is composed. 
We added three toolchain resolver
1. Resolver for resolving defined bundled version from oracle as openjdk
2. Resolve all available jdks from Adoption
3. Resolve archived Oracle jdk distributions. 

We should be able to remove the JdkDownloadPlugin altogether without having that in place, but we'll do that in a separate effort.

Fixes #95094
2023-05-03 15:28:47 +02:00
Rene Groeschke
2b210b5220
Fix paralle detector configuration cache compatibility (#95452) 2023-04-24 06:41:18 -04:00
Rene Groeschke
025b8ee66a
Revert "Make ParallelDetector Gradle configuration cache compliant (#95434)"
This reverts commit 4fc6dda21e.
2023-04-21 13:24:27 +02:00
Rene Groeschke
4fc6dda21e
Make ParallelDetector Gradle configuration cache compliant (#95434) 2023-04-21 13:14:23 +02:00
Rene Groeschke
e735455431
Provide hints to Gradle Task.onlyIf declarations (#94953)
* Update gradle enterprise plugin to show skip reasons in build scans
* Unify OS specific handling in build logic
2023-03-31 23:57:55 +02:00
Rene Groeschke
1efb95b857
Ensure all sourceSets are compiled as part of Gradle precommit (#91897) 2022-11-24 15:30:41 -05:00
Mark Vieira
7d6dc6c19b
Improve robustness of formatting plugin in composite builds (#91028) 2022-10-19 12:53:19 -07:00
Slobodan Adamović
bd58c74a49
Fix usage of IndexAccessControl in CustomAuthorizationEngine (#90559)
* Fix usage of `IndexAccessControl` in `CustomAuthorizationEngine`

* Make version properties loader more robust

Co-authored-by: Mark Vieira <portugee@gmail.com>
2022-09-30 18:18:38 +02:00
Mark Vieira
c495baee84
Make version properties plugin more robust in a composite build (#90535)
The current logic in `VersionPropertiesPlugin` for determining the
location of the "elasticsearch" project workspace doesn't account well
for scenarios where the elasticsearch project itself is an included
build in a larger composite. This change accounts for this by
traversing the build hierarchy.
2022-09-29 12:40:00 -07:00
Mark Vieira
12b841e048
Add support for Git submodules to GitInfo (#89741) 2022-09-06 09:21:25 -07:00
Rory Hunter
0df14382b9
Add Checkstyle rule for broken switch cases (#88739)
We use `between(x, y)` calls with `switch` statements in tests to
randomize test behaviour. However, some usages define `case` statements
that can never execute, because the `case` value is outside the range
defined by the `between` call.

Write a rule that inspects the switches and the cases, and fails on the
broken cases. This rule checks `between`, `randomIntBetween` and
`randomInt`.
2022-07-27 09:22:06 +01:00
Rory Hunter
a57e645613
Fix checkstyle version drift and API change (#88283)
Fix checkstyle version drift and API change.
2022-07-05 21:37:16 +01:00
Rene Groeschke
8ccae4da71
Setup elasticsearch dependency monitoring with Snyk for production code (#88036)
This adds the generation and upload logic of Gradle dependency graphs to snyk

We directly implemented a rest api based snyk plugin as:

the existing snyk gradle plugin delegates to the snyk command line tool the command line tool 
uses custom gradle logic by injecting a init file that is 

a) using deprecated build logic which we definitely want to avoid
b) uses gradle api we avoid like eager task creation.

Shipping this as a internal gradle plugin gives us the most flexibility as we only want to monitor 
production code for now we apply this plugin as part of the elasticsearch.build plugin, 
that usage has been for now the de-facto indicator if a project is considered a "production" project 
that ends up in our distribution or public maven repositories. This isnt yet ideal and we will revisit 
the distinction between production and non production code / projects in a separate effort.

As part of this effort we added the elasticsearch.build plugin to more projects that actually end up 
in the distribution. To unblock us on this we for now disabled a few check tasks that started failing by applying elasticsearch.build. 

Addresses  #87620
2022-06-29 13:29:14 +02:00
Juan Camilo Bages
abc174bdad
Add support for building elasticsearch source on macos before monterey (#87430)
Closes #87426
2022-06-06 14:09:57 -07:00
Rene Groeschke
da5750c460
Port build dependencies to gradle version catalogue (#86548)
We introduce the use of a Gradle version catalogue for handling build related dependencies.

This provides type safe accessors for dependencies and allow centralised version definitions.
Later we want to move all our dependency handling to version catalogues.
Since this is a Gradle feature we remove long term maintenance cost for custom version handling in
our build and make centralised version handling more straight forward and support better tooling
based on version catalogues

Fixes asm version alignment on the way using 9.3 everywhere in our build logic.
2022-05-10 12:15:36 +02:00
Rene Groeschke
8bbc7c2e0b
Port javadoc configuration logic into a binary plugin (#86471)
Also adding test coverage and fixing certain issues we stumbled into

when resolving project dependencies of compileClasspath we need to use allDependencies instead of dependencies as usually no dependencies are added directly to compileClasspath but via implementation, compileonly and api and friends
Fixed javadoc setup for projects using shadowed dependencies via shadow plugin
Fixed dealing with skipped javadoc tasks in referenced dependent projects.
In general this PR only fixes expected javadoc generation as it was intended before this PR.

This also contains some tweaks to our gradle integration test fixtures for setting up and debugging test projects
2022-05-10 09:58:43 +02:00
Rene Groeschke
2d85fa7c20
Update build convention dependencies (#85444)
- Update spotless to potentially fix invalid git worktree handling
- Update shadow plugin to be in sync with version used in build-tools
2022-03-30 11:08:34 +02:00
Mark Vieira
216c774451
Fall back to naive parallel forks calculation in non-standard cases (#85410)
Some architectures provide non-standard output in /proc/cpuinfo.
Specifically, AWS graviton. In case we can't properly calculate physical
cpu cores via the standard method just fallback to using the JDK-backed
implementation.
2022-03-28 14:42:15 -07:00
Mark Vieira
da8d8b17dd
Fix calculation of max parallel forks for test execution (#85360) 2022-03-28 10:33:14 -07:00
Rene Groeschke
751c8b5330
Fix spotless exclude for build benchmarking (#85204)
Use targetExclude for excluding file from spotless checks as formatter
warnings are not reported as Error in spotless and still can cause the
build to fail
2022-03-22 06:14:55 -04:00
Rene Groeschke
f2a117095b
Split build benchmark jobs for faster feedback (#84978)
Also handle gradle-profiler introduced spotless issue when running performance tests
2022-03-16 12:34:54 +01:00
Rene Groeschke
c4686128f0
Replace getProject() references with injected services in task implementations where possible (#81681)
- Rework task implementations to avoid project usage at execution time
- In general usages of getProject() within a task should be avoided as it is not compatible
with gradle configuration cache. Related to #57918
2022-02-23 12:56:21 +01:00
Rene Groeschke
a86f9c5f02
Remove usage of deprecated Provider#forUseAtConfigurationTime (#83932)
Remove gradle api usage that has been deprecated with Gradle 7.4
2022-02-15 08:06:22 -05:00
Rene Groeschke
ccc18d7f73
Update gradle wrapper to 7.4 (#81963)
* Make ForbiddenApisPrecommitPlugin plugin Gradle 8.0 compatible
* Fix deprecations on ignoring empty folders for task inputs
* Update Gradle wrapper to 7.4 GA
2022-02-14 09:48:54 +01:00
Rory Hunter
2282cf75d0
Upgrade Checkstyle to 9.3 (#83314)
Checkstyle 9.3 has been released, and contains a fix for the memory
problems we saw in previous versions. Upgrade to this version.

Note that the IDEA config has also been updated, but the plugin
doesn't yet have 9.3 as an option according to the release notes.
This shouldn't be a problem.
2022-02-07 10:34:43 +00:00
Rory Hunter
bb0da0e47a Revert "Refine Checkstyle for method Javadoc (#83224)"
This reverts commit 10dd638550.
2022-02-02 17:10:29 +00:00
Rory Hunter
10dd638550
Refine Checkstyle for method Javadoc (#83224)
The contribution guide's Javadoc section suggests writing Javadoc on
test methods. However the extra Checktyle rules for IDEs flag up missing
test method Javadoc at "warning", which is too severe. Since the
Checktyle rule is not very configurable, fork it and add more
configuration parameters, then add more targetted rules so that test
method Javadoc violations are only reported at "info" level.
2022-02-01 15:18:09 +00:00
Rene Groeschke
d84b875698
Update checkstyle to latest 8.x release (#82186)
- Updates checkstyle to 8.45.1

- This was update was triggered by us running into checkstyle/checkstyle#9897 We do not update to latest 9.x release yet as we see a performance decrease when running precommit with this. likely related to checkstyle/checkstyle#10934
2022-01-05 12:45:51 +01:00
Rory Hunter
5b49982309
Formatting escape hatch (#81806)
Thanks to https://bugs.eclipse.org/bugs/show_bug.cgi?id=574437,
we've run into a situation where Spotless is incorrectly formatting
a particular piece of syntax (due the underlying Eclipse bug). We
were able to turn off formatting of this syntax using `// @formatter:off`
and `// @formatter:on`, but there was a further problem. We configure
IntelliJ to use the Eclipse formatter plugin, but this doesn't
respect the `@formatter` tags since these are set at the Spotless
level, not the Eclipse formatter level. Note that these tags aren't
set in the Eclipse formatter config, because there we use `// tag::`
and `// end::` in order to avoid reformatting docs snippets, which
have a much narrower line width.

What a mess.

So, to get around all this, drop the `@formatter` tags and tweak
our custom `SnippetLengthCheck` Checkstyle rule so that
`// tag:noformat` regions are not subject to the narrower line length
check, but are still exempt from formatting.
2021-12-16 16:18:34 +00:00
Rory Hunter
3f01fade7c
Introduce StringFormattingCheck checkstyle rule (#81603)
The new rule Checks for calls to `String#formatted(Object...)` that
include format specifiers that are not locale-safe. This method always
uses the default `Locale`, and so for our purposes it is safer to use
`String#format(Locale, String, Object...)`.

Note that this rule can currently only detect violations when calling
`formatted()` on a string literal or text block. In theory, it could be
extended to detect violations in local variables or statics.

Note that this change also forbids `.formatted()` in server code, so
we are only permitted to use `.formatted()` in test code.
2021-12-16 10:32:18 +00:00
Mark Vieira
06d7e1682e
Bump source compatibility version to Java 17 (#80851) 2021-12-06 10:58:56 -08:00
Rory Hunter
a61159e730
Revert some EQL shadowed var changes and improve HiddenField rule (#81317)
Change our fork of `HiddenFieldCheck` rule to allow it to ignore
shadowed variables for methods shorter than a configured minimim line
count. While this technically defeats the point of the rule, in practice
short methods are easier to verify by eye, compared to longer methods
where accidentally referencing the wrong variable is harder to spot.

Following this, revert some changes in the EQL code which were required
to pass the `HiddenField` check before the `minLineCount` change.

Additionally, introduce a mechanism for ignoring shadowed variables when
used created a new object. This allowed us to ignore variables in usages
of e.g. `ConstructingObjectParser` whose purpose, as the name suggests,
is to build objects, and object shadows variables in the course of
building objects.
2021-12-03 19:30:53 +00:00
Rory Hunter
c1efe471fb
Checkstyle shadows vars pt8 (#81147)
Part of #19752. Fix more instances where local variable names were
shadowing field names. Also:    * Remove unused bits and pieces from
`XPackClientPlugin`.    * Expand the possible method names that are
skipped when       checking for shadowed vars, and allow shadowed vars
in       builder classes.
2021-12-02 04:57:29 -05:00
Rory Hunter
85b3435100
Fix shadowed vars pt7 (#80996)
Part of #19752. Fix more instances where local variable names were
shadowing field names.

Also modify our fork of HiddenFieldCheck to add the ignoreConstructorBody
and ignoredMethodNames parameters, so that the check can ignore
more matches.
2021-11-29 20:10:16 +00:00
Rory Hunter
add386dd00
Fix shadowed vars pt5 (#80855)
Part of #19752. Fix more instances where local variable names were shadowing field names.
2021-11-19 10:47:26 +00:00
Mark Vieira
025dbdc73e
Don't apply the spotless plugin to non-applicable projects (#80679)
This is an attempt at resolving, or at least reducing the prevalence of
#77837. A more robust solution is probably required, but this should
help reduce this problem since we now apply spotless to about 90 fewer
subprojects.
2021-11-11 18:17:10 -05:00
Mark Vieira
afbf2fe5c6
Update Gradle wrapper to 7.3 (#80633) 2021-11-10 13:49:52 -08:00
Mark Vieira
2cb182fbff
Upgrade spotless gradle plugin to 6.0.0 (#80560) 2021-11-10 11:48:01 -08:00
Rory Hunter
cb26146629
Fix HiddenField checkstyle problems in client/ (#80549)
Part of #19752.

Fix a number of cases of shadows vars under `client/rest-high-level`. As
part of this, fork the Checkstyle `HiddeFieldCheck` class so that it
understand the pattern of settings with no "set" prefix.
2021-11-10 13:25:29 +00:00