Skip to content

Replace groovy build-tools (buildSrc) with java #34459

@alpar-t

Description

@alpar-t

We want to have build code implemented in Java to make it easier to maintain.
We can easily mix java and groovy implementations and everything is already set up to do so, so it's already easy to create new classes in Java.
It would also be great to take this opportunity to add tests for the newly written Java code.

The ingredients of a great rewrite:

  • the groovy code is removed, the java implementation is actually used by the build
  • the java implementation does not use the Groovy SDK ( no groovy imports in Java).
    • note that the "convert to java" option in IDEA does add calls to it
  • Existing Groovy tests are also ported to Java
    • when there are no existing tests, new unit and/or integration tests are created. There is a precedent for both. Integration tests use Gradle Test Kit. We should have tests for basic functionality, making sure that the test is up-to-date when the inputs/outputs don't change and in some cases for error conditions.
  • follow conventions showcased in Gradle example plugin and detailed in the Gradle user guide: writing custom tasks and writing plugins. Make sure to follow the instructions on making tasks incremental.
  • Don't use, and replace the use of project.afterEvaluate in custom task implementations as well as any other configuration logic from the task constructor. The custom task constructor should not reference project. Gradle calls methods annotated with @TaskAction as well as @Input, @Output and the like at execution time rather than configuration time as defined by the
    Gradle build lifecycle.

Here's a list of what is still in Groovy. Note that it goes from simple to complex and there are some inner dependencies :

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions