elastic/elasticsearch

Replace groovy build-tools (buildSrc) with java

Closed

#34,459 opened on Oct 15, 2018

 (37 comments) (0 reactions) (1 assignee)Java (25,882 forks)batch import
:Delivery/Build>refactoringTeam:Deliverygood first issue

Repository metrics

Stars
 (76,700 stars)
PR merge metrics
 (Avg merge 2d) (1,000 merged PRs in 30d)

Description

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 :

  • stand alone tasks and plugins
    • ConcatFilesTask (#34476, #37497)
    • NoticeTask (#34769)
    • PluginPropertiesTask #39605
    • PluginPropertiesExtension #39605
    • MavenFilteringHack
    • FileContentsTask (#34539)
    • DependenciesInfoTask
    • VersionCollection (#34050)
    • MessyTestPlugin ( possibly dead code elastic/x-plugins/issues/724 )
    • EmptyDirTask (#34672)
  • precommit
    • FilePermissionsTask (#34674)
    • ForbiddenPatternsTask (#36194)
    • UpdateShasTask ( #35231 , #41921 )
    • DependencyLicensesTask (#35231 , #41921)
    • PrecommitTasks
  • doc
    • RestTestFromSnippetsTaskTests
    • RestTestsFromSnippetsTask
    • DocsTestPlugin
    • SnippetsTask
    • RestTestsFromSnippetsTask
  • ant and and fixtures
    • LicenseHeadersTask
    • AntTask
  • dependent on the new testclusters implementation
    • AntFixture ( used in multipe build scripts )
    • RestTestPlugin
    • StandaloneRestTestPlugin
    • Fixture
    • RestIntegTestTask
    • [x ]RunTask
    • ClusterConfiguration
    • [x ]NodeInfo
    • ClusterFormationTasks
  • vagrant
    • VagrantFixture
    • VagrantLoggerOutputStream
    • VagrantCommandTask
    • VagrantTestPlugin
    • BatsOverVagrantTask
    • TapLoggerOutputStream
    • VagrantPropertiesExtension
  • plugins
    • BuildPlugin
    • StandaloneTestPlugin
    • PluginBuildPlugin
    • RestTestPlugin
    • StandaloneRestTestPlugin
    • VagrantSupportPlugin
    • TestWithDependenciesPlugin
  • carrotsearch : either push changes upstream or replace with Gradle runner ( #31496 )

Contributor guide