diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/AntTask.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/AntTask.class deleted file mode 100644 index d7c3b753c37cc..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/AntTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2$_closure3$_closure4$_closure6.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2$_closure3$_closure4$_closure6.class deleted file mode 100644 index 1fc0c09a4e37d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2$_closure3$_closure4$_closure6.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2$_closure3$_closure4.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2$_closure3$_closure4.class deleted file mode 100644 index 5917f31828fc3..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2$_closure3$_closure4.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2$_closure3$_closure5$_closure7.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2$_closure3$_closure5$_closure7.class deleted file mode 100644 index 60a2ddfa4fee0..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2$_closure3$_closure5$_closure7.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2$_closure3$_closure5.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2$_closure3$_closure5.class deleted file mode 100644 index a6d5829dced24..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2$_closure3$_closure5.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2$_closure3.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2$_closure3.class deleted file mode 100644 index 96321b5da9df5..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2$_closure3.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2.class deleted file mode 100644 index c0f52d2a876b3..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1$_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1.class deleted file mode 100644 index 533e428744139..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin$_configureLicenseAndNotice_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin.class deleted file mode 100644 index ec846c9639135..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/BuildPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoPlugin$_apply_closure1$_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoPlugin$_apply_closure1$_closure2.class deleted file mode 100644 index 8f924c5bb0229..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoPlugin$_apply_closure1$_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoPlugin$_apply_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoPlugin$_apply_closure1.class deleted file mode 100644 index e6e93bd67f4dc..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoPlugin$_apply_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoPlugin.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoPlugin.class deleted file mode 100644 index 322b0bb002025..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoTask$_generateDependenciesInfo_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoTask$_generateDependenciesInfo_closure1.class deleted file mode 100644 index ac10d0e0d3911..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoTask$_generateDependenciesInfo_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoTask$_getDependencyInfoFile_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoTask$_getDependencyInfoFile_closure2.class deleted file mode 100644 index 83fc22b52449e..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoTask$_getDependencyInfoFile_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoTask$_getDependencyInfoFile_closure3.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoTask$_getDependencyInfoFile_closure3.class deleted file mode 100644 index c12388ff198b6..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoTask$_getDependencyInfoFile_closure3.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoTask.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoTask.class deleted file mode 100644 index 163687b54d534..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/DependenciesInfoTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/FileContentsTask.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/FileContentsTask.class deleted file mode 100644 index 95398f05806f6..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/FileContentsTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/MavenFilteringHack$_filter_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/MavenFilteringHack$_filter_closure1.class deleted file mode 100644 index 15cb267c5085d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/MavenFilteringHack$_filter_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/MavenFilteringHack.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/MavenFilteringHack.class deleted file mode 100644 index 988af750f5da5..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/MavenFilteringHack.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/NoticeTask$_generateNotice_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/NoticeTask$_generateNotice_closure1.class deleted file mode 100644 index 6c5c36bcec2d5..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/NoticeTask$_generateNotice_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/NoticeTask$_getNoticeFiles_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/NoticeTask$_getNoticeFiles_closure2.class deleted file mode 100644 index ecdaa1873791f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/NoticeTask$_getNoticeFiles_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/NoticeTask$_getNoticeFiles_closure3.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/NoticeTask$_getNoticeFiles_closure3.class deleted file mode 100644 index c36fb77a6404b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/NoticeTask$_getNoticeFiles_closure3.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/NoticeTask.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/NoticeTask.class deleted file mode 100644 index 39e109e227923..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/NoticeTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/ResolveAllDependencies.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/ResolveAllDependencies.class deleted file mode 100644 index 19d269abb4cbd..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/ResolveAllDependencies.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure1.class deleted file mode 100644 index 71a0f5e89bae9..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure2.class deleted file mode 100644 index 0107d58632ce8..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure3.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure3.class deleted file mode 100644 index f84f74462bd67..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure3.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure4$_closure7.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure4$_closure7.class deleted file mode 100644 index 51a7cc3e6f9f5..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure4$_closure7.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure4.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure4.class deleted file mode 100644 index 649a0ac5b4875..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure4.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure5$_closure8.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure5$_closure8.class deleted file mode 100644 index 75821745a892b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure5$_closure8.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure5.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure5.class deleted file mode 100644 index b23819e7f081e..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure5.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure6.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure6.class deleted file mode 100644 index d3752e4729291..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin$_apply_closure6.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin.class deleted file mode 100644 index 4bc0c6e0c582b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/DocsTestPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$__clinit__closure6.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$__clinit__closure6.class deleted file mode 100644 index 2ca8bb80f94c8..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$__clinit__closure6.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$_body_closure3.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$_body_closure3.class deleted file mode 100644 index 1684a357625db..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$_body_closure3.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$_checkUnconverted_closure4.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$_checkUnconverted_closure4.class deleted file mode 100644 index 1949136db4146..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$_checkUnconverted_closure4.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$_checkUnconverted_closure5.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$_checkUnconverted_closure5.class deleted file mode 100644 index d2f6ba8fb1128..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$_checkUnconverted_closure5.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$_emitDo_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$_emitDo_closure2.class deleted file mode 100644 index 16079c3e03101..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$_emitDo_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$_response_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$_response_closure1.class deleted file mode 100644 index d33e7122669a1..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder$_response_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder.class deleted file mode 100644 index c695918779c6d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$TestBuilder.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$_closure1.class deleted file mode 100644 index 4c9198852cb0b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$_closure2.class deleted file mode 100644 index ba0799b3a4b2d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask$_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask.class deleted file mode 100644 index 447354f745500..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/RestTestsFromSnippetsTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$Snippet.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$Snippet.class deleted file mode 100644 index 83de97aaeaae8..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$Snippet.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_closure1.class deleted file mode 100644 index 6877b44877758..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_executeTask_closure2$_closure5.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_executeTask_closure2$_closure5.class deleted file mode 100644 index ec1690db91029..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_executeTask_closure2$_closure5.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_executeTask_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_executeTask_closure2.class deleted file mode 100644 index 706730afc9a4d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_executeTask_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_executeTask_closure3$_closure6.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_executeTask_closure3$_closure6.class deleted file mode 100644 index 9dbd46e92b99f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_executeTask_closure3$_closure6.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_executeTask_closure3$_closure7.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_executeTask_closure3$_closure7.class deleted file mode 100644 index b33cbdc474634..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_executeTask_closure3$_closure7.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_executeTask_closure3.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_executeTask_closure3.class deleted file mode 100644 index 9342be51b3144..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_executeTask_closure3.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_parse_closure4.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_parse_closure4.class deleted file mode 100644 index b12ae4460e13a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask$_parse_closure4.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask.class deleted file mode 100644 index 8a1604725385f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/doc/SnippetsTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_addNoticeGeneration_closure11$_closure23$_closure24.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_addNoticeGeneration_closure11$_closure23$_closure24.class deleted file mode 100644 index ae4aba57bcdad..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_addNoticeGeneration_closure11$_closure23$_closure24.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_addNoticeGeneration_closure11$_closure23.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_addNoticeGeneration_closure11$_closure23.class deleted file mode 100644 index 07dcf61c7b551..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_addNoticeGeneration_closure11$_closure23.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_addNoticeGeneration_closure11.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_addNoticeGeneration_closure11.class deleted file mode 100644 index b8d2e08913ca6..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_addNoticeGeneration_closure11.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_addNoticeGeneration_closure12.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_addNoticeGeneration_closure12.class deleted file mode 100644 index 6b5d52687ab9c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_addNoticeGeneration_closure12.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_addNoticeGeneration_closure13.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_addNoticeGeneration_closure13.class deleted file mode 100644 index 81bfe34c64b2a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_addNoticeGeneration_closure13.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure1$_closure14$_closure16.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure1$_closure14$_closure16.class deleted file mode 100644 index 66306976edb3b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure1$_closure14$_closure16.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure1$_closure14.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure1$_closure14.class deleted file mode 100644 index 66e84ad366b98..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure1$_closure14.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure1$_closure15.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure1$_closure15.class deleted file mode 100644 index adb6da8fdb458..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure1$_closure15.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure1.class deleted file mode 100644 index 7ea2d19625863..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure2$_closure17$_closure18.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure2$_closure17$_closure18.class deleted file mode 100644 index fc072080aaad2..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure2$_closure17$_closure18.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure2$_closure17$_closure19.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure2$_closure17$_closure19.class deleted file mode 100644 index af042949304c5..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure2$_closure17$_closure19.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure2$_closure17.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure2$_closure17.class deleted file mode 100644 index 3db717deac06e..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure2$_closure17.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure2.class deleted file mode 100644 index b6055cdeb6026..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure3.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure3.class deleted file mode 100644 index 4c162ba73bf14..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_apply_closure3.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_configureDependencies_closure6.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_configureDependencies_closure6.class deleted file mode 100644 index fc46e05e57604..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_configureDependencies_closure6.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_configurePublishing_closure4.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_configurePublishing_closure4.class deleted file mode 100644 index e93619a4e821f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_configurePublishing_closure4.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_configurePublishing_closure5.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_configurePublishing_closure5.class deleted file mode 100644 index 1ea617bbce485..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_configurePublishing_closure5.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure10.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure10.class deleted file mode 100644 index bbba3dd35c1ee..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure10.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure7$_closure20.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure7$_closure20.class deleted file mode 100644 index 7af25435042e6..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure7$_closure20.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure7.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure7.class deleted file mode 100644 index d77227e2318bc..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure7.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure8.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure8.class deleted file mode 100644 index e416b7fdaf07a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure8.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure9$_closure21.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure9$_closure21.class deleted file mode 100644 index a9567e0479f48..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure9$_closure21.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure9$_closure22.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure9$_closure22.class deleted file mode 100644 index 6699272c2c612..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure9$_closure22.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure9.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure9.class deleted file mode 100644 index 63e07ab985f71..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin$_createBundleTasks_closure9.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin.class deleted file mode 100644 index 1d6a33d755eea..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/plugin/PluginBuildPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersPrecommitPlugin.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersPrecommitPlugin.class deleted file mode 100644 index 0a86dbd9f722e..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersPrecommitPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_getJavaFiles_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_getJavaFiles_closure1.class deleted file mode 100644 index 7ac16f54d27b6..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_getJavaFiles_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure10.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure10.class deleted file mode 100644 index f17987126c803..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure10.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure5.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure5.class deleted file mode 100644 index a424a33b0d0f2..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure5.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure6.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure6.class deleted file mode 100644 index 13bd0cf0be7e7..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure6.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure7.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure7.class deleted file mode 100644 index 0c633a9eb82ad..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure7.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure8.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure8.class deleted file mode 100644 index f0ad0faeca04b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure8.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure9.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure9.class deleted file mode 100644 index 3e869fe079060..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2$_closure9.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2.class deleted file mode 100644 index cb6d0fa4db22e..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure3.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure3.class deleted file mode 100644 index a12daddbb7384..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure3.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure4.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure4.class deleted file mode 100644 index 4198061568914..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask$_runAnt_closure4.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask.class deleted file mode 100644 index 7e2fb10b231a9..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/LicenseHeadersTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/PrecommitTasks.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/PrecommitTasks.class deleted file mode 100644 index 131980e730364..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/precommit/PrecommitTasks.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_closure1.class deleted file mode 100644 index 0f37b4bbb98e9..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure10.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure10.class deleted file mode 100644 index 1b6dda044f63c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure10.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure11$_closure19.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure11$_closure19.class deleted file mode 100644 index 9a234463a326b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure11$_closure19.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure11$_closure20.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure11$_closure20.class deleted file mode 100644 index 0674b343149cb..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure11$_closure20.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure11$_closure21$_closure22.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure11$_closure21$_closure22.class deleted file mode 100644 index 11ca1f8dac655..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure11$_closure21$_closure22.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure11$_closure21.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure11$_closure21.class deleted file mode 100644 index 0863fea4b83e9..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure11$_closure21.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure11.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure11.class deleted file mode 100644 index 04e6af0266d1e..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_createStopTask_closure11.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_fail_closure8.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_fail_closure8.class deleted file mode 100644 index f017459c47869..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_fail_closure8.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_fail_closure9.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_fail_closure9.class deleted file mode 100644 index dac438bbb6420..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_fail_closure9.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_getCommandString_closure6.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_getCommandString_closure6.class deleted file mode 100644 index f03213e7da5c5..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_getCommandString_closure6.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_getCommandString_closure7.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_getCommandString_closure7.class deleted file mode 100644 index 16bc1ab57e325..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_getCommandString_closure7.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure2.class deleted file mode 100644 index 743ffd772c53b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure3.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure3.class deleted file mode 100644 index c7ab858199b15..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure3.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure4$_closure12.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure4$_closure12.class deleted file mode 100644 index 1d0601628f64d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure4$_closure12.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure4$_closure13.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure4$_closure13.class deleted file mode 100644 index 22c6269f4cb5c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure4$_closure13.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure4.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure4.class deleted file mode 100644 index e58a45e30dd95..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure4.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5$_closure14$_closure15.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5$_closure14$_closure15.class deleted file mode 100644 index 08bab3cc91a17..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5$_closure14$_closure15.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5$_closure14$_closure16$_closure17.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5$_closure14$_closure16$_closure17.class deleted file mode 100644 index 276c63013ae0b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5$_closure14$_closure16$_closure17.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5$_closure14$_closure16$_closure18.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5$_closure14$_closure16$_closure18.class deleted file mode 100644 index 3fce27b8b3889..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5$_closure14$_closure16$_closure18.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5$_closure14$_closure16.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5$_closure14$_closure16.class deleted file mode 100644 index a0ddfd5cd0414..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5$_closure14$_closure16.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5$_closure14.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5$_closure14.class deleted file mode 100644 index f1a135e5f54ea..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5$_closure14.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5.class deleted file mode 100644 index de782acd879f7..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture$_runAnt_closure5.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture.class deleted file mode 100644 index 2abbb8e55f2b0..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/AntFixture.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure1.class deleted file mode 100644 index 03ebbdd73e57e..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure2$_closure5$_closure6.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure2$_closure5$_closure6.class deleted file mode 100644 index b569557d8269a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure2$_closure5$_closure6.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure2$_closure5.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure2$_closure5.class deleted file mode 100644 index 391f52fb3fefa..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure2$_closure5.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure2.class deleted file mode 100644 index eb2ec0afec0b0..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure3.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure3.class deleted file mode 100644 index 73ddc34942121..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure3.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure4.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure4.class deleted file mode 100644 index 4b82fb323ef73..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration$_closure4.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration.class deleted file mode 100644 index 34b149cca218b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterConfiguration.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$EscapeCommaWrapper.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$EscapeCommaWrapper.class deleted file mode 100644 index ed358d9cb80c6..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$EscapeCommaWrapper.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureAddKeystoreFileTasks_closure12.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureAddKeystoreFileTasks_closure12.class deleted file mode 100644 index 0430f80b618da..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureAddKeystoreFileTasks_closure12.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureAddKeystoreFileTasks_closure13.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureAddKeystoreFileTasks_closure13.class deleted file mode 100644 index 64e7be302431c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureAddKeystoreFileTasks_closure13.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureAddKeystoreSettingTasks_closure10.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureAddKeystoreSettingTasks_closure10.class deleted file mode 100644 index 78f1b1d4c4e77..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureAddKeystoreSettingTasks_closure10.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureAddKeystoreSettingTasks_closure11.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureAddKeystoreSettingTasks_closure11.class deleted file mode 100644 index 00d7f5dac3ecc..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureAddKeystoreSettingTasks_closure11.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCheckPreviousTask_closure32$_closure57.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCheckPreviousTask_closure32$_closure57.class deleted file mode 100644 index 576d7371e4cf0..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCheckPreviousTask_closure32$_closure57.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCheckPreviousTask_closure32$_closure58.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCheckPreviousTask_closure32$_closure58.class deleted file mode 100644 index 11d25fd93390b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCheckPreviousTask_closure32$_closure58.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCheckPreviousTask_closure32$_closure59.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCheckPreviousTask_closure32$_closure59.class deleted file mode 100644 index 2590345e1d14d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCheckPreviousTask_closure32$_closure59.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCheckPreviousTask_closure32.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCheckPreviousTask_closure32.class deleted file mode 100644 index 482044cf88829..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCheckPreviousTask_closure32.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCopyBwcPluginsTask_closure17.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCopyBwcPluginsTask_closure17.class deleted file mode 100644 index 70feb527a5c6a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCopyBwcPluginsTask_closure17.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCopyBwcPluginsTask_closure18.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCopyBwcPluginsTask_closure18.class deleted file mode 100644 index 5986ae9cf7a2f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCopyBwcPluginsTask_closure18.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCreateKeystoreTask_closure9.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCreateKeystoreTask_closure9.class deleted file mode 100644 index 78d598f5fad13..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureCreateKeystoreTask_closure9.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExecTask_closure22$_closure42.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExecTask_closure22$_closure42.class deleted file mode 100644 index 17b71c9ba5e0f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExecTask_closure22$_closure42.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExecTask_closure22.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExecTask_closure22.class deleted file mode 100644 index 5a2e07e3a9b2a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExecTask_closure22.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtraConfigFilesTask_closure14.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtraConfigFilesTask_closure14.class deleted file mode 100644 index 23829174f2925..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtraConfigFilesTask_closure14.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtraConfigFilesTask_closure15.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtraConfigFilesTask_closure15.class deleted file mode 100644 index 15b2a768bd4e8..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtraConfigFilesTask_closure15.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtraConfigFilesTask_closure16$_closure41.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtraConfigFilesTask_closure16$_closure41.class deleted file mode 100644 index d5e130b081008..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtraConfigFilesTask_closure16$_closure41.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtraConfigFilesTask_closure16.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtraConfigFilesTask_closure16.class deleted file mode 100644 index 98a1ae6ec23b2..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtraConfigFilesTask_closure16.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtractTask_closure7$_closure38.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtractTask_closure7$_closure38.class deleted file mode 100644 index 30587dfc9e69d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtractTask_closure7$_closure38.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtractTask_closure7$_closure39.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtractTask_closure7$_closure39.class deleted file mode 100644 index c2bfb3f13d970..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtractTask_closure7$_closure39.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtractTask_closure7.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtractTask_closure7.class deleted file mode 100644 index 3683da2a4c593..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureExtractTask_closure7.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureInstallModuleTask_closure19.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureInstallModuleTask_closure19.class deleted file mode 100644 index 0e0732e127f2e..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureInstallModuleTask_closure19.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureInstallPluginTask_closure20.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureInstallPluginTask_closure20.class deleted file mode 100644 index ce3525e2f5282..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureInstallPluginTask_closure20.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureInstallPluginTask_closure21.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureInstallPluginTask_closure21.class deleted file mode 100644 index a442ed64fa3b4..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureInstallPluginTask_closure21.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureNode_closure4.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureNode_closure4.class deleted file mode 100644 index 690e37587c47d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureNode_closure4.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureNode_closure5$_closure37.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureNode_closure5$_closure37.class deleted file mode 100644 index 62fbaf202f3dd..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureNode_closure5$_closure37.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureNode_closure5.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureNode_closure5.class deleted file mode 100644 index 2af4243ae1d1b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureNode_closure5.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureNode_closure6.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureNode_closure6.class deleted file mode 100644 index dedf01e46dfc7..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureNode_closure6.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure23$_closure43$_closure44.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure23$_closure43$_closure44.class deleted file mode 100644 index c14c5966dfd22..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure23$_closure43$_closure44.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure23$_closure43$_closure45.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure23$_closure43$_closure45.class deleted file mode 100644 index 83d252928eb3d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure23$_closure43$_closure45.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure23$_closure43.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure23$_closure43.class deleted file mode 100644 index 55a2dd4226894..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure23$_closure43.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure23.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure23.class deleted file mode 100644 index f66122504f2f8..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure23.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure24$_closure46.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure24$_closure46.class deleted file mode 100644 index df615c0dab470..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure24$_closure46.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure24.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure24.class deleted file mode 100644 index abb26c5f6699b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure24.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure25$_closure47.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure25$_closure47.class deleted file mode 100644 index 09f191e86e035..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure25$_closure47.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure25.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure25.class deleted file mode 100644 index b90b8ba37398b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStartTask_closure25.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStopTask_closure33$_closure60.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStopTask_closure33$_closure60.class deleted file mode 100644 index 18198e3b202b4..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStopTask_closure33$_closure60.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStopTask_closure33$_closure61.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStopTask_closure33$_closure61.class deleted file mode 100644 index 0ae7bc3a2d23d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStopTask_closure33$_closure61.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStopTask_closure33$_closure62.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStopTask_closure33$_closure62.class deleted file mode 100644 index 87e18c26fd5dd..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStopTask_closure33$_closure62.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStopTask_closure33$_closure63.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStopTask_closure33$_closure63.class deleted file mode 100644 index 617b3b86df0de..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStopTask_closure33$_closure63.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStopTask_closure33.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStopTask_closure33.class deleted file mode 100644 index a0ba8922351d4..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureStopTask_closure33.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure48.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure48.class deleted file mode 100644 index 8819fb2f517fd..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure48.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure49.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure49.class deleted file mode 100644 index f5cd2bdbc06d4..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure49.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51$_closure52.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51$_closure52.class deleted file mode 100644 index f0f475deba2b9..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51$_closure52.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51$_closure53$_closure54.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51$_closure53$_closure54.class deleted file mode 100644 index 4f94fd3d62c92..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51$_closure53$_closure54.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51$_closure53$_closure55.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51$_closure53$_closure55.class deleted file mode 100644 index 3de216b7d38c1..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51$_closure53$_closure55.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51$_closure53$_closure56.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51$_closure53$_closure56.class deleted file mode 100644 index dbf1d463643c4..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51$_closure53$_closure56.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51$_closure53.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51$_closure53.class deleted file mode 100644 index 9852baaae1bf9..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51$_closure53.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51.class deleted file mode 100644 index a333066e74234..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50$_closure51.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50.class deleted file mode 100644 index 74dc5c085c75e..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26$_closure50.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26.class deleted file mode 100644 index 856d6396f7e10..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWaitTask_closure26.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWriteConfigTask_closure8$_closure40.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWriteConfigTask_closure8$_closure40.class deleted file mode 100644 index 48ea58dd90ff1..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWriteConfigTask_closure8$_closure40.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWriteConfigTask_closure8.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWriteConfigTask_closure8.class deleted file mode 100644 index 412f15f0c6223..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_configureWriteConfigTask_closure8.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_pluginTaskName_closure34.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_pluginTaskName_closure34.class deleted file mode 100644 index 8fe6444cb088d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_pluginTaskName_closure34.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_setup_closure1$_closure35.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_setup_closure1$_closure35.class deleted file mode 100644 index a8457f387c1ad..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_setup_closure1$_closure35.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_setup_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_setup_closure1.class deleted file mode 100644 index e83c6b6ee9267..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_setup_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_setup_closure2$_closure36.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_setup_closure2$_closure36.class deleted file mode 100644 index 1fd412f18f4c6..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_setup_closure2$_closure36.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_setup_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_setup_closure2.class deleted file mode 100644 index 04fffb60231b0..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_setup_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_setup_closure3.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_setup_closure3.class deleted file mode 100644 index ae9b2bf3e57bc..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_setup_closure3.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_waitFailed_closure27.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_waitFailed_closure27.class deleted file mode 100644 index 46a8395aad9e8..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_waitFailed_closure27.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_waitFailed_closure28.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_waitFailed_closure28.class deleted file mode 100644 index 96ae01b3bb2f1..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_waitFailed_closure28.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_waitFailed_closure29.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_waitFailed_closure29.class deleted file mode 100644 index e3e966c63b94c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_waitFailed_closure29.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_waitFailed_closure30.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_waitFailed_closure30.class deleted file mode 100644 index 98d98d7626b86..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_waitFailed_closure30.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_waitFailed_closure31.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_waitFailed_closure31.class deleted file mode 100644 index 80b41c2e6ca34..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks$_waitFailed_closure31.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks.class deleted file mode 100644 index 41fe5e1339c75..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/ClusterFormationTasks.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_closure1.class deleted file mode 100644 index 2090ce571c2ae..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_closure2.class deleted file mode 100644 index c631b29211e6c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_closure3.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_closure3.class deleted file mode 100644 index 6a61b548fc2e5..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_closure3.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_closure4.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_closure4.class deleted file mode 100644 index 904c1c073c94f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_closure4.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_closure5.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_closure5.class deleted file mode 100644 index 96bc4b7377202..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_closure5.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_getCommandString_closure6.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_getCommandString_closure6.class deleted file mode 100644 index 7bee5e1d7d2b6..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_getCommandString_closure6.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_getCommandString_closure7.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_getCommandString_closure7.class deleted file mode 100644 index 971316da3978c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_getCommandString_closure7.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_getCommandString_closure8.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_getCommandString_closure8.class deleted file mode 100644 index 116d9ba4a0a34..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo$_getCommandString_closure8.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo.class deleted file mode 100644 index 541391e9f1682..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/NodeInfo.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/RestTestPlugin$_apply_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/RestTestPlugin$_apply_closure1.class deleted file mode 100644 index c69119d8c4f59..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/RestTestPlugin$_apply_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/RestTestPlugin$_apply_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/RestTestPlugin$_apply_closure2.class deleted file mode 100644 index ccd463237abaa..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/RestTestPlugin$_apply_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/RestTestPlugin.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/RestTestPlugin.class deleted file mode 100644 index e4b3b8012de22..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/RestTestPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/StandaloneRestTestPlugin$_apply_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/StandaloneRestTestPlugin$_apply_closure1.class deleted file mode 100644 index badf7ba8a6253..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/StandaloneRestTestPlugin$_apply_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/StandaloneRestTestPlugin.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/StandaloneRestTestPlugin.class deleted file mode 100644 index 018f9607f024f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/StandaloneRestTestPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/StandaloneTestPlugin$_apply_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/StandaloneTestPlugin$_apply_closure1.class deleted file mode 100644 index b8e027a01afd5..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/StandaloneTestPlugin$_apply_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/StandaloneTestPlugin$_apply_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/StandaloneTestPlugin$_apply_closure2.class deleted file mode 100644 index 11cf88c9c6446..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/StandaloneTestPlugin$_apply_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/StandaloneTestPlugin.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/StandaloneTestPlugin.class deleted file mode 100644 index 749b65084cf77..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/StandaloneTestPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithDependenciesPlugin$_addPluginResources_closure2.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithDependenciesPlugin$_addPluginResources_closure2.class deleted file mode 100644 index 5b6d2ba149e42..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithDependenciesPlugin$_addPluginResources_closure2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithDependenciesPlugin$_addPluginResources_closure3.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithDependenciesPlugin$_addPluginResources_closure3.class deleted file mode 100644 index a3f11716b5e3a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithDependenciesPlugin$_addPluginResources_closure3.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithDependenciesPlugin$_apply_closure1$_closure4.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithDependenciesPlugin$_apply_closure1$_closure4.class deleted file mode 100644 index 977a897774b47..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithDependenciesPlugin$_apply_closure1$_closure4.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithDependenciesPlugin$_apply_closure1.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithDependenciesPlugin$_apply_closure1.class deleted file mode 100644 index dba67395170f7..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithDependenciesPlugin$_apply_closure1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithDependenciesPlugin.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithDependenciesPlugin.class deleted file mode 100644 index ac062b4eb9ec0..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithDependenciesPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithSslPlugin.class b/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithSslPlugin.class deleted file mode 100644 index e82ca8b7c030e..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/groovy/main/org/opensearch/gradle/test/TestWithSslPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/AbstractLazyPropertyCollection.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/AbstractLazyPropertyCollection.class deleted file mode 100644 index 4b7ca7f0a3a2e..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/AbstractLazyPropertyCollection.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Architecture.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Architecture.class deleted file mode 100644 index bf1f0acbfbe4b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Architecture.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/BwcVersions$UnreleasedVersionInfo.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/BwcVersions$UnreleasedVersionInfo.class deleted file mode 100644 index e3928dcaefa5b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/BwcVersions$UnreleasedVersionInfo.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/BwcVersions.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/BwcVersions.class deleted file mode 100644 index b6d0f9c021b58..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/BwcVersions.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/ConcatFilesTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/ConcatFilesTask.class deleted file mode 100644 index 0856982ddabc1..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/ConcatFilesTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionDependency$StringBasedDistributionDependency.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionDependency$StringBasedDistributionDependency.class deleted file mode 100644 index 122a005c5af6a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionDependency$StringBasedDistributionDependency.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionDependency.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionDependency.class deleted file mode 100644 index 32e546bb9373a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionDependency.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionDownloadPlugin$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionDownloadPlugin$1.class deleted file mode 100644 index 2cb9bd60b6a82..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionDownloadPlugin$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionDownloadPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionDownloadPlugin.class deleted file mode 100644 index 5110e3329fc16..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionDownloadPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionResolution$Resolver.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionResolution$Resolver.class deleted file mode 100644 index af2bda18d93da..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionResolution$Resolver.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionResolution.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionResolution.class deleted file mode 100644 index 379059c73f156..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DistributionResolution.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DockerBase.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DockerBase.class deleted file mode 100644 index 7ec075bea6ef1..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/DockerBase.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/EmptyDirTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/EmptyDirTask.class deleted file mode 100644 index d61bc179bad69..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/EmptyDirTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/ExportOpenSearchBuildResourcesTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/ExportOpenSearchBuildResourcesTask.class deleted file mode 100644 index c7d1568578aa8..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/ExportOpenSearchBuildResourcesTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/FileSupplier.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/FileSupplier.class deleted file mode 100644 index ff449089f1ce1..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/FileSupplier.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/FileSystemOperationsAware.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/FileSystemOperationsAware.class deleted file mode 100644 index c012487c6862e..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/FileSystemOperationsAware.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Jdk$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Jdk$1.class deleted file mode 100644 index 37eaf45dffd8e..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Jdk$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Jdk$2.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Jdk$2.class deleted file mode 100644 index fd56f53719103..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Jdk$2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Jdk.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Jdk.class deleted file mode 100644 index a5e552d3d346d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Jdk.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/JdkDownloadPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/JdkDownloadPlugin.class deleted file mode 100644 index f528b0d4e1acd..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/JdkDownloadPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyFileOutputStream$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyFileOutputStream$1.class deleted file mode 100644 index 883147124a9f6..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyFileOutputStream$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyFileOutputStream.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyFileOutputStream.class deleted file mode 100644 index d0bbbd2a17555..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyFileOutputStream.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyPropertyList$PropertyListEntry.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyPropertyList$PropertyListEntry.class deleted file mode 100644 index 3b0a08ad6651b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyPropertyList$PropertyListEntry.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyPropertyList.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyPropertyList.class deleted file mode 100644 index 2cf0724714467..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyPropertyList.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyPropertyMap$PropertyMapEntry.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyPropertyMap$PropertyMapEntry.class deleted file mode 100644 index b8583ada83c56..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyPropertyMap$PropertyMapEntry.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyPropertyMap.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyPropertyMap.class deleted file mode 100644 index 9d77108b91fc9..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LazyPropertyMap.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LoggedExec$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LoggedExec$1.class deleted file mode 100644 index c561fd95bca23..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LoggedExec$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LoggedExec.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LoggedExec.class deleted file mode 100644 index b2c7d2ffaeb7f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LoggedExec.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LoggingOutputStream.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LoggingOutputStream.class deleted file mode 100644 index 40c492bca61e6..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/LoggingOutputStream.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OS$Conditional.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OS$Conditional.class deleted file mode 100644 index 4ffeacb602d71..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OS$Conditional.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OS.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OS.class deleted file mode 100644 index dbd4ac7e5da69..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OS.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchDistribution$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchDistribution$1.class deleted file mode 100644 index df0966ba39b85..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchDistribution$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchDistribution$Platform.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchDistribution$Platform.class deleted file mode 100644 index 2b0151dbc6889..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchDistribution$Platform.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchDistribution$Type.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchDistribution$Type.class deleted file mode 100644 index 8f1e39c1cdd3a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchDistribution$Type.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchDistribution.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchDistribution.class deleted file mode 100644 index f0d3e8742ee11..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchDistribution.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchJavaPlugin$1$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchJavaPlugin$1$1.class deleted file mode 100644 index 457818a68f569..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchJavaPlugin$1$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchJavaPlugin$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchJavaPlugin$1.class deleted file mode 100644 index 45d853940c606..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchJavaPlugin$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchJavaPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchJavaPlugin.class deleted file mode 100644 index 5433e72b94476..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchJavaPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchTestBasePlugin$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchTestBasePlugin$1.class deleted file mode 100644 index 1a6589d3ba7b4..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchTestBasePlugin$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchTestBasePlugin$2.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchTestBasePlugin$2.class deleted file mode 100644 index 41b5336a81de8..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchTestBasePlugin$2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchTestBasePlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchTestBasePlugin.class deleted file mode 100644 index 33480afde10e9..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/OpenSearchTestBasePlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/PropertyNormalization.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/PropertyNormalization.class deleted file mode 100644 index cd744a858db92..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/PropertyNormalization.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/PublishPlugin$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/PublishPlugin$1.class deleted file mode 100644 index b701a963ba322..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/PublishPlugin$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/PublishPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/PublishPlugin.class deleted file mode 100644 index 00a24e3919edb..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/PublishPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/ReaperPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/ReaperPlugin.class deleted file mode 100644 index c65503056913a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/ReaperPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/ReaperService.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/ReaperService.class deleted file mode 100644 index 2d0d9b7545b26..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/ReaperService.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/RepositoriesSetupPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/RepositoriesSetupPlugin.class deleted file mode 100644 index 81fb264dc6a4b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/RepositoriesSetupPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/SimpleCommandLineArgumentProvider.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/SimpleCommandLineArgumentProvider.class deleted file mode 100644 index f47b887cc1be6..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/SimpleCommandLineArgumentProvider.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/SystemPropertyCommandLineArgumentProvider.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/SystemPropertyCommandLineArgumentProvider.class deleted file mode 100644 index f91081c7033f3..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/SystemPropertyCommandLineArgumentProvider.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Version$Mode.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Version$Mode.class deleted file mode 100644 index 072b26c760d90..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Version$Mode.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Version.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Version.class deleted file mode 100644 index 85b4b4f9c1203..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/Version.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/VersionProperties.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/VersionProperties.class deleted file mode 100644 index fc33784b32c8b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/VersionProperties.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/dependencies/CompileOnlyResolvePlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/dependencies/CompileOnlyResolvePlugin.class deleted file mode 100644 index 1be809f31ae01..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/dependencies/CompileOnlyResolvePlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerBuildTask$DockerBuildAction.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerBuildTask$DockerBuildAction.class deleted file mode 100644 index f5b4eba67dadf..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerBuildTask$DockerBuildAction.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerBuildTask$Parameters.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerBuildTask$Parameters.class deleted file mode 100644 index a0ce5d026edfb..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerBuildTask$Parameters.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerBuildTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerBuildTask.class deleted file mode 100644 index f5ded2d15e958..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerBuildTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerSupportPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerSupportPlugin.class deleted file mode 100644 index a148f86d9c36b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerSupportPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerSupportService$DockerAvailability.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerSupportService$DockerAvailability.class deleted file mode 100644 index ea970a271f257..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerSupportService$DockerAvailability.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerSupportService$Parameters.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerSupportService$Parameters.class deleted file mode 100644 index 75251ade0d14a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerSupportService$Parameters.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerSupportService$Result.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerSupportService$Result.class deleted file mode 100644 index de7a89385387c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerSupportService$Result.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerSupportService.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerSupportService.class deleted file mode 100644 index f51910811bc76..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/docker/DockerSupportService.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/http/WaitForHttpResource.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/http/WaitForHttpResource.class deleted file mode 100644 index 286a190e02b57..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/http/WaitForHttpResource.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/info/BuildParams$MutableBuildParams.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/info/BuildParams$MutableBuildParams.class deleted file mode 100644 index a8977746fccf6..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/info/BuildParams$MutableBuildParams.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/info/BuildParams.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/info/BuildParams.class deleted file mode 100644 index 4cfb1251a3fcf..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/info/BuildParams.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/info/GlobalBuildInfoPlugin$GitInfo.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/info/GlobalBuildInfoPlugin$GitInfo.class deleted file mode 100644 index ad874d1a762d5..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/info/GlobalBuildInfoPlugin$GitInfo.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/info/GlobalBuildInfoPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/info/GlobalBuildInfoPlugin.class deleted file mode 100644 index 2f60fb511805d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/info/GlobalBuildInfoPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/info/JavaHome.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/info/JavaHome.class deleted file mode 100644 index 500351b002098..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/info/JavaHome.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/BwcGitExtension.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/BwcGitExtension.class deleted file mode 100644 index 0745dc3603be5..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/BwcGitExtension.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/BwcSetupExtension$IndentingOutputStream.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/BwcSetupExtension$IndentingOutputStream.class deleted file mode 100644 index 426d180e831d6..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/BwcSetupExtension$IndentingOutputStream.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/BwcSetupExtension.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/BwcSetupExtension.class deleted file mode 100644 index 2cb104648f1af..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/BwcSetupExtension.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/DistributionArchive.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/DistributionArchive.class deleted file mode 100644 index 9104ba1d409b9..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/DistributionArchive.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/DistributionArchiveCheckExtension.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/DistributionArchiveCheckExtension.class deleted file mode 100644 index 60af2cfa5915f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/DistributionArchiveCheckExtension.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalBwcGitPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalBwcGitPlugin.class deleted file mode 100644 index b1bde0e833932..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalBwcGitPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPlugin$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPlugin$1.class deleted file mode 100644 index c66daac519adb..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPlugin$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPlugin$2.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPlugin$2.class deleted file mode 100644 index f9377c03ec35f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPlugin$2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPlugin$3.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPlugin$3.class deleted file mode 100644 index b1f037f9be210..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPlugin$3.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPlugin.class deleted file mode 100644 index 9a70e01cc7acd..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionArchiveSetupPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionArchiveSetupPlugin.class deleted file mode 100644 index c8366f78413df..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionArchiveSetupPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin$DistributionProject.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin$DistributionProject.class deleted file mode 100644 index f34ef72ac6bfa..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin$DistributionProject.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin.class deleted file mode 100644 index 6dfdb07bde631..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionDownloadPlugin$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionDownloadPlugin$1.class deleted file mode 100644 index 80c5cc2849d93..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionDownloadPlugin$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionDownloadPlugin$ProjectBasedDistributionDependency.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionDownloadPlugin$ProjectBasedDistributionDependency.class deleted file mode 100644 index 62d2b903ba10f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionDownloadPlugin$ProjectBasedDistributionDependency.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionDownloadPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionDownloadPlugin.class deleted file mode 100644 index 3060a215e782f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/internal/InternalDistributionDownloadPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/plugin/PluginPropertiesExtension.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/plugin/PluginPropertiesExtension.class deleted file mode 100644 index b493117658457..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/plugin/PluginPropertiesExtension.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/DependencyLicensesPrecommitPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/DependencyLicensesPrecommitPlugin.class deleted file mode 100644 index ecd7ebda96f68..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/DependencyLicensesPrecommitPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/DependencyLicensesTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/DependencyLicensesTask.class deleted file mode 100644 index f8715191fb7a8..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/DependencyLicensesTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/FilePermissionsPrecommitPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/FilePermissionsPrecommitPlugin.class deleted file mode 100644 index 435c4fe0a1881..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/FilePermissionsPrecommitPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/FilePermissionsTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/FilePermissionsTask.class deleted file mode 100644 index 3093ad05014a2..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/FilePermissionsTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ForbiddenApisPrecommitPlugin$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ForbiddenApisPrecommitPlugin$1.class deleted file mode 100644 index b874998ec4f30..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ForbiddenApisPrecommitPlugin$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ForbiddenApisPrecommitPlugin$2.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ForbiddenApisPrecommitPlugin$2.class deleted file mode 100644 index 331ab52a4c55d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ForbiddenApisPrecommitPlugin$2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ForbiddenApisPrecommitPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ForbiddenApisPrecommitPlugin.class deleted file mode 100644 index e51f9f0892b4b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ForbiddenApisPrecommitPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ForbiddenPatternsPrecommitPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ForbiddenPatternsPrecommitPlugin.class deleted file mode 100644 index b28ba96c9f60c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ForbiddenPatternsPrecommitPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ForbiddenPatternsTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ForbiddenPatternsTask.class deleted file mode 100644 index cbe46a637ad50..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ForbiddenPatternsTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/JarHellPrecommitPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/JarHellPrecommitPlugin.class deleted file mode 100644 index 6f0f444bb70bd..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/JarHellPrecommitPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/JarHellTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/JarHellTask.class deleted file mode 100644 index 63c7a9b3e6af0..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/JarHellTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/LicenseAnalyzer$LicenseInfo.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/LicenseAnalyzer$LicenseInfo.class deleted file mode 100644 index 673420d7bb106..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/LicenseAnalyzer$LicenseInfo.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/LicenseAnalyzer$LicenseMatcher.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/LicenseAnalyzer$LicenseMatcher.class deleted file mode 100644 index 1dd97affd6be1..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/LicenseAnalyzer$LicenseMatcher.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/LicenseAnalyzer.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/LicenseAnalyzer.class deleted file mode 100644 index e738322ce984c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/LicenseAnalyzer.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/LoggerUsagePrecommitPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/LoggerUsagePrecommitPlugin.class deleted file mode 100644 index 832746806279c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/LoggerUsagePrecommitPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/LoggerUsageTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/LoggerUsageTask.class deleted file mode 100644 index 7a5b0c9da10ba..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/LoggerUsageTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/PomValidationPrecommitPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/PomValidationPrecommitPlugin.class deleted file mode 100644 index db490cd12b4e2..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/PomValidationPrecommitPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/PomValidationTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/PomValidationTask.class deleted file mode 100644 index e9b7cb365e67e..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/PomValidationTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/PrecommitPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/PrecommitPlugin.class deleted file mode 100644 index aff63a7c82719..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/PrecommitPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/PrecommitTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/PrecommitTask.class deleted file mode 100644 index 27c52657f46ee..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/PrecommitTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/PrecommitTaskPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/PrecommitTaskPlugin.class deleted file mode 100644 index a59442f8de367..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/PrecommitTaskPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/TestingConventionRule.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/TestingConventionRule.class deleted file mode 100644 index cad4b25b9afcd..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/TestingConventionRule.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/TestingConventionsPrecommitPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/TestingConventionsPrecommitPlugin.class deleted file mode 100644 index 65848cd17c8aa..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/TestingConventionsPrecommitPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/TestingConventionsTasks$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/TestingConventionsTasks$1.class deleted file mode 100644 index d615b92c75d41..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/TestingConventionsTasks$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/TestingConventionsTasks.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/TestingConventionsTasks.class deleted file mode 100644 index 93ec6ba255511..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/TestingConventionsTasks.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ThirdPartyAuditPrecommitPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ThirdPartyAuditPrecommitPlugin.class deleted file mode 100644 index 551f7ab739473..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ThirdPartyAuditPrecommitPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ThirdPartyAuditTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ThirdPartyAuditTask.class deleted file mode 100644 index 33b16b04b0b27..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ThirdPartyAuditTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/UpdateShasTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/UpdateShasTask.class deleted file mode 100644 index 2f43f46c9348c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/UpdateShasTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ValidateJsonAgainstSchemaTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ValidateJsonAgainstSchemaTask.class deleted file mode 100644 index 69e363b8923de..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ValidateJsonAgainstSchemaTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ValidateJsonNoKeywordsTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ValidateJsonNoKeywordsTask.class deleted file mode 100644 index 0a4ac40eed099..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ValidateJsonNoKeywordsTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ValidateRestSpecPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ValidateRestSpecPlugin.class deleted file mode 100644 index 63b4a1452a500..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/precommit/ValidateRestSpecPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/tar/SymbolicLinkPreservingTar$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/tar/SymbolicLinkPreservingTar$1.class deleted file mode 100644 index 95b3cb726806d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/tar/SymbolicLinkPreservingTar$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/tar/SymbolicLinkPreservingTar$SymbolicLinkPreservingTarCopyAction$SymbolicLinkPreservingTarStreamAction.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/tar/SymbolicLinkPreservingTar$SymbolicLinkPreservingTarCopyAction$SymbolicLinkPreservingTarStreamAction.class deleted file mode 100644 index 0e841c9f357ca..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/tar/SymbolicLinkPreservingTar$SymbolicLinkPreservingTarCopyAction$SymbolicLinkPreservingTarStreamAction.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/tar/SymbolicLinkPreservingTar$SymbolicLinkPreservingTarCopyAction.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/tar/SymbolicLinkPreservingTar$SymbolicLinkPreservingTarCopyAction.class deleted file mode 100644 index 5c628277ed349..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/tar/SymbolicLinkPreservingTar$SymbolicLinkPreservingTarCopyAction.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/tar/SymbolicLinkPreservingTar.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/tar/SymbolicLinkPreservingTar.class deleted file mode 100644 index 451c7ef2b5b7f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/tar/SymbolicLinkPreservingTar.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/tar/SymoblicLinkPreservingTarPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/tar/SymoblicLinkPreservingTarPlugin.class deleted file mode 100644 index 3c7ee82f44e81..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/tar/SymoblicLinkPreservingTarPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/DistroTestPlugin$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/DistroTestPlugin$1.class deleted file mode 100644 index 468b00989665f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/DistroTestPlugin$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/DistroTestPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/DistroTestPlugin.class deleted file mode 100644 index 79e71fa3020cc..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/DistroTestPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/ErrorReportingTestListener$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/ErrorReportingTestListener$1.class deleted file mode 100644 index b02c2da4a9091..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/ErrorReportingTestListener$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/ErrorReportingTestListener$Descriptor.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/ErrorReportingTestListener$Descriptor.class deleted file mode 100644 index 7595dc201cb41..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/ErrorReportingTestListener$Descriptor.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/ErrorReportingTestListener$EventWriter.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/ErrorReportingTestListener$EventWriter.class deleted file mode 100644 index c466b9f7f783b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/ErrorReportingTestListener$EventWriter.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/ErrorReportingTestListener.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/ErrorReportingTestListener.class deleted file mode 100644 index 1d6289cfced6c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/ErrorReportingTestListener.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/Fixture.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/Fixture.class deleted file mode 100644 index 545ce451a1140..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/Fixture.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/GradleDistroTestTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/GradleDistroTestTask.class deleted file mode 100644 index c6f936454c3af..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/GradleDistroTestTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/InternalClusterTestPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/InternalClusterTestPlugin.class deleted file mode 100644 index 507bb17d9189a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/InternalClusterTestPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/JNAKernel32Library$Holder.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/JNAKernel32Library$Holder.class deleted file mode 100644 index 898899f3d918d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/JNAKernel32Library$Holder.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/JNAKernel32Library.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/JNAKernel32Library.class deleted file mode 100644 index 764dab322c7a7..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/JNAKernel32Library.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/RestIntegTestTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/RestIntegTestTask.class deleted file mode 100644 index 0c11f7e87f89a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/RestIntegTestTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/RestTestBasePlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/RestTestBasePlugin.class deleted file mode 100644 index 14acf2c6de4fd..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/RestTestBasePlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/CopyRestApiTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/CopyRestApiTask.class deleted file mode 100644 index 7ede2b4981e3b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/CopyRestApiTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/CopyRestTestsTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/CopyRestTestsTask.class deleted file mode 100644 index d02f037fc62cc..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/CopyRestTestsTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/JavaRestTestPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/JavaRestTestPlugin.class deleted file mode 100644 index 1fb524df06b8b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/JavaRestTestPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestResourcesExtension$RestResourcesSpec.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestResourcesExtension$RestResourcesSpec.class deleted file mode 100644 index 5e3873e10ada7..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestResourcesExtension$RestResourcesSpec.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestResourcesExtension.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestResourcesExtension.class deleted file mode 100644 index 7a90e3a05265c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestResourcesExtension.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestResourcesPlugin$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestResourcesPlugin$1.class deleted file mode 100644 index 5c666be7a8a5c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestResourcesPlugin$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestResourcesPlugin$2.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestResourcesPlugin$2.class deleted file mode 100644 index 1bf2deb2f9ab2..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestResourcesPlugin$2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestResourcesPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestResourcesPlugin.class deleted file mode 100644 index ef4c899a338ae..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestResourcesPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestTestUtil.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestTestUtil.class deleted file mode 100644 index 4853e9f65bc12..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/RestTestUtil.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/YamlRestTestPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/YamlRestTestPlugin.class deleted file mode 100644 index 542227f961aee..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/test/rest/YamlRestTestPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/DefaultTestClustersTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/DefaultTestClustersTask.class deleted file mode 100644 index 9d03246ab4dbc..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/DefaultTestClustersTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchCluster.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchCluster.class deleted file mode 100644 index 3963eeccd90a4..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchCluster.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode$1.class deleted file mode 100644 index d92ae18622660..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode$CliEntry.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode$CliEntry.class deleted file mode 100644 index df1dabecfcebd..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode$CliEntry.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode$Config.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode$Config.class deleted file mode 100644 index 70579316ddbe0..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode$Config.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode$FileEntry.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode$FileEntry.class deleted file mode 100644 index 37ab074a4d898..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode$FileEntry.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode$LinkCreationException.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode$LinkCreationException.class deleted file mode 100644 index 2e9502c609fb4..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode$LinkCreationException.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode.class deleted file mode 100644 index 5aaa06f5ab250..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/OpenSearchNode.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/RunTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/RunTask.class deleted file mode 100644 index 88401734c1191..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/RunTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/StandaloneRestIntegTestTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/StandaloneRestIntegTestTask.class deleted file mode 100644 index e3db4080b8387..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/StandaloneRestIntegTestTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClusterConfiguration.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClusterConfiguration.class deleted file mode 100644 index 7d6783583ae77..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClusterConfiguration.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersAware.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersAware.class deleted file mode 100644 index 024edb8ce08e0..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersAware.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersException.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersException.class deleted file mode 100644 index 2abe2ba2e9f7d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersException.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersPlugin$TestClustersHookPlugin$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersPlugin$TestClustersHookPlugin$1.class deleted file mode 100644 index 56750383f1536..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersPlugin$TestClustersHookPlugin$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersPlugin$TestClustersHookPlugin$2.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersPlugin$TestClustersHookPlugin$2.class deleted file mode 100644 index e22837a5d2420..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersPlugin$TestClustersHookPlugin$2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersPlugin$TestClustersHookPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersPlugin$TestClustersHookPlugin.class deleted file mode 100644 index 6c6cd2c26f868..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersPlugin$TestClustersHookPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersPlugin.class deleted file mode 100644 index bac6a086c61b5..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersRegistry.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersRegistry.class deleted file mode 100644 index dd095c527132c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersRegistry.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersThrottle.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersThrottle.class deleted file mode 100644 index f4a06a16e881f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestClustersThrottle.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestDistribution.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestDistribution.class deleted file mode 100644 index cea376b89e451..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testclusters/TestDistribution.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testfixtures/DockerComposeThrottle.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testfixtures/DockerComposeThrottle.class deleted file mode 100644 index c8b0c996f8ef3..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testfixtures/DockerComposeThrottle.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testfixtures/TestFixtureExtension.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testfixtures/TestFixtureExtension.class deleted file mode 100644 index 176d21e069eb1..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testfixtures/TestFixtureExtension.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testfixtures/TestFixturesPlugin$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testfixtures/TestFixturesPlugin$1.class deleted file mode 100644 index 7cd7b87402883..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testfixtures/TestFixturesPlugin$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testfixtures/TestFixturesPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testfixtures/TestFixturesPlugin.class deleted file mode 100644 index f1801080835ea..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/testfixtures/TestFixturesPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/transform/SymbolicLinkPreservingUntarTransform.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/transform/SymbolicLinkPreservingUntarTransform.class deleted file mode 100644 index 6cde713ee8630..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/transform/SymbolicLinkPreservingUntarTransform.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/transform/UnpackTransform$Parameters.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/transform/UnpackTransform$Parameters.class deleted file mode 100644 index fb0c09a652f27..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/transform/UnpackTransform$Parameters.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/transform/UnpackTransform.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/transform/UnpackTransform.class deleted file mode 100644 index 55bb62bc82768..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/transform/UnpackTransform.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/transform/UnzipTransform.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/transform/UnzipTransform.class deleted file mode 100644 index 90dc5c0f21e8b..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/transform/UnzipTransform.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/FileUtils.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/FileUtils.class deleted file mode 100644 index 84c739d9c0627..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/FileUtils.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/GradleUtils$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/GradleUtils$1.class deleted file mode 100644 index 110aabb56b570..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/GradleUtils$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/GradleUtils.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/GradleUtils.class deleted file mode 100644 index cd5611ac20e8d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/GradleUtils.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/JavaUtil.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/JavaUtil.class deleted file mode 100644 index 8c0cf30d559ca..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/JavaUtil.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/PermissionUtils.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/PermissionUtils.class deleted file mode 100644 index 05d38afffec1a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/PermissionUtils.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/Util$1.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/Util$1.class deleted file mode 100644 index 91ce9111c99d4..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/Util$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/Util.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/Util.class deleted file mode 100644 index f59dcd65f1787..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/util/Util.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantBasePlugin$VagrantManagerPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantBasePlugin$VagrantManagerPlugin.class deleted file mode 100644 index d335a2a6ea1d6..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantBasePlugin$VagrantManagerPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantBasePlugin$VagrantSetupCheckerPlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantBasePlugin$VagrantSetupCheckerPlugin.class deleted file mode 100644 index 7a37d5698a3a2..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantBasePlugin$VagrantSetupCheckerPlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantBasePlugin.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantBasePlugin.class deleted file mode 100644 index d165dc635c33a..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantBasePlugin.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantExtension.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantExtension.class deleted file mode 100644 index cbeaf26f5b036..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantExtension.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantMachine$ProgressOutputStream.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantMachine$ProgressOutputStream.class deleted file mode 100644 index 0b5278cac4721..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantMachine$ProgressOutputStream.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantMachine$VagrantExecSpec.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantMachine$VagrantExecSpec.class deleted file mode 100644 index 3d541ff918dd2..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantMachine$VagrantExecSpec.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantMachine.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantMachine.class deleted file mode 100644 index 3524887b4d45d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantMachine.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantProgressLogger.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantProgressLogger.class deleted file mode 100644 index 2b861b0403c20..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantProgressLogger.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantShellTask.class b/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantShellTask.class deleted file mode 100644 index af2cd0920ee90..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/main/org/opensearch/gradle/vagrant/VagrantShellTask.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/ArchitectureTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/ArchitectureTests.class deleted file mode 100644 index 4294a56914d20..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/ArchitectureTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/BwcOpenSearchVersionsTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/BwcOpenSearchVersionsTests.class deleted file mode 100644 index 46dda882cf7e9..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/BwcOpenSearchVersionsTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/BwcVersionsTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/BwcVersionsTests.class deleted file mode 100644 index 2787d45bf54b4..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/BwcVersionsTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/ConcatFilesTaskTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/ConcatFilesTaskTests.class deleted file mode 100644 index 06280222177bb..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/ConcatFilesTaskTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/DistributionDownloadPluginTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/DistributionDownloadPluginTests.class deleted file mode 100644 index d7a258c2faf0f..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/DistributionDownloadPluginTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/EmptyDirTaskTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/EmptyDirTaskTests.class deleted file mode 100644 index 5ddf8ff4d2dbe..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/EmptyDirTaskTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/JdkDownloadPluginTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/JdkDownloadPluginTests.class deleted file mode 100644 index 8f3ba576309c5..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/JdkDownloadPluginTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/VersionTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/VersionTests.class deleted file mode 100644 index 3ea2cc9687c42..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/VersionTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/doc/RestTestFromSnippetsTaskTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/doc/RestTestFromSnippetsTaskTests.class deleted file mode 100644 index f4177c9bbc6e8..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/doc/RestTestFromSnippetsTaskTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/docker/DockerSupportServiceTests$1.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/docker/DockerSupportServiceTests$1.class deleted file mode 100644 index 21df36ec68b91..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/docker/DockerSupportServiceTests$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/docker/DockerSupportServiceTests$2.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/docker/DockerSupportServiceTests$2.class deleted file mode 100644 index 4c2a1f0b28bac..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/docker/DockerSupportServiceTests$2.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/docker/DockerSupportServiceTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/docker/DockerSupportServiceTests.class deleted file mode 100644 index 8bbee736af85d..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/docker/DockerSupportServiceTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/http/WaitForHttpResourceTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/http/WaitForHttpResourceTests.class deleted file mode 100644 index 7299e089e7b84..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/http/WaitForHttpResourceTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/plugin/PluginBuildPluginTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/plugin/PluginBuildPluginTests.class deleted file mode 100644 index f99a312289104..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/plugin/PluginBuildPluginTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/plugin/PluginPropertiesExtensionTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/plugin/PluginPropertiesExtensionTests.class deleted file mode 100644 index 590cd8ff5ee68..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/plugin/PluginPropertiesExtensionTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/DependencyLicensesTaskTests$1.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/DependencyLicensesTaskTests$1.class deleted file mode 100644 index 731121e0ac2ad..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/DependencyLicensesTaskTests$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/DependencyLicensesTaskTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/DependencyLicensesTaskTests.class deleted file mode 100644 index bd0937810de05..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/DependencyLicensesTaskTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/FilePermissionsTaskTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/FilePermissionsTaskTests.class deleted file mode 100644 index 97ebce65b1b68..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/FilePermissionsTaskTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/ForbiddenPatternsTaskTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/ForbiddenPatternsTaskTests.class deleted file mode 100644 index e31ea49f4271c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/ForbiddenPatternsTaskTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/UpdateShasTaskTests$1.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/UpdateShasTaskTests$1.class deleted file mode 100644 index ab6bc29475027..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/UpdateShasTaskTests$1.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/UpdateShasTaskTests.class b/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/UpdateShasTaskTests.class deleted file mode 100644 index 963a6327b5ac2..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/test/org/opensearch/gradle/precommit/UpdateShasTaskTests.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/BaseTestCase$ThrowingRunnable.class b/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/BaseTestCase$ThrowingRunnable.class deleted file mode 100644 index 724772363370c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/BaseTestCase$ThrowingRunnable.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/BaseTestCase.class b/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/BaseTestCase.class deleted file mode 100644 index af313446c68fa..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/BaseTestCase.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/GradleIntegrationTestCase.class b/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/GradleIntegrationTestCase.class deleted file mode 100644 index 9320949017637..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/GradleIntegrationTestCase.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/GradleThreadsFilter.class b/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/GradleThreadsFilter.class deleted file mode 100644 index 6511c439e4e29..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/GradleThreadsFilter.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/GradleUnitTestCase.class b/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/GradleUnitTestCase.class deleted file mode 100644 index 4dbd6c799c2fc..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/GradleUnitTestCase.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/JUnit3MethodProvider.class b/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/JUnit3MethodProvider.class deleted file mode 100644 index 2fe12d970266c..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/JUnit3MethodProvider.class and /dev/null differ diff --git a/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/TestClasspathUtils.class b/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/TestClasspathUtils.class deleted file mode 100644 index 1f4bf126d9f85..0000000000000 Binary files a/buildSrc/build-bootstrap/classes/java/testFixtures/org/opensearch/gradle/test/TestClasspathUtils.class and /dev/null differ diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle deleted file mode 100644 index 39ee079b5b6e6..0000000000000 --- a/buildSrc/build.gradle +++ /dev/null @@ -1,353 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.gradle.internal.jvm.Jvm -import org.gradle.util.GradleVersion - -plugins { - id 'java-gradle-plugin' - id 'groovy' - id 'java-test-fixtures' -} - -group = 'org.opensearch.gradle' - -String minimumGradleVersion = file('src/main/resources/minimumGradleVersion').text.trim() -if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) { - throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build opensearch") -} - -if (project == rootProject) { - // change the build dir used during build init, so that doing a clean - // won't wipe out the buildscript jar - buildDir = 'build-bootstrap' -} - -/***************************************************************************** - * Propagating version.properties to the rest of the build * - *****************************************************************************/ - -// we update the version property to reflect if we are building a snapshot or a release build -// we write this back out below to load it in the Build.java which will be shown in rest main action -// to indicate this being a snapshot build or a release build. -Properties props = VersionPropertiesLoader.loadBuildSrcVersion(project.file('version.properties')) -version = props.getProperty("opensearch") - -def generateVersionProperties = tasks.register("generateVersionProperties", WriteProperties) { - outputFile = "${buildDir}/version.properties" - comment = 'Generated version properties' - properties(props) -} - -processResources { - from(generateVersionProperties) -} - -/***************************************************************************** - * Java version * - *****************************************************************************/ - -if (JavaVersion.current() < JavaVersion.VERSION_11) { - throw new GradleException('At least Java 11 is required to build opensearch gradle tools') -} - -sourceSets { - integTest { - compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"] - runtimeClasspath += output + compileClasspath - } -} - -tasks.withType(JavaCompile).configureEach { - options.encoding = 'UTF-8' -} - -/***************************************************************************** - * Dependencies used by the entire build * - *****************************************************************************/ - -repositories { - mavenCentral() - gradlePluginPortal() -} - -dependencies { - - modules { - module("org.bouncycastle:bcprov-jdk15on") { - replacedBy("org.bouncycastle:bcprov-jdk15to18", "the jdk15on artifacts are not supported anymore") - } - module("org.bouncycastle:bcpkix-jdk15on") { - replacedBy("org.bouncycastle:bcpkix-jdk15to18", "the jdk15on artifacts are not supported anymore") - } - module("org.bouncycastle:bcpg-jdk15on") { - replacedBy("org.bouncycastle:bcpg-jdk15to18", "the jdk15on artifacts are not supported anymore") - } - module("org.bouncycastle:bcutil-jdk15on") { - replacedBy("org.bouncycastle:bcutil-jdk15to18", "the jdk15on artifacts are not supported anymore") - } - } - api localGroovy() - - api 'commons-codec:commons-codec:1.15' - api 'org.apache.commons:commons-compress:1.21' - api 'org.apache.ant:ant:1.10.12' - api 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3' - api 'com.netflix.nebula:nebula-publishing-plugin:4.7.0' - api("com.netflix.nebula:gradle-info-plugin:8.2.0") { - exclude module: 'jgit' - } - api 'org.eclipse.jgit:org.eclipse.jgit:6.8.0.202311291450-r' - api 'org.apache.rat:apache-rat:0.13' - api 'commons-io:commons-io:2.16.0' - api "net.java.dev.jna:jna:5.5.0" - api 'com.github.jengelman.gradle.plugins:shadow:6.0.0' - api 'de.thetaphi:forbiddenapis:3.2' - api 'com.avast.gradle:gradle-docker-compose-plugin:0.14.12' - api "org.yaml:snakeyaml:${props.getProperty('snakeyaml')}" - api 'org.apache.maven:maven-model:3.6.2' - api 'com.networknt:json-schema-validator:1.0.36' - api "com.fasterxml.jackson.core:jackson-databind:${props.getProperty('jackson_databind')}" - api "org.bouncycastle:bcprov-jdk15to18:${props.getProperty('bouncycastle')}" - api "org.bouncycastle:bcpkix-jdk15to18:${props.getProperty('bouncycastle')}" - api "org.bouncycastle:bcpg-jdk15to18:${props.getProperty('bouncycastle')}" - api "org.bouncycastle:bcutil-jdk15to18:${props.getProperty('bouncycastle')}" - - testFixturesApi "junit:junit:${props.getProperty('junit')}" - testFixturesApi "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}" - testFixturesApi gradleApi() - testFixturesApi gradleTestKit() - testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone:2.35.1' - testImplementation "org.mockito:mockito-core:${props.getProperty('mockito')}" - integTestImplementation('org.spockframework:spock-core:2.3-groovy-2.5') { - exclude module: "groovy" - } - constraints { - runtimeOnly("org.apache.logging.log4j:log4j-core:${props.getProperty('log4j')}") { - because 'log4j CVE' - } - runtimeOnly("org.jdom:jdom2:${props.getProperty('jdom2')}") { - because 'CVE-2021-33813 violation' - } - } -} - -configurations.all { - resolutionStrategy { - force "com.google.guava:guava:${props.getProperty('guava')}" - } -} - -/***************************************************************************** - * Bootstrap repositories * - *****************************************************************************/ -// this will only happen when buildSrc is built on its own during build init -if (project == rootProject) { - repositories { - if (System.getProperty("repos.mavenLocal") != null) { - mavenLocal() - } - } - dependencies { - // add this so the runtime classpath so Gradle will properly track it as a build runtime classpath input - runtimeOnly project('reaper') - } - // only run tests as build-tools - test.enabled = false -} - -/***************************************************************************** - * Normal project checks * - *****************************************************************************/ - -// this happens when included as a normal project in the build, which we do -// to enforce precommit checks like forbidden apis, as well as setup publishing -if (project != rootProject) { - apply plugin: 'opensearch.build' - apply plugin: 'opensearch.publish' - - allprojects { - targetCompatibility = 8 - sourceCompatibility = 8 - } - - // groovydoc succeeds, but has some weird internal exception... - groovydoc.enabled = false - - // build-tools is not ready for primetime with these... - tasks.named("dependencyLicenses").configure { it.enabled = false } - dependenciesInfo.enabled = false - disableTasks('forbiddenApisMain', 'forbiddenApisTest', 'forbiddenApisIntegTest', 'forbiddenApisTestFixtures') - jarHell.enabled = false - thirdPartyAudit.enabled = false - if (org.opensearch.gradle.info.BuildParams.inFipsJvm) { - // We don't support running gradle with a JVM that is in FIPS 140 mode, so we don't test it. - // WaitForHttpResourceTests tests would fail as they use JKS/PKCS12 keystores - test.enabled = false - testingConventions.enabled = false - } - - configurations.register("distribution") - configurations.register("reaper") - - dependencies { - reaper project('reaper') - distribution project(':distribution:archives:darwin-tar') - distribution project(':distribution:archives:linux-arm64-tar') - distribution project(':distribution:archives:linux-tar') - distribution project(':distribution:archives:windows-zip') - - integTestRuntimeOnly(project(":libs:opensearch-core")) - } - - // for external projects we want to remove the marker file indicating we are running the OpenSearch project - processResources { - exclude 'buildSrc.marker' - into('META-INF') { - from configurations.reaper - } - } - - // Track reaper jar as a test input using runtime classpath normalization strategy - tasks.withType(Test).configureEach { - inputs.files(configurations.reaper).withNormalizer(ClasspathNormalizer) - } - - normalization { - runtimeClasspath { - // We already include the reaper jar as part of our runtime classpath. Ignore the copy in META-INF. - ignore('META-INF/reaper.jar') - } - } - - forbiddenPatterns { - exclude '**/*.wav' - exclude '**/*.p12' - exclude '**/*.jks' - exclude '**/*.crt' - // the file that actually defines nocommit - exclude '**/ForbiddenPatternsTask.java' - exclude '**/*.bcfks' - } - - testingConventions { - naming.clear() - naming { - Tests { - baseClass 'org.opensearch.gradle.test.GradleUnitTestCase' - } - IT { - baseClass 'org.opensearch.gradle.test.GradleIntegrationTestCase' - } - } - } - - // disable fail-on-warnings for this specific task which trips Java 11 bug - // https://bugs.openjdk.java.net/browse/JDK-8209058 - tasks.named("compileTestFixturesJava").configure { - options.compilerArgs -= '-Werror' - } - - tasks.register("integTest", Test) { - inputs.dir(file("src/testKit")).withPropertyName("testkit dir").withPathSensitivity(PathSensitivity.RELATIVE) - systemProperty 'test.version_under_test', version - onlyIf { org.opensearch.gradle.info.BuildParams.inFipsJvm == false } - maxParallelForks = System.getProperty('tests.jvms', org.opensearch.gradle.info.BuildParams.defaultParallel.toString()) as Integer - testClassesDirs = sourceSets.integTest.output.classesDirs - classpath = sourceSets.integTest.runtimeClasspath - } - check.dependsOn("integTest") - - // for now we hardcode the tests for our build to use the gradle jvm. - tasks.withType(Test).configureEach { - it.executable = Jvm.current().getJavaExecutable() - } - - /* - * We already configure publication and we don't need or want this one that - * comes from the java-gradle-plugin. - */ - afterEvaluate { - generatePomFileForPluginMavenPublication.enabled = false - } - - publishing.publications.named("nebula").configure { - suppressPomMetadataWarningsFor("testFixturesApiElements") - suppressPomMetadataWarningsFor("testFixturesRuntimeElements") - } -} - -// Define this here because we need it early. -class VersionPropertiesLoader { - static Properties loadBuildSrcVersion(File input) throws IOException { - Properties props = new Properties(); - InputStream is = new FileInputStream(input) - try { - props.load(is) - } finally { - is.close() - } - loadBuildSrcVersion(props, System.getProperties()) - return props - } - - protected static void loadBuildSrcVersion(Properties loadedProps, Properties systemProperties) { - String opensearch = loadedProps.getProperty("opensearch") - if (opensearch == null) { - throw new IllegalStateException("OpenSearch version is missing from properties.") - } - if (opensearch.matches("[0-9]+\\.[0-9]+\\.[0-9]+") == false) { - throw new IllegalStateException( - "Expected opensearch version to be numbers only of the form X.Y.Z but it was: " + - opensearch - ) - } - String qualifier = systemProperties.getProperty("build.version_qualifier", ""); - if (qualifier.isEmpty() == false) { - if (qualifier.matches("(alpha|beta|rc)\\d+") == false) { - throw new IllegalStateException("Invalid qualifier: " + qualifier) - } - opensearch += "-" + qualifier - } - final String buildSnapshotSystemProperty = systemProperties.getProperty("build.snapshot", "true"); - switch (buildSnapshotSystemProperty) { - case "true": - opensearch += "-SNAPSHOT" - break; - case "false": - // do nothing - break; - default: - throw new IllegalArgumentException( - "build.snapshot was set to [" + buildSnapshotSystemProperty + "] but can only be unset or [true|false]"); - } - loadedProps.put("opensearch", opensearch) - } -} diff --git a/buildSrc/formatterConfig.xml b/buildSrc/formatterConfig.xml deleted file mode 100644 index 713e55274d93e..0000000000000 --- a/buildSrc/formatterConfig.xml +++ /dev/null @@ -1,362 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/buildSrc/reaper/build.gradle b/buildSrc/reaper/build.gradle deleted file mode 100644 index d5e8d6ebc7099..0000000000000 --- a/buildSrc/reaper/build.gradle +++ /dev/null @@ -1,19 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -apply plugin: 'java' - -jar { - archiveFileName = "${project.name}.jar" - manifest { - attributes 'Main-Class': 'org.opensearch.gradle.reaper.Reaper' - } -} diff --git a/buildSrc/reaper/src/main/java/org/opensearch/gradle/reaper/Reaper.java b/buildSrc/reaper/src/main/java/org/opensearch/gradle/reaper/Reaper.java deleted file mode 100644 index c5b4de157c75c..0000000000000 --- a/buildSrc/reaper/src/main/java/org/opensearch/gradle/reaper/Reaper.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.reaper; - -import java.io.Closeable; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * A standalone process that will reap external services after a build dies. - * - *

Input

- * Since how to reap a given service is platform and service dependent, this tool - * operates on system commands to execute. It takes a single argument, a directory - * that will contain files with reaping commands. Each line in each file will be - * executed with {@link Runtime#exec(String)}. - * - * The main method will wait indefinitely on the parent process (Gradle) by - * reading from stdin. When Gradle shuts down, whether normally or abruptly, the - * pipe will be broken and read will return. - * - * The reaper will then iterate over the files in the configured directory, - * and execute the given commands. If any commands fail, a failure message is - * written to stderr. Otherwise, the input file will be deleted. If no inputs - * produced errors, the entire input directory is deleted upon completion of reaping. - */ -public class Reaper implements Closeable { - - private Path inputDir; - private boolean failed; - - private Reaper(Path inputDir) { - this.inputDir = inputDir; - this.failed = false; - } - - public static void main(String[] args) throws Exception { - if (args.length != 1) { - System.err.println("Expected one argument.\nUsage: java -jar reaper.jar "); - System.exit(1); - } - Path inputDir = Paths.get(args[0]); - - try (Reaper reaper = new Reaper(inputDir)) { - System.in.read(); - reaper.reap(); - } - } - - private void reap() { - try (Stream stream = Files.list(inputDir)) { - final List inputFiles = stream.filter(p -> p.getFileName().toString().endsWith(".cmd")).collect(Collectors.toList()); - - for (Path inputFile : inputFiles) { - System.out.println("Process file: " + inputFile); - String line = Files.readString(inputFile); - System.out.println("Running command: " + line); - String[] command = line.split(" "); - Process process = Runtime.getRuntime().exec(command); - int ret = process.waitFor(); - - System.out.print("Stdout: "); - process.getInputStream().transferTo(System.out); - System.out.print("\nStderr: "); - process.getErrorStream().transferTo(System.out); - System.out.println(); // end the stream - if (ret != 0) { - logFailure("Command [" + line + "] failed with exit code " + ret, null); - } else { - delete(inputFile); - } - } - } catch (Exception e) { - logFailure("Failed to reap inputs", e); - } - } - - private void logFailure(String message, Exception e) { - System.err.println(message); - if (e != null) { - e.printStackTrace(System.err); - } - failed = true; - } - - private void delete(Path toDelete) { - try { - Files.delete(toDelete); - } catch (IOException e) { - logFailure("Failed to delete [" + toDelete + "]", e); - } - } - - @Override - public void close() { - if (failed == false) { - try (Stream stream = Files.walk(inputDir)) { - stream.sorted(Comparator.reverseOrder()).forEach(this::delete); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - } -} diff --git a/buildSrc/settings.gradle b/buildSrc/settings.gradle deleted file mode 100644 index 963177afaa2de..0000000000000 --- a/buildSrc/settings.gradle +++ /dev/null @@ -1,12 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -include 'reaper' diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/DistributionDownloadPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/DistributionDownloadPluginFuncTest.groovy deleted file mode 100644 index d49c85f0f0e17..0000000000000 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/DistributionDownloadPluginFuncTest.groovy +++ /dev/null @@ -1,169 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle - - -import org.opensearch.gradle.fixtures.AbstractGradleFuncTest -import org.opensearch.gradle.transform.SymbolicLinkPreservingUntarTransform -import org.gradle.testkit.runner.TaskOutcome -import spock.lang.Unroll - -import static org.opensearch.gradle.fixtures.DistributionDownloadFixture.withMockedDistributionDownload - -class DistributionDownloadPluginFuncTest extends AbstractGradleFuncTest { - - @Unroll - def "#distType version can be resolved"() { - given: - buildFile << applyPluginAndSetupDistro(version, platform) - - when: - def result = withMockedDistributionDownload(version, platform, gradleRunner('setupDistro', '-i')) { - build() - } - - then: - result.task(":setupDistro").outcome == TaskOutcome.SUCCESS - assertExtractedDistroCreated("build/distro") - - where: - version | platform | distType - VersionProperties.getOpenSearch() | OpenSearchDistribution.Platform.LINUX | "current" - "8.1.0-SNAPSHOT" | OpenSearchDistribution.Platform.LINUX | "bwc" - "7.0.0" | OpenSearchDistribution.Platform.WINDOWS | "released" - } - - - def "transformed versions are kept across builds"() { - given: - def version = VersionProperties.getOpenSearch() - def platform = OpenSearchDistribution.Platform.LINUX - - buildFile << applyPluginAndSetupDistro(version, platform) - buildFile << """ - apply plugin:'base' - """ - - when: - def runner = gradleRunner('clean', 'setupDistro', '-i') - def result = withMockedDistributionDownload(version, platform, runner) { - // initial run - build() - // 2nd invocation - build() - } - - then: - result.task(":setupDistro").outcome == TaskOutcome.SUCCESS - assertOutputContains(result.output, "Skipping ${SymbolicLinkPreservingUntarTransform.class.simpleName}") - } - - def "transforms are reused across projects"() { - given: - def version = VersionProperties.getOpenSearch() - def platform = OpenSearchDistribution.Platform.LINUX - - 3.times { - settingsFile << """ - include ':sub-$it' - """ - } - buildFile.text = """ - import org.opensearch.gradle.Architecture - - plugins { - id 'opensearch.distribution-download' - } - - subprojects { - apply plugin: 'opensearch.distribution-download' - - ${setupTestDistro(version, platform)} - ${setupDistroTask()} - } - """ - - when: - def customGradleUserHome = testProjectDir.newFolder().absolutePath; - def runner = gradleRunner('setupDistro', '-i', '-g', customGradleUserHome) - def result = withMockedDistributionDownload(version, platform, runner) { - build() - } - - then: - result.tasks.size() == 3 - result.output.count("Unpacking opensearch-${version}-linux-x64.tar.gz " + - "using SymbolicLinkPreservingUntarTransform.") == 1 - } - - private boolean assertExtractedDistroCreated(String relativePath) { - File distroExtracted = new File(testProjectDir.root, relativePath) - assert distroExtracted.exists() - assert distroExtracted.isDirectory() - assert new File(distroExtracted, "opensearch-1.2.3/bin/opensearch").exists() - true - } - - private static String applyPluginAndSetupDistro(String version, OpenSearchDistribution.Platform platform) { - """ - import org.opensearch.gradle.Architecture - - plugins { - id 'opensearch.distribution-download' - } - - ${setupTestDistro(version, platform)} - ${setupDistroTask()} - - """ - } - - private static String setupTestDistro(String version, OpenSearchDistribution.Platform platform) { - return """ - opensearch_distributions { - test_distro { - version = "$version" - type = "archive" - platform = "$platform" - architecture = Architecture.current(); - } - } - """ - } - - private static String setupDistroTask() { - return """ - tasks.register("setupDistro", Sync) { - from(opensearch_distributions.test_distro.extracted) - into("build/distro") - } - """ - } -} diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/JdkDownloadPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/JdkDownloadPluginFuncTest.groovy deleted file mode 100644 index 160e7805b3648..0000000000000 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/JdkDownloadPluginFuncTest.groovy +++ /dev/null @@ -1,253 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle - -import com.github.tomakehurst.wiremock.WireMockServer -import org.opensearch.gradle.fixtures.AbstractGradleFuncTest -import org.opensearch.gradle.transform.SymbolicLinkPreservingUntarTransform -import org.opensearch.gradle.transform.UnzipTransform -import org.opensearch.gradle.fixtures.WiremockFixture -import spock.lang.Unroll - -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths -import java.util.regex.Matcher -import java.util.regex.Pattern - -import static JdkDownloadPlugin.VENDOR_ADOPTOPENJDK -import static JdkDownloadPlugin.VENDOR_OPENJDK - -class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest { - - private static final String OPENJDK_VERSION_OLD = "1+99" - private static final String ADOPT_JDK_VERSION = "12.0.2+10" - private static final String OPEN_JDK_VERSION = "12.0.1+99@123456789123456789123456789abcde" - private static final Pattern JDK_HOME_LOGLINE = Pattern.compile("JDK HOME: (.*)"); - - @Unroll - def "jdk #jdkVendor for #platform#suffix are downloaded and extracted"() { - given: - def mockRepoUrl = urlPath(jdkVendor, jdkVersion, platform); - def mockedContent = filebytes(jdkVendor, platform) - buildFile.text = """ - plugins { - id 'opensearch.jdk-download' - } - - jdks { - myJdk { - vendor = '$jdkVendor' - version = '$jdkVersion' - platform = "$platform" - architecture = "x64" - } - } - - tasks.register("getJdk") { - dependsOn jdks.myJdk - doLast { - println "JDK HOME: " + jdks.myJdk - } - } - """ - - when: - def result = WiremockFixture.withWireMock(mockRepoUrl, mockedContent) { server -> - buildFile << repositoryMockSetup(server, jdkVendor, jdkVersion) - gradleRunner("getJdk").build() - } - - then: - assertExtraction(result.output, expectedJavaBin); - - where: - platform | jdkVendor | jdkVersion | expectedJavaBin | suffix - "linux" | VENDOR_ADOPTOPENJDK | ADOPT_JDK_VERSION | "bin/java" | "" - "linux" | VENDOR_OPENJDK | OPEN_JDK_VERSION | "bin/java" | "" - "linux" | VENDOR_OPENJDK | OPENJDK_VERSION_OLD | "bin/java" | "(old version)" - "windows" | VENDOR_ADOPTOPENJDK | ADOPT_JDK_VERSION | "bin/java" | "" - "windows" | VENDOR_OPENJDK | OPEN_JDK_VERSION | "bin/java" | "" - "windows" | VENDOR_OPENJDK | OPENJDK_VERSION_OLD | "bin/java" | "(old version)" - "darwin" | VENDOR_ADOPTOPENJDK | ADOPT_JDK_VERSION | "Contents/Home/bin/java" | "" - "darwin" | VENDOR_OPENJDK | OPEN_JDK_VERSION | "Contents/Home/bin/java" | "" - "darwin" | VENDOR_OPENJDK | OPENJDK_VERSION_OLD | "Contents/Home/bin/java" | "(old version)" - "mac" | VENDOR_OPENJDK | OPEN_JDK_VERSION | "Contents/Home/bin/java" | "" - "mac" | VENDOR_OPENJDK | OPENJDK_VERSION_OLD | "Contents/Home/bin/java" | "(old version)" - } - - def "transforms are reused across projects"() { - given: - def mockRepoUrl = urlPath(jdkVendor, jdkVersion, platform) - def mockedContent = filebytes(jdkVendor, platform) - 3.times { - settingsFile << """ - include ':sub-$it' - """ - } - buildFile.text = """ - plugins { - id 'opensearch.jdk-download' apply false - } - - subprojects { - apply plugin: 'opensearch.jdk-download' - - jdks { - myJdk { - vendor = '$jdkVendor' - version = '$jdkVersion' - platform = "$platform" - architecture = "x64" - } - } - tasks.register("getJdk") { - dependsOn jdks.myJdk - doLast { - println "JDK HOME: " + jdks.myJdk - } - } - } - """ - - when: - def result = WiremockFixture.withWireMock(mockRepoUrl, mockedContent) { server -> - buildFile << repositoryMockSetup(server, jdkVendor, jdkVersion) - gradleRunner('getJdk', '-i', '-g', testProjectDir.newFolder().toString()).build() - } - - then: - result.tasks.size() == 3 - result.output.count("Unpacking linux-12.0.2-x64.tar.gz using ${SymbolicLinkPreservingUntarTransform.simpleName}.") == 1 - - where: - platform | jdkVendor | jdkVersion | expectedJavaBin - "linux" | VENDOR_ADOPTOPENJDK | ADOPT_JDK_VERSION | "bin/java" - } - - @Unroll - def "transforms of type #transformType are kept across builds"() { - given: - def mockRepoUrl = urlPath(VENDOR_ADOPTOPENJDK, ADOPT_JDK_VERSION, platform) - def mockedContent = filebytes(VENDOR_ADOPTOPENJDK, platform) - buildFile.text = """ - plugins { - id 'opensearch.jdk-download' - } - apply plugin: 'base' - apply plugin: 'opensearch.jdk-download' - - jdks { - myJdk { - vendor = '$VENDOR_ADOPTOPENJDK' - version = '$ADOPT_JDK_VERSION' - platform = "$platform" - architecture = "x64" - } - } - - tasks.register("getJdk") { - dependsOn jdks.myJdk - doLast { - println "JDK HOME: " + jdks.myJdk - } - } - """ - - when: - def result = WiremockFixture.withWireMock(mockRepoUrl, mockedContent) { server -> - buildFile << repositoryMockSetup(server, VENDOR_ADOPTOPENJDK, ADOPT_JDK_VERSION) - - def commonGradleUserHome = testProjectDir.newFolder().toString() - // initial run - gradleRunner('clean', 'getJdk', '-g', commonGradleUserHome).build() - // run against up-to-date transformations - gradleRunner('clean', 'getJdk', '-i', '-g', commonGradleUserHome).build() - } - - then: - assertOutputContains(result.output, "Skipping $transformType") - - where: - platform | transformType - "linux" | SymbolicLinkPreservingUntarTransform.class.simpleName - "windows" | UnzipTransform.class.simpleName - } - - static boolean assertExtraction(String output, String javaBin) { - Matcher matcher = JDK_HOME_LOGLINE.matcher(output); - assert matcher.find() == true; - String jdkHome = matcher.group(1); - Path javaPath = Paths.get(jdkHome, javaBin); - assert Files.exists(javaPath) == true; - true - } - - private static String urlPath(final String vendor, final String version, final String platform) { - if (vendor.equals(VENDOR_ADOPTOPENJDK)) { - final String module = isMac(platform) ? "mac" : platform; - return "/jdk-12.0.2+10/" + module + "/x64/jdk/hotspot/normal/adoptopenjdk"; - } else if (vendor.equals(VENDOR_OPENJDK)) { - final String effectivePlatform = isMac(platform) ? "osx" : platform; - final boolean isOld = version.equals(OPENJDK_VERSION_OLD); - final String versionPath = isOld ? "jdk1/99" : "jdk12.0.1/123456789123456789123456789abcde/99"; - final String filename = "openjdk-" + (isOld ? "1" : "12.0.1") + "_" + effectivePlatform + "-x64_bin." + extension(platform); - return "/java/GA/" + versionPath + "/GPL/" + filename; - } - } - - private static byte[] filebytes(final String vendor, final String platform) throws IOException { - final String effectivePlatform = isMac(platform) ? "osx" : platform; - if (vendor.equals(VENDOR_ADOPTOPENJDK)) { - return JdkDownloadPluginFuncTest.class.getResourceAsStream("fake_adoptopenjdk_" + effectivePlatform + "." + extension(platform)).getBytes() - } else if (vendor.equals(VENDOR_OPENJDK)) { - JdkDownloadPluginFuncTest.class.getResourceAsStream("fake_openjdk_" + effectivePlatform + "." + extension(platform)).getBytes() - } - } - - private static boolean isMac(String platform) { - platform.equals("darwin") || platform.equals("mac") - } - - private static String extension(String platform) { - platform.equals("windows") ? "zip" : "tar.gz"; - } - - private static String repositoryMockSetup(WireMockServer server, String jdkVendor, String jdkVersion) { - """allprojects{ p -> - // wire the jdk repo to wiremock - p.repositories.all { repo -> - if(repo.name == "jdk_repo_${jdkVendor}_${jdkVersion}") { - repo.setUrl('${server.baseUrl()}') - } - } - }""" - } -} diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/OpenSearchJavaPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/OpenSearchJavaPluginFuncTest.groovy deleted file mode 100644 index cd2a9523699fc..0000000000000 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/OpenSearchJavaPluginFuncTest.groovy +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle - -import org.opensearch.gradle.fixtures.AbstractGradleFuncTest - -class OpenSearchJavaPluginFuncTest extends AbstractGradleFuncTest { - - def "compatibility options are resolved from from build params minimum runtime version"() { - when: - buildFile.text = """ - plugins { - id 'opensearch.global-build-info' - } - import org.opensearch.gradle.Architecture - import org.opensearch.gradle.info.BuildParams - BuildParams.init { it.setMinimumRuntimeVersion(JavaVersion.VERSION_1_10) } - - apply plugin:'opensearch.java' - - assert compileJava.sourceCompatibility == JavaVersion.VERSION_1_10.toString() - assert compileJava.targetCompatibility == JavaVersion.VERSION_1_10.toString() - """ - - then: - gradleRunner("help").build() - } - - def "compile option --release is configured from targetCompatibility"() { - when: - buildFile.text = """ - plugins { - id 'opensearch.java' - } - - compileJava.targetCompatibility = "1.10" - afterEvaluate { - assert compileJava.options.release.get() == 10 - } - """ - then: - gradleRunner("help").build() - } - - private File someJavaSource() { - file("src/main/java/org/acme/SomeClass.java") << """ - package org.acme; - public class SomeClass {} - """ - } -} diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/OpenSearchTestBasePluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/OpenSearchTestBasePluginFuncTest.groovy deleted file mode 100644 index fb61bbded5e09..0000000000000 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/OpenSearchTestBasePluginFuncTest.groovy +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle - -import org.opensearch.gradle.fixtures.AbstractGradleFuncTest -import org.gradle.testkit.runner.TaskOutcome - -class OpenSearchTestBasePluginFuncTest extends AbstractGradleFuncTest { - - def "can configure nonInputProperties for test tasks"() { - given: - file("src/test/java/acme/SomeTests.java").text = """ - - public class SomeTests { - @org.junit.Test - public void testSysInput() { - org.junit.Assert.assertEquals("bar", System.getProperty("foo")); - } - } - - """ - buildFile.text = """ - plugins { - id 'java' - id 'opensearch.test-base' - } - - repositories { - mavenCentral() - } - - dependencies { - testImplementation 'junit:junit:4.13.1' - } - - tasks.named('test').configure { - nonInputProperties.systemProperty("foo", project.getProperty('foo')) - } - """ - - when: - def result = gradleRunner("test", '-Dtests.seed=default', '-Pfoo=bar').build() - - then: - result.task(':test').outcome == TaskOutcome.SUCCESS - - when: - result = gradleRunner("test", '-i', '-Dtests.seed=default', '-Pfoo=baz').build() - - then: - result.task(':test').outcome == TaskOutcome.UP_TO_DATE - } -} diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/TestClustersPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/TestClustersPluginFuncTest.groovy deleted file mode 100644 index ad948191e43a6..0000000000000 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/TestClustersPluginFuncTest.groovy +++ /dev/null @@ -1,131 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle - -import org.opensearch.gradle.fixtures.AbstractGradleFuncTest -import spock.lang.IgnoreIf - -import static org.opensearch.gradle.fixtures.DistributionDownloadFixture.withMockedDistributionDownload - -/** - * We do not have coverage for the test cluster startup on windows yet. - * One step at a time... - * */ -@IgnoreIf({ os.isWindows() }) -class TestClustersPluginFuncTest extends AbstractGradleFuncTest { - - def setup() { - buildFile << """ - import org.opensearch.gradle.testclusters.DefaultTestClustersTask - plugins { - id 'opensearch.testclusters' - } - - class SomeClusterAwareTask extends DefaultTestClustersTask { - @TaskAction void doSomething() { - println 'SomeClusterAwareTask executed' - } - } - """ - } - - def "test cluster distribution is configured and started"() { - given: - buildFile << """ - testClusters { - myCluster { - testDistribution = 'archive' - } - } - - tasks.register('myTask', SomeClusterAwareTask) { - useCluster testClusters.myCluster - } - """ - - when: - def result = withMockedDistributionDownload(gradleRunner("myTask", '-i')) { - build() - } - - then: - result.output.contains("opensearch-keystore script executed!") - assertOpenSearchStdoutContains("myCluster", "Starting OpenSearch process") - assertOpenSearchStdoutContains("myCluster", "Stopping node") - assertNoCustomDistro('myCluster') - } - - def "custom distro folder created for tweaked cluster distribution"() { - given: - buildFile << """ - testClusters { - myCluster { - testDistribution = 'archive' - extraJarFile(file('${someJar().absolutePath}')) - } - } - - tasks.register('myTask', SomeClusterAwareTask) { - useCluster testClusters.myCluster - } - """ - - when: - def result = withMockedDistributionDownload(gradleRunner("myTask", '-i')) { - build() - } - - then: - result.output.contains("opensearch-keystore script executed!") - assertOpenSearchStdoutContains("myCluster", "Starting OpenSearch process") - assertOpenSearchStdoutContains("myCluster", "Stopping node") - assertCustomDistro('myCluster') - } - - boolean assertOpenSearchStdoutContains(String testCluster, String expectedOutput) { - assert new File(testProjectDir.root, - "build/testclusters/${testCluster}-0/logs/opensearch.stdout.log").text.contains(expectedOutput) - true - } - - boolean assertCustomDistro(String clusterName) { - assert customDistroFolder(clusterName).exists() - true - } - - boolean assertNoCustomDistro(String clusterName) { - assert !customDistroFolder(clusterName).exists() - true - } - - private File customDistroFolder(String clusterName) { - new File(testProjectDir.root, "build/testclusters/${clusterName}-0/distro") - } -} diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/fixtures/AbstractGradleFuncTest.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/fixtures/AbstractGradleFuncTest.groovy deleted file mode 100644 index 6443bff93a892..0000000000000 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/fixtures/AbstractGradleFuncTest.groovy +++ /dev/null @@ -1,141 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle.fixtures - -import org.gradle.testkit.runner.GradleRunner -import org.junit.Rule -import org.junit.rules.TemporaryFolder -import spock.lang.Specification - -import java.lang.management.ManagementFactory -import java.util.jar.JarEntry -import java.util.jar.JarOutputStream - -abstract class AbstractGradleFuncTest extends Specification { - - @Rule - TemporaryFolder testProjectDir = new TemporaryFolder() - - File settingsFile - File buildFile - - def setup() { - settingsFile = testProjectDir.newFile('settings.gradle') - settingsFile << "rootProject.name = 'hello-world'\n" - buildFile = testProjectDir.newFile('build.gradle') - } - - GradleRunner gradleRunner(String... arguments) { - return gradleRunner(testProjectDir.root, arguments) - } - - GradleRunner gradleRunner(File projectDir, String... arguments) { - GradleRunner.create() - .withDebug(ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("-agentlib:jdwp") > 0) - .withProjectDir(projectDir) - .withArguments(arguments) - .withPluginClasspath() - .forwardOutput() - } - - def assertOutputContains(String givenOutput, String expected) { - assert normalizedOutput(givenOutput).contains(normalizedOutput(expected)) - true - } - - String normalizedOutput(String input) { - String normalizedPathPrefix = testProjectDir.root.canonicalPath.replace('\\', '/') - return input.readLines() - .collect { it.replace('\\', '/') } - .collect {it.replace(normalizedPathPrefix , '.') } - .join("\n") - } - - File file(String path) { - File newFile = new File(testProjectDir.root, path) - newFile.getParentFile().mkdirs() - newFile - } - - File someJar(String fileName = 'some.jar') { - File jarFolder = new File(testProjectDir.root, "jars"); - jarFolder.mkdirs() - File jarFile = new File(jarFolder, fileName) - JarEntry entry = new JarEntry("foo.txt"); - - jarFile.withOutputStream { - JarOutputStream target = new JarOutputStream(it) - target.putNextEntry(entry); - target.closeEntry(); - target.close(); - } - - return jarFile; - } - - File internalBuild(File buildScript = buildFile) { - buildScript << """plugins { - id 'opensearch.global-build-info' - } - import org.opensearch.gradle.Architecture - import org.opensearch.gradle.info.BuildParams - - BuildParams.init { it.setIsInternal(true) } - - import org.opensearch.gradle.BwcVersions - import org.opensearch.gradle.Version - - Version currentVersion = Version.fromString("9.0.0") - BwcVersions versions = new BwcVersions(new TreeSet<>( - Arrays.asList(Version.fromString("8.0.0"), Version.fromString("8.0.1"), Version.fromString("8.1.0"), currentVersion)), - currentVersion) - - BuildParams.init { it.setBwcVersions(versions) } - """ - } - - void setupLocalGitRepo() { - //TODO: cleanup - execute("git init") - execute('git config user.email "build-tool@opensearch.org"') - execute('git config user.name "Build tool"') - execute("git add .") - execute('git commit -m "Initial"') - } - - void execute(String command, File workingDir = testProjectDir.root) { - def proc = command.execute(Collections.emptyList(), workingDir) - proc.waitFor() - if(proc.exitValue()) { - println "Error running command ${command}:" - println "Syserr: " + proc.errorStream.text - } - } -} diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/fixtures/DistributionDownloadFixture.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/fixtures/DistributionDownloadFixture.groovy deleted file mode 100644 index d99a01e2b8398..0000000000000 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/fixtures/DistributionDownloadFixture.groovy +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle.fixtures - - -import org.opensearch.gradle.OpenSearchDistribution -import org.opensearch.gradle.Version -import org.opensearch.gradle.VersionProperties -import org.gradle.testkit.runner.BuildResult -import org.gradle.testkit.runner.GradleRunner - -class DistributionDownloadFixture { - - public static final String INIT_SCRIPT = "repositories-init.gradle" - - static BuildResult withMockedDistributionDownload(GradleRunner gradleRunner, Closure buildRunClosure) { - return withMockedDistributionDownload(VersionProperties.getOpenSearch(), OpenSearchDistribution.CURRENT_PLATFORM, - gradleRunner, buildRunClosure) - } - - static BuildResult withMockedDistributionDownload(String version, OpenSearchDistribution.Platform platform, - GradleRunner gradleRunner, Closure buildRunClosure) { - String urlPath = urlPath(version, platform); - return WiremockFixture.withWireMock(urlPath, filebytes(urlPath)) { server -> - File initFile = new File(gradleRunner.getProjectDir(), INIT_SCRIPT) - initFile.text = """allprojects { p -> - p.repositories.all { repo -> - repo.allowInsecureProtocol = true - repo.setUrl('${server.baseUrl()}') - } - }""" - List givenArguments = gradleRunner.getArguments() - GradleRunner effectiveRunner = gradleRunner.withArguments(givenArguments + ['-I', initFile.getAbsolutePath()]) - buildRunClosure.delegate = effectiveRunner - return buildRunClosure.call(effectiveRunner) - } - } - - private static String urlPath(String version, OpenSearchDistribution.Platform platform) { - String fileType = ((platform == OpenSearchDistribution.Platform.LINUX || - platform == OpenSearchDistribution.Platform.DARWIN)) ? "tar.gz" : "zip" - if (Version.fromString(version).onOrAfter(Version.fromString("1.0.0"))) { - if (version.contains("SNAPSHOT")) { - return "/snapshots/core/opensearch/${version}/opensearch-min-${version}-${platform}-x64-latest.$fileType" - } - return "/releases/core/opensearch/${version}/opensearch-min-${version}-${platform}-x64.$fileType" - } else { - return "/downloads/elasticsearch/elasticsearch-oss-${version}-${platform}-x86_64.$fileType" - } - } - - private static byte[] filebytes(String urlPath) throws IOException { - String suffix = urlPath.endsWith("zip") ? "zip" : "tar.gz"; - return DistributionDownloadFixture.getResourceAsStream("/org/opensearch/gradle/fake_opensearch." + suffix).getBytes() - } -} diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/fixtures/WiremockFixture.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/fixtures/WiremockFixture.groovy deleted file mode 100644 index 453b2111697e8..0000000000000 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/fixtures/WiremockFixture.groovy +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle.fixtures - -import com.github.tomakehurst.wiremock.WireMockServer -import org.gradle.testkit.runner.BuildResult - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse -import static com.github.tomakehurst.wiremock.client.WireMock.get -import static com.github.tomakehurst.wiremock.client.WireMock.head -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo - -/** - * A test fixture that allows running testkit builds with wiremock - * */ -class WiremockFixture { - - /** - * the buildRunClosure has passed an instance of WireMockServer that can be used to access e.g. the baseUrl of - * the configured server: - * - *
-     *  WiremockFixture.withWireMock(mockRepoUrl, mockedContent) { server ->
-     *      buildFile << """
-     *          // wire a gradle repository with wiremock
-*               repositories {
-     *              maven {
-     *                 url = '${server.baseUrl()}'
-     *              }
-     *          }
-     *      }
-     *      gadleRunner('myTask').build()
-     * 
- * */ - static BuildResult withWireMock(String expectedUrl, byte[] expectedContent, Closure buildRunClosure) { - WireMockServer wireMock = new WireMockServer(0); - try { - wireMock.stubFor(head(urlEqualTo(expectedUrl)).willReturn(aResponse().withStatus(200))); - wireMock.stubFor( - get(urlEqualTo(expectedUrl)).willReturn(aResponse().withStatus(200).withBody(expectedContent)) - ) - wireMock.start(); - return buildRunClosure.call(wireMock); - } catch (Exception e) { - // for debugging - System.err.println("missed requests: " + wireMock.findUnmatchedRequests().getRequests()); - throw e; - } finally { - wireMock.stop(); - } - } - -} diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalBwcGitPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalBwcGitPluginFuncTest.groovy deleted file mode 100644 index 8451ec2418e6d..0000000000000 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalBwcGitPluginFuncTest.groovy +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle.internal - -import org.opensearch.gradle.fixtures.AbstractGradleFuncTest -import org.gradle.testkit.runner.TaskOutcome - -class InternalBwcGitPluginFuncTest extends AbstractGradleFuncTest { - - def setup() { - setupLocalGitRepo() - } - - def "current repository can be cloned"() { - given: - internalBuild(); - buildFile << """ - import org.opensearch.gradle.Version; - apply plugin: org.opensearch.gradle.internal.InternalBwcGitPlugin - - bwcGitConfig { - bwcVersion = project.provider { Version.fromString("7.10.0") } - bwcBranch = project.provider { "7.x" } - checkoutDir = project.provider{file("build/checkout")} - } - """ - when: - def result = gradleRunner("createClone", '--stacktrace').build() - then: - result.task(":createClone").outcome == TaskOutcome.SUCCESS - file("build/checkout/build.gradle").exists() - file("build/checkout/settings.gradle").exists() - } -} diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPluginFuncTest.groovy deleted file mode 100644 index 94a840fbbfade..0000000000000 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPluginFuncTest.groovy +++ /dev/null @@ -1,137 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle.internal - -import org.gradle.internal.os.OperatingSystem -import org.opensearch.gradle.VersionProperties -import org.opensearch.gradle.fixtures.AbstractGradleFuncTest -import org.gradle.testkit.runner.TaskOutcome -import spock.lang.Unroll - -class InternalDistributionArchiveCheckPluginFuncTest extends AbstractGradleFuncTest { - - def setup() { - ["darwin-zip", 'darwin-tar'].each { projName -> - settingsFile << """ - include ':${projName}' - """ - - file("${projName}/build.gradle") << """ - plugins { - id 'opensearch.internal-distribution-archive-check' - }""" - } - file("SomeFile.txt") << """ - some dummy txt file - """ - - buildFile << """ - allprojects { - apply plugin:'base' - ext.elasticLicenseUrl = "http://foo.bar" - } - tasks.register("buildDarwinTar", Tar) { - compression = Compression.GZIP - from 'SomeFile.class' - } - tasks.register("buildDarwinZip", Zip) { - from 'SomeFile.txt' - }""" - } - - @Unroll - def "plain class files in distribution #archiveType archives are detected"() { - given: - file("SomeFile.class") << """ - some dummy class file - """ - buildFile << """ - tasks.withType(AbstractArchiveTask).configureEach { - from 'SomeFile.class' - } - """ - if (OperatingSystem.current() == OperatingSystem.WINDOWS) { - when: - def result = gradleRunner(":darwin-${archiveType}:check", '--stacktrace').build() - then: - result.task(":darwin-${archiveType}:checkExtraction").outcome == TaskOutcome.SKIPPED - } else { - when: - def result = gradleRunner(":darwin-${archiveType}:check", '--stacktrace').buildAndFail() - then: - result.task(":darwin-${archiveType}:checkExtraction").outcome == TaskOutcome.FAILED - result.output.contains("Detected class file in distribution ('SomeFile.class')") - } - - where: - archiveType << ["zip", 'tar'] - } - - def "fails on unexpected notice content"() { - given: - license(file("LICENSE.txt")) - file("NOTICE.txt").text = """OpenSearch (https://opensearch.org/) -Copyright 2009-2018 Acme Coorp""" - buildFile << """ - apply plugin:'base' - tasks.withType(AbstractArchiveTask).configureEach { - into("opensearch-${VersionProperties.getOpenSearch()}") { - from 'LICENSE.txt' - from 'SomeFile.txt' - from 'NOTICE.txt' - } - } - """ - - if (OperatingSystem.current() == OperatingSystem.WINDOWS) { - when: - def result = gradleRunner(":darwin-tar:checkNotice").build() - then: - result.task(":darwin-tar:checkNotice").outcome == TaskOutcome.SKIPPED - } else { - when: - def result = gradleRunner(":darwin-tar:checkNotice").buildAndFail() - then: - result.task(":darwin-tar:checkNotice").outcome == TaskOutcome.FAILED - normalizedOutput(result.output).contains("> expected line [2] in " + - "[./darwin-tar/build/tar-extracted/opensearch-${VersionProperties.getOpenSearch()}/NOTICE.txt] " + - "to be [Copyright OpenSearch Contributors] but was [Copyright 2009-2018 Acme Coorp]") - } - - } - - void license(File file = file("licenses/APACHE-LICENSE-2.0.txt")) { - file << """license coorp stuff line 1 -license coorp stuff line 2 -license coorp stuff line 3 -""" - } - -} diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionArchiveSetupPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionArchiveSetupPluginFuncTest.groovy deleted file mode 100644 index b5f643e6f4083..0000000000000 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionArchiveSetupPluginFuncTest.groovy +++ /dev/null @@ -1,237 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle.internal - -import org.apache.commons.compress.archivers.tar.TarArchiveEntry -import org.apache.commons.compress.archivers.tar.TarArchiveInputStream -import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream -import org.apache.tools.zip.ZipEntry -import org.apache.tools.zip.ZipFile -import org.gradle.internal.os.OperatingSystem -import org.opensearch.gradle.fixtures.AbstractGradleFuncTest -import org.gradle.testkit.runner.BuildResult -import org.gradle.testkit.runner.TaskOutcome - -class InternalDistributionArchiveSetupPluginFuncTest extends AbstractGradleFuncTest { - - def setup() { - buildFile << """ - import org.opensearch.gradle.tar.SymbolicLinkPreservingTar - plugins { - id 'opensearch.internal-distribution-archive-setup' - } - """ - file('someFile.txt') << "some content" - } - - def "applies defaults to tar tasks"() { - given: - file('someFile.txt') << "some content" - buildFile << """ - tasks.register('${buildTaskName}', SymbolicLinkPreservingTar) { - from 'someFile.txt' - } - """ - - when: - def result = gradleRunner(buildTaskName).build() - - then: - file(expectedOutputArchivePath).exists() - assertTarPermissionDefaults(file(expectedOutputArchivePath)) - assertEmptyDirTasksTriggered(result) - - where: - buildTaskName | expectedOutputArchivePath - "buildDarwinTar" | "darwin-tar/build/distributions/opensearch-min.tar.gz" - } - - def "applies defaults to zip tasks"() { - given: - buildFile << """ - tasks.register('${buildTaskName}', Zip) { - from 'someFile.txt' - } - """ - - when: - def result = gradleRunner(buildTaskName).build() - - then: - file(expectedOutputArchivePath).exists() - assertZipPermissionDefaults(file(expectedOutputArchivePath)) - assertEmptyDirTasksTriggered(result) - - where: - buildTaskName | expectedOutputArchivePath - "buildDarwinZip" | "darwin-zip/build/distributions/opensearch-min.zip" - } - - def "registered distribution provides archives and directory variant"() { - given: - file('someFile.txt') << "some content" - - settingsFile << """ - include ':consumer' - include ':producer-tar' - """ - - buildFile << """ - import org.gradle.api.artifacts.type.ArtifactTypeDefinition; - import org.gradle.api.internal.artifacts.ArtifactAttributes; - def snapshotFile = file("snapshot-\${version}.txt") - snapshotFile << 'some snapshot content' - distribution_archives { - producerTar { - content { - project.copySpec { - from 'someFile.txt' - from snapshotFile - } - } - } - } - project('consumer') { p -> - configurations { - consumeArchive {} - consumeDir {} - } - dependencies { - consumeDir project(path: ':producer-tar', configuration:'extracted') - consumeArchive project(path: ':producer-tar', configuration:'default' ) - } - tasks.register("copyDir", Copy) { - from(configurations.consumeDir) - into('build/dir') - } - tasks.register("copyArchive", Copy) { - from(configurations.consumeArchive) - into('build/archives') - } - } - """ - - if (OperatingSystem.current() != OperatingSystem.WINDOWS) { - when: - def result = gradleRunner("copyArchive").build() - then: "tar task executed and target folder contains plain tar" - result.task(':buildProducerTar').outcome == TaskOutcome.SUCCESS - result.task(':consumer:copyArchive').outcome == TaskOutcome.SUCCESS - file("producer-tar/build/distributions/opensearch-min.tar.gz").exists() - file("consumer/build/archives/opensearch-min.tar.gz").exists() - - when: - result = gradleRunner("copyDir", "-Pversion=1.0").build() - then: "plain copy task executed and target folder contains plain content" - result.task(':buildProducer').outcome == TaskOutcome.SUCCESS - result.task(':consumer:copyDir').outcome == TaskOutcome.SUCCESS - file("producer-tar/build/install/someFile.txt").exists() - file("producer-tar/build/install/snapshot-1.0.txt").exists() - file("consumer/build/dir/someFile.txt").exists() - - when: - gradleRunner("copyDir", "-Pversion=2.0").build() - then: "old content is cleared out" - file("producer-tar/build/install/someFile.txt").exists() - !file("producer-tar/build/install/snapshot-1.0.txt").exists() - file("producer-tar/build/install/snapshot-2.0.txt").exists() - } else { - when: - def result = gradleRunner("copyArchive").build() - then: "tar task execution skipped on windows" - result.task(':buildProducerTar').outcome == TaskOutcome.SKIPPED - result.task(':consumer:copyArchive').outcome == TaskOutcome.NO_SOURCE - - when: - result = gradleRunner("copyDir", "-Pversion=1.0").build() - then: "plain copy task execution skipped on windows" - result.task(':buildProducer').outcome == TaskOutcome.SKIPPED - result.task(':consumer:copyDir').outcome == TaskOutcome.NO_SOURCE - } - - } - - private static boolean assertTarPermissionDefaults(File tarArchive) { - TarArchiveInputStream tarInput = new TarArchiveInputStream(new GzipCompressorInputStream(new FileInputStream(tarArchive))) - try { - TarArchiveEntry currentEntry = tarInput.getNextTarEntry() - while (currentEntry != null) { - if (currentEntry.isDirectory()) { - assertDefaultDirPermissions(currentEntry.getMode()) - } else { - assertDefaultFilePermissions(currentEntry.getMode()) - } - currentEntry = tarInput.getNextTarEntry() - } - return true - } finally { - tarInput.close() - } - } - - private static boolean assertZipPermissionDefaults(File archive) { - ZipFile zip = new ZipFile(archive) - try { - Enumeration entries = zip.getEntries() - while (entries.hasMoreElements()) { - ZipEntry zipEntry = entries.nextElement() - if (zipEntry.isDirectory()) { - assertDefaultDirPermissions(zipEntry.getUnixMode()) - } else { - assertDefaultFilePermissions(zipEntry.getUnixMode()) - } - } - } finally { - zip.close() - } - true - } - - private static boolean assertDefaultDirPermissions(int mode) { - assert ((mode >> 6) & 07) == 7 - assert ((mode >> 3) & 07) == 5 - assert ((mode >> 0) & 07) == 5 - true - } - - private static boolean assertDefaultFilePermissions(int mode) { - assert ((mode >> 6) & 07) == 6 - assert ((mode >> 3) & 07) == 4 - assert ((mode >> 0) & 07) == 4 - true - } - - private static boolean assertEmptyDirTasksTriggered(BuildResult result) { - result.task(":createJvmOptionsDir").outcome == TaskOutcome.SUCCESS - result.task(":createLogsDir").outcome == TaskOutcome.SUCCESS - result.task(":createPluginsDir").outcome == TaskOutcome.SUCCESS - true - } -} diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionBwcSetupPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionBwcSetupPluginFuncTest.groovy deleted file mode 100644 index 9d5e8009e3553..0000000000000 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionBwcSetupPluginFuncTest.groovy +++ /dev/null @@ -1,160 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle.internal - -import org.apache.commons.io.FileUtils -import org.opensearch.gradle.fixtures.AbstractGradleFuncTest -import org.gradle.testkit.runner.TaskOutcome -import org.junit.Rule -import org.junit.rules.TemporaryFolder - -class InternalDistributionBwcSetupPluginFuncTest extends AbstractGradleFuncTest { - - @Rule - TemporaryFolder remoteRepoDirs = new TemporaryFolder() - - File remoteGitRepo - - def setup() { - remoteGitRepo = new File(setupGitRemote(), '.git') - - "git clone ${remoteGitRepo.absolutePath}".execute(Collections.emptyList(), testProjectDir.root).waitFor() - File buildScript = new File(testProjectDir.root, 'remote/build.gradle') - internalBuild(buildScript) - buildScript << """ - apply plugin: 'opensearch.internal-distribution-bwc-setup' - """ - } - - def "builds distribution from branches via archives assemble"() { - when: - def result = gradleRunner(new File(testProjectDir.root, "remote"), - ":distribution:bwc:bugfix:buildBwcDarwinTar", - "-DtestRemoteRepo=" + remoteGitRepo, - "-Dbwc.remote=origin") - .build() - then: - result.task(":distribution:bwc:bugfix:buildBwcDarwinTar").outcome == TaskOutcome.SUCCESS - - and: "assemble task triggered" - result.output.contains("[8.0.1] > Task :distribution:archives:darwin-tar:assemble") - } - - def "bwc distribution archives can be resolved as bwc project artifact"() { - setup: - new File(testProjectDir.root, 'remote/build.gradle') << """ - - configurations { - dists - } - - dependencies { - dists project(path: ":distribution:bwc:bugfix", configuration:"darwin-tar") - } - - tasks.register("resolveDistributionArchive") { - inputs.files(configurations.dists) - doLast { - configurations.dists.files.each { - println "distfile " + (it.absolutePath - project.rootDir.absolutePath) - } - } - } - """ - when: - def result = gradleRunner(new File(testProjectDir.root, "remote"), - ":resolveDistributionArchive", - "-DtestRemoteRepo=" + remoteGitRepo, - "-Dbwc.remote=origin") - .build() - then: - result.task(":resolveDistributionArchive").outcome == TaskOutcome.SUCCESS - result.task(":distribution:bwc:bugfix:buildBwcDarwinTar").outcome == TaskOutcome.SUCCESS - - and: "assemble task triggered" - result.output.contains("[8.0.1] > Task :distribution:archives:darwin-tar:assemble") - normalizedOutput(result.output) - .contains("distfile /distribution/bwc/bugfix/build/bwc/checkout-8.0/distribution/archives/darwin-tar/" + - "build/distributions/opensearch-8.0.1-SNAPSHOT-darwin-x64.tar.gz") - } - - def "bwc expanded distribution folder can be resolved as bwc project artifact"() { - setup: - new File(testProjectDir.root, 'remote/build.gradle') << """ - - configurations { - expandedDist - } - - dependencies { - expandedDist project(path: ":distribution:bwc:bugfix", configuration:"expanded-darwin-tar") - } - - tasks.register("resolveExpandedDistribution") { - inputs.files(configurations.expandedDist) - doLast { - configurations.expandedDist.files.each { - println "distfile " + (it.absolutePath - project.rootDir.absolutePath) - } - } - } - """ - when: - def result = gradleRunner(new File(testProjectDir.root, "remote"), - ":resolveExpandedDistribution", - "-DtestRemoteRepo=" + remoteGitRepo, - "-Dbwc.remote=origin") - .build() - then: - result.task(":resolveExpandedDistribution").outcome == TaskOutcome.SUCCESS - result.task(":distribution:bwc:bugfix:buildBwcDarwinTar").outcome == TaskOutcome.SUCCESS - - and: "assemble task triggered" - result.output.contains("[8.0.1] > Task :distribution:archives:darwin-tar:assemble") - normalizedOutput(result.output) - .contains("distfile /distribution/bwc/bugfix/build/bwc/checkout-8.0/" + - "distribution/archives/darwin-tar/build/install") - } - - File setupGitRemote() { - URL fakeRemote = getClass().getResource("fake_git/remote") - File workingRemoteGit = new File(remoteRepoDirs.root, 'remote') - FileUtils.copyDirectory(new File(fakeRemote.file), workingRemoteGit) - fakeRemote.file + "/.git" - gradleRunner(workingRemoteGit, "wrapper").build() - execute("git init", workingRemoteGit) - execute('git config user.email "build-tool@opensearch.org"', workingRemoteGit) - execute('git config user.name "Build tool"', workingRemoteGit) - execute("git add .", workingRemoteGit) - execute('git commit -m"Initial"', workingRemoteGit) - execute("git checkout -b origin/8.0", workingRemoteGit) - return workingRemoteGit; - } -} diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionDownloadPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionDownloadPluginFuncTest.groovy deleted file mode 100644 index 46143687b83a7..0000000000000 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionDownloadPluginFuncTest.groovy +++ /dev/null @@ -1,224 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle.internal - -import org.opensearch.gradle.VersionProperties -import org.opensearch.gradle.fixtures.AbstractGradleFuncTest -import org.gradle.testkit.runner.GradleRunner -import org.gradle.testkit.runner.TaskOutcome -import org.junit.Rule -import org.junit.rules.TemporaryFolder - -import java.lang.management.ManagementFactory - -class InternalDistributionDownloadPluginFuncTest extends AbstractGradleFuncTest { - - def "plugin application fails on non internal build"() { - given: - buildFile.text = """ - plugins { - id 'opensearch.internal-distribution-download' - } - """ - - when: - def result = gradleRunner("tasks").buildAndFail() - - then: - assertOutputContains(result.output, "Plugin 'opensearch.internal-distribution-download' is not supported. " + - "Use 'opensearch.distribution-download' plugin instead") - } - - def "resolves current version from local build"() { - given: - internalBuild() - localDistroSetup() - def distroVersion = VersionProperties.getOpenSearch() - buildFile << """ - apply plugin: 'opensearch.internal-distribution-download' - - opensearch_distributions { - test_distro { - version = "$distroVersion" - type = "archive" - platform = "linux" - architecture = Architecture.current(); - } - } - tasks.register("setupDistro", Sync) { - from(opensearch_distributions.test_distro.extracted) - into("build/distro") - } - """ - - when: - def result = gradleRunner("setupDistro", '-g', testProjectDir.newFolder('GUH').path).build() - - then: - result.task(":distribution:archives:linux-tar:buildExpanded").outcome == TaskOutcome.SUCCESS - result.task(":setupDistro").outcome == TaskOutcome.SUCCESS - assertExtractedDistroIsCreated("build/distro", 'current-marker.txt') - } - - def "resolves expanded bwc versions from source"() { - given: - internalBuild() - bwcMinorProjectSetup() - buildFile << """ - apply plugin: 'opensearch.internal-distribution-download' - - opensearch_distributions { - test_distro { - version = "8.1.0" - type = "archive" - platform = "linux" - architecture = Architecture.current(); - } - } - tasks.register("setupDistro", Sync) { - from(opensearch_distributions.test_distro.extracted) - into("build/distro") - } - """ - when: - - def result = gradleRunner("setupDistro").build() - then: - result.task(":distribution:bwc:minor:buildBwcExpandedTask").outcome == TaskOutcome.SUCCESS - result.task(":setupDistro").outcome == TaskOutcome.SUCCESS - assertExtractedDistroIsCreated("distribution/bwc/minor/build/install/opensearch-distro", - 'bwc-marker.txt') - } - - def "fails on resolving bwc versions with no bundled jdk"() { - given: - internalBuild() - bwcMinorProjectSetup() - buildFile << """ - apply plugin: 'opensearch.internal-distribution-download' - - opensearch_distributions { - test_distro { - version = "8.1.0" - type = "archive" - platform = "linux" - architecture = Architecture.current(); - bundledJdk = false - } - } - tasks.register("createExtractedTestDistro") { - dependsOn opensearch_distributions.test_distro.extracted - } - """ - when: - def result = gradleRunner("createExtractedTestDistro").buildAndFail() - then: - assertOutputContains(result.output, "Configuring a snapshot bwc distribution ('test_distro') " + - "without a bundled JDK is not supported.") - } - - private void bwcMinorProjectSetup() { - settingsFile << """ - include ':distribution:bwc:minor' - """ - def bwcSubProjectFolder = testProjectDir.newFolder("distribution", "bwc", "minor") - new File(bwcSubProjectFolder, 'bwc-marker.txt') << "bwc=minor" - new File(bwcSubProjectFolder, 'build.gradle') << """ - apply plugin:'base' - - // packed distro - configurations.create("linux-tar") - tasks.register("buildBwcTask", Tar) { - from('bwc-marker.txt') - archiveExtension = "tar.gz" - compression = Compression.GZIP - } - artifacts { - it.add("linux-tar", buildBwcTask) - } - - // expanded distro - configurations.create("expanded-linux-tar") - def expandedTask = tasks.register("buildBwcExpandedTask", Copy) { - from('bwc-marker.txt') - into('build/install/opensearch-distro') - } - artifacts { - it.add("expanded-linux-tar", file('build/install')) { - builtBy expandedTask - type = 'directory' - } - } - """ - } - - private void localDistroSetup() { - settingsFile << """ - include ":distribution:archives:linux-tar" - """ - def bwcSubProjectFolder = testProjectDir.newFolder("distribution", "archives", "linux-tar") - new File(bwcSubProjectFolder, 'current-marker.txt') << "current" - new File(bwcSubProjectFolder, 'build.gradle') << """ - import org.gradle.api.internal.artifacts.ArtifactAttributes; - - apply plugin:'distribution' - - def buildTar = tasks.register("buildTar", Tar) { - from('current-marker.txt') - archiveExtension = "tar.gz" - compression = Compression.GZIP - } - def buildExpanded = tasks.register("buildExpanded", Copy) { - from('current-marker.txt') - into("build/local") - } - configurations { - extracted { - attributes { - attribute(ArtifactAttributes.ARTIFACT_FORMAT, "directory") - } - } - } - artifacts { - it.add("default", buildTar) - it.add("extracted", buildExpanded) - } - """ - buildFile << """ - """ - } - - boolean assertExtractedDistroIsCreated(String relativeDistroPath, String markerFileName) { - File extractedFolder = new File(testProjectDir.root, relativeDistroPath) - assert extractedFolder.exists() - assert new File(extractedFolder, markerFileName).exists() - true - } -} diff --git a/buildSrc/src/integTest/java/org/opensearch/gradle/BuildPluginIT.java b/buildSrc/src/integTest/java/org/opensearch/gradle/BuildPluginIT.java deleted file mode 100644 index 4658b31d77fe1..0000000000000 --- a/buildSrc/src/integTest/java/org/opensearch/gradle/BuildPluginIT.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.opensearch.gradle.test.GradleIntegrationTestCase; -import org.gradle.testkit.runner.BuildResult; -import org.gradle.testkit.runner.GradleRunner; -import org.junit.Rule; -import org.junit.rules.TemporaryFolder; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.List; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import static org.opensearch.gradle.test.TestClasspathUtils.setupJarJdkClasspath; - -public class BuildPluginIT extends GradleIntegrationTestCase { - - @Rule - public TemporaryFolder tmpDir = new TemporaryFolder(); - - public void testPluginCanBeApplied() { - BuildResult result = getGradleRunner("opensearch.build").withArguments("hello", "-s").build(); - assertTaskSuccessful(result, ":hello"); - assertOutputContains("build plugin can be applied"); - } - - public void testCheckTask() { - setupJarJdkClasspath(getProjectDir("opensearch.build")); - BuildResult result = getGradleRunner("opensearch.build").withArguments("check", "assemble", "-s").build(); - assertTaskSuccessful(result, ":check"); - } - - public void testInsecureMavenRepository() throws IOException { - final String name = "opensearch-maven"; - final String url = "http://s3.amazonaws.com/artifacts.opensearch.org/maven"; - // add an insecure maven repository to the build.gradle - final List lines = Arrays.asList( - "repositories {", - " maven {", - " name \"opensearch-maven\"", - " url \"" + url + "\"\n", - " }", - "}" - ); - runInsecureArtifactRepositoryTest(name, url, lines); - } - - public void testInsecureIvyRepository() throws IOException { - final String name = "opensearch-ivy"; - final String url = "http://s3.amazonaws.com/artifacts.opensearch.org/ivy"; - // add an insecure ivy repository to the build.gradle - final List lines = Arrays.asList( - "repositories {", - " ivy {", - " name \"opensearch-ivy\"", - " url \"" + url + "\"\n", - " }", - "}" - ); - runInsecureArtifactRepositoryTest(name, url, lines); - } - - private void runInsecureArtifactRepositoryTest(final String name, final String url, final List lines) throws IOException { - final File projectDir = getProjectDir("opensearch.build"); - final Path projectDirPath = projectDir.toPath(); - FileUtils.copyDirectory(projectDir, tmpDir.getRoot(), file -> { - final Path relativePath = projectDirPath.relativize(file.toPath()); - for (Path segment : relativePath) { - if (segment.toString().equals("build")) { - return false; - } - } - return true; - }); - final List buildGradleLines = Files.readAllLines(tmpDir.getRoot().toPath().resolve("build.gradle"), StandardCharsets.UTF_8); - buildGradleLines.addAll(lines); - Files.write(tmpDir.getRoot().toPath().resolve("build.gradle"), buildGradleLines, StandardCharsets.UTF_8); - final BuildResult result = GradleRunner.create() - .withProjectDir(tmpDir.getRoot()) - .withArguments("clean", "hello", "-s", "-i", "--warning-mode=all", "--scan") - .withPluginClasspath() - .buildAndFail(); - assertOutputContains( - result.getOutput(), - "repository [" + name + "] on project with path [:] is not using a secure protocol for artifacts on [" + url + "]" - ); - } - - public void testLicenseAndNotice() throws IOException { - BuildResult result = getGradleRunner("opensearch.build").withArguments("clean", "assemble").build(); - - assertTaskSuccessful(result, ":assemble"); - - assertBuildFileExists(result, "opensearch.build", "distributions/opensearch.build.jar"); - - try (ZipFile zipFile = new ZipFile(new File(getBuildDir("opensearch.build"), "distributions/opensearch.build.jar"))) { - ZipEntry licenseEntry = zipFile.getEntry("META-INF/LICENSE.txt"); - ZipEntry noticeEntry = zipFile.getEntry("META-INF/NOTICE.txt"); - assertNotNull("Jar does not have META-INF/LICENSE.txt", licenseEntry); - assertNotNull("Jar does not have META-INF/NOTICE.txt", noticeEntry); - try (InputStream license = zipFile.getInputStream(licenseEntry); InputStream notice = zipFile.getInputStream(noticeEntry)) { - assertEquals("this is a test license file", IOUtils.toString(license, StandardCharsets.UTF_8.name())); - assertEquals("this is a test notice file", IOUtils.toString(notice, StandardCharsets.UTF_8.name())); - } - } - } - -} diff --git a/buildSrc/src/integTest/java/org/opensearch/gradle/ExportOpenSearchBuildResourcesTaskIT.java b/buildSrc/src/integTest/java/org/opensearch/gradle/ExportOpenSearchBuildResourcesTaskIT.java deleted file mode 100644 index b05250f8a66a7..0000000000000 --- a/buildSrc/src/integTest/java/org/opensearch/gradle/ExportOpenSearchBuildResourcesTaskIT.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.opensearch.gradle.test.GradleIntegrationTestCase; - -public class ExportOpenSearchBuildResourcesTaskIT extends GradleIntegrationTestCase { - - public static final String PROJECT_NAME = "opensearch-build-resources"; - - public void testIncorrectUsage() { - assertOutputContains( - getGradleRunner(PROJECT_NAME).withArguments("noConfigAfterExecution", "-s", "-i").buildAndFail().getOutput(), - "buildResources can't be configured after the task ran" - ); - } -} diff --git a/buildSrc/src/integTest/java/org/opensearch/gradle/ReaperPluginIT.java b/buildSrc/src/integTest/java/org/opensearch/gradle/ReaperPluginIT.java deleted file mode 100644 index 2d4ec77827fcf..0000000000000 --- a/buildSrc/src/integTest/java/org/opensearch/gradle/ReaperPluginIT.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.opensearch.gradle.test.GradleIntegrationTestCase; -import org.gradle.testkit.runner.BuildResult; -import org.gradle.testkit.runner.GradleRunner; -import org.junit.Before; - -public class ReaperPluginIT extends GradleIntegrationTestCase { - private GradleRunner runner; - - @Before - public void setup() { - runner = getGradleRunner("reaper"); - } - - public void testCanLaunchReaper() { - BuildResult result = runner.withArguments(":launchReaper", "-S", "--info").build(); - assertTaskSuccessful(result, ":launchReaper"); - assertOutputContains(result.getOutput(), "Copying reaper.jar..."); - } -} diff --git a/buildSrc/src/integTest/java/org/opensearch/gradle/precommit/TestingConventionsTasksIT.java b/buildSrc/src/integTest/java/org/opensearch/gradle/precommit/TestingConventionsTasksIT.java deleted file mode 100644 index 436bfc557756d..0000000000000 --- a/buildSrc/src/integTest/java/org/opensearch/gradle/precommit/TestingConventionsTasksIT.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.opensearch.gradle.test.GradleIntegrationTestCase; -import org.gradle.testkit.runner.BuildResult; -import org.gradle.testkit.runner.GradleRunner; -import org.junit.Before; - -public class TestingConventionsTasksIT extends GradleIntegrationTestCase { - - @Before - public void setUp() {} - - public void testInnerClasses() { - GradleRunner runner = getGradleRunner("testingConventions").withArguments( - "clean", - ":no_tests_in_inner_classes:testingConventions", - "-i", - "-s" - ); - BuildResult result = runner.buildAndFail(); - assertOutputContains( - result.getOutput(), - "Test classes implemented by inner classes will not run:", - " * org.opensearch.gradle.testkit.NastyInnerClasses$LooksLikeATestWithoutNamingConvention1", - " * org.opensearch.gradle.testkit.NastyInnerClasses$LooksLikeATestWithoutNamingConvention2", - " * org.opensearch.gradle.testkit.NastyInnerClasses$LooksLikeATestWithoutNamingConvention3", - " * org.opensearch.gradle.testkit.NastyInnerClasses$NamingConventionIT", - " * org.opensearch.gradle.testkit.NastyInnerClasses$NamingConventionTests" - ); - } - - public void testNamingConvention() { - GradleRunner runner = getGradleRunner("testingConventions").withArguments( - "clean", - ":incorrect_naming_conventions:testingConventions", - "-i", - "-s" - ); - BuildResult result = runner.buildAndFail(); - assertOutputContains( - result.getOutput(), - "Seem like test classes but don't match naming convention:", - " * org.opensearch.gradle.testkit.LooksLikeATestWithoutNamingConvention1", - " * org.opensearch.gradle.testkit.LooksLikeATestWithoutNamingConvention2", - " * org.opensearch.gradle.testkit.LooksLikeATestWithoutNamingConvention3" - ); - assertOutputDoesNotContain(result.getOutput(), "LooksLikeTestsButAbstract"); - } - - public void testNoEmptyTasks() { - GradleRunner runner = getGradleRunner("testingConventions").withArguments( - "clean", - ":empty_test_task:testingConventions", - "-i", - "-s" - ); - BuildResult result = runner.buildAndFail(); - assertOutputContains( - result.getOutput(), - "Expected at least one test class included in task :empty_test_task:emptyTest, but found none.", - "Expected at least one test class included in task :empty_test_task:test, but found none." - ); - } - - public void testAllTestTasksIncluded() { - GradleRunner runner = getGradleRunner("testingConventions").withArguments( - "clean", - ":all_classes_in_tasks:testingConventions", - "-i", - "-s" - ); - BuildResult result = runner.buildAndFail(); - assertOutputContains( - result.getOutput(), - "Test classes are not included in any enabled task (:all_classes_in_tasks:test):", - " * org.opensearch.gradle.testkit.NamingConventionIT" - ); - } - - public void testTaskNotImplementBaseClass() { - GradleRunner runner = getGradleRunner("testingConventions").withArguments( - "clean", - ":not_implementing_base:testingConventions", - "-i", - "-s" - ); - BuildResult result = runner.buildAndFail(); - assertOutputContains( - result.getOutput(), - "Tests classes with suffix `IT` should extend org.opensearch.gradle.testkit.Integration but the following classes do not:", - " * org.opensearch.gradle.testkit.NamingConventionIT", - " * org.opensearch.gradle.testkit.NamingConventionMissmatchIT", - "Tests classes with suffix `Tests` should extend org.opensearch.gradle.testkit.Unit but the following classes do not:", - " * org.opensearch.gradle.testkit.NamingConventionMissmatchTests", - " * org.opensearch.gradle.testkit.NamingConventionTests" - ); - } - - public void testValidSetupWithoutBaseClass() { - GradleRunner runner = getGradleRunner("testingConventions").withArguments( - "clean", - ":valid_setup_no_base:testingConventions", - "-i", - "-s" - ); - BuildResult result = runner.build(); - assertTaskSuccessful(result, ":valid_setup_no_base:testingConventions"); - } - - public void testValidSetupWithBaseClass() { - GradleRunner runner = getGradleRunner("testingConventions").withArguments( - "clean", - ":valid_setup_with_base:testingConventions", - "-i", - "-s" - ); - BuildResult result = runner.build(); - assertTaskSuccessful(result, ":valid_setup_with_base:testingConventions"); - } - - public void testTestsInMain() { - GradleRunner runner = getGradleRunner("testingConventions").withArguments("clean", ":tests_in_main:testingConventions", "-i", "-s"); - BuildResult result = runner.buildAndFail(); - assertOutputContains( - result.getOutput(), - "Classes matching the test naming convention should be in test not main:", - " * NamingConventionIT", - " * NamingConventionTests" - ); - } - -} diff --git a/buildSrc/src/integTest/java/org/opensearch/gradle/precommit/ThirdPartyAuditTaskIT.java b/buildSrc/src/integTest/java/org/opensearch/gradle/precommit/ThirdPartyAuditTaskIT.java deleted file mode 100644 index 4e5bbfd409f90..0000000000000 --- a/buildSrc/src/integTest/java/org/opensearch/gradle/precommit/ThirdPartyAuditTaskIT.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.opensearch.gradle.test.GradleIntegrationTestCase; -import org.gradle.testkit.runner.BuildResult; -import org.junit.Before; - -import static org.opensearch.gradle.test.TestClasspathUtils.setupJarJdkClasspath; - -public class ThirdPartyAuditTaskIT extends GradleIntegrationTestCase { - - @Before - public void setUp() throws Exception { - // Build the sample jars - getGradleRunner("thirdPartyAudit").withArguments(":sample_jars:build", "-s").build(); - // propagate jdkjarhell jar - setupJarJdkClasspath(getProjectDir("thirdPartyAudit")); - } - - public void testOpenSearchIgnored() { - BuildResult result = getGradleRunner("thirdPartyAudit").withArguments( - ":clean", - ":empty", - "-s", - "-PcompileOnlyGroup=opensearch.gradle:broken-log4j", - "-PcompileOnlyVersion=0.0.1", - "-PcompileGroup=opensearch.gradle:dummy-io", - "-PcompileVersion=0.0.1" - ).build(); - assertTaskNoSource(result, ":empty"); - assertNoDeprecationWarning(result); - } - - public void testWithEmptyRules() { - getGradleRunner("thirdPartyAudit").withArguments( - ":clean", - ":empty", - "-s", - "-PcompileOnlyGroup=other.gradle:broken-log4j", - "-PcompileOnlyVersion=0.0.1", - "-PcompileGroup=other.gradle:dummy-io", - "-PcompileVersion=0.0.1" - ).build(); - } - - public void testViolationFoundAndCompileOnlyIgnored() { - BuildResult result = getGradleRunner("thirdPartyAudit").withArguments( - ":clean", - ":absurd", - "-s", - "-PcompileOnlyGroup=other.gradle:broken-log4j", - "-PcompileOnlyVersion=0.0.1", - "-PcompileGroup=other.gradle:dummy-io", - "-PcompileVersion=0.0.1" - ).buildAndFail(); - - assertTaskFailed(result, ":absurd"); - assertOutputContains(result.getOutput(), "Classes with violations:", " * TestingIO", "> Audit of third party dependencies failed"); - assertOutputDoesNotContain(result.getOutput(), "Missing classes:"); - assertNoDeprecationWarning(result); - } - - public void testClassNotFoundAndCompileOnlyIgnored() { - BuildResult result = getGradleRunner("thirdPartyAudit").withArguments( - ":clean", - ":absurd", - "-s", - "-PcompileGroup=other.gradle:broken-log4j", - "-PcompileVersion=0.0.1", - "-PcompileOnlyGroup=other.gradle:dummy-io", - "-PcompileOnlyVersion=0.0.1" - ).buildAndFail(); - assertTaskFailed(result, ":absurd"); - - assertOutputContains( - result.getOutput(), - "Missing classes:", - " * org.apache.logging.log4j.LogManager", - "> Audit of third party dependencies failed" - ); - assertOutputDoesNotContain(result.getOutput(), "Classes with violations:"); - assertNoDeprecationWarning(result); - } - - public void testJarHellWithJDK() { - BuildResult result = getGradleRunner("thirdPartyAudit").withArguments( - ":clean", - ":absurd", - "-s", - "-PcompileGroup=other.gradle:jarhellJdk", - "-PcompileVersion=0.0.1", - "-PcompileOnlyGroup=other.gradle:dummy-io", - "-PcompileOnlyVersion=0.0.1" - ).buildAndFail(); - assertTaskFailed(result, ":absurd"); - - assertOutputContains( - result.getOutput(), - "> Audit of third party dependencies failed:", - " Jar Hell with the JDK:", - " * java.lang.String" - ); - assertOutputDoesNotContain(result.getOutput(), "Classes with violations:"); - assertNoDeprecationWarning(result); - } - - public void testOpenSearchIgnoredWithViolations() { - BuildResult result = getGradleRunner("thirdPartyAudit").withArguments( - ":clean", - ":absurd", - "-s", - "-PcompileOnlyGroup=opensearch.gradle:broken-log4j", - "-PcompileOnlyVersion=0.0.1", - "-PcompileGroup=opensearch.gradle:dummy-io", - "-PcompileVersion=0.0.1" - ).build(); - assertTaskNoSource(result, ":absurd"); - assertNoDeprecationWarning(result); - } - -} diff --git a/buildSrc/src/integTest/java/org/opensearch/gradle/tar/SymbolicLinkPreservingTarIT.java b/buildSrc/src/integTest/java/org/opensearch/gradle/tar/SymbolicLinkPreservingTarIT.java deleted file mode 100644 index 61aa55b9c6b53..0000000000000 --- a/buildSrc/src/integTest/java/org/opensearch/gradle/tar/SymbolicLinkPreservingTarIT.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.tar; - -import org.apache.commons.compress.archivers.tar.TarArchiveEntry; -import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; -import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; -import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream; -import org.apache.tools.ant.taskdefs.condition.Os; -import org.opensearch.gradle.test.GradleIntegrationTestCase; -import org.gradle.api.GradleException; -import org.gradle.testkit.runner.GradleRunner; -import org.junit.Before; -import org.junit.Rule; -import org.junit.rules.TemporaryFolder; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import static org.hamcrest.CoreMatchers.anyOf; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assume.assumeFalse; - -public class SymbolicLinkPreservingTarIT extends GradleIntegrationTestCase { - - @Rule - public final TemporaryFolder temporaryFolder = new TemporaryFolder(); - - @Before - public void before() throws IOException { - assumeFalse("Skip tar tests on windows.", Os.isFamily(Os.FAMILY_WINDOWS)); - final Path realFolder = temporaryFolder.getRoot().toPath().resolve("real-folder"); - Files.createDirectory(realFolder); - Files.createFile(realFolder.resolve("file")); - Files.createSymbolicLink(realFolder.resolve("link-to-file"), Paths.get("./file")); - final Path linkInFolder = temporaryFolder.getRoot().toPath().resolve("link-in-folder"); - Files.createDirectory(linkInFolder); - Files.createSymbolicLink(linkInFolder.resolve("link-to-file"), Paths.get("../real-folder/file")); - final Path linkToRealFolder = temporaryFolder.getRoot().toPath().resolve("link-to-real-folder"); - Files.createSymbolicLink(linkToRealFolder, Paths.get("./real-folder")); - } - - public void testBZip2Tar() throws IOException { - runBuild("buildBZip2Tar", true); - assertTar(".bz2", BZip2CompressorInputStream::new, true); - } - - public void testBZip2TarDoNotPreserveFileTimestamps() throws IOException { - runBuild("buildBZip2Tar", false); - assertTar(".bz2", BZip2CompressorInputStream::new, false); - } - - public void testGZipTar() throws IOException { - runBuild("buildGZipTar", true); - assertTar(".gz", GzipCompressorInputStream::new, true); - } - - public void testGZipTarDoNotPreserveFileTimestamps() throws IOException { - runBuild("buildGZipTar", false); - assertTar(".gz", GzipCompressorInputStream::new, false); - } - - public void testTar() throws IOException { - runBuild("buildTar", true); - assertTar("", fis -> fis, true); - } - - public void testTarDoNotPreserveFileTimestamps() throws IOException { - runBuild("buildTar", false); - assertTar("", fis -> fis, false); - } - - interface FileInputStreamWrapper { - InputStream apply(FileInputStream fis) throws IOException; - } - - private void assertTar(final String extension, final FileInputStreamWrapper wrapper, boolean preserveFileTimestamps) - throws IOException { - try ( - FileInputStream fis = new FileInputStream(getOutputFile(extension)); - TarArchiveInputStream tar = new TarArchiveInputStream(wrapper.apply(fis)) - ) { - TarArchiveEntry entry = tar.getNextTarEntry(); - boolean realFolderEntry = false; - boolean fileEntry = false; - boolean linkToFileEntry = false; - boolean linkInFolderEntry = false; - boolean linkInFolderLinkToFileEntry = false; - boolean linkToRealFolderEntry = false; - while (entry != null) { - if (entry.getName().equals("real-folder/")) { - assertTrue(entry.isDirectory()); - realFolderEntry = true; - } else if (entry.getName().equals("real-folder/file")) { - assertTrue(entry.isFile()); - fileEntry = true; - } else if (entry.getName().equals("real-folder/link-to-file")) { - assertTrue(entry.isSymbolicLink()); - assertThat(entry.getLinkName(), anyOf(equalTo("./file"), equalTo(".\\file"))); - linkToFileEntry = true; - } else if (entry.getName().equals("link-in-folder/")) { - assertTrue(entry.isDirectory()); - linkInFolderEntry = true; - } else if (entry.getName().equals("link-in-folder/link-to-file")) { - assertTrue(entry.isSymbolicLink()); - assertThat(entry.getLinkName(), anyOf(equalTo("../real-folder/file"), equalTo("..\\real-folder\\file"))); - linkInFolderLinkToFileEntry = true; - } else if (entry.getName().equals("link-to-real-folder")) { - assertTrue(entry.isSymbolicLink()); - assertThat(entry.getLinkName(), anyOf(equalTo("./real-folder"), equalTo(".\\real-folder"))); - linkToRealFolderEntry = true; - } else { - throw new GradleException("unexpected entry [" + entry.getName() + "]"); - } - if (preserveFileTimestamps) { - assertTrue(entry.getModTime().getTime() > 0); - } else { - assertThat(entry.getModTime().getTime(), equalTo(0L)); - } - entry = tar.getNextTarEntry(); - } - assertTrue(realFolderEntry); - assertTrue(fileEntry); - assertTrue(linkToFileEntry); - assertTrue(linkInFolderEntry); - assertTrue(linkInFolderLinkToFileEntry); - assertTrue(linkToRealFolderEntry); - } - } - - private void runBuild(final String task, final boolean preserveFileTimestamps) { - final GradleRunner runner = GradleRunner.create() - .withProjectDir(getProjectDir()) - .withArguments( - task, - "-Dtests.symbolic_link_preserving_tar_source=" + temporaryFolder.getRoot().toString(), - "-Dtests.symbolic_link_preserving_tar_preserve_file_timestamps=" + preserveFileTimestamps, - "-i" - ) - .withPluginClasspath(); - - runner.build(); - } - - private File getProjectDir() { - return getProjectDir("symbolic-link-preserving-tar"); - } - - private File getOutputFile(final String extension) { - return getProjectDir().toPath().resolve("build/distributions/symbolic-link-preserving-tar.tar" + extension).toFile(); - } - -} diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_adoptopenjdk_linux.tar.gz b/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_adoptopenjdk_linux.tar.gz deleted file mode 100644 index d38b03a4c2a48..0000000000000 Binary files a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_adoptopenjdk_linux.tar.gz and /dev/null differ diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_adoptopenjdk_osx.tar.gz b/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_adoptopenjdk_osx.tar.gz deleted file mode 100644 index 10c8f6e806550..0000000000000 Binary files a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_adoptopenjdk_osx.tar.gz and /dev/null differ diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_adoptopenjdk_windows.zip b/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_adoptopenjdk_windows.zip deleted file mode 100644 index 61b6b867397d6..0000000000000 Binary files a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_adoptopenjdk_windows.zip and /dev/null differ diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_openjdk_linux.tar.gz b/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_openjdk_linux.tar.gz deleted file mode 100644 index d38b03a4c2a48..0000000000000 Binary files a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_openjdk_linux.tar.gz and /dev/null differ diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_openjdk_osx.tar.gz b/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_openjdk_osx.tar.gz deleted file mode 100644 index 9ac1da5e18146..0000000000000 Binary files a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_openjdk_osx.tar.gz and /dev/null differ diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_openjdk_windows.zip b/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_openjdk_windows.zip deleted file mode 100644 index 61b6b867397d6..0000000000000 Binary files a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_openjdk_windows.zip and /dev/null differ diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_opensearch.tar.gz b/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_opensearch.tar.gz deleted file mode 100644 index 3491faf4cad7c..0000000000000 Binary files a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_opensearch.tar.gz and /dev/null differ diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_opensearch.zip b/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_opensearch.zip deleted file mode 100644 index 3a20d332e4842..0000000000000 Binary files a/buildSrc/src/integTest/resources/org/opensearch/gradle/fake_opensearch.zip and /dev/null differ diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/.ci/java-versions.properties b/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/.ci/java-versions.properties deleted file mode 100644 index 51fc2b4015ef3..0000000000000 --- a/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/.ci/java-versions.properties +++ /dev/null @@ -1,32 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -OPENSEARCH_BUILD_JAVA=openjdk14 -OPENSEARCH_RUNTIME_JAVA=openjdk14 -GRADLE_TASK=build diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/build.gradle b/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/build.gradle deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/archives/build.gradle b/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/archives/build.gradle deleted file mode 100644 index fbd5936061779..0000000000000 --- a/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/archives/build.gradle +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -subprojects { - apply plugin:'base' - - tasks.register('tar', Tar) { - from('.') - destinationDirectory.set(file('build/distributions')) - archiveBaseName.set("opensearch") - archiveVersion.set("8.0.1-SNAPSHOT") - archiveClassifier.set("darwin-x64") - archiveExtension.set('tar.gz') - } - - assemble.dependsOn('tar') -} diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/archives/darwin-tar/build.gradle b/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/archives/darwin-tar/build.gradle deleted file mode 100644 index 8b30d7157953c..0000000000000 --- a/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/archives/darwin-tar/build.gradle +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/archives/oss-darwin-tar/build.gradle b/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/archives/oss-darwin-tar/build.gradle deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/bwc/bugfix/build.gradle b/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/bwc/bugfix/build.gradle deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/bwc/minor/build.gradle b/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/bwc/minor/build.gradle deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/settings.gradle b/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/settings.gradle deleted file mode 100644 index a4aaba7133b81..0000000000000 --- a/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/settings.gradle +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -include ":distribution:bwc:bugfix" -include ":distribution:bwc:minor" -include ":distribution:archives:darwin-tar" diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/AntTask.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/AntTask.groovy deleted file mode 100644 index 72a8fe6783917..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/AntTask.groovy +++ /dev/null @@ -1,118 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle - -import org.apache.tools.ant.BuildListener -import org.apache.tools.ant.BuildLogger -import org.apache.tools.ant.DefaultLogger -import org.apache.tools.ant.Project -import org.gradle.api.DefaultTask -import org.gradle.api.GradleException -import org.gradle.api.file.FileSystemOperations -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.TaskAction - -import javax.inject.Inject -import java.nio.charset.Charset - -/** - * A task which will run ant commands. - * - * Logging for the task is customizable for subclasses by overriding makeLogger. - */ -public abstract class AntTask extends DefaultTask { - - /** - * A buffer that will contain the output of the ant code run, - * if the output was not already written directly to stdout. - */ - public final ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream() - - @Inject - protected FileSystemOperations getFileSystemOperations() { - throw new UnsupportedOperationException(); - } - - @TaskAction - final void executeTask() { - AntBuilder ant = new AntBuilder() - - // remove existing loggers, we add our own - List toRemove = new ArrayList<>(); - for (BuildListener listener : ant.project.getBuildListeners()) { - if (listener instanceof BuildLogger) { - toRemove.add(listener); - } - } - for (BuildLogger listener : toRemove) { - ant.project.removeBuildListener(listener) - } - - // otherwise groovy replaces System.out, and you have no chance to debug - // ant.saveStreams = false - - final int outputLevel = logger.isDebugEnabled() ? Project.MSG_DEBUG : Project.MSG_INFO - final PrintStream stream = useStdout() ? System.out : new PrintStream(outputBuffer, true, Charset.defaultCharset().name()) - BuildLogger antLogger = makeLogger(stream, outputLevel) - - ant.project.addBuildListener(antLogger) - try { - runAnt(ant) - } catch (Exception e) { - // ant failed, so see if we have buffered output to emit, then rethrow the failure - String buffer = outputBuffer.toString() - if (buffer.isEmpty() == false) { - logger.error("=== Ant output ===\n${buffer}") - } - throw e - } - } - - /** Runs the doAnt closure. This can be overridden by subclasses instead of having to set a closure. */ - protected abstract void runAnt(AntBuilder ant) - - /** Create the logger the ant runner will use, with the given stream for error/output. */ - protected BuildLogger makeLogger(PrintStream stream, int outputLevel) { - return new DefaultLogger( - errorPrintStream: stream, - outputPrintStream: stream, - messageOutputLevel: outputLevel) - } - - /** - * Returns true if the ant logger should write to stdout, or false if to the buffer. - * The default implementation writes to the buffer when gradle info logging is disabled. - */ - protected boolean useStdout() { - return logger.isInfoEnabled() - } - - -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/BuildPlugin.groovy deleted file mode 100644 index 0a1bc7dfd2395..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/BuildPlugin.groovy +++ /dev/null @@ -1,116 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.opensearch.gradle - -import groovy.transform.CompileStatic -import org.apache.commons.io.IOUtils -import org.opensearch.gradle.info.BuildParams -import org.opensearch.gradle.info.GlobalBuildInfoPlugin -import org.opensearch.gradle.precommit.PrecommitTasks -import org.opensearch.gradle.test.ErrorReportingTestListener -import org.opensearch.gradle.testclusters.OpenSearchCluster -import org.opensearch.gradle.testclusters.TestClustersPlugin -import org.opensearch.gradle.testclusters.TestDistribution -import org.opensearch.gradle.util.GradleUtils -import org.gradle.api.JavaVersion -import org.gradle.api.* -import org.gradle.api.artifacts.Configuration -import org.gradle.api.artifacts.Dependency -import org.gradle.api.artifacts.ModuleDependency -import org.gradle.api.artifacts.ProjectDependency -import org.gradle.api.artifacts.dsl.RepositoryHandler -import org.gradle.api.artifacts.repositories.ExclusiveContentRepository -import org.gradle.api.artifacts.repositories.IvyArtifactRepository -import org.gradle.api.artifacts.repositories.IvyPatternRepositoryLayout -import org.gradle.api.artifacts.repositories.MavenArtifactRepository -import org.gradle.api.credentials.HttpHeaderCredentials -import org.gradle.api.execution.TaskActionListener -import org.opensearch.gradle.info.GlobalBuildInfoPlugin -import org.opensearch.gradle.precommit.PrecommitTasks -import org.gradle.api.GradleException -import org.gradle.api.InvalidUserDataException -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.file.CopySpec -import org.gradle.api.plugins.ExtraPropertiesExtension -import org.gradle.api.tasks.bundling.Jar - -/** - * Encapsulates build configuration for opensearch projects. - */ -@CompileStatic -class BuildPlugin implements Plugin { - - @Override - void apply(Project project) { - // make sure the global build info plugin is applied to the root project - project.rootProject.pluginManager.apply(GlobalBuildInfoPlugin) - - if (project.pluginManager.hasPlugin('opensearch.standalone-rest-test')) { - throw new InvalidUserDataException('opensearch.standalone-test, ' - + 'opensearch.standalone-rest-test, and opensearch.build ' - + 'are mutually exclusive') - } - project.pluginManager.apply('opensearch.java') - configureLicenseAndNotice(project) - project.pluginManager.apply('opensearch.publish') - project.pluginManager.apply(DependenciesInfoPlugin) - project.pluginManager.apply('jacoco') - - PrecommitTasks.create(project, true) - } - - static void configureLicenseAndNotice(Project project) { - ExtraPropertiesExtension ext = project.extensions.getByType(ExtraPropertiesExtension) - ext.set('licenseFile', null) - ext.set('noticeFile', null) - // add license/notice files - project.afterEvaluate { - project.tasks.withType(Jar).configureEach { Jar jarTask -> - if (ext.has('licenseFile') == false || ext.get('licenseFile') == null || ext.has('noticeFile') == false || ext.get('noticeFile') == null) { - throw new GradleException("Must specify license and notice file for project ${project.path}") - } - - File licenseFile = ext.get('licenseFile') as File - File noticeFile = ext.get('noticeFile') as File - - jarTask.metaInf { CopySpec spec -> - spec.from(licenseFile.parent) { CopySpec from -> - from.include licenseFile.name - from.rename { 'LICENSE.txt' } - } - spec.from(noticeFile.parent) { CopySpec from -> - from.include noticeFile.name - from.rename { 'NOTICE.txt' } - } - } - } - } - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/DependenciesInfoPlugin.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/DependenciesInfoPlugin.groovy deleted file mode 100644 index 0ea2951817c8e..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/DependenciesInfoPlugin.groovy +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle - -import org.opensearch.gradle.dependencies.CompileOnlyResolvePlugin -import org.opensearch.gradle.precommit.DependencyLicensesTask -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.plugins.JavaPlugin -import org.gradle.api.tasks.TaskProvider - -class DependenciesInfoPlugin implements Plugin { - @Override - void apply(Project project) { - project.getPlugins().apply(CompileOnlyResolvePlugin.class); - TaskProvider depsInfo = project.getTasks().register("dependenciesInfo", DependenciesInfoTask.class); - depsInfo.configure { DependenciesInfoTask t -> - t.setRuntimeConfiguration(project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)); - t.setCompileOnlyConfiguration(project.getConfigurations().getByName(CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME)); - t.getConventionMapping().map("mappings") { -> - TaskProvider depLic = project.getTasks().named("dependencyLicenses", DependencyLicensesTask.class); - return depLic.get().getMappings(); - } - } - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/DependenciesInfoTask.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/DependenciesInfoTask.groovy deleted file mode 100644 index 21686b702d874..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/DependenciesInfoTask.groovy +++ /dev/null @@ -1,190 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle - -import org.opensearch.gradle.precommit.DependencyLicensesTask -import org.opensearch.gradle.precommit.LicenseAnalyzer -import org.gradle.api.artifacts.Configuration -import org.gradle.api.artifacts.Dependency -import org.gradle.api.artifacts.DependencySet -import org.gradle.api.artifacts.ProjectDependency -import org.gradle.api.internal.ConventionTask -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputDirectory -import org.gradle.api.tasks.InputFiles -import org.gradle.api.tasks.Optional -import org.gradle.api.tasks.OutputFile -import org.gradle.api.tasks.TaskAction - -/** - * A task to gather information about the dependencies and export them into a csv file. - * - * The following information is gathered: - *
    - *
  • name: name that identifies the library (groupId:artifactId)
  • - *
  • version
  • - *
  • URL: link to have more information about the dependency.
  • - *
  • license: SPDX license identifier, custom license or UNKNOWN.
  • - *
- * - */ -class DependenciesInfoTask extends ConventionTask { - - /** Dependencies to gather information from. */ - @InputFiles - Configuration runtimeConfiguration - - /** We subtract compile-only dependencies. */ - @InputFiles - Configuration compileOnlyConfiguration - - /** Directory to read license files */ - @Optional - @InputDirectory - File licensesDir = new File(project.projectDir, 'licenses').exists() ? new File(project.projectDir, 'licenses') : null - - @OutputFile - File outputFile = new File(project.buildDir, "reports/dependencies/dependencies.csv") - - private LinkedHashMap mappings - - DependenciesInfoTask() { - description = 'Create a CSV file with dependencies information.' - } - - @TaskAction - void generateDependenciesInfo() { - - final DependencySet runtimeDependencies = runtimeConfiguration.getAllDependencies() - // we have to resolve the transitive dependencies and create a group:artifactId:version map - final Set compileOnlyArtifacts = - compileOnlyConfiguration - .getResolvedConfiguration() - .resolvedArtifacts - .collect { it -> "${it.moduleVersion.id.group}:${it.moduleVersion.id.name}:${it.moduleVersion.id.version}" } - - final StringBuilder output = new StringBuilder() - - for (final Dependency dependency : runtimeDependencies) { - // we do not need compile-only dependencies here - if (compileOnlyArtifacts.contains("${dependency.group}:${dependency.name}:${dependency.version}")) { - continue - } - // only external dependencies are checked - if (dependency instanceof ProjectDependency) { - continue - } - - final String url = createURL(dependency.group, dependency.name, dependency.version) - final String dependencyName = DependencyLicensesTask.getDependencyName(getMappings(), dependency.name) - logger.info("mapped dependency ${dependency.group}:${dependency.name} to ${dependencyName} for license info") - - final String licenseType = getLicenseType(dependency.group, dependencyName) - output.append("${dependency.group}:${dependency.name},${dependency.version},${url},${licenseType}\n") - - } - outputFile.setText(output.toString(), 'UTF-8') - } - - @Input - LinkedHashMap getMappings() { - return mappings - } - - void setMappings(LinkedHashMap mappings) { - this.mappings = mappings - } - - /** - * Create an URL on Maven Central - * based on dependency coordinates. - */ - protected String createURL(final String group, final String name, final String version){ - final String baseURL = 'https://repo1.maven.org/maven2' - return "${baseURL}/${group.replaceAll('\\.' , '/')}/${name}/${version}" - } - - /** - * Read the LICENSE file associated with the dependency and determine a license type. - * - * The license type is one of the following values: - * - *
  • UNKNOWN if LICENSE file is not present for this dependency.
  • - *
  • one SPDX identifier if the LICENSE content matches with an SPDX license.
  • - *
  • Custom;URL if it's not an SPDX license, - * URL is the Github URL to the LICENSE file in opensearch repository.
  • - * - * - * @param group dependency group - * @param name dependency name - * @return SPDX identifier, UNKNOWN or a Custom license - */ - protected String getLicenseType(final String group, final String name) { - File license = getDependencyInfoFile(group, name, 'LICENSE') - String licenseType - - final LicenseAnalyzer.LicenseInfo licenseInfo = LicenseAnalyzer.licenseType(license) - if (licenseInfo.spdxLicense == false) { - // License has not be identified as SPDX. - // As we have the license file, we create a Custom entry with the URL to this license file. - final gitBranch = System.getProperty('build.branch', 'master') - final String githubBaseURL = "https://raw.githubusercontent.com/elastic/elasticsearch/${gitBranch}/" - licenseType = "${licenseInfo.identifier};${license.getCanonicalPath().replaceFirst('.*/elasticsearch/', githubBaseURL)}," - } else { - licenseType = "${licenseInfo.identifier}," - } - - if (licenseInfo.sourceRedistributionRequired) { - File sources = getDependencyInfoFile(group, name, 'SOURCES') - licenseType += "${sources.text.trim()}" - } - - return licenseType - } - - protected File getDependencyInfoFile(final String group, final String name, final String infoFileSuffix) { - File license = null - - if (licensesDir != null) { - licensesDir.eachFileMatch({ it ==~ /.*-${infoFileSuffix}.*/ }) { File file -> - String prefix = file.name.split("-${infoFileSuffix}.*")[0] - if (group.contains(prefix) || name.contains(prefix)) { - license = file.getAbsoluteFile() - } - } - } - - if (license == null) { - throw new IllegalStateException("Unable to find ${infoFileSuffix} file for dependency ${group}:${name} in ${licensesDir}") - } - - return license - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/FileContentsTask.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/FileContentsTask.groovy deleted file mode 100644 index b5165b981728f..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/FileContentsTask.groovy +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.opensearch.gradle - -import org.gradle.api.DefaultTask -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.OutputFile -import org.gradle.api.tasks.TaskAction - -/** - * Creates a file and sets it contents to something. - */ -class FileContentsTask extends DefaultTask { - /** - * The file to be built. Must be of type File to make @OutputFile happy. - */ - @OutputFile - File file - - @Input - Object contents - - /** - * The file to be built. Takes any objecct and coerces to a file. - */ - void setFile(Object file) { - this.file = file as File - } - - @TaskAction - void setContents() { - file = file as File - file.text = contents.toString() - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/MavenFilteringHack.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/MavenFilteringHack.groovy deleted file mode 100644 index 6b072fca50913..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/MavenFilteringHack.groovy +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.opensearch.gradle - -import org.apache.tools.ant.filters.ReplaceTokens -import org.gradle.api.file.CopySpec - -/** - * Gradle provides "expansion" functionality using groovy's SimpleTemplatingEngine (TODO: check name). - * However, it allows substitutions of the form {@code $foo} (no curlies). Rest tests provide - * some substitution from the test runner, which this form is used for. - * - * This class provides a helper to do maven filtering, where only the form {@code $\{foo\}} is supported. - * - * TODO: we should get rid of this hack, and make the rest tests use some other identifier - * for builtin vars - */ -class MavenFilteringHack { - /** - * Adds a filter to the given copy spec that will substitute maven variables. - * @param CopySpec - */ - static void filter(CopySpec copySpec, Map substitutions) { - Map mavenSubstitutions = substitutions.collectEntries() { - key, value -> ["{${key}".toString(), value.toString()] - } - copySpec.filter(ReplaceTokens, tokens: mavenSubstitutions, beginToken: '$', endToken: '}') - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/NoticeTask.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/NoticeTask.groovy deleted file mode 100644 index 7b3a0fc01ab65..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/NoticeTask.groovy +++ /dev/null @@ -1,196 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle - -import org.gradle.api.DefaultTask -import org.gradle.api.file.FileCollection -import org.gradle.api.file.FileTree -import org.gradle.api.file.SourceDirectorySet -import org.gradle.api.tasks.InputFile -import org.gradle.api.tasks.InputFiles -import org.gradle.api.tasks.Optional -import org.gradle.api.tasks.OutputFile -import org.gradle.api.tasks.TaskAction - -import java.nio.file.Files -import java.nio.file.attribute.PosixFilePermissions - -/** - * A task to create a notice file which includes dependencies' notices. - */ -class NoticeTask extends DefaultTask { - - @InputFile - File inputFile = project.rootProject.file('NOTICE.txt') - - @OutputFile - File outputFile = new File(project.buildDir, "notices/${name}/NOTICE.txt") - - private FileTree sources - - /** Directories to include notices from */ - private List licensesDirs = new ArrayList<>() - - NoticeTask() { - description = 'Create a notice file from dependencies' - // Default licenses directory is ${projectDir}/licenses (if it exists) - File licensesDir = new File(project.projectDir, 'licenses') - if (licensesDir.exists()) { - licensesDirs.add(licensesDir) - } - } - - /** Add notices from the specified directory. */ - void licensesDir(File licensesDir) { - licensesDirs.add(licensesDir) - } - - void source(Object source) { - if (sources == null) { - sources = project.fileTree(source) - } else { - sources += project.fileTree(source) - } - } - - void source(SourceDirectorySet source) { - if (sources == null) { - sources = source - } else { - sources += source - } - } - - @TaskAction - void generateNotice() { - StringBuilder output = new StringBuilder() - output.append(inputFile.getText('UTF-8')) - output.append('\n\n') - // This is a map rather than a set so that the sort order is the 3rd - // party component names, unaffected by the full path to the various files - Map seen = new TreeMap<>() - noticeFiles.each { File file -> - String name = file.name.replaceFirst(/-NOTICE\.txt$/, "") - if (seen.containsKey(name)) { - File prevFile = seen.get(name) - if (prevFile.text != file.text) { - throw new RuntimeException("Two different notices exist for dependency '" + - name + "': " + prevFile + " and " + file) - } - } else { - seen.put(name, file) - } - } - - // Add all LICENSE and NOTICE files in licenses directory - for (Map.Entry entry : seen.entrySet()) { - String name = entry.getKey() - File file = entry.getValue() - appendFile(file, name, 'NOTICE', output) - appendFile(new File(file.parentFile, "${name}-LICENSE.txt"), name, 'LICENSE', output) - } - - // Find any source files with "@notice" annotated license header - for (File sourceFile : sources.files) { - boolean isPackageInfo = sourceFile.name == 'package-info.java' - boolean foundNotice = false - boolean inNotice = false - StringBuilder header = new StringBuilder() - String packageDeclaration - - for (String line : sourceFile.readLines()) { - if (isPackageInfo && packageDeclaration == null && line.startsWith('package')) { - packageDeclaration = line - } - - if (foundNotice == false) { - foundNotice = line.contains('@notice') - inNotice = true - } else { - if (line.contains('*/')) { - inNotice = false - - if (!isPackageInfo) { - break - } - } else if (inNotice) { - header.append(line.stripMargin('*')) - header.append('\n') - } - } - } - - if (foundNotice) { - appendText(header.toString(), isPackageInfo ? packageDeclaration : sourceFile.name, '', output) - } - } - outputFile.setText(output.toString(), 'UTF-8') - if (OS.current() != OS.WINDOWS) { - Files.setPosixFilePermissions(outputFile.toPath(), PosixFilePermissions.fromString("rw-r--r--")) - } - } - - @InputFiles - @Optional - FileCollection getNoticeFiles() { - FileTree tree - licensesDirs.each { dir -> - if (tree == null) { - tree = project.fileTree(dir) - } else { - tree += project.fileTree(dir) - } - } - - return tree?.matching { include '**/*-NOTICE.txt' } - } - - @InputFiles - @Optional - FileCollection getSources() { - return sources - } - - static void appendFile(File file, String name, String type, StringBuilder output) { - String text = file.getText('UTF-8') - if (text.trim().isEmpty()) { - return - } - appendText(text, name, type, output) - } - - static void appendText(String text, String name, String type, StringBuilder output) { - output.append('================================================================================\n') - output.append("${name} ${type}\n") - output.append('================================================================================\n') - output.append(text) - output.append('\n\n') - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/ResolveAllDependencies.java b/buildSrc/src/main/groovy/org/opensearch/gradle/ResolveAllDependencies.java deleted file mode 100644 index 63ad25a977b68..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/ResolveAllDependencies.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.gradle.api.DefaultTask; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.tasks.TaskAction; -import org.gradle.internal.deprecation.DeprecatableConfiguration; - -import java.util.Collection; - -import static org.opensearch.gradle.DistributionDownloadPlugin.DISTRO_EXTRACTED_CONFIG_PREFIX; - -public class ResolveAllDependencies extends DefaultTask { - - Collection configs; - - @TaskAction - void resolveAll() { - configs.stream().filter(it -> canBeResolved(it)).forEach(it -> it.resolve()); - } - - static boolean canBeResolved(Configuration configuration) { - if (configuration.isCanBeResolved() == false) { - return false; - } - if (configuration instanceof org.gradle.internal.deprecation.DeprecatableConfiguration) { - DeprecatableConfiguration deprecatableConfiguration = (DeprecatableConfiguration) configuration; - if (deprecatableConfiguration.canSafelyBeResolved() == false) { - return false; - } - } - return configuration.getName().startsWith(DISTRO_EXTRACTED_CONFIG_PREFIX) == false; - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/doc/DocsTestPlugin.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/doc/DocsTestPlugin.groovy deleted file mode 100644 index 417cfd9bd171d..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/doc/DocsTestPlugin.groovy +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.opensearch.gradle.doc - -import org.opensearch.gradle.OS -import org.opensearch.gradle.Version -import org.opensearch.gradle.VersionProperties -import org.gradle.api.Plugin -import org.gradle.api.Project - -/** - * Sets up tests for documentation. - */ -class DocsTestPlugin implements Plugin { - - @Override - void apply(Project project) { - project.pluginManager.apply('opensearch.testclusters') - project.pluginManager.apply('opensearch.standalone-rest-test') - project.pluginManager.apply('opensearch.rest-test') - - String distribution = System.getProperty('tests.distribution', 'archive') - // The distribution can be configured with -Dtests.distribution on the command line - project.testClusters.integTest.testDistribution = distribution.toUpperCase() - - project.testClusters.integTest.nameCustomization = { it.replace("integTest", "node") } - // Docs are published separately so no need to assemble - project.tasks.assemble.enabled = false - Map commonDefaultSubstitutions = [ - /* These match up with the asciidoc syntax for substitutions but - * the values may differ. In particular {version} needs to resolve - * to the version being built for testing but needs to resolve to - * the last released version for docs. */ - '\\{version\\}': Version.fromString(VersionProperties.getOpenSearch()).toString(), - '\\{version_qualified\\}': VersionProperties.getOpenSearch(), - '\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''), - '\\{build_type\\}' : OS.conditionalString().onWindows({"zip"}).onUnix({"tar"}).supply(), - ] - project.tasks.register('listSnippets', SnippetsTask) { - group 'Docs' - description 'List each snippet' - defaultSubstitutions = commonDefaultSubstitutions - perSnippet { println(it.toString()) } - } - project.tasks.register('listConsoleCandidates', SnippetsTask) { - group 'Docs' - description - 'List snippets that probably should be marked // CONSOLE' - defaultSubstitutions = commonDefaultSubstitutions - perSnippet { - if (RestTestsFromSnippetsTask.isConsoleCandidate(it)) { - println(it.toString()) - } - } - } - - project.tasks.register('buildRestTests', RestTestsFromSnippetsTask) { - defaultSubstitutions = commonDefaultSubstitutions - } - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/doc/RestTestsFromSnippetsTask.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/doc/RestTestsFromSnippetsTask.groovy deleted file mode 100644 index f10b703ff7c20..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/doc/RestTestsFromSnippetsTask.groovy +++ /dev/null @@ -1,465 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle.doc - -import groovy.transform.PackageScope -import org.opensearch.gradle.doc.SnippetsTask.Snippet -import org.gradle.api.InvalidUserDataException -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.Internal -import org.gradle.api.tasks.OutputDirectory - -import java.nio.file.Files -import java.nio.file.Path - -/** - * Generates REST tests for each snippet marked // TEST. - */ -class RestTestsFromSnippetsTask extends SnippetsTask { - /** - * These languages aren't supported by the syntax highlighter so we - * shouldn't use them. - */ - private static final List BAD_LANGUAGES = ['json', 'javascript'] - - @Input - Map setups = new HashMap() - - /** - * A list of files that contain snippets that *probably* should be - * converted to `// CONSOLE` but have yet to be converted. If a file is in - * this list and doesn't contain unconverted snippets this task will fail. - * If there are unconverted snippets not in this list then this task will - * fail. All files are paths relative to the docs dir. - */ - @Input - List expectedUnconvertedCandidates = [] - - /** - * Root directory of the tests being generated. To make rest tests happy - * we generate them in a testRoot() which is contained in this directory. - */ - @OutputDirectory - File testRoot = project.file('build/rest') - - @Internal - Set names = new HashSet<>() - - RestTestsFromSnippetsTask() { - project.afterEvaluate { - // Wait to set this so testRoot can be customized - project.sourceSets.test.output.dir(testRoot, builtBy: this) - } - TestBuilder builder = new TestBuilder() - doFirst { outputRoot().delete() } - perSnippet builder.&handleSnippet - doLast builder.&checkUnconverted - doLast builder.&finishLastTest - } - - /** - * Root directory containing all the files generated by this task. It is - * contained within testRoot. - */ - File outputRoot() { - return new File(testRoot, '/rest-api-spec/test') - } - - /** - * Is this snippet a candidate for conversion to `// CONSOLE`? - */ - static isConsoleCandidate(Snippet snippet) { - /* Snippets that are responses or already marked as `// CONSOLE` or - * `// NOTCONSOLE` are not candidates. */ - if (snippet.console != null || snippet.testResponse) { - return false - } - /* js snippets almost always should be marked with `// CONSOLE`. js - * snippets that shouldn't be marked `// CONSOLE`, like examples for - * js client, should always be marked with `// NOTCONSOLE`. - * - * `sh` snippets that contain `curl` almost always should be marked - * with `// CONSOLE`. In the exceptionally rare cases where they are - * not communicating with Elasticsearch, like the examples in the ec2 - * and gce discovery plugins, the snippets should be marked - * `// NOTCONSOLE`. */ - return snippet.language == 'js' || snippet.curl - } - - /** - * Certain requests should not have the shard failure check because the - * format of the response is incompatible i.e. it is not a JSON object. - */ - static shouldAddShardFailureCheck(String path) { - return path.startsWith('_cat') == false - } - - /** - * Converts Kibana's block quoted strings into standard JSON. These - * {@code """} delimited strings can be embedded in CONSOLE and can - * contain newlines and {@code "} without the normal JSON escaping. - * This has to add it. - */ - @PackageScope - static String replaceBlockQuote(String body) { - int start = body.indexOf('"""'); - if (start < 0) { - return body - } - /* - * 1.3 is a fairly wild guess of the extra space needed to hold - * the escaped string. - */ - StringBuilder result = new StringBuilder((int) (body.length() * 1.3)); - int startOfNormal = 0; - while (start >= 0) { - int end = body.indexOf('"""', start + 3); - if (end < 0) { - throw new InvalidUserDataException( - "Invalid block quote starting at $start in:\n$body") - } - result.append(body.substring(startOfNormal, start)); - result.append('"'); - result.append(body.substring(start + 3, end) - .replace('"', '\\"') - .replace("\n", "\\n")); - result.append('"'); - startOfNormal = end + 3; - start = body.indexOf('"""', startOfNormal); - } - result.append(body.substring(startOfNormal)); - return result.toString(); - } - - private class TestBuilder { - private static final String SYNTAX = { - String method = /(?GET|PUT|POST|HEAD|OPTIONS|DELETE)/ - String pathAndQuery = /(?[^\n]+)/ - String badBody = /GET|PUT|POST|HEAD|OPTIONS|DELETE|startyaml|#/ - String body = /(?(?:\n(?!$badBody)[^\n]+)+)/ - String rawRequest = /(?:$method\s+$pathAndQuery$body?)/ - String yamlRequest = /(?:startyaml(?s)(?.+?)(?-s)endyaml)/ - String nonComment = /(?:$rawRequest|$yamlRequest)/ - String comment = /(?#.+)/ - /(?:$comment|$nonComment)\n+/ - }() - - /** - * The file in which we saw the last snippet that made a test. - */ - Path lastDocsPath - - /** - * The file we're building. - */ - PrintWriter current - - /** - * Files containing all snippets that *probably* should be converted - * to `// CONSOLE` but have yet to be converted. All files are paths - * relative to the docs dir. - */ - Set unconvertedCandidates = new HashSet<>() - - /** - * The last non-TESTRESPONSE snippet. - */ - Snippet previousTest - - /** - * Called each time a snippet is encountered. Tracks the snippets and - * calls buildTest to actually build the test. - */ - void handleSnippet(Snippet snippet) { - if (RestTestsFromSnippetsTask.isConsoleCandidate(snippet)) { - unconvertedCandidates.add(snippet.path.toString() - .replace('\\', '/')) - } - if (BAD_LANGUAGES.contains(snippet.language)) { - throw new InvalidUserDataException( - "$snippet: Use `js` instead of `${snippet.language}`.") - } - if (snippet.testSetup) { - testSetup(snippet) - previousTest = snippet - return - } - if (snippet.testTearDown) { - testTearDown(snippet) - previousTest = snippet - return - } - if (snippet.testResponse || snippet.language == 'console-result') { - response(snippet) - return - } - if ((snippet.language == 'js') && (snippet.console)) { - throw new InvalidUserDataException( - "$snippet: Use `[source,console]` instead of `// CONSOLE`.") - } - if (snippet.test || snippet.language == 'console') { - test(snippet) - previousTest = snippet - return - } - // Must be an unmarked snippet.... - } - - private void test(Snippet test) { - setupCurrent(test) - - if (test.continued) { - /* Catch some difficult to debug errors with // TEST[continued] - * and throw a helpful error message. */ - if (previousTest == null || previousTest.path != test.path) { - throw new InvalidUserDataException("// TEST[continued] " + - "cannot be on first snippet in a file: $test") - } - if (previousTest != null && previousTest.testSetup) { - throw new InvalidUserDataException("// TEST[continued] " + - "cannot immediately follow // TESTSETUP: $test") - } - if (previousTest != null && previousTest.testTearDown) { - throw new InvalidUserDataException("// TEST[continued] " + - "cannot immediately follow // TEARDOWN: $test") - } - } else { - current.println('---') - current.println("\"line_$test.start\":") - /* The Elasticsearch test runner doesn't support quite a few - * constructs unless we output this skip. We don't know if - * we're going to use these constructs, but we might so we - * output the skip just in case. */ - current.println(" - skip:") - current.println(" features: ") - current.println(" - default_shards") - current.println(" - stash_in_key") - current.println(" - stash_in_path") - current.println(" - stash_path_replace") - current.println(" - warnings") - if (test.testEnv != null) { - throw new InvalidUserDataException('Unsupported testEnv: ' + test.testEnv); - } - } - if (test.skip) { - if (test.continued) { - throw new InvalidUserDataException("Continued snippets " - + "can't be skipped") - } - current.println(" - always_skip") - current.println(" reason: $test.skip") - } - if (test.setup != null) { - setup(test) - } - - body(test, false) - } - - private void setup(final Snippet snippet) { - // insert a setup defined outside of the docs - for (final String setupName : snippet.setup.split(',')) { - final String setup = setups[setupName] - if (setup == null) { - throw new InvalidUserDataException("Couldn't find setup for $snippet") - } - current.println(setup) - } - } - - private void response(Snippet response) { - if (null == response.skip) { - current.println(" - match: ") - current.println(" \$body: ") - replaceBlockQuote(response.contents).eachLine { - current.println(" $it") - } - } - } - - void emitDo(String method, String pathAndQuery, String body, - String catchPart, List warnings, boolean inSetup, boolean skipShardFailures) { - def (String path, String query) = pathAndQuery.tokenize('?') - if (path == null) { - path = '' // Catch requests to the root... - } else { - path = path.replace('<', '%3C').replace('>', '%3E') - } - current.println(" - do:") - if (catchPart != null) { - current.println(" catch: $catchPart") - } - if (false == warnings.isEmpty()) { - current.println(" warnings:") - for (String warning in warnings) { - // Escape " because we're going to quote the warning - String escaped = warning.replaceAll('"', '\\\\"') - /* Quote the warning in case it starts with [ which makes - * it look too much like an array. */ - current.println(" - \"$escaped\"") - } - } - current.println(" raw:") - current.println(" method: $method") - current.println(" path: \"$path\"") - if (query != null) { - for (String param: query.tokenize('&')) { - def (String name, String value) = param.tokenize('=') - if (value == null) { - value = '' - } - current.println(" $name: \"$value\"") - } - } - if (body != null) { - // Throw out the leading newline we get from parsing the body - body = body.substring(1) - // Replace """ quoted strings with valid json ones - body = replaceBlockQuote(body) - current.println(" body: |") - body.eachLine { current.println(" $it") } - } - /* Catch any shard failures. These only cause a non-200 response if - * no shard succeeds. But we need to fail the tests on all of these - * because they mean invalid syntax or broken queries or something - * else that we don't want to teach people to do. The REST test - * framework doesn't allow us to have assertions in the setup - * section so we have to skip it there. We also omit the assertion - * from APIs that don't return a JSON object - */ - if (false == inSetup && skipShardFailures == false && shouldAddShardFailureCheck(path)) { - current.println(" - is_false: _shards.failures") - } - } - - private void testSetup(Snippet snippet) { - if (lastDocsPath == snippet.path) { - throw new InvalidUserDataException("$snippet: wasn't first. TESTSETUP can only be used in the first snippet of a document.") - } - setupCurrent(snippet) - current.println('---') - current.println("setup:") - if (snippet.setup != null) { - setup(snippet) - } - body(snippet, true) - } - - private void testTearDown(Snippet snippet) { - if (previousTest.testSetup == false && lastDocsPath == snippet.path) { - throw new InvalidUserDataException("$snippet must follow test setup or be first") - } - setupCurrent(snippet) - current.println('---') - current.println('teardown:') - body(snippet, true) - } - - private void body(Snippet snippet, boolean inSetup) { - parse("$snippet", snippet.contents, SYNTAX) { matcher, last -> - if (matcher.group("comment") != null) { - // Comment - return - } - String yamlRequest = matcher.group("yaml"); - if (yamlRequest != null) { - current.println(yamlRequest) - return - } - String method = matcher.group("method") - String pathAndQuery = matcher.group("pathAndQuery") - String body = matcher.group("body") - String catchPart = last ? snippet.catchPart : null - if (pathAndQuery.startsWith('/')) { - // Leading '/'s break the generated paths - pathAndQuery = pathAndQuery.substring(1) - } - emitDo(method, pathAndQuery, body, catchPart, snippet.warnings, - inSetup, snippet.skipShardsFailures) - } - } - - private PrintWriter setupCurrent(Snippet test) { - if (lastDocsPath == test.path) { - return - } - finishLastTest() - lastDocsPath = test.path - - // Make the destination file: - // Shift the path into the destination directory tree - Path dest = outputRoot().toPath().resolve(test.path) - // Replace the extension - String fileName = dest.getName(dest.nameCount - 1) - dest = dest.parent.resolve(fileName.replace('.asciidoc', '.yml')) - - // Now setup the writer - Files.createDirectories(dest.parent) - current = dest.newPrintWriter('UTF-8') - } - - void finishLastTest() { - if (current != null) { - current.close() - current = null - } - } - - void checkUnconverted() { - List listedButNotFound = [] - for (String listed : expectedUnconvertedCandidates) { - if (false == unconvertedCandidates.remove(listed)) { - listedButNotFound.add(listed) - } - } - String message = "" - if (false == listedButNotFound.isEmpty()) { - Collections.sort(listedButNotFound) - listedButNotFound = listedButNotFound.collect {' ' + it} - message += "Expected unconverted snippets but none found in:\n" - message += listedButNotFound.join("\n") - } - if (false == unconvertedCandidates.isEmpty()) { - List foundButNotListed = - new ArrayList<>(unconvertedCandidates) - Collections.sort(foundButNotListed) - foundButNotListed = foundButNotListed.collect {' ' + it} - if (false == "".equals(message)) { - message += "\n" - } - message += "Unexpected unconverted snippets:\n" - message += foundButNotListed.join("\n") - } - if (false == "".equals(message)) { - throw new InvalidUserDataException(message); - } - } - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/doc/SnippetsTask.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/doc/SnippetsTask.groovy deleted file mode 100644 index 287a88cadf834..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/doc/SnippetsTask.groovy +++ /dev/null @@ -1,439 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle.doc - -import groovy.json.JsonException -import groovy.json.JsonParserType -import groovy.json.JsonSlurper - -import org.gradle.api.DefaultTask -import org.gradle.api.InvalidUserDataException -import org.gradle.api.file.ConfigurableFileTree -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputFiles -import org.gradle.api.tasks.Internal -import org.gradle.api.tasks.TaskAction - -import java.nio.file.Path -import java.util.regex.Matcher - -/** - * A task which will run a closure on each snippet in the documentation. - */ -class SnippetsTask extends DefaultTask { - private static final String SCHAR = /(?:\\\/|[^\/])/ - private static final String SUBSTITUTION = /s\/($SCHAR+)\/($SCHAR*)\// - private static final String CATCH = /catch:\s*((?:\/[^\/]+\/)|[^ \]]+)/ - private static final String SKIP = /skip:([^\]]+)/ - private static final String SETUP = /setup:([^ \]]+)/ - private static final String WARNING = /warning:(.+)/ - private static final String NON_JSON = /(non_json)/ - private static final String TEST_SYNTAX = - /(?:$CATCH|$SUBSTITUTION|$SKIP|(continued)|$SETUP|$WARNING|(skip_shard_failures)) ?/ - - /** - * Action to take on each snippet. Called with a single parameter, an - * instance of Snippet. - */ - @Internal - Closure perSnippet - - /** - * The docs to scan. Defaults to every file in the directory exception the - * build.gradle file because that is appropriate for OpenSearch's docs - * directory. - */ - @InputFiles - ConfigurableFileTree docs = project.fileTree(project.projectDir) { - // No snippets in the build file - exclude 'build.gradle' - // That is where the snippets go, not where they come from! - exclude 'build' - } - - /** - * Substitutions done on every snippet's contents. - */ - @Input - Map defaultSubstitutions = [:] - - @TaskAction - void executeTask() { - /* - * Walks each line of each file, building snippets as it encounters - * the lines that make up the snippet. - */ - for (File file: docs) { - String lastLanguage - int lastLanguageLine - Snippet snippet = null - StringBuilder contents = null - List substitutions = null - String testEnv = null - Closure emit = { - snippet.contents = contents.toString() - contents = null - Closure doSubstitution = { String pattern, String subst -> - /* - * $body is really common but it looks like a - * backreference so we just escape it here to make the - * tests cleaner. - */ - subst = subst.replace('$body', '\\$body') - subst = subst.replace('$_path', '\\$_path') - // \n is a new line.... - subst = subst.replace('\\n', '\n') - snippet.contents = snippet.contents.replaceAll( - pattern, subst) - } - defaultSubstitutions.each doSubstitution - if (substitutions != null) { - substitutions.each doSubstitution - substitutions = null - } - if (snippet.language == null) { - throw new InvalidUserDataException("$snippet: " - + "Snippet missing a language. This is required by " - + "OpenSearch's doc testing infrastructure so we " - + "be sure we don't accidentally forget to test a " - + "snippet.") - } - // Try to detect snippets that contain `curl` - if (snippet.language == 'sh' || snippet.language == 'shell') { - snippet.curl = snippet.contents.contains('curl') - if (snippet.console == false && snippet.curl == false) { - throw new InvalidUserDataException("$snippet: " - + "No need for NOTCONSOLE if snippet doesn't " - + "contain `curl`.") - } - } - if (snippet.testResponse - && ('js' == snippet.language || 'console-result' == snippet.language) - && null == snippet.skip) { - String quoted = snippet.contents - // quote values starting with $ - .replaceAll(/([:,])\s*(\$[^ ,\n}]+)/, '$1 "$2"') - // quote fields starting with $ - .replaceAll(/(\$[^ ,\n}]+)\s*:/, '"$1":') - JsonSlurper slurper = - new JsonSlurper(type: JsonParserType.INDEX_OVERLAY) - try { - slurper.parseText(quoted) - } catch (JsonException e) { - throw new InvalidUserDataException("Invalid json " - + "in $snippet. The error is:\n${e.message}.\n" - + "After substitutions and munging, the json " - + "looks like:\n$quoted", e) - } - } - perSnippet(snippet) - snippet = null - } - file.eachLine('UTF-8') { String line, int lineNumber -> - Matcher matcher - matcher = line =~ /\[testenv="([^"]+)"\]\s*/ - if (matcher.matches()) { - testEnv = matcher.group(1) - } - if (line ==~ /-{4,}\s*/) { // Four dashes looks like a snippet - if (snippet == null) { - Path path = docs.dir.toPath().relativize(file.toPath()) - snippet = new Snippet(path: path, start: lineNumber, testEnv: testEnv) - if (lastLanguageLine == lineNumber - 1) { - snippet.language = lastLanguage - } - } else { - snippet.end = lineNumber - } - return - } - matcher = line =~ /\["?source"?,\s*"?([-\w]+)"?(,.*)?].*/ - if (matcher.matches()) { - lastLanguage = matcher.group(1) - lastLanguageLine = lineNumber - return - } - if (line ==~ /\/\/\s*AUTOSENSE\s*/) { - throw new InvalidUserDataException("$file:$lineNumber: " - + "AUTOSENSE has been replaced by CONSOLE.") - } - if (line ==~ /\/\/\s*CONSOLE\s*/) { - if (snippet == null) { - throw new InvalidUserDataException("$file:$lineNumber: " - + "CONSOLE not paired with a snippet") - } - if (snippet.console != null) { - throw new InvalidUserDataException("$file:$lineNumber: " - + "Can't be both CONSOLE and NOTCONSOLE") - } - snippet.console = true - return - } - if (line ==~ /\/\/\s*NOTCONSOLE\s*/) { - if (snippet == null) { - throw new InvalidUserDataException("$file:$lineNumber: " - + "NOTCONSOLE not paired with a snippet") - } - if (snippet.console != null) { - throw new InvalidUserDataException("$file:$lineNumber: " - + "Can't be both CONSOLE and NOTCONSOLE") - } - snippet.console = false - return - } - matcher = line =~ /\/\/\s*TEST(\[(.+)\])?\s*/ - if (matcher.matches()) { - if (snippet == null) { - throw new InvalidUserDataException("$file:$lineNumber: " - + "TEST not paired with a snippet at ") - } - snippet.test = true - if (matcher.group(2) != null) { - String loc = "$file:$lineNumber" - parse(loc, matcher.group(2), TEST_SYNTAX) { - if (it.group(1) != null) { - snippet.catchPart = it.group(1) - return - } - if (it.group(2) != null) { - if (substitutions == null) { - substitutions = [] - } - substitutions.add([it.group(2), it.group(3)]) - return - } - if (it.group(4) != null) { - snippet.skip = it.group(4) - return - } - if (it.group(5) != null) { - snippet.continued = true - return - } - if (it.group(6) != null) { - snippet.setup = it.group(6) - return - } - if (it.group(7) != null) { - snippet.warnings.add(it.group(7)) - return - } - if (it.group(8) != null) { - snippet.skipShardsFailures = true - return - } - throw new InvalidUserDataException( - "Invalid test marker: $line") - } - } - return - } - matcher = line =~ /\/\/\s*TESTRESPONSE(\[(.+)\])?\s*/ - if (matcher.matches()) { - if (snippet == null) { - throw new InvalidUserDataException("$file:$lineNumber: " - + "TESTRESPONSE not paired with a snippet") - } - snippet.testResponse = true - if (matcher.group(2) != null) { - if (substitutions == null) { - substitutions = [] - } - String loc = "$file:$lineNumber" - parse(loc, matcher.group(2), /(?:$SUBSTITUTION|$NON_JSON|$SKIP) ?/) { - if (it.group(1) != null) { - // TESTRESPONSE[s/adsf/jkl/] - substitutions.add([it.group(1), it.group(2)]) - } else if (it.group(3) != null) { - // TESTRESPONSE[non_json] - substitutions.add(['^', '/']) - substitutions.add(['\n$', '\\\\s*/']) - substitutions.add(['( +)', '$1\\\\s+']) - substitutions.add(['\n', '\\\\s*\n ']) - } else if (it.group(4) != null) { - // TESTRESPONSE[skip:reason] - snippet.skip = it.group(4) - } - } - } - return - } - if (line ==~ /\/\/\s*TESTSETUP\s*/) { - snippet.testSetup = true - return - } - if (line ==~ /\/\/\s*TEARDOWN\s*/) { - snippet.testTearDown = true - return - } - if (snippet == null) { - // Outside - return - } - if (snippet.end == Snippet.NOT_FINISHED) { - // Inside - if (contents == null) { - contents = new StringBuilder() - } - // We don't need the annotations - line = line.replaceAll(/<\d+>/, '') - // Nor any trailing spaces - line = line.replaceAll(/\s+$/, '') - contents.append(line).append('\n') - return - } - // Allow line continuations for console snippets within lists - if (snippet != null && line.trim() == '+') { - return - } - // Just finished - emit() - } - if (snippet != null) emit() - } - } - - static class Snippet { - static final int NOT_FINISHED = -1 - - /** - * Path to the file containing this snippet. Relative to docs.dir of the - * SnippetsTask that created it. - */ - Path path - int start - int end = NOT_FINISHED - String contents - String testEnv - - Boolean console = null - boolean test = false - boolean testResponse = false - boolean testSetup = false - boolean testTearDown = false - String skip = null - boolean continued = false - String language = null - String catchPart = null - String setup = null - boolean curl - List warnings = new ArrayList() - boolean skipShardsFailures = false - - @Override - public String toString() { - String result = "$path[$start:$end]" - if (language != null) { - result += "($language)" - } - if (console != null) { - result += console ? '// CONSOLE' : '// NOTCONSOLE' - } - if (test) { - result += '// TEST' - if (testEnv != null) { - result += "[testenv=$testEnv]" - } - if (catchPart) { - result += "[catch: $catchPart]" - } - if (skip) { - result += "[skip=$skip]" - } - if (continued) { - result += '[continued]' - } - if (setup) { - result += "[setup:$setup]" - } - for (String warning in warnings) { - result += "[warning:$warning]" - } - if (skipShardsFailures) { - result += '[skip_shard_failures]' - } - } - if (testResponse) { - result += '// TESTRESPONSE' - if (skip) { - result += "[skip=$skip]" - } - } - if (testSetup) { - result += '// TESTSETUP' - } - if (curl) { - result += '(curl)' - } - return result - } - } - - /** - * Repeatedly match the pattern to the string, calling the closure with the - * matchers each time there is a match. If there are characters that don't - * match then blow up. If the closure takes two parameters then the second - * one is "is this the last match?". - */ - protected parse(String location, String s, String pattern, Closure c) { - if (s == null) { - return // Silly null, only real stuff gets to match! - } - Matcher m = s =~ pattern - int offset = 0 - Closure extraContent = { message -> - StringBuilder cutOut = new StringBuilder() - cutOut.append(s[offset - 6..offset - 1]) - cutOut.append('*') - cutOut.append(s[offset..Math.min(offset + 5, s.length() - 1)]) - String cutOutNoNl = cutOut.toString().replace('\n', '\\n') - throw new InvalidUserDataException("$location: Extra content " - + "$message ('$cutOutNoNl') matching [$pattern]: $s") - } - while (m.find()) { - if (m.start() != offset) { - extraContent("between [$offset] and [${m.start()}]") - } - offset = m.end() - if (c.maximumNumberOfParameters == 1) { - c(m) - } else { - c(m, offset == s.length()) - } - } - if (offset == 0) { - throw new InvalidUserDataException("$location: Didn't match " - + "$pattern: $s") - } - if (offset != s.length()) { - extraContent("after [$offset]") - } - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy deleted file mode 100644 index 427e3f2740a89..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy +++ /dev/null @@ -1,261 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.opensearch.gradle.plugin - -import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin -import org.opensearch.gradle.BuildPlugin -import org.opensearch.gradle.NoticeTask -import org.opensearch.gradle.Version -import org.opensearch.gradle.VersionProperties -import org.opensearch.gradle.dependencies.CompileOnlyResolvePlugin -import org.opensearch.gradle.info.BuildParams -import org.opensearch.gradle.plugin.PluginPropertiesExtension -import org.opensearch.gradle.test.RestTestBasePlugin -import org.opensearch.gradle.testclusters.RunTask -import org.opensearch.gradle.util.Util -import org.gradle.api.InvalidUserDataException -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.plugins.BasePlugin -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.api.publish.maven.plugins.MavenPublishPlugin -import org.gradle.api.publish.maven.tasks.GenerateMavenPom -import org.gradle.api.tasks.Copy -import org.gradle.api.tasks.SourceSet -import org.gradle.api.tasks.TaskProvider -import org.gradle.api.tasks.bundling.Zip -import org.gradle.jvm.tasks.Jar - -/** - * Encapsulates build configuration for an OpenSearch plugin. - */ -class PluginBuildPlugin implements Plugin { - - public static final String PLUGIN_EXTENSION_NAME = 'opensearchplugin' - - @Override - void apply(Project project) { - project.pluginManager.apply(BuildPlugin) - project.pluginManager.apply(RestTestBasePlugin) - project.pluginManager.apply(CompileOnlyResolvePlugin.class); - - PluginPropertiesExtension extension = project.extensions.create(PLUGIN_EXTENSION_NAME, PluginPropertiesExtension, project) - configureDependencies(project) - - boolean isModule = project.path.startsWith(':modules:') - - createBundleTasks(project, extension) - - project.afterEvaluate { - project.extensions.getByType(PluginPropertiesExtension).extendedPlugins.each { pluginName -> - // Auto add dependent modules to the test cluster - if (project.findProject(":modules:${pluginName}") != null) { - project.testClusters.all { - module(":modules:${pluginName}") - } - } - } - PluginPropertiesExtension extension1 = project.getExtensions().getByType(PluginPropertiesExtension.class) - configurePublishing(project, extension1) - String name = extension1.name - project.archivesBaseName = name - project.description = extension1.description - - if (extension1.name == null) { - throw new InvalidUserDataException('name is a required setting for opensearchplugin') - } - if (extension1.description == null) { - throw new InvalidUserDataException('description is a required setting for opensearchplugin') - } - if (extension1.classname == null) { - throw new InvalidUserDataException('classname is a required setting for opensearchplugin') - } - - Map properties = [ - 'name' : extension1.name, - 'description' : extension1.description, - 'version' : extension1.version, - 'opensearchVersion' : Version.fromString(VersionProperties.getOpenSearch()).toString(), - 'javaVersion' : project.targetCompatibility as String, - 'classname' : extension1.classname, - 'customFolderName' : extension1.customFolderName, - 'extendedPlugins' : extension1.extendedPlugins.join(','), - 'hasNativeController' : extension1.hasNativeController, - 'requiresKeystore' : extension1.requiresKeystore - ] - project.tasks.named('pluginProperties').configure { - expand(properties) - inputs.properties(properties) - } - if (isModule == false) { - addNoticeGeneration(project, extension1) - } - } - - project.tasks.named('testingConventions').configure { - naming.clear() - naming { - Tests { - baseClass 'org.apache.lucene.util.LuceneTestCase' - } - IT { - baseClass 'org.opensearch.test.OpenSearchIntegTestCase' - baseClass 'org.opensearch.test.rest.OpenSearchRestTestCase' - baseClass 'org.opensearch.test.OpenSearchSingleNodeTestCase' - } - } - } - project.configurations.getByName('default') - .extendsFrom(project.configurations.getByName('runtimeClasspath')) - // allow running ES with this plugin in the foreground of a build - project.tasks.register('run', RunTask) { - dependsOn(project.tasks.bundlePlugin) - } - } - - private void configurePublishing(Project project, PluginPropertiesExtension extension) { - // Only configure publishing if applied externally - if (extension.hasClientJar) { - project.pluginManager.apply('nebula.maven-base-publish') - // Only change Jar tasks, we don't want a -client zip so we can't change archivesBaseName - project.tasks.withType(Jar) { - archiveBaseName = archiveBaseName.get() + "-client" - } - // always configure publishing for client jars - project.publishing.publications.nebula(MavenPublication).artifactId(extension.name + "-client") - project.tasks.withType(GenerateMavenPom.class).configureEach { GenerateMavenPom generatePOMTask -> - generatePOMTask.destination = "${project.buildDir}/distributions/${project.archivesBaseName}-client-${project.versions.opensearch}.pom" - } - } else { - if (project.plugins.hasPlugin(MavenPublishPlugin)) { - project.publishing.publications.nebula(MavenPublication).artifactId(extension.name) - } - } - } - - private static void configureDependencies(Project project) { - project.dependencies { - if (BuildParams.internal) { - compileOnly project.project(':server') - testImplementation project.project(':test:framework') - } else { - compileOnly "org.opensearch:opensearch:${project.versions.opensearch}" - testImplementation "org.opensearch.test:framework:${project.versions.opensearch}" - } - // we "upgrade" these optional deps to provided for plugins, since they will run - // with a full opensearch server that includes optional deps - compileOnly "org.locationtech.spatial4j:spatial4j:${project.versions.spatial4j}" - compileOnly "org.locationtech.jts:jts-core:${project.versions.jts}" - compileOnly "org.apache.logging.log4j:log4j-api:${project.versions.log4j}" - compileOnly "org.apache.logging.log4j:log4j-core:${project.versions.log4j}" - compileOnly "net.java.dev.jna:jna:${project.versions.jna}" - } - } - - /** - * Adds a bundlePlugin task which builds the zip containing the plugin jars, - * metadata, properties, and packaging files - */ - private static void createBundleTasks(Project project, PluginPropertiesExtension extension) { - File pluginMetadata = project.file('src/main/plugin-metadata') - File templateFile = new File(project.buildDir, "templates/plugin-descriptor.properties") - - // create tasks to build the properties file for this plugin - TaskProvider copyPluginPropertiesTemplate = project.tasks.register('copyPluginPropertiesTemplate') { - outputs.file(templateFile) - doLast { - InputStream resourceTemplate = PluginBuildPlugin.getResourceAsStream("/${templateFile.name}") - templateFile.setText(resourceTemplate.getText('UTF-8'), 'UTF-8') - } - } - - TaskProvider buildProperties = project.tasks.register('pluginProperties', Copy) { - dependsOn(copyPluginPropertiesTemplate) - from(templateFile) - into("${project.buildDir}/generated-resources") - } - - // add the plugin properties and metadata to test resources, so unit tests can - // know about the plugin (used by test security code to statically initialize the plugin in unit tests) - SourceSet testSourceSet = project.sourceSets.test - testSourceSet.output.dir("${project.buildDir}/generated-resources", builtBy: buildProperties) - testSourceSet.resources.srcDir(pluginMetadata) - - // create the actual bundle task, which zips up all the files for the plugin - TaskProvider bundle = project.tasks.register('bundlePlugin', Zip) { - from buildProperties - from pluginMetadata // metadata (eg custom security policy) - /* - * If the plugin is using the shadow plugin then we need to bundle - * that shadow jar. - */ - from { project.plugins.hasPlugin(ShadowPlugin) ? project.shadowJar : project.jar } - from project.configurations.runtimeClasspath - project.configurations.getByName( - CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME - ) - // extra files for the plugin to go into the zip - from('src/main/packaging') // TODO: move all config/bin/_size/etc into packaging - from('src/main') { - include 'config/**' - include 'bin/**' - } - } - project.tasks.named(BasePlugin.ASSEMBLE_TASK_NAME).configure { - dependsOn(bundle) - } - - // also make the zip available as a configuration (used when depending on this project) - project.configurations.create('zip') - project.artifacts.add('zip', bundle) - } - - /** Configure the pom for the main jar of this plugin */ - protected static void addNoticeGeneration(Project project, PluginPropertiesExtension extension) { - File licenseFile = extension.licenseFile - if (licenseFile != null) { - project.tasks.named('bundlePlugin').configure { - from(licenseFile.parentFile) { - include(licenseFile.name) - rename { 'LICENSE.txt' } - } - } - } - File noticeFile = extension.noticeFile - if (noticeFile != null) { - TaskProvider generateNotice = project.tasks.register('generateNotice', NoticeTask) { - inputFile = noticeFile - source(Util.getJavaMainSourceSet(project).get().allJava) - } - project.tasks.named('bundlePlugin').configure { - from(generateNotice) - } - } - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/precommit/LicenseHeadersPrecommitPlugin.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/precommit/LicenseHeadersPrecommitPlugin.groovy deleted file mode 100644 index fddabd09b01d2..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/precommit/LicenseHeadersPrecommitPlugin.groovy +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle.precommit - -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.tasks.TaskProvider - -class LicenseHeadersPrecommitPlugin extends PrecommitPlugin { - @Override - TaskProvider createTask(Project project) { - return project.getTasks().register("licenseHeaders", LicenseHeadersTask.class); - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/precommit/LicenseHeadersTask.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/precommit/LicenseHeadersTask.groovy deleted file mode 100644 index b330934ed2d26..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/precommit/LicenseHeadersTask.groovy +++ /dev/null @@ -1,199 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.opensearch.gradle.precommit - -import org.apache.rat.anttasks.Report -import org.apache.rat.anttasks.SubstringLicenseMatcher -import org.apache.rat.license.SimpleLicenseFamily -import org.opensearch.gradle.AntTask -import org.gradle.api.file.FileCollection -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputFiles -import org.gradle.api.tasks.OutputFile -import org.gradle.api.tasks.SkipWhenEmpty - -import java.nio.file.Files - -/** - * Checks files for license headers. - *

    - * This is a port of the apache lucene check - */ -class LicenseHeadersTask extends AntTask { - - @OutputFile - File reportFile = new File(project.buildDir, 'reports/licenseHeaders/rat.log') - - /** Allowed license families for this project. */ - @Input - List approvedLicenses = ['Apache', 'Generated', 'SPDX', 'Vendored'] - - /** - * Files that should be excluded from the license header check. Use with extreme care, only in situations where the license on the - * source file is compatible with the codebase but we do not want to add the license to the list of approved headers (to avoid the - * possibility of inadvertently using the license on our own source files). - */ - @Input - List excludes = [] - - /** - * Additional license families that may be found. The key is the license category name (5 characters), - * followed by the family name and the value list of patterns to search for. - */ - protected Map additionalLicenses = new HashMap<>() - - LicenseHeadersTask() { - description = "Checks sources for missing, incorrect, or unacceptable license headers" - } - - /** - * The list of java files to check. protected so the afterEvaluate closure in the - * constructor can write to it. - */ - @InputFiles - @SkipWhenEmpty - List getJavaFiles() { - return project.sourceSets.collect({it.allJava}) - } - - /** - * Add a new license type. - * - * The license may be added to the {@link #approvedLicenses} using the {@code familyName}. - * - * @param categoryName A 5-character string identifier for the license - * @param familyName An expanded string name for the license - * @param pattern A pattern to search for, which if found, indicates a file contains the license - */ - void additionalLicense(String categoryName, String familyName, String pattern) { - if (categoryName.length() != 5) { - throw new IllegalArgumentException("License category name must be exactly 5 characters, got ${categoryName}"); - } - additionalLicenses.put(categoryName + familyName, pattern); - } - - @Override - protected void runAnt(AntBuilder ant) { - ant.project.addTaskDefinition('ratReport', Report) - ant.project.addDataTypeDefinition('substringMatcher', SubstringLicenseMatcher) - ant.project.addDataTypeDefinition('approvedLicense', SimpleLicenseFamily) - - Files.deleteIfExists(reportFile.toPath()) - - // run rat, going to the file - ant.ratReport(reportFile: reportFile.absolutePath, addDefaultLicenseMatchers: true) { - for (FileCollection dirSet : javaFiles) { - for (File dir: dirSet.srcDirs) { - // sometimes these dirs don't exist, e.g. site-plugin has no actual java src/main... - if (dir.exists()) { - ant.fileset(dir: dir, excludes: excludes.join(' ')) - } - } - } - - // BSD 4-clause stuff (is disallowed below) - // we keep this here, in case someone adds BSD code for some reason, it should never be allowed. - substringMatcher(licenseFamilyCategory: "BSD4 ", - licenseFamilyName: "Original BSD License (with advertising clause)") { - pattern(substring: "All advertising materials") - } - - // Apache - substringMatcher(licenseFamilyCategory: "AL ", - licenseFamilyName: "Apache") { - // Apache license (ES) - pattern(substring: "Licensed to Elasticsearch under one or more contributor") - } - - // SPDX - substringMatcher(licenseFamilyCategory: "SPDX ", - licenseFamilyName: "SPDX") { - // Apache license (OpenSearch) - pattern(substring: "SPDX-License-Identifier: Apache-2.0") - pattern(substring: "Copyright OpenSearch Contributors.") - } - - // Generated resources - substringMatcher(licenseFamilyCategory: "GEN ", - licenseFamilyName: "Generated") { - // parsers generated by antlr - pattern(substring: "ANTLR GENERATED CODE") - } - - // Vendored Code - substringMatcher(licenseFamilyCategory: "VEN ", - licenseFamilyName: "Vendored") { - pattern(substring: "@notice") - } - - // license types added by the project - for (Map.Entry additional : additionalLicenses.entrySet()) { - String category = additional.getKey().substring(0, 5) - String family = additional.getKey().substring(5) - substringMatcher(licenseFamilyCategory: category, - licenseFamilyName: family) { - pattern(substring: additional.getValue()) - } - } - - // approved categories - for (String licenseFamily : approvedLicenses) { - approvedLicense(familyName: licenseFamily) - } - } - - // check the license file for any errors, this should be fast. - boolean zeroUnknownLicenses = false - boolean foundProblemsWithFiles = false - reportFile.eachLine('UTF-8') { line -> - if (line.startsWith("0 Unknown Licenses")) { - zeroUnknownLicenses = true - } - - if (line.startsWith(" !")) { - foundProblemsWithFiles = true - } - } - - if (zeroUnknownLicenses == false || foundProblemsWithFiles) { - // print the unapproved license section, usually its all you need to fix problems. - int sectionNumber = 0 - reportFile.eachLine('UTF-8') { line -> - if (line.startsWith("*******************************")) { - sectionNumber++ - } else { - if (sectionNumber == 2) { - logger.error(line) - } - } - } - throw new IllegalStateException("License header problems were found! Full details: " + reportFile.absolutePath) - } - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/precommit/PrecommitTasks.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/precommit/PrecommitTasks.groovy deleted file mode 100644 index e5cd4cda65040..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/precommit/PrecommitTasks.groovy +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.opensearch.gradle.precommit - - -import org.gradle.api.Project - -/** - * Validation tasks which should be run before committing. These run before tests. - */ -class PrecommitTasks { - - /** Adds a precommit task, which depends on non-test verification tasks. */ - - static void create(Project project, boolean includeDependencyLicenses) { - - project.pluginManager.apply(ForbiddenApisPrecommitPlugin) - project.pluginManager.apply(JarHellPrecommitPlugin) - project.pluginManager.apply(ForbiddenPatternsPrecommitPlugin) - project.pluginManager.apply(LicenseHeadersPrecommitPlugin) - project.pluginManager.apply(FilePermissionsPrecommitPlugin) - project.pluginManager.apply(ThirdPartyAuditPrecommitPlugin) - project.pluginManager.apply(TestingConventionsPrecommitPlugin) - - // tasks with just tests don't need dependency licenses, so this flag makes adding - // the task optional - if (includeDependencyLicenses) { - project.pluginManager.apply(DependencyLicensesPrecommitPlugin) - } - if (project.path != ':build-tools') { - /* - * Sadly, build-tools can't have logger-usage-check because that - * would create a circular project dependency between build-tools - * (which provides NamingConventionsCheck) and :test:logger-usage - * which provides the logger usage check. Since the build tools - * don't use the logger usage check because they don't have any - * of Elaticsearch's loggers and :test:logger-usage actually does - * use the NamingConventionsCheck we break the circular dependency - * here. - */ - project.pluginManager.apply(LoggerUsagePrecommitPlugin) - } - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/test/AntFixture.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/test/AntFixture.groovy deleted file mode 100644 index 316db8aa01764..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/test/AntFixture.groovy +++ /dev/null @@ -1,322 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle.test - -import org.apache.tools.ant.taskdefs.condition.Os -import org.gradle.api.GradleException -import org.gradle.api.tasks.Exec -import org.gradle.api.tasks.Internal -import org.gradle.api.tasks.TaskProvider -import org.opensearch.gradle.AntTask -import org.opensearch.gradle.LoggedExec -/** - * A fixture for integration tests which runs in a separate process launched by Ant. - */ -class AntFixture extends AntTask implements Fixture { - - /** The path to the executable that starts the fixture. */ - @Internal - String executable - - private final List arguments = new ArrayList<>() - - void args(Object... args) { - arguments.addAll(args) - } - - /** - * Environment variables for the fixture process. The value can be any object, which - * will have toString() called at execution time. - */ - private final Map environment = new HashMap<>() - - void env(String key, Object value) { - environment.put(key, value) - } - - /** A flag to indicate whether the command should be executed from a shell. */ - @Internal - boolean useShell = false - - @Internal - int maxWaitInSeconds = 30 - - /** - * A flag to indicate whether the fixture should be run in the foreground, or spawned. - * It is protected so subclasses can override (eg RunTask). - */ - protected boolean spawn = true - - /** - * A closure to call before the fixture is considered ready. The closure is passed the fixture object, - * as well as a groovy AntBuilder, to enable running ant condition checks. The default wait - * condition is for http on the http port. - */ - @Internal - Closure waitCondition = { AntFixture fixture, AntBuilder ant -> - File tmpFile = new File(fixture.cwd, 'wait.success') - ant.get(src: "http://${fixture.addressAndPort}", - dest: tmpFile.toString(), - ignoreerrors: true, // do not fail on error, so logging information can be flushed - retries: 10) - return tmpFile.exists() - } - - private final TaskProvider stopTask - - AntFixture() { - stopTask = createStopTask() - finalizedBy(stopTask) - } - - @Override - @Internal - TaskProvider getStopTask() { - return stopTask - } - - @Override - protected void runAnt(AntBuilder ant) { - // reset everything - getFileSystemOperations().delete { - it.delete(baseDir) - } - cwd.mkdirs() - final String realExecutable - final List realArgs = new ArrayList<>() - final Map realEnv = environment - // We need to choose which executable we are using. In shell mode, or when we - // are spawning and thus using the wrapper script, the executable is the shell. - if (useShell || spawn) { - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - realExecutable = 'cmd' - realArgs.add('/C') - realArgs.add('"') // quote the entire command - } else { - realExecutable = 'sh' - } - } else { - realExecutable = executable - realArgs.addAll(arguments) - } - if (spawn) { - writeWrapperScript(executable) - realArgs.add(wrapperScript) - realArgs.addAll(arguments) - } - if (Os.isFamily(Os.FAMILY_WINDOWS) && (useShell || spawn)) { - realArgs.add('"') - } - commandString.eachLine { line -> logger.info(line) } - - ant.exec(executable: realExecutable, spawn: spawn, dir: cwd, taskname: name) { - realEnv.each { key, value -> env(key: key, value: value) } - realArgs.each { arg(value: it) } - } - - String failedProp = "failed${name}" - // first wait for resources, or the failure marker from the wrapper script - ant.waitfor(maxwait: maxWaitInSeconds, maxwaitunit: 'second', checkevery: '500', checkeveryunit: 'millisecond', timeoutproperty: failedProp) { - or { - resourceexists { - file(file: failureMarker.toString()) - } - and { - resourceexists { - file(file: pidFile.toString()) - } - resourceexists { - file(file: portsFile.toString()) - } - } - } - } - - if (ant.project.getProperty(failedProp) || failureMarker.exists()) { - fail("Failed to start ${name}") - } - - // the process is started (has a pid) and is bound to a network interface - // so now evaluates if the waitCondition is successful - // TODO: change this to a loop? - boolean success - try { - success = waitCondition(this, ant) - } catch (Exception e) { - String msg = "Wait condition caught exception for ${name}" - logger.error(msg, e) - fail(msg, e) - } - if (success == false) { - fail("Wait condition failed for ${name}") - } - } - - /** Returns a debug string used to log information about how the fixture was run. */ - @Internal - protected String getCommandString() { - String commandString = "\n${name} configuration:\n" - commandString += "-----------------------------------------\n" - commandString += " cwd: ${cwd}\n" - commandString += " command: ${executable} ${arguments.join(' ')}\n" - commandString += ' environment:\n' - environment.each { k, v -> commandString += " ${k}: ${v}\n" } - if (spawn) { - commandString += "\n [${wrapperScript.name}]\n" - wrapperScript.eachLine('UTF-8', { line -> commandString += " ${line}\n"}) - } - return commandString - } - - /** - * Writes a script to run the real executable, so that stdout/stderr can be captured. - * TODO: this could be removed if we do use our own ProcessBuilder and pump output from the process - */ - private void writeWrapperScript(String executable) { - wrapperScript.parentFile.mkdirs() - String argsPasser = '"$@"' - String exitMarker = "; if [ \$? != 0 ]; then touch run.failed; fi" - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - argsPasser = '%*' - exitMarker = "\r\n if \"%errorlevel%\" neq \"0\" ( type nul >> run.failed )" - } - wrapperScript.setText("\"${executable}\" ${argsPasser} > run.log 2>&1 ${exitMarker}", 'UTF-8') - } - - /** Fail the build with the given message, and logging relevant info*/ - private void fail(String msg, Exception... suppressed) { - if (logger.isInfoEnabled() == false) { - // We already log the command at info level. No need to do it twice. - commandString.eachLine { line -> logger.error(line) } - } - logger.error("${name} output:") - logger.error("-----------------------------------------") - logger.error(" failure marker exists: ${failureMarker.exists()}") - logger.error(" pid file exists: ${pidFile.exists()}") - logger.error(" ports file exists: ${portsFile.exists()}") - // also dump the log file for the startup script (which will include ES logging output to stdout) - if (runLog.exists()) { - logger.error("\n [log]") - runLog.eachLine { line -> logger.error(" ${line}") } - } - logger.error("-----------------------------------------") - GradleException toThrow = new GradleException(msg) - for (Exception e : suppressed) { - toThrow.addSuppressed(e) - } - throw toThrow - } - - /** Adds a task to kill an opensearch node with the given pidfile */ - private TaskProvider createStopTask() { - final AntFixture fixture = this - final Object pid = "${ -> fixture.pid }" - TaskProvider stop = project.tasks.register("${name}#stop", LoggedExec) - stop.configure { - onlyIf { fixture.pidFile.exists() } - doFirst { - logger.info("Shutting down ${fixture.name} with pid ${pid}") - } - - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - executable = 'Taskkill' - args('/PID', pid, '/F') - } else { - executable = 'kill' - args('-9', pid) - } - doLast { - getFileSystemOperations().delete { - it.delete(fixture.pidFile) - } - } - - } - - return stop - } - - /** - * A path relative to the build dir that all configuration and runtime files - * will live in for this fixture - */ - @Internal - protected File getBaseDir() { - return new File(project.buildDir, "fixtures/${name}") - } - - /** Returns the working directory for the process. Defaults to "cwd" inside baseDir. */ - @Internal - protected File getCwd() { - return new File(baseDir, 'cwd') - } - - /** Returns the file the process writes its pid to. Defaults to "pid" inside baseDir. */ - @Internal - protected File getPidFile() { - return new File(baseDir, 'pid') - } - - /** Reads the pid file and returns the process' pid */ - @Internal - int getPid() { - return Integer.parseInt(pidFile.getText('UTF-8').trim()) - } - - /** Returns the file the process writes its bound ports to. Defaults to "ports" inside baseDir. */ - @Internal - protected File getPortsFile() { - return new File(baseDir, 'ports') - } - - /** Returns an address and port suitable for a uri to connect to this node over http */ - @Internal - String getAddressAndPort() { - return portsFile.readLines("UTF-8").get(0) - } - - /** Returns a file that wraps around the actual command when {@code spawn == true}. */ - @Internal - protected File getWrapperScript() { - return new File(cwd, Os.isFamily(Os.FAMILY_WINDOWS) ? 'run.bat' : 'run') - } - - /** Returns a file that the wrapper script writes when the command failed. */ - @Internal - protected File getFailureMarker() { - return new File(cwd, 'run.failed') - } - - /** Returns a file that the wrapper script writes when the command failed. */ - @Internal - protected File getRunLog() { - return new File(cwd, 'run.log') - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterConfiguration.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterConfiguration.groovy deleted file mode 100644 index a5207933c3c72..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterConfiguration.groovy +++ /dev/null @@ -1,277 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.opensearch.gradle.test - -import org.opensearch.gradle.Version -import org.gradle.api.GradleException -import org.gradle.api.Project -import org.gradle.api.tasks.Input - -/** Configuration for an opensearch cluster, used for integration tests. */ -class ClusterConfiguration { - - private final Project project - - @Input - String distribution = 'archive' - - @Input - int numNodes = 1 - - @Input - int numBwcNodes = 0 - - @Input - Version bwcVersion = null - - @Input - int httpPort = 0 - - @Input - int transportPort = 0 - - /** - * An override of the data directory. Input is the node number and output - * is the override data directory. - */ - @Input - Closure dataDir = null - - /** Optional override of the cluster name. */ - @Input - String clusterName = null - - @Input - boolean daemonize = true - - @Input - boolean debug = false - - /** - * Configuration of the setting {@code discovery.zen.minimum_master_nodes} on the nodes. - * In case of more than one node, this defaults to the number of nodes - */ - @Input - Closure minimumMasterNodes = { - if (bwcVersion != null && bwcVersion.before("6.5.0")) { - return numNodes > 1 ? numNodes : -1 - } else { - return numNodes > 1 ? numNodes.intdiv(2) + 1 : -1 - } - } - - /** - * Whether the initial_master_nodes setting should be automatically derived from the nodes - * in the cluster. Only takes effect if all nodes in the cluster understand this setting - * and the discovery type is not explicitly set. - */ - @Input - boolean autoSetInitialMasterNodes = true - - /** - * Whether the file-based discovery provider should be automatically setup based on - * the nodes in the cluster. Only takes effect if no other hosts provider is already - * configured. - */ - @Input - boolean autoSetHostsProvider = true - - @Input - String jvmArgs = "-Xms" + System.getProperty('tests.heap.size', '512m') + - " " + "-Xmx" + System.getProperty('tests.heap.size', '512m') + - " " + System.getProperty('tests.jvm.argline', '') - - /** - * Should the shared environment be cleaned on cluster startup? Defaults - * to {@code true} so we run with a clean cluster but some tests wish to - * preserve snapshots between clusters so they set this to true. - */ - @Input - boolean cleanShared = true - - /** - * A closure to call which returns the unicast host to connect to for cluster formation. - * - * This allows multi node clusters, or a new cluster to connect to an existing cluster. - * The closure takes three arguments, the NodeInfo for the first node in the cluster, - * the NodeInfo for the node current being configured, an AntBuilder which may be used - * to wait on conditions before returning. - */ - @Input - Closure unicastTransportUri = { NodeInfo seedNode, NodeInfo node, AntBuilder ant -> - if (seedNode == node) { - return null - } - ant.waitfor(maxwait: '40', maxwaitunit: 'second', checkevery: '500', checkeveryunit: 'millisecond', - timeoutproperty: "failed.${seedNode.transportPortsFile.path}") { - resourceexists { - file(file: seedNode.transportPortsFile.toString()) - } - } - if (ant.properties.containsKey("failed.${seedNode.transportPortsFile.path}".toString())) { - throw new GradleException("Failed to locate seed node transport file [${seedNode.transportPortsFile}]: " + - "timed out waiting for it to be created after 40 seconds") - } - return seedNode.transportUri() - } - - /** - * A closure to call which returns a manually supplied list of unicast seed hosts. - */ - @Input - Closure> otherUnicastHostAddresses = { - Collections.emptyList() - } - - /** - * A closure to call before the cluster is considered ready. The closure is passed the node info, - * as well as a groovy AntBuilder, to enable running ant condition checks. The default wait - * condition is for http on the http port. - */ - @Input - Closure waitCondition = { NodeInfo node, AntBuilder ant -> - File tmpFile = new File(node.cwd, 'wait.success') - String waitUrl = "http://${node.httpUri()}/_cluster/health?wait_for_nodes=>=${numNodes}&wait_for_status=yellow" - ant.echo(message: "==> [${new Date()}] checking health: ${waitUrl}", - level: 'info') - // checking here for wait_for_nodes to be >= the number of nodes because its possible - // this cluster is attempting to connect to nodes created by another task (same cluster name), - // so there will be more nodes in that case in the cluster state - ant.get(src: waitUrl, - dest: tmpFile.toString(), - ignoreerrors: true, // do not fail on error, so logging buffers can be flushed by the wait task - retries: 10) - return tmpFile.exists() - } - - /** - * The maximum number of seconds to wait for nodes to complete startup, which includes writing - * the ports files for the transports and the pid file. This wait time occurs before the wait - * condition is executed. - */ - @Input - int nodeStartupWaitSeconds = 30 - - public ClusterConfiguration(Project project) { - this.project = project - } - - // **Note** for systemProperties, settings, keystoreFiles etc: - // value could be a GString that is evaluated to just a String - // there are cases when value depends on task that is not executed yet on configuration stage - Map systemProperties = new HashMap<>() - - Map environmentVariables = new HashMap<>() - - Map settings = new HashMap<>() - - Map keystoreSettings = new HashMap<>() - - Map keystoreFiles = new HashMap<>() - - // map from destination path, to source file - Map extraConfigFiles = new HashMap<>() - - LinkedHashMap plugins = new LinkedHashMap<>() - - List modules = new ArrayList<>() - - LinkedHashMap setupCommands = new LinkedHashMap<>() - - List dependencies = new ArrayList<>() - - @Input - void systemProperty(String property, Object value) { - systemProperties.put(property, value) - } - - @Input - void environment(String variable, Object value) { - environmentVariables.put(variable, value) - } - - @Input - void setting(String name, Object value) { - settings.put(name, value) - } - - @Input - void keystoreSetting(String name, String value) { - keystoreSettings.put(name, value) - } - - /** - * Adds a file to the keystore. The name is the secure setting name, and the sourceFile - * is anything accepted by project.file() - */ - @Input - void keystoreFile(String name, Object sourceFile) { - keystoreFiles.put(name, sourceFile) - } - - @Input - void plugin(String path) { - Project pluginProject = project.project(path) - plugins.put(pluginProject.name, pluginProject) - } - - @Input - void mavenPlugin(String name, String mavenCoords) { - plugins.put(name, mavenCoords) - } - - /** Add a module to the cluster. The project must be an opensearchplugin and have a single zip default artifact. */ - @Input - void module(Project moduleProject) { - modules.add(moduleProject) - } - - @Input - void setupCommand(String name, Object... args) { - setupCommands.put(name, args) - } - - /** - * Add an extra configuration file. The path is relative to the config dir, and the sourceFile - * is anything accepted by project.file() - */ - @Input - void extraConfigFile(String path, Object sourceFile) { - if (path == 'opensearch.yml') { - throw new GradleException('Overwriting opensearch.yml is not allowed, add additional settings using cluster { setting "foo", "bar" }') - } - extraConfigFiles.put(path, sourceFile) - } - - /** Add dependencies that must be run before the first task setting up the cluster. */ - @Input - void dependsOn(Object... deps) { - dependencies.addAll(deps) - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy deleted file mode 100644 index c3dd2526de385..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy +++ /dev/null @@ -1,1017 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.opensearch.gradle.test - -import org.apache.tools.ant.DefaultLogger -import org.apache.tools.ant.taskdefs.condition.Os -import org.opensearch.gradle.BuildPlugin -import org.opensearch.gradle.BwcVersions -import org.opensearch.gradle.LoggedExec -import org.opensearch.gradle.Version -import org.opensearch.gradle.VersionProperties -import org.opensearch.gradle.info.BuildParams -import org.opensearch.gradle.plugin.PluginBuildPlugin -import org.opensearch.gradle.plugin.PluginPropertiesExtension -import org.gradle.api.AntBuilder -import org.gradle.api.DefaultTask -import org.gradle.api.GradleException -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.artifacts.Configuration -import org.gradle.api.artifacts.Dependency -import org.gradle.api.file.FileCollection -import org.gradle.api.logging.Logger -import org.gradle.api.tasks.Copy -import org.gradle.api.tasks.Delete -import org.gradle.api.tasks.Exec -import org.gradle.internal.jvm.Jvm - -import java.nio.charset.StandardCharsets -import java.nio.file.Paths -import java.util.concurrent.TimeUnit -import java.util.stream.Collectors - -/** - * A helper for creating tasks to build a cluster that is used by a task, and tear down the cluster when the task is finished. - */ -class ClusterFormationTasks { - - /** - * Adds dependent tasks to the given task to start and stop a cluster with the given configuration. - * - * Returns a list of NodeInfo objects for each node in the cluster. - */ - static List setup(Project project, String prefix, Task runner, ClusterConfiguration config) { - File sharedDir = new File(project.buildDir, "cluster/shared") - Object startDependencies = config.dependencies - /* First, if we want a clean environment, we remove everything in the - * shared cluster directory to ensure there are no leftovers in repos - * or anything in theory this should not be necessary but repositories - * are only deleted in the cluster-state and not on-disk such that - * snapshots survive failures / test runs and there is no simple way - * today to fix that. */ - if (config.cleanShared) { - Task cleanup = project.tasks.create( - name: "${prefix}#prepareCluster.cleanShared", - type: Delete, - dependsOn: startDependencies) { - delete sharedDir - doLast { - sharedDir.mkdirs() - } - } - startDependencies = cleanup - } - List startTasks = [] - List nodes = [] - if (config.numNodes < config.numBwcNodes) { - throw new GradleException("numNodes must be >= numBwcNodes [${config.numNodes} < ${config.numBwcNodes}]") - } - if (config.numBwcNodes > 0 && config.bwcVersion == null) { - throw new GradleException("bwcVersion must not be null if numBwcNodes is > 0") - } - // this is our current version distribution configuration we use for all kinds of REST tests etc. - Configuration currentDistro = project.configurations.create("${prefix}_opensearchDistro") - Configuration bwcDistro = project.configurations.create("${prefix}_opensearchBwcDistro") - Configuration bwcPlugins = project.configurations.create("${prefix}_opensearchBwcPlugins") - if (System.getProperty('tests.distribution', 'archive') == 'integ-test-zip') { - throw new Exception("tests.distribution=integ-test-zip is not supported") - } - configureDistributionDependency(project, config.distribution, currentDistro, VersionProperties.getOpenSearch()) - boolean hasBwcNodes = config.numBwcNodes > 0 - if (hasBwcNodes) { - if (config.bwcVersion == null) { - throw new IllegalArgumentException("Must specify bwcVersion when numBwcNodes > 0") - } - // if we have a cluster that has a BWC cluster we also need to configure a dependency on the BWC version - // this version uses the same distribution etc. and only differs in the version we depend on. - // from here on everything else works the same as if it's the current version, we fetch the BWC version - // from mirrors using gradles built-in mechanism etc. - - configureDistributionDependency(project, config.distribution, bwcDistro, config.bwcVersion.toString()) - for (Map.Entry entry : config.plugins.entrySet()) { - configureBwcPluginDependency(project, entry.getValue(), bwcPlugins, config.bwcVersion) - } - bwcDistro.resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS) - bwcPlugins.resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS) - } - for (int i = 0; i < config.numNodes; i++) { - // we start N nodes and out of these N nodes there might be M bwc nodes. - // for each of those nodes we might have a different configuration - Configuration distro - String opensearchVersion - if (i < config.numBwcNodes) { - opensearchVersion = config.bwcVersion.toString() - if (project.bwcVersions.unreleased.contains(config.bwcVersion)) { - opensearchVersion += "-SNAPSHOT" - } - distro = bwcDistro - } else { - opensearchVersion = VersionProperties.getOpenSearch() - distro = currentDistro - } - NodeInfo node = new NodeInfo(config, i, project, prefix, opensearchVersion, sharedDir) - nodes.add(node) - Closure writeConfigSetup - Object dependsOn - if (node.nodeVersion.onOrAfter("6.5.0")) { - writeConfigSetup = { Map esConfig -> - if (config.getAutoSetHostsProvider()) { - // Don't force discovery provider if one is set by the test cluster specs already - final String seedProvidersSettingName = - node.nodeVersion.onOrAfter("7.0.0") ? "discovery.seed_providers" : "discovery.zen.hosts_provider"; - if (esConfig.containsKey(seedProvidersSettingName) == false) { - esConfig[seedProvidersSettingName] = 'file' - } - esConfig[node.nodeVersion.onOrAfter("7.0.0") ? "discovery.seed_hosts" : "discovery.zen.ping.unicast.hosts"] = [] - } - boolean supportsInitialMasterNodes = hasBwcNodes == false || config.bwcVersion.onOrAfter("7.0.0") - if (esConfig['discovery.type'] == null && config.getAutoSetInitialMasterNodes() && supportsInitialMasterNodes) { - esConfig['cluster.initial_master_nodes'] = nodes.stream().map({ n -> - if (n.config.settings['node.name'] == null) { - return "node-" + n.nodeNum - } else { - return n.config.settings['node.name'] - } - }).collect(Collectors.toList()) - } - esConfig - } - dependsOn = startDependencies - } else { - dependsOn = startTasks.empty ? startDependencies : startTasks.get(0) - writeConfigSetup = { Map esConfig -> - String unicastTransportUri = node.config.unicastTransportUri(nodes.get(0), node, project.createAntBuilder()) - if (unicastTransportUri == null) { - esConfig['discovery.zen.ping.unicast.hosts'] = [] - } else { - esConfig['discovery.zen.ping.unicast.hosts'] = "\"${unicastTransportUri}\"" - } - esConfig - } - } - startTasks.add(configureNode(project, prefix, runner, dependsOn, node, config, distro, writeConfigSetup)) - } - - Task wait = configureWaitTask("${prefix}#wait", project, nodes, startTasks, config.nodeStartupWaitSeconds) - runner.dependsOn(wait) - - return nodes - } - - /** Adds a dependency on the given distribution */ - static void configureDistributionDependency(Project project, String distro, Configuration configuration, String opensearchVersion) { - boolean internalBuild = project.hasProperty('bwcVersions') - if (distro.equals("integ-test-zip")) { - // short circuit integ test so it doesn't complicate the rest of the distribution setup below - if (internalBuild) { - project.dependencies.add( - configuration.name, - project.dependencies.project(path: ":distribution", configuration: 'integ-test-zip') - ) - } else { - project.dependencies.add( - configuration.name, - "org.opensearch.distribution.integ-test-zip:opensearch:${opensearchVersion}@zip" - ) - } - return - } - - Version version = Version.fromString(opensearchVersion) - String os = getOs() - String classifier = "-${os}-x64" - String packaging = os.equals('windows') ? 'zip' : 'tar.gz' - String artifactName = 'opensearch' - Object dependency - String snapshotProject = "${os}-${os.equals('windows') ? 'zip' : 'tar'}" - if (version.before("7.0.0")) { - snapshotProject = "zip" - packaging = "zip" - } - - BwcVersions.UnreleasedVersionInfo unreleasedInfo = null - - if (project.hasProperty('bwcVersions')) { - // NOTE: leniency is needed for external plugin authors using build-tools. maybe build the version compat info into build-tools? - unreleasedInfo = project.bwcVersions.unreleasedInfo(version) - } - if (unreleasedInfo != null) { - dependency = project.dependencies.project( - path: unreleasedInfo.gradleProjectPath, configuration: snapshotProject - ) - } else if (internalBuild && opensearchVersion.equals(VersionProperties.getOpenSearch())) { - dependency = project.dependencies.project(path: ":distribution:archives:${snapshotProject}") - } else { - if (version.before('7.0.0')) { - classifier = "" // for bwc, before we had classifiers - } - // group does not matter as it is not used when we pull from the ivy repo that points to the download service - dependency = "dnm:${artifactName}:${opensearchVersion}${classifier}@${packaging}" - } - project.dependencies.add(configuration.name, dependency) - } - - /** Adds a dependency on a different version of the given plugin, which will be retrieved using gradle's dependency resolution */ - static void configureBwcPluginDependency(Project project, Object plugin, Configuration configuration, Version opensearchVersion) { - if (plugin instanceof Project) { - Project pluginProject = (Project)plugin - verifyProjectHasBuildPlugin(configuration.name, opensearchVersion, project, pluginProject) - final String pluginName = findPluginName(pluginProject) - project.dependencies.add(configuration.name, "org.opensearch.plugin:${pluginName}:${opensearchVersion}@zip") - } else { - project.dependencies.add(configuration.name, "${plugin}@zip") - } - } - - /** - * Adds dependent tasks to start an opensearch cluster before the given task is executed, - * and stop it after it has finished executing. - * - * The setup of the cluster involves the following: - *
      - *
    1. Cleanup the extraction directory
    2. - *
    3. Extract a fresh copy of opensearch
    4. - *
    5. Write an opensearch.yml config file
    6. - *
    7. Copy plugins that will be installed to a temporary dir (which contains spaces)
    8. - *
    9. Install plugins
    10. - *
    11. Run additional setup commands
    12. - *
    13. Start opensearch
    14. - *
    - * - * @return a task which starts the node. - */ - static Task configureNode(Project project, String prefix, Task runner, Object dependsOn, NodeInfo node, ClusterConfiguration config, - Configuration distribution, Closure writeConfig) { - - // tasks are chained so their execution order is maintained - Task setup = project.tasks.create(name: taskName(prefix, node, 'clean'), type: Delete, dependsOn: dependsOn) { - delete node.homeDir - delete node.cwd - } - setup = project.tasks.create(name: taskName(prefix, node, 'createCwd'), type: DefaultTask, dependsOn: setup) { - doLast { - node.cwd.mkdirs() - } - outputs.dir node.cwd - } - setup = configureCheckPreviousTask(taskName(prefix, node, 'checkPrevious'), project, setup, node) - setup = configureStopTask(taskName(prefix, node, 'stopPrevious'), project, setup, node) - setup = configureExtractTask(taskName(prefix, node, 'extract'), project, setup, node, distribution, config.distribution) - setup = configureWriteConfigTask(taskName(prefix, node, 'configure'), project, setup, node, writeConfig) - setup = configureCreateKeystoreTask(taskName(prefix, node, 'createKeystore'), project, setup, node) - setup = configureAddKeystoreSettingTasks(prefix, project, setup, node) - setup = configureAddKeystoreFileTasks(prefix, project, setup, node) - - if (node.config.plugins.isEmpty() == false) { - if (node.nodeVersion == Version.fromString(VersionProperties.getOpenSearch())) { - setup = configureCopyPluginsTask(taskName(prefix, node, 'copyPlugins'), project, setup, node, prefix) - } else { - setup = configureCopyBwcPluginsTask(taskName(prefix, node, 'copyBwcPlugins'), project, setup, node, prefix) - } - } - - // install modules - for (Project module : node.config.modules) { - String actionName = pluginTaskName('install', module.name, 'Module') - setup = configureInstallModuleTask(taskName(prefix, node, actionName), project, setup, node, module) - } - - // install plugins - for (String pluginName : node.config.plugins.keySet()) { - String actionName = pluginTaskName('install', pluginName, 'Plugin') - setup = configureInstallPluginTask(taskName(prefix, node, actionName), project, setup, node, pluginName, prefix) - } - - // sets up any extra config files that need to be copied over to the ES instance; - // its run after plugins have been installed, as the extra config files may belong to plugins - setup = configureExtraConfigFilesTask(taskName(prefix, node, 'extraConfig'), project, setup, node) - - // extra setup commands - for (Map.Entry command : node.config.setupCommands.entrySet()) { - // the first argument is the actual script name, relative to home - Object[] args = command.getValue().clone() - final Object commandPath - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - /* - * We have to delay building the string as the path will not exist during configuration which will fail on Windows due to - * getting the short name requiring the path to already exist. Note that we have to capture the value of arg[0] now - * otherwise we would stack overflow later since arg[0] is replaced below. - */ - String argsZero = args[0] - commandPath = "${-> Paths.get(NodeInfo.getShortPathName(node.homeDir.toString())).resolve(argsZero.toString()).toString()}" - } else { - commandPath = node.homeDir.toPath().resolve(args[0].toString()).toString() - } - args[0] = commandPath - setup = configureExecTask(taskName(prefix, node, command.getKey()), project, setup, node, args) - } - - Task start = configureStartTask(taskName(prefix, node, 'start'), project, setup, node) - - if (node.config.daemonize) { - Task stop = configureStopTask(taskName(prefix, node, 'stop'), project, [], node) - // if we are running in the background, make sure to stop the server when the task completes - runner.finalizedBy(stop) - start.finalizedBy(stop) - for (Object dependency : config.dependencies) { - if (dependency instanceof Fixture) { - def depStop = ((Fixture)dependency).stopTask - runner.finalizedBy(depStop) - start.finalizedBy(depStop) - } - } - } - return start - } - - /** Adds a task to extract the opensearch distribution */ - static Task configureExtractTask(String name, Project project, Task setup, NodeInfo node, - Configuration configuration, String distribution) { - List extractDependsOn = [configuration, setup] - /* configuration.singleFile will be an external artifact if this is being run by a plugin not living in the - opensearch source tree. If this is a plugin built in the opensearch source tree or this is a distro in - the opensearch source tree then this should be the version of opensearch built by the source tree. - If it isn't then Bad Things(TM) will happen. */ - Task extract = project.tasks.create(name: name, type: Copy, dependsOn: extractDependsOn) { - if (getOs().equals("windows") || distribution.equals("integ-test-zip") || node.nodeVersion.before("7.0.0")) { - from { - project.zipTree(configuration.singleFile) - } - } else { - // macos and linux use tar - from { - project.tarTree(project.resources.gzip(configuration.singleFile)) - } - } - into node.baseDir - } - - return extract - } - - /** Adds a task to write opensearch.yml for the given node configuration */ - static Task configureWriteConfigTask(String name, Project project, Task setup, NodeInfo node, Closure configFilter) { - Map esConfig = [ - 'cluster.name' : node.clusterName, - 'node.name' : "node-" + node.nodeNum, - (node.nodeVersion.onOrAfter('7.4.0') ? 'node.pidfile' : 'pidfile') : node.pidFile, - 'path.repo' : "${node.sharedDir}/repo", - 'path.shared_data' : "${node.sharedDir}/", - // Define a node attribute so we can test that it exists - 'node.attr.testattr' : 'test', - // Don't wait for state, just start up quickly. This will also allow new and old nodes in the BWC case to become the master - 'discovery.initial_state_timeout' : '0s' - ] - int minimumMasterNodes = node.config.minimumMasterNodes.call() - if (node.nodeVersion.before("7.0.0") && minimumMasterNodes > 0) { - esConfig['discovery.zen.minimum_master_nodes'] = minimumMasterNodes - } - if (node.nodeVersion.before("7.0.0") && esConfig.containsKey('discovery.zen.master_election.wait_for_joins_timeout') == false) { - // If a node decides to become master based on partial information from the pinging, don't let it hang for 30 seconds to correct - // its mistake. Instead, only wait 5s to do another round of pinging. - // This is necessary since we use 30s as the default timeout in REST requests waiting for cluster formation - // so we need to bail quicker than the default 30s for the cluster to form in time. - esConfig['discovery.zen.master_election.wait_for_joins_timeout'] = '5s' - } - esConfig['http.port'] = node.config.httpPort - if (node.nodeVersion.onOrAfter('6.7.0')) { - esConfig['transport.port'] = node.config.transportPort - } else { - esConfig['transport.tcp.port'] = node.config.transportPort - } - // Default the watermarks to absurdly low to prevent the tests from failing on nodes without enough disk space - esConfig['cluster.routing.allocation.disk.watermark.low'] = '1b' - esConfig['cluster.routing.allocation.disk.watermark.high'] = '1b' - if (node.nodeVersion.major >= 6) { - esConfig['cluster.routing.allocation.disk.watermark.flood_stage'] = '1b' - } - // increase script compilation limit since tests can rapid-fire script compilations - if (node.nodeVersion.onOrAfter('7.9.0')) { - esConfig['script.disable_max_compilations_rate'] = 'true' - } else { - esConfig['script.max_compilations_rate'] = '2048/1m' - } - // Temporarily disable the real memory usage circuit breaker. It depends on real memory usage which we have no full control - // over and the REST client will not retry on circuit breaking exceptions yet (see #31986 for details). Once the REST client - // can retry on circuit breaking exceptions, we can revert again to the default configuration. - if (node.nodeVersion.major >= 7) { - esConfig['indices.breaker.total.use_real_memory'] = false - } - - Task writeConfig = project.tasks.create(name: name, type: DefaultTask, dependsOn: setup) - writeConfig.doFirst { - for (Map.Entry setting : node.config.settings) { - if (setting.value == null) { - esConfig.remove(setting.key) - } else { - esConfig.put(setting.key, setting.value) - } - } - - esConfig = configFilter.call(esConfig) - File configFile = new File(node.pathConf, 'opensearch.yml') - logger.info("Configuring ${configFile}") - configFile.setText(esConfig.collect { key, value -> "${key}: ${value}" }.join('\n'), 'UTF-8') - } - } - - /** Adds a task to create keystore */ - static Task configureCreateKeystoreTask(String name, Project project, Task setup, NodeInfo node) { - if (node.config.keystoreSettings.isEmpty() && node.config.keystoreFiles.isEmpty()) { - return setup - } else { - /* - * We have to delay building the string as the path will not exist during configuration which will fail on Windows due to - * getting the short name requiring the path to already exist. - */ - final Object esKeystoreUtil = "${-> node.binPath().resolve('opensearch-keystore').toString()}" - return configureExecTask(name, project, setup, node, esKeystoreUtil, 'create') - } - } - - /** Adds tasks to add settings to the keystore */ - static Task configureAddKeystoreSettingTasks(String parent, Project project, Task setup, NodeInfo node) { - Map kvs = node.config.keystoreSettings - Task parentTask = setup - /* - * We have to delay building the string as the path will not exist during configuration which will fail on Windows due to getting - * the short name requiring the path to already exist. - */ - final Object esKeystoreUtil = "${-> node.binPath().resolve('opensearch-keystore').toString()}" - for (Map.Entry entry in kvs) { - String key = entry.getKey() - String name = taskName(parent, node, 'addToKeystore#' + key) - Task t = configureExecTask(name, project, parentTask, node, esKeystoreUtil, 'add', key, '-x') - String settingsValue = entry.getValue() // eval this early otherwise it will not use the right value - t.doFirst { - standardInput = new ByteArrayInputStream(settingsValue.getBytes(StandardCharsets.UTF_8)) - } - parentTask = t - } - return parentTask - } - - /** Adds tasks to add files to the keystore */ - static Task configureAddKeystoreFileTasks(String parent, Project project, Task setup, NodeInfo node) { - Map kvs = node.config.keystoreFiles - if (kvs.isEmpty()) { - return setup - } - Task parentTask = setup - /* - * We have to delay building the string as the path will not exist during configuration which will fail on Windows due to getting - * the short name requiring the path to already exist. - */ - final Object esKeystoreUtil = "${-> node.binPath().resolve('opensearch-keystore').toString()}" - for (Map.Entry entry in kvs) { - String key = entry.getKey() - String name = taskName(parent, node, 'addToKeystore#' + key) - String srcFileName = entry.getValue() - Task t = configureExecTask(name, project, parentTask, node, esKeystoreUtil, 'add-file', key, srcFileName) - t.doFirst { - File srcFile = project.file(srcFileName) - if (srcFile.isDirectory()) { - throw new GradleException("Source for keystoreFile must be a file: ${srcFile}") - } - if (srcFile.exists() == false) { - throw new GradleException("Source file for keystoreFile does not exist: ${srcFile}") - } - } - parentTask = t - } - return parentTask - } - - static Task configureExtraConfigFilesTask(String name, Project project, Task setup, NodeInfo node) { - if (node.config.extraConfigFiles.isEmpty()) { - return setup - } - Copy copyConfig = project.tasks.create(name: name, type: Copy, dependsOn: setup) - File configDir = new File(node.homeDir, 'config') - copyConfig.into(configDir) // copy must always have a general dest dir, even though we don't use it - for (Map.Entry extraConfigFile : node.config.extraConfigFiles.entrySet()) { - Object extraConfigFileValue = extraConfigFile.getValue() - copyConfig.doFirst { - // make sure the copy won't be a no-op or act on a directory - File srcConfigFile = project.file(extraConfigFileValue) - if (srcConfigFile.isDirectory()) { - throw new GradleException("Source for extraConfigFile must be a file: ${srcConfigFile}") - } - if (srcConfigFile.exists() == false) { - throw new GradleException("Source file for extraConfigFile does not exist: ${srcConfigFile}") - } - } - File destConfigFile = new File(node.homeDir, 'config/' + extraConfigFile.getKey()) - // wrap source file in closure to delay resolution to execution time - copyConfig.from({ extraConfigFileValue }) { - // this must be in a closure so it is only applied to the single file specified in from above - into(configDir.toPath().relativize(destConfigFile.canonicalFile.parentFile.toPath()).toFile()) - rename { destConfigFile.name } - } - } - return copyConfig - } - - /** - * Adds a task to copy plugins to a temp dir, which they will later be installed from. - * - * For each plugin, if the plugin has rest spec apis in its tests, those api files are also copied - * to the test resources for this project. - */ - static Task configureCopyPluginsTask(String name, Project project, Task setup, NodeInfo node, String prefix) { - Copy copyPlugins = project.tasks.create(name: name, type: Copy, dependsOn: setup) - - List pluginFiles = [] - for (Map.Entry plugin : node.config.plugins.entrySet()) { - - String configurationName = pluginConfigurationName(prefix, plugin.key) - Configuration configuration = project.configurations.findByName(configurationName) - if (configuration == null) { - configuration = project.configurations.create(configurationName) - } - - if (plugin.getValue() instanceof Project) { - Project pluginProject = plugin.getValue() - verifyProjectHasBuildPlugin(name, node.nodeVersion, project, pluginProject) - - project.dependencies.add(configurationName, project.dependencies.project(path: pluginProject.path, configuration: 'zip')) - setup.dependsOn(pluginProject.tasks.bundlePlugin) - - // also allow rest tests to use the rest spec from the plugin - String copyRestSpecTaskName = pluginTaskName('copy', plugin.getKey(), 'PluginRestSpec') - Copy copyRestSpec = project.tasks.findByName(copyRestSpecTaskName) - for (File resourceDir : pluginProject.sourceSets.test.resources.srcDirs) { - File restApiDir = new File(resourceDir, 'rest-api-spec/api') - if (restApiDir.exists() == false) continue - if (copyRestSpec == null) { - copyRestSpec = project.tasks.create(name: copyRestSpecTaskName, type: Copy) - copyPlugins.dependsOn(copyRestSpec) - copyRestSpec.into(project.sourceSets.test.output.resourcesDir) - } - copyRestSpec.from(resourceDir).include('rest-api-spec/api/**') - } - } else { - project.dependencies.add(configurationName, "${plugin.getValue()}@zip") - } - - - - pluginFiles.add(configuration) - } - - copyPlugins.into(node.pluginsTmpDir) - copyPlugins.from(pluginFiles) - return copyPlugins - } - - private static String pluginConfigurationName(final String prefix, final String name) { - return "_plugin_${prefix}_${name}".replace(':', '_') - } - - private static String pluginBwcConfigurationName(final String prefix, final String name) { - return "_plugin_bwc_${prefix}_${name}".replace(':', '_') - } - - /** Configures task to copy a plugin based on a zip file resolved using dependencies for an older version */ - static Task configureCopyBwcPluginsTask(String name, Project project, Task setup, NodeInfo node, String prefix) { - Configuration bwcPlugins = project.configurations.getByName("${prefix}_opensearchBwcPlugins") - for (Map.Entry plugin : node.config.plugins.entrySet()) { - String configurationName = pluginBwcConfigurationName(prefix, plugin.key) - Configuration configuration = project.configurations.findByName(configurationName) - if (configuration == null) { - configuration = project.configurations.create(configurationName) - } - - if (plugin.getValue() instanceof Project) { - Project pluginProject = plugin.getValue() - verifyProjectHasBuildPlugin(name, node.nodeVersion, project, pluginProject) - - final String depName = findPluginName(pluginProject) - - Dependency dep = bwcPlugins.dependencies.find { - it.name == depName - } - configuration.dependencies.add(dep) - } else { - project.dependencies.add(configurationName, "${plugin.getValue()}@zip") - } - } - - Copy copyPlugins = project.tasks.create(name: name, type: Copy, dependsOn: setup) { - from bwcPlugins - into node.pluginsTmpDir - } - return copyPlugins - } - - static Task configureInstallModuleTask(String name, Project project, Task setup, NodeInfo node, Project module) { - if (node.config.distribution != 'integ-test-zip') { - project.logger.info("Not installing modules for $name, ${node.config.distribution} already has them") - return setup - } - if (module.plugins.hasPlugin(PluginBuildPlugin) == false) { - throw new GradleException("Task ${name} cannot include module ${module.path} which is not an opensearchplugin") - } - Copy installModule = project.tasks.create(name, Copy.class) - installModule.dependsOn(setup) - installModule.dependsOn(module.tasks.bundlePlugin) - installModule.into(new File(node.homeDir, "modules/${module.name}")) - installModule.from({ project.zipTree(module.tasks.bundlePlugin.outputs.files.singleFile) }) - return installModule - } - - static Task configureInstallPluginTask(String name, Project project, Task setup, NodeInfo node, String pluginName, String prefix) { - FileCollection pluginZip; - if (node.nodeVersion != Version.fromString(VersionProperties.getOpenSearch())) { - pluginZip = project.configurations.getByName(pluginBwcConfigurationName(prefix, pluginName)) - } else { - pluginZip = project.configurations.getByName(pluginConfigurationName(prefix, pluginName)) - } - // delay reading the file location until execution time by wrapping in a closure within a GString - final Object file = "${-> new File(node.pluginsTmpDir, pluginZip.singleFile.getName()).toURI().toURL().toString()}" - /* - * We have to delay building the string as the path will not exist during configuration which will fail on Windows due to getting - * the short name requiring the path to already exist. - */ - final Object esPluginUtil = "${-> node.binPath().resolve('opensearch-plugin').toString()}" - final Object[] args = [esPluginUtil, 'install', '--batch', file] - return configureExecTask(name, project, setup, node, args) - } - - /** Wrapper for command line argument: surrounds comma with double quotes **/ - private static class EscapeCommaWrapper { - - Object arg - - public String toString() { - String s = arg.toString() - - /// Surround strings that contains a comma with double quotes - if (s.indexOf(',') != -1) { - return "\"${s}\"" - } - return s - } - } - - /** Adds a task to execute a command to help setup the cluster */ - static Task configureExecTask(String name, Project project, Task setup, NodeInfo node, Object[] execArgs) { - return project.tasks.create(name: name, type: LoggedExec, dependsOn: setup) { Exec exec -> - exec.workingDir node.cwd - if (useRuntimeJava(project, node)) { - exec.environment.put('JAVA_HOME', project.runtimeJavaHome) - } else { - // force JAVA_HOME to *not* be set - exec.environment.remove('JAVA_HOME') - } - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - exec.executable 'cmd' - exec.args '/C', 'call' - // On Windows the comma character is considered a parameter separator: - // argument are wrapped in an ExecArgWrapper that escapes commas - exec.args execArgs.collect { a -> new EscapeCommaWrapper(arg: a) } - } else { - exec.commandLine execArgs - } - } - } - - public static boolean useRuntimeJava(Project project, NodeInfo node) { - return (BuildParams.isRuntimeJavaHomeSet || - (node.isBwcNode == false && node.nodeVersion.before(Version.fromString("7.0.0"))) || - node.config.distribution == 'integ-test-zip') - } - - /** Adds a task to start an opensearch node with the given configuration */ - static Task configureStartTask(String name, Project project, Task setup, NodeInfo node) { - // this closure is converted into ant nodes by groovy's AntBuilder - Closure antRunner = { AntBuilder ant -> - ant.exec(executable: node.executable, spawn: node.config.daemonize, newenvironment: true, - dir: node.cwd, taskname: 'opensearch') { - node.env.each { key, value -> env(key: key, value: value) } - if (useRuntimeJava(project, node)) { - env(key: 'JAVA_HOME', value: project.runtimeJavaHome) - } - node.args.each { arg(value: it) } - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - // Having no TMP on Windows defaults to C:\Windows and permission errors - // Since we configure ant to run with a new environment above, we need to explicitly pass this - String tmp = System.getenv("TMP") - assert tmp != null - env(key: "TMP", value: tmp) - } - } - } - - // this closure is the actual code to run opensearch - Closure opensearchRunner = { - // Due to how ant exec works with the spawn option, we lose all stdout/stderr from the - // process executed. To work around this, when spawning, we wrap the opensearch start - // command inside another shell script, which simply internally redirects the output - // of the real opensearch script. This allows ant to keep the streams open with the - // dummy process, but us to have the output available if there is an error in the - // opensearch start script - if (node.config.daemonize) { - node.writeWrapperScript() - } - - node.getCommandString().eachLine { line -> logger.info(line) } - - if (logger.isInfoEnabled() || node.config.daemonize == false) { - runAntCommand(project, antRunner, System.out, System.err) - } else { - // buffer the output, we may not need to print it - PrintStream captureStream = new PrintStream(node.buffer, true, "UTF-8") - runAntCommand(project, antRunner, captureStream, captureStream) - } - } - - Task start = project.tasks.create(name: name, type: DefaultTask, dependsOn: setup) - if (node.javaVersion != null) { - BuildPlugin.requireJavaHome(start, node.javaVersion) - } - start.doLast(opensearchRunner) - start.doFirst { - // If the node runs in a FIPS 140-2 JVM, the BCFKS default keystore will be password protected - if (BuildParams.inFipsJvm) { - node.config.systemProperties.put('javax.net.ssl.trustStorePassword', 'password') - node.config.systemProperties.put('javax.net.ssl.keyStorePassword', 'password') - } - - // Configure ES JAVA OPTS - adds system properties, assertion flags, remote debug etc - List opensearchJavaOpts = [node.env.get('OPENSEARCH_JAVA_OPTS', '')] - String collectedSystemProperties = node.config.systemProperties.collect { key, value -> "-D${key}=${value}" }.join(" ") - opensearchJavaOpts.add(collectedSystemProperties) - opensearchJavaOpts.add(node.config.jvmArgs) - if (Boolean.parseBoolean(System.getProperty('tests.asserts', 'true'))) { - // put the enable assertions options before other options to allow - // flexibility to disable assertions for specific packages or classes - // in the cluster-specific options - opensearchJavaOpts.add("-ea") - opensearchJavaOpts.add("-esa") - } - // we must add debug options inside the closure so the config is read at execution time, as - // gradle task options are not processed until the end of the configuration phase - if (node.config.debug) { - println 'Running opensearch in debug mode, suspending until connected on port 8000' - opensearchJavaOpts.add('-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000') - } - node.env['OPENSEARCH_JAVA_OPTS'] = opensearchJavaOpts.join(" ") - - // - project.logger.info("Starting node in ${node.clusterName} distribution: ${node.config.distribution}") - } - return start - } - - static Task configureWaitTask(String name, Project project, List nodes, List startTasks, int waitSeconds) { - Task wait = project.tasks.create(name: name, dependsOn: startTasks) - wait.doLast { - - Collection unicastHosts = new HashSet<>() - nodes.forEach { node -> - unicastHosts.addAll(node.config.otherUnicastHostAddresses.call()) - String unicastHost = node.config.unicastTransportUri(node, null, project.createAntBuilder()) - if (unicastHost != null) { - unicastHosts.add(unicastHost) - } - } - String unicastHostsTxt = String.join("\n", unicastHosts) - nodes.forEach { node -> - node.pathConf.toPath().resolve("unicast_hosts.txt").setText(unicastHostsTxt) - } - - ant.waitfor(maxwait: "${waitSeconds}", maxwaitunit: 'second', checkevery: '500', checkeveryunit: 'millisecond', timeoutproperty: "failed${name}") { - or { - for (NodeInfo node : nodes) { - resourceexists { - file(file: node.failedMarker.toString()) - } - } - and { - for (NodeInfo node : nodes) { - resourceexists { - file(file: node.pidFile.toString()) - } - resourceexists { - file(file: node.httpPortsFile.toString()) - } - resourceexists { - file(file: node.transportPortsFile.toString()) - } - } - } - } - } - if (ant.properties.containsKey("failed${name}".toString())) { - waitFailed(project, nodes, logger, "Failed to start opensearch: timed out after ${waitSeconds} seconds") - } - - boolean anyNodeFailed = false - for (NodeInfo node : nodes) { - if (node.failedMarker.exists()) { - logger.error("Failed to start opensearch: ${node.failedMarker.toString()} exists") - anyNodeFailed = true - } - } - if (anyNodeFailed) { - waitFailed(project, nodes, logger, 'Failed to start opensearch') - } - - // make sure all files exist otherwise we haven't fully started up - boolean missingFile = false - for (NodeInfo node : nodes) { - missingFile |= node.pidFile.exists() == false - missingFile |= node.httpPortsFile.exists() == false - missingFile |= node.transportPortsFile.exists() == false - } - if (missingFile) { - waitFailed(project, nodes, logger, 'OpenSearch did not complete startup in time allotted') - } - - // go through each node checking the wait condition - for (NodeInfo node : nodes) { - // first bind node info to the closure, then pass to the ant runner so we can get good logging - Closure antRunner = node.config.waitCondition.curry(node) - - boolean success - if (logger.isInfoEnabled()) { - success = runAntCommand(project, antRunner, System.out, System.err) - } else { - PrintStream captureStream = new PrintStream(node.buffer, true, "UTF-8") - success = runAntCommand(project, antRunner, captureStream, captureStream) - } - - if (success == false) { - waitFailed(project, nodes, logger, 'OpenSearch cluster failed to pass wait condition') - } - } - } - return wait - } - - static void waitFailed(Project project, List nodes, Logger logger, String msg) { - for (NodeInfo node : nodes) { - if (logger.isInfoEnabled() == false) { - // We already log the command at info level. No need to do it twice. - node.getCommandString().eachLine { line -> logger.error(line) } - } - logger.error("Node ${node.nodeNum} output:") - logger.error("|-----------------------------------------") - logger.error("| failure marker exists: ${node.failedMarker.exists()}") - logger.error("| pid file exists: ${node.pidFile.exists()}") - logger.error("| http ports file exists: ${node.httpPortsFile.exists()}") - logger.error("| transport ports file exists: ${node.transportPortsFile.exists()}") - // the waitfor failed, so dump any output we got (if info logging this goes directly to stdout) - logger.error("|\n| [ant output]") - node.buffer.toString('UTF-8').eachLine { line -> logger.error("| ${line}") } - // also dump the log file for the startup script (which will include ES logging output to stdout) - if (node.startLog.exists()) { - logger.error("|\n| [log]") - node.startLog.eachLine { line -> logger.error("| ${line}") } - } - if (node.pidFile.exists() && node.failedMarker.exists() == false && - (node.httpPortsFile.exists() == false || node.transportPortsFile.exists() == false)) { - logger.error("|\n| [jstack]") - String pid = node.pidFile.getText('UTF-8') - ByteArrayOutputStream output = new ByteArrayOutputStream() - project.exec { - commandLine = ["${project.runtimeJavaHome}/bin/jstack", pid] - standardOutput = output - } - output.toString('UTF-8').eachLine { line -> logger.error("| ${line}") } - } - logger.error("|-----------------------------------------") - } - throw new GradleException(msg) - } - - /** Adds a task to check if the process with the given pidfile is actually opensearch */ - static Task configureCheckPreviousTask(String name, Project project, Object depends, NodeInfo node) { - return project.tasks.create(name: name, type: Exec, dependsOn: depends) { - onlyIf { node.pidFile.exists() } - // the pid file won't actually be read until execution time, since the read is wrapped within an inner closure of the GString - ext.pid = "${ -> node.pidFile.getText('UTF-8').trim()}" - final File jps = Jvm.forHome(project.runtimeJavaHome).getExecutable('jps') - commandLine jps, '-l' - standardOutput = new ByteArrayOutputStream() - doLast { - String out = standardOutput.toString() - if (out.contains("${ext.pid} org.opensearch.bootstrap.OpenSearch") == false) { - logger.error('jps -l') - logger.error(out) - logger.error("pid file: ${node.pidFile}") - logger.error("pid: ${ext.pid}") - throw new GradleException("jps -l did not report any process with org.opensearch.bootstrap.OpenSearch\n" + - "Did you run gradle clean? Maybe an old pid file is still lying around.") - } else { - logger.info(out) - } - } - } - } - - /** Adds a task to kill an opensearch node with the given pidfile */ - static Task configureStopTask(String name, Project project, Object depends, NodeInfo node) { - return project.tasks.create(name: name, type: LoggedExec, dependsOn: depends) { - onlyIf { node.pidFile.exists() } - // the pid file won't actually be read until execution time, since the read is wrapped within an inner closure of the GString - ext.pid = "${ -> node.pidFile.getText('UTF-8').trim()}" - doFirst { - logger.info("Shutting down external node with pid ${pid}") - } - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - executable 'Taskkill' - args '/PID', pid, '/F' - } else { - executable 'kill' - args '-9', pid - } - doLast { - project.delete(node.pidFile) - // Large tests can exhaust disk space, clean up jdk from the distribution to save some space - project.delete(new File(node.homeDir, "jdk")) - } - } - } - - /** Returns a unique task name for this task and node configuration */ - static String taskName(String prefix, NodeInfo node, String action) { - if (node.config.numNodes > 1) { - return "${prefix}#node${node.nodeNum}.${action}" - } else { - return "${prefix}#${action}" - } - } - - public static String pluginTaskName(String action, String name, String suffix) { - // replace every dash followed by a character with just the uppercase character - String camelName = name.replaceAll(/-(\w)/) { _, c -> c.toUpperCase(Locale.ROOT) } - return action + camelName[0].toUpperCase(Locale.ROOT) + camelName.substring(1) + suffix - } - - /** Runs an ant command, sending output to the given out and error streams */ - static Object runAntCommand(Project project, Closure command, PrintStream outputStream, PrintStream errorStream) { - DefaultLogger listener = new DefaultLogger( - errorPrintStream: errorStream, - outputPrintStream: outputStream, - messageOutputLevel: org.apache.tools.ant.Project.MSG_INFO) - - AntBuilder ant = project.createAntBuilder() - ant.project.addBuildListener(listener) - Object retVal = command(ant) - ant.project.removeBuildListener(listener) - return retVal - } - - static void verifyProjectHasBuildPlugin(String name, Version version, Project project, Project pluginProject) { - if (pluginProject.plugins.hasPlugin(PluginBuildPlugin) == false) { - throw new GradleException("Task [${name}] cannot add plugin [${pluginProject.path}] with version [${version}] to project's " + - "[${project.path}] dependencies: the plugin is not an opensearchplugin") - } - } - - /** Find the plugin name in the given project. */ - static String findPluginName(Project pluginProject) { - PluginPropertiesExtension extension = pluginProject.extensions.findByName('opensearchplugin') - return extension.name - } - - /** Find the current OS */ - static String getOs() { - String os = "linux" - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - os = "windows" - } else if (Os.isFamily(Os.FAMILY_MAC)) { - os = "darwin" - } - return os - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/test/NodeInfo.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/test/NodeInfo.groovy deleted file mode 100644 index b42b7b29e8dab..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/test/NodeInfo.groovy +++ /dev/null @@ -1,308 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle.test - -import com.sun.jna.Native -import com.sun.jna.WString -import org.apache.tools.ant.taskdefs.condition.Os -import org.opensearch.gradle.Version -import org.opensearch.gradle.VersionProperties -import org.gradle.api.Project -import org.opensearch.gradle.test.JNAKernel32Library - -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths -/** - * A container for the files and configuration associated with a single node in a test cluster. - */ -class NodeInfo { - /** Gradle project this node is part of */ - Project project - - /** common configuration for all nodes, including this one */ - ClusterConfiguration config - - /** node number within the cluster, for creating unique names and paths */ - int nodeNum - - /** name of the cluster this node is part of */ - String clusterName - - /** root directory all node files and operations happen under */ - File baseDir - - /** shared data directory all nodes share */ - File sharedDir - - /** the pid file the node will use */ - File pidFile - - /** a file written by opensearch containing the ports of each bound address for http */ - File httpPortsFile - - /** a file written by opensearch containing the ports of each bound address for transport */ - File transportPortsFile - - /** opensearch home dir */ - File homeDir - - /** config directory */ - File pathConf - - /** data directory (as an Object, to allow lazy evaluation) */ - Object dataDir - - /** THE config file */ - File configFile - - /** working directory for the node process */ - File cwd - - /** file that if it exists, indicates the node failed to start */ - File failedMarker - - /** stdout/stderr log of the opensearch process for this node */ - File startLog - - /** directory to install plugins from */ - File pluginsTmpDir - - /** Major version of java this node runs with, or {@code null} if using the runtime java version */ - Integer javaVersion - - /** environment variables to start the node with */ - Map env - - /** arguments to start the node with */ - List args - - /** Executable to run the bin/opensearch with, either cmd or sh */ - String executable - - /** Path to the opensearch start script */ - private Object opensearchScript - - /** script to run when running in the background */ - private File wrapperScript - - /** buffer for ant output when starting this node */ - ByteArrayOutputStream buffer = new ByteArrayOutputStream() - - /** the version of opensearch that this node runs */ - Version nodeVersion - - /** true if the node is not the current version */ - boolean isBwcNode - - /** Holds node configuration for part of a test cluster. */ - NodeInfo(ClusterConfiguration config, int nodeNum, Project project, String prefix, String nodeVersion, File sharedDir) { - this.config = config - this.nodeNum = nodeNum - this.project = project - this.sharedDir = sharedDir - if (config.clusterName != null) { - clusterName = config.clusterName - } else { - clusterName = project.path.replace(':', '_').substring(1) + '_' + prefix - } - baseDir = new File(project.buildDir, "cluster/${prefix} node${nodeNum}") - pidFile = new File(baseDir, 'opensearch.pid') - this.nodeVersion = Version.fromString(nodeVersion) - this.isBwcNode = this.nodeVersion.before(VersionProperties.getOpenSearch()) - homeDir = new File(baseDir, "opensearch-${nodeVersion}") - pathConf = new File(homeDir, 'config') - if (config.dataDir != null) { - dataDir = "${config.dataDir(nodeNum)}" - } else { - dataDir = new File(homeDir, "data") - } - configFile = new File(pathConf, 'opensearch.yml') - // even for rpm/deb, the logs are under home because we dont start with real services - File logsDir = new File(homeDir, 'logs') - httpPortsFile = new File(logsDir, 'http.ports') - transportPortsFile = new File(logsDir, 'transport.ports') - cwd = new File(baseDir, "cwd") - failedMarker = new File(cwd, 'run.failed') - startLog = new File(cwd, 'run.log') - pluginsTmpDir = new File(baseDir, "plugins tmp") - - args = [] - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - executable = 'cmd' - args.add('/C') - args.add('"') // quote the entire command - wrapperScript = new File(cwd, "run.bat") - /* - * We have to delay building the string as the path will not exist during configuration which will fail on Windows due to - * getting the short name requiring the path to already exist. - */ - opensearchScript = "${-> binPath().resolve('opensearch.bat').toString()}" - } else { - executable = 'bash' - wrapperScript = new File(cwd, "run") - opensearchScript = binPath().resolve('opensearch') - } - if (config.daemonize) { - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - /* - * We have to delay building the string as the path will not exist during configuration which will fail on Windows due to - * getting the short name requiring the path to already exist. - */ - args.add("${-> getShortPathName(wrapperScript.toString())}") - } else { - args.add("${wrapperScript}") - } - } else { - args.add("${opensearchScript}") - } - - - if (this.nodeVersion.before("6.2.0")) { - javaVersion = 8 - } else if (this.nodeVersion.onOrAfter("6.2.0") && this.nodeVersion.before("6.3.0")) { - javaVersion = 9 - } else if (this.nodeVersion.onOrAfter("6.3.0") && this.nodeVersion.before("6.5.0")) { - javaVersion = 10 - } - - args.addAll("-E", "node.portsfile=true") - env = [:] - env.putAll(config.environmentVariables) - for (Map.Entry property : System.properties.entrySet()) { - if (property.key.startsWith('tests.opensearch.')) { - args.add("-E") - args.add("${property.key.substring('tests.opensearch.'.size())}=${property.value}") - } - } - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - /* - * We have to delay building the string as the path will not exist during configuration which will fail on Windows due to - * getting the short name requiring the path to already exist. - */ - env.put('OPENSEARCH_PATH_CONF', "${-> getShortPathName(pathConf.toString())}") - } - else { - env.put('OPENSEARCH_PATH_CONF', pathConf) - } - if (!System.properties.containsKey("tests.opensearch.path.data")) { - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - /* - * We have to delay building the string as the path will not exist during configuration which will fail on Windows due to - * getting the short name requiring the path to already exist. This one is extra tricky because usually we rely on the node - * creating its data directory on startup but we simply can not do that here because getting the short path name requires - * the directory to already exist. Therefore, we create this directory immediately before getting the short name. - */ - args.addAll("-E", "path.data=${-> Files.createDirectories(Paths.get(dataDir.toString())); getShortPathName(dataDir.toString())}") - } else { - args.addAll("-E", "path.data=${-> dataDir.toString()}") - } - } - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - args.add('"') // end the entire command, quoted - } - } - - Path binPath() { - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - return Paths.get(getShortPathName(new File(homeDir, 'bin').toString())) - } else { - return Paths.get(new File(homeDir, 'bin').toURI()) - } - } - - static String getShortPathName(String path) { - assert Os.isFamily(Os.FAMILY_WINDOWS) - final WString longPath = new WString("\\\\?\\" + path) - // first we get the length of the buffer needed - final int length = JNAKernel32Library.getInstance().GetShortPathNameW(longPath, null, 0) - if (length == 0) { - throw new IllegalStateException("path [" + path + "] encountered error [" + Native.getLastError() + "]") - } - final char[] shortPath = new char[length] - // knowing the length of the buffer, now we get the short name - if (JNAKernel32Library.getInstance().GetShortPathNameW(longPath, shortPath, length) == 0) { - throw new IllegalStateException("path [" + path + "] encountered error [" + Native.getLastError() + "]") - } - // we have to strip the \\?\ away from the path for cmd.exe - return Native.toString(shortPath).substring(4) - } - - /** Returns debug string for the command that started this node. */ - String getCommandString() { - String esCommandString = "\nNode ${nodeNum} configuration:\n" - esCommandString += "|-----------------------------------------\n" - esCommandString += "| cwd: ${cwd}\n" - esCommandString += "| command: ${executable} ${args.join(' ')}\n" - esCommandString += '| environment:\n' - env.each { k, v -> esCommandString += "| ${k}: ${v}\n" } - if (config.daemonize) { - esCommandString += "|\n| [${wrapperScript.name}]\n" - wrapperScript.eachLine('UTF-8', { line -> esCommandString += " ${line}\n"}) - } - esCommandString += '|\n| [opensearch.yml]\n' - configFile.eachLine('UTF-8', { line -> esCommandString += "| ${line}\n" }) - esCommandString += "|-----------------------------------------" - return esCommandString - } - - void writeWrapperScript() { - String argsPasser = '"$@"' - String exitMarker = "; if [ \$? != 0 ]; then touch run.failed; fi" - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - argsPasser = '%*' - exitMarker = "\r\n if \"%errorlevel%\" neq \"0\" ( type nul >> run.failed )" - } - wrapperScript.setText("\"${opensearchScript}\" ${argsPasser} > run.log 2>&1 ${exitMarker}", 'UTF-8') - } - - /** Returns an address and port suitable for a uri to connect to this node over http */ - String httpUri() { - return httpPortsFile.readLines("UTF-8").get(0) - } - - /** Returns an address and port suitable for a uri to connect to this node over transport protocol */ - String transportUri() { - return transportPortsFile.readLines("UTF-8").get(0) - } - - /** Returns the file which contains the transport protocol ports for this node */ - File getTransportPortsFile() { - return transportPortsFile - } - - /** Returns the data directory for this node */ - File getDataDir() { - if (!(dataDir instanceof File)) { - return new File(dataDir) - } - return dataDir - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/test/RestTestPlugin.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/test/RestTestPlugin.groovy deleted file mode 100644 index 93a9e61db6f32..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/test/RestTestPlugin.groovy +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.opensearch.gradle.test - -import groovy.transform.CompileStatic -import org.opensearch.gradle.BuildPlugin -import org.opensearch.gradle.testclusters.TestClustersPlugin -import org.gradle.api.InvalidUserDataException -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.plugins.JavaBasePlugin - -/** - * Adds support for starting an OpenSearch cluster before running integration - * tests. Used in conjunction with {@link StandaloneRestTestPlugin} for qa - * projects and in conjunction with {@link BuildPlugin} for testing the rest - * client. - */ -@CompileStatic -class RestTestPlugin implements Plugin { - List REQUIRED_PLUGINS = [ - 'opensearch.build', - 'opensearch.standalone-rest-test'] - - @Override - void apply(Project project) { - if (false == REQUIRED_PLUGINS.any { project.pluginManager.hasPlugin(it) }) { - throw new InvalidUserDataException('opensearch.rest-test ' - + 'requires either opensearch.build or ' - + 'opensearch.standalone-rest-test') - } - project.getPlugins().apply(RestTestBasePlugin.class); - project.pluginManager.apply(TestClustersPlugin) - RestIntegTestTask integTest = project.tasks.create('integTest', RestIntegTestTask.class) - integTest.description = 'Runs rest tests against an opensearch cluster.' - integTest.group = JavaBasePlugin.VERIFICATION_GROUP - integTest.mustRunAfter(project.tasks.named('precommit')) - project.tasks.named('check').configure { it.dependsOn(integTest) } - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/test/StandaloneRestTestPlugin.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/test/StandaloneRestTestPlugin.groovy deleted file mode 100644 index edd10b24b2000..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/test/StandaloneRestTestPlugin.groovy +++ /dev/null @@ -1,106 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -package org.opensearch.gradle.test - -import groovy.transform.CompileStatic -import org.opensearch.gradle.OpenSearchJavaPlugin -import org.opensearch.gradle.ExportOpenSearchBuildResourcesTask -import org.opensearch.gradle.RepositoriesSetupPlugin -import org.opensearch.gradle.info.BuildParams -import org.opensearch.gradle.info.GlobalBuildInfoPlugin -import org.opensearch.gradle.precommit.PrecommitTasks -import org.opensearch.gradle.testclusters.TestClustersPlugin -import org.gradle.api.InvalidUserDataException -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.artifacts.Configuration -import org.gradle.api.plugins.JavaBasePlugin -import org.gradle.api.plugins.JavaPlugin -import org.gradle.api.plugins.JavaPluginExtension -import org.gradle.api.tasks.SourceSet -import org.gradle.api.tasks.SourceSetContainer -import org.gradle.api.tasks.testing.Test -import org.gradle.plugins.ide.eclipse.model.EclipseModel -import org.gradle.plugins.ide.idea.model.IdeaModel - -/** - * Configures the build to compile tests against OpenSearch's test framework - * and run REST tests. Use BuildPlugin if you want to build main code as well - * as tests. - */ -@CompileStatic -class StandaloneRestTestPlugin implements Plugin { - - @Override - void apply(Project project) { - if (project.pluginManager.hasPlugin('opensearch.build')) { - throw new InvalidUserDataException('opensearch.standalone-test ' - + 'opensearch.standalone-rest-test, and opensearch.build ' - + 'are mutually exclusive') - } - project.rootProject.pluginManager.apply(GlobalBuildInfoPlugin) - project.pluginManager.apply(JavaBasePlugin) - project.pluginManager.apply(TestClustersPlugin) - project.pluginManager.apply(RepositoriesSetupPlugin) - project.pluginManager.apply(RestTestBasePlugin) - - project.getTasks().register("buildResources", ExportOpenSearchBuildResourcesTask) - OpenSearchJavaPlugin.configureInputNormalization(project) - OpenSearchJavaPlugin.configureCompile(project) - - - project.extensions.getByType(JavaPluginExtension).sourceCompatibility = BuildParams.minimumRuntimeVersion - project.extensions.getByType(JavaPluginExtension).targetCompatibility = BuildParams.minimumRuntimeVersion - - // only setup tests to build - SourceSetContainer sourceSets = project.extensions.getByType(SourceSetContainer) - SourceSet testSourceSet = sourceSets.create('test') - - project.tasks.withType(Test).configureEach { Test test -> - test.testClassesDirs = testSourceSet.output.classesDirs - test.classpath = testSourceSet.runtimeClasspath - } - - // create a compileOnly configuration as others might expect it - project.configurations.create("compileOnly") - project.dependencies.add('testImplementation', project.project(':test:framework')) - - EclipseModel eclipse = project.extensions.getByType(EclipseModel) - eclipse.classpath.sourceSets = [testSourceSet] - eclipse.classpath.plusConfigurations = [project.configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME)] - - IdeaModel idea = project.extensions.getByType(IdeaModel) - idea.module.testSourceDirs += testSourceSet.java.srcDirs - idea.module.scopes.put('TEST', [plus: [project.configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME)]] as Map>) - - PrecommitTasks.create(project, false) - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/test/StandaloneTestPlugin.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/test/StandaloneTestPlugin.groovy deleted file mode 100644 index 89489ce0d828d..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/test/StandaloneTestPlugin.groovy +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle.test - -import groovy.transform.CompileStatic -import org.opensearch.gradle.OpenSearchJavaPlugin -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.plugins.JavaBasePlugin -import org.gradle.api.tasks.testing.Test - -/** - * Configures the build to compile against OpenSearch's test framework and - * run integration and unit tests. Use BuildPlugin if you want to build main - * code as well as tests. */ -@CompileStatic -class StandaloneTestPlugin implements Plugin { - - @Override - void apply(Project project) { - project.pluginManager.apply(StandaloneRestTestPlugin) - - project.tasks.register('test', Test).configure { t -> - t.group = JavaBasePlugin.VERIFICATION_GROUP - t.description = 'Runs unit tests that are separate' - t.mustRunAfter(project.tasks.getByName('precommit')) - } - - OpenSearchJavaPlugin.configureCompile(project) - project.tasks.named('check').configure { it.dependsOn(project.tasks.named('test')) } - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/test/TestWithDependenciesPlugin.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/test/TestWithDependenciesPlugin.groovy deleted file mode 100644 index e84493d442f39..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/test/TestWithDependenciesPlugin.groovy +++ /dev/null @@ -1,79 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.opensearch.gradle.test - -import org.opensearch.gradle.plugin.PluginBuildPlugin -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.artifacts.Dependency -import org.gradle.api.artifacts.ProjectDependency -import org.gradle.api.tasks.Copy - -/** - * A plugin to run tests that depend on other plugins or modules. - * - * This plugin will add the plugin-metadata and properties files for each - * dependency to the test source set. - */ -class TestWithDependenciesPlugin implements Plugin { - - @Override - void apply(Project project) { - if (project.isEclipse) { - /* The changes this plugin makes both break and aren't needed by - * Eclipse. This is because Eclipse flattens main and test - * dependencies into a single dependency. Because Eclipse is - * "special".... */ - return - } - - project.configurations.testImplementation.dependencies.all { Dependency dep -> - // this closure is run every time a compile dependency is added - if (dep instanceof ProjectDependency && dep.dependencyProject.plugins.hasPlugin(PluginBuildPlugin)) { - project.gradle.projectsEvaluated { - addPluginResources(project, dep.dependencyProject) - } - } - } - } - - private static addPluginResources(Project project, Project pluginProject) { - String outputDir = "${project.buildDir}/generated-resources/${pluginProject.name}" - String camelName = pluginProject.name.replaceAll(/-(\w)/) { _, c -> c.toUpperCase(Locale.ROOT) } - String taskName = "copy" + camelName[0].toUpperCase(Locale.ROOT) + camelName.substring(1) + "Metadata" - project.tasks.register(taskName, Copy.class) { - into(outputDir) - from(pluginProject.tasks.pluginProperties) - from(pluginProject.file('src/main/plugin-metadata')) - } - - project.sourceSets.test.output.dir(outputDir, builtBy: taskName) - } -} diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/test/TestWithSslPlugin.java b/buildSrc/src/main/groovy/org/opensearch/gradle/test/TestWithSslPlugin.java deleted file mode 100644 index 33e8966bd32c1..0000000000000 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/test/TestWithSslPlugin.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test; - -import org.opensearch.gradle.ExportOpenSearchBuildResourcesTask; -import org.opensearch.gradle.precommit.ForbiddenPatternsTask; -import org.opensearch.gradle.testclusters.OpenSearchCluster; -import org.opensearch.gradle.testclusters.TestClustersAware; -import org.opensearch.gradle.testclusters.TestClustersPlugin; -import org.opensearch.gradle.util.Util; -import org.gradle.api.NamedDomainObjectContainer; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.TaskProvider; - -import java.io.File; - -public class TestWithSslPlugin implements Plugin { - - @Override - public void apply(Project project) { - File keyStoreDir = new File(project.getBuildDir(), "keystore"); - TaskProvider exportKeyStore = project.getTasks() - .register("copyTestCertificates", ExportOpenSearchBuildResourcesTask.class, (t) -> { - t.copy("test/ssl/test-client.crt"); - t.copy("test/ssl/test-client.jks"); - t.copy("test/ssl/test-node.crt"); - t.copy("test/ssl/test-node.jks"); - t.setOutputDir(keyStoreDir); - }); - - project.getPlugins().withType(StandaloneRestTestPlugin.class).configureEach(restTestPlugin -> { - SourceSet testSourceSet = Util.getJavaTestSourceSet(project).get(); - testSourceSet.getResources().srcDir(new File(keyStoreDir, "test/ssl")); - testSourceSet.compiledBy(exportKeyStore); - - project.getTasks().withType(TestClustersAware.class).configureEach(clusterAware -> clusterAware.dependsOn(exportKeyStore)); - - // Tell the tests we're running with ssl enabled - project.getTasks() - .withType(RestIntegTestTask.class) - .configureEach(runner -> runner.systemProperty("tests.ssl.enabled", "true")); - }); - - project.getPlugins().withType(TestClustersPlugin.class).configureEach(clustersPlugin -> { - File keystoreDir = new File(project.getBuildDir(), "keystore/test/ssl"); - File nodeKeystore = new File(keystoreDir, "test-node.jks"); - File clientKeyStore = new File(keystoreDir, "test-client.jks"); - NamedDomainObjectContainer clusters = (NamedDomainObjectContainer) project.getExtensions() - .getByName(TestClustersPlugin.EXTENSION_NAME); - clusters.all(c -> { - // copy keystores & certs into config/ - c.extraConfigFile(nodeKeystore.getName(), nodeKeystore); - c.extraConfigFile(clientKeyStore.getName(), clientKeyStore); - }); - }); - - project.getTasks() - .withType(ForbiddenPatternsTask.class) - .configureEach(forbiddenPatternTask -> forbiddenPatternTask.exclude("**/*.crt")); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/AbstractLazyPropertyCollection.java b/buildSrc/src/main/java/org/opensearch/gradle/AbstractLazyPropertyCollection.java deleted file mode 100644 index 5572ece6ba91c..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/AbstractLazyPropertyCollection.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import java.util.List; - -public abstract class AbstractLazyPropertyCollection { - - final String name; - final Object owner; - - public AbstractLazyPropertyCollection(String name) { - this(name, null); - } - - public AbstractLazyPropertyCollection(String name, Object owner) { - this.name = name; - this.owner = owner; - } - - public abstract List getNormalizedCollection(); - - void assertNotNull(Object value, String description) { - if (value == null) { - throw new NullPointerException(name + " " + description + " was null" + (owner != null ? " when configuring " + owner : "")); - } - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/Architecture.java b/buildSrc/src/main/java/org/opensearch/gradle/Architecture.java deleted file mode 100644 index 432426f089860..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/Architecture.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -public enum Architecture { - - X64, - ARM64, - PPC64LE; - - public static Architecture current() { - final String architecture = System.getProperty("os.arch", ""); - switch (architecture) { - case "amd64": - case "x86_64": - return X64; - case "aarch64": - return ARM64; - case "ppc64le": - return PPC64LE; - default: - throw new IllegalArgumentException("can not determine architecture from [" + architecture + "]"); - } - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/BwcVersions.java b/buildSrc/src/main/java/org/opensearch/gradle/BwcVersions.java deleted file mode 100644 index d04fd2c7f4c56..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/BwcVersions.java +++ /dev/null @@ -1,431 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.function.Consumer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static java.util.Collections.emptyList; -import static java.util.Collections.unmodifiableList; - -/** - * A container for opensearch supported version information used in BWC testing. - * - * Parse the Java source file containing the versions declarations and use the known rules to figure out which are all - * the version the current one is wire and index compatible with. - * On top of this, figure out which of these are unreleased and provide the branch they can be built from. - * - * Note that in this context, currentVersion is the unreleased version this build operates on. - * At any point in time there will surely be four such unreleased versions being worked on, - * thus currentVersion will be one of these. - * - * Considering: - *
    - *
    M, M > 0
    - *
    last released major
    - *
    N, N > 0
    - *
    last released minor
    - *
    - * - *
      - *
    • the unreleased major, M+1.0.0 on the `master` branch
    • - *
    • the unreleased minor, M.N.0 on the `M.x` (x is literal) branch
    • - *
    • the unreleased bugfix, M.N.c (c > 0) on the `M.N` branch
    • - *
    • the unreleased maintenance, M-1.d.e ( d > 0, e > 0) on the `(M-1).d` branch
    • - *
    - * In addition to these, there will be a fifth one when a minor reaches feature freeze, we call this the staged - * version: - *
      - *
    • the unreleased staged, M.N-2.0 (N > 2) on the `M.(N-2)` branch
    • - *
    - * - * Each build is only concerned with versions before it, as those are the ones that need to be tested - * for backwards compatibility. We never look forward, and don't add forward facing version number to branches of previous - * version. - * - * Each branch has a current version, and expected compatible versions are parsed from the server code's Version` class. - * We can reliably figure out which the unreleased versions are due to the convention of always adding the next unreleased - * version number to server in all branches when a version is released. - * E.x when M.N.c is released M.N.c+1 is added to the Version class mentioned above in all the following branches: - * `M.N`, `M.x` and `master` so we can reliably assume that the leafs of the version tree are unreleased. - * This convention is enforced by checking the versions we consider to be unreleased against an - * authoritative source (maven central). - * We are then able to map the unreleased version to branches in git and Gradle projects that are capable of checking - * out and building them, so we can include these in the testing plan as well. - */ -public class BwcVersions { - - private static final Pattern LINE_PATTERN = Pattern.compile( - "\\W+public static final (LegacyES)?Version V_(\\d+)_(\\d+)_(\\d+)(_alpha\\d+|_beta\\d+|_rc\\d+)? .*" - ); - - private final Version currentVersion; - private final Map> groupByMajor; - private final Map unreleased; - - public class UnreleasedVersionInfo { - public final Version version; - public final String branch; - public final String gradleProjectPath; - - UnreleasedVersionInfo(Version version, String branch, String gradleProjectPath) { - this.version = version; - this.branch = branch; - this.gradleProjectPath = gradleProjectPath; - } - } - - public BwcVersions(List versionLines) { - this(versionLines, Version.fromString(VersionProperties.getOpenSearch())); - } - - protected BwcVersions(List versionLines, Version currentVersionProperty) { - this( - versionLines.stream() - .map(LINE_PATTERN::matcher) - .filter(Matcher::matches) - .map( - match -> new Version( - Integer.parseInt(match.group(2)), - Integer.parseInt(match.group(3)), - Integer.parseInt(match.group(4)) - ) - ) - .collect(Collectors.toCollection(TreeSet::new)), - currentVersionProperty - ); - } - - // for testkit tests, until BwcVersions is extracted into an extension - public BwcVersions(SortedSet allVersions, Version currentVersionProperty) { - if (allVersions.isEmpty()) { - throw new IllegalArgumentException("Could not parse any versions"); - } - - // hack: this is horribly volatile like this entire logic; fix - currentVersion = allVersions.last(); - - groupByMajor = allVersions.stream() - // We only care about the last 2 majors when it comes to BWC. - // It might take us time to remove the older ones from versionLines, so we allow them to exist. - // Adjust the major number since OpenSearch 1.x is released after predecessor version 7.x - .filter( - version -> (version.getMajor() == 1 ? 7 : version.getMajor()) > (currentVersion.getMajor() == 1 - ? 7 - : currentVersion.getMajor()) - 2 - ) - .collect(Collectors.groupingBy(Version::getMajor, Collectors.toList())); - - assertCurrentVersionMatchesParsed(currentVersionProperty); - - assertNoOlderThanTwoMajors(); - - Map unreleased = new HashMap<>(); - for (Version unreleasedVersion : getUnreleased()) { - unreleased.put( - unreleasedVersion, - new UnreleasedVersionInfo(unreleasedVersion, getBranchFor(unreleasedVersion), getGradleProjectPathFor(unreleasedVersion)) - ); - } - this.unreleased = Collections.unmodifiableMap(unreleased); - } - - private void assertNoOlderThanTwoMajors() { - Set majors = groupByMajor.keySet(); - // until OpenSearch 3.0 we will need to carry three major support - // (1, 7, 6) && (2, 1, 7) since OpenSearch 1.0 === Legacy 7.x - int numSupportedMajors = (currentVersion.getMajor() < 3) ? 3 : 2; - if (majors.size() != numSupportedMajors && currentVersion.getMinor() != 0 && currentVersion.getRevision() != 0) { - throw new IllegalStateException("Expected exactly 2 majors in parsed versions but found: " + majors); - } - } - - private void assertCurrentVersionMatchesParsed(Version currentVersionProperty) { - if (currentVersionProperty.equals(currentVersion) == false) { - throw new IllegalStateException( - "Parsed versions latest version does not match the one configured in build properties. " - + "Parsed latest version is " - + currentVersion - + " but the build has " - + currentVersionProperty - ); - } - } - - /** - * Returns info about the unreleased version, or {@code null} if the version is released. - */ - public UnreleasedVersionInfo unreleasedInfo(Version version) { - return unreleased.get(version); - } - - public void forPreviousUnreleased(Consumer consumer) { - List collect = getUnreleased().stream() - .filter(version -> version.equals(currentVersion) == false) - .map(version -> new UnreleasedVersionInfo(version, getBranchFor(version), getGradleProjectPathFor(version))) - .collect(Collectors.toList()); - - collect.forEach(uvi -> consumer.accept(uvi)); - } - - private String getGradleProjectPathFor(Version version) { - // We have Gradle projects set up to check out and build unreleased versions based on the our branching - // conventions described in this classes javadoc - if (version.equals(currentVersion)) { - return ":distribution"; - } - - Map> releasedMajorGroupedByMinor = getReleasedMajorGroupedByMinor(); - - if (version.getRevision() == 0) { - List unreleasedStagedOrMinor = getUnreleased().stream().filter(v -> v.getRevision() == 0).collect(Collectors.toList()); - if (unreleasedStagedOrMinor.size() > 2) { - if (unreleasedStagedOrMinor.get(unreleasedStagedOrMinor.size() - 2).equals(version)) { - return ":distribution:bwc:minor"; - } else { - return ":distribution:bwc:staged"; - } - } else { - return ":distribution:bwc:minor"; - } - } else { - if (releasedMajorGroupedByMinor.getOrDefault(version.getMinor(), emptyList()).contains(version)) { - return ":distribution:bwc:bugfix"; - } else { - return ":distribution:bwc:maintenance"; - } - } - } - - private String getBranchFor(Version version) { - // based on the rules described in this classes javadoc, figure out the branch on which an unreleased version - // lives. - // We do this based on the Gradle project path because there's a direct correlation, so we dont have to duplicate - // the logic from there - switch (getGradleProjectPathFor(version)) { - case ":distribution": - return "master"; - case ":distribution:bwc:minor": - // The .x branch will always point to the latest minor (for that major), so a "minor" project will be on the .x branch - // unless there is more recent (higher) minor. - final Version latestInMajor = getLatestVersionByKey(groupByMajor, version.getMajor()); - if (latestInMajor.getMinor() == version.getMinor()) { - return version.getMajor() + ".x"; - } else { - return version.getMajor() + "." + version.getMinor(); - } - case ":distribution:bwc:staged": - case ":distribution:bwc:maintenance": - case ":distribution:bwc:bugfix": - return version.getMajor() + "." + version.getMinor(); - default: - throw new IllegalStateException("Unexpected Gradle project name"); - } - } - - public List getUnreleased() { - List unreleased = new ArrayList<>(); - - // The current version is being worked, is always unreleased - unreleased.add(currentVersion); - - // No unreleased versions for 1.0.0 - // todo remove this hack - if (currentVersion.equals(Version.fromString("1.0.0"))) { - return unmodifiableList(unreleased); - } - - // the tip of the previous major is unreleased for sure, be it a minor or a bugfix - if (currentVersion.getMajor() != 1) { - final Version latestOfPreviousMajor = getLatestVersionByKey( - this.groupByMajor, - currentVersion.getMajor() == 1 ? 7 : currentVersion.getMajor() - 1 - ); - unreleased.add(latestOfPreviousMajor); - if (latestOfPreviousMajor.getRevision() == 0) { - // if the previous major is a x.y.0 release, then the tip of the minor before that (y-1) is also unreleased - final Version previousMinor = getLatestInMinor(latestOfPreviousMajor.getMajor(), latestOfPreviousMajor.getMinor() - 1); - if (previousMinor != null) { - unreleased.add(previousMinor); - } - } - } - - final Map> groupByMinor = getReleasedMajorGroupedByMinor(); - int greatestMinor = groupByMinor.keySet().stream().max(Integer::compareTo).orElse(0); - - // the last bugfix for this minor series is always unreleased - unreleased.add(getLatestVersionByKey(groupByMinor, greatestMinor)); - - if (groupByMinor.get(greatestMinor).size() == 1) { - // we found an unreleased minor - unreleased.add(getLatestVersionByKey(groupByMinor, greatestMinor - 1)); - if (groupByMinor.getOrDefault(greatestMinor - 1, emptyList()).size() == 1) { - // we found that the previous minor is staged but not yet released - // in this case, the minor before that has a bugfix, should there be such a minor - if (greatestMinor >= 2) { - unreleased.add(getLatestVersionByKey(groupByMinor, greatestMinor - 2)); - } - } - } - - return unmodifiableList(unreleased.stream().sorted().distinct().collect(Collectors.toList())); - } - - private Version getLatestInMinor(int major, int minor) { - return groupByMajor.get(major).stream().filter(v -> v.getMinor() == minor).max(Version::compareTo).orElse(null); - } - - private Version getLatestVersionByKey(Map> groupByMajor, int key) { - return groupByMajor.getOrDefault(key, emptyList()) - .stream() - .max(Version::compareTo) - .orElseThrow(() -> new IllegalStateException("Unexpected number of versions in collection")); - } - - private Map> getReleasedMajorGroupedByMinor() { - int currentMajor = currentVersion.getMajor(); - List currentMajorVersions = groupByMajor.get(currentMajor); - List previousMajorVersions = groupByMajor.get(getPreviousMajor(currentMajor)); - - final Map> groupByMinor; - if (currentMajorVersions.size() == 1) { - // Current is an unreleased major: x.0.0 so we have to look for other unreleased versions in the previous major - groupByMinor = previousMajorVersions.stream().collect(Collectors.groupingBy(Version::getMinor, Collectors.toList())); - } else { - groupByMinor = currentMajorVersions.stream().collect(Collectors.groupingBy(Version::getMinor, Collectors.toList())); - } - return groupByMinor; - } - - public void compareToAuthoritative(List authoritativeReleasedVersions) { - Set notReallyReleased = new HashSet<>(getReleased()); - notReallyReleased.removeAll(authoritativeReleasedVersions); - if (notReallyReleased.isEmpty() == false) { - throw new IllegalStateException( - "out-of-date released versions" - + "\nFollowing versions are not really released, but the build thinks they are: " - + notReallyReleased - ); - } - - Set incorrectlyConsideredUnreleased = new HashSet<>(authoritativeReleasedVersions); - incorrectlyConsideredUnreleased.retainAll(getUnreleased()); - if (incorrectlyConsideredUnreleased.isEmpty() == false) { - throw new IllegalStateException( - "out-of-date released versions" - + "\nBuild considers versions unreleased, " - + "but they are released according to an authoritative source: " - + incorrectlyConsideredUnreleased - + "\nThe next versions probably needs to be added to Version.java (CURRENT doesn't count)." - ); - } - } - - private List getReleased() { - List unreleased = getUnreleased(); - return groupByMajor.values() - .stream() - .flatMap(Collection::stream) - .filter(each -> unreleased.contains(each) == false) - .collect(Collectors.toList()); - } - - public List getIndexCompatible() { - int currentMajor = currentVersion.getMajor(); - int prevMajor = getPreviousMajor(currentMajor); - List result = Stream.concat(groupByMajor.get(prevMajor).stream(), groupByMajor.get(currentMajor).stream()) - .filter(version -> version.equals(currentVersion) == false) - .collect(Collectors.toList()); - if (currentMajor == 1) { - // add 6.x compatible for OpenSearch 1.0.0 - return unmodifiableList(Stream.concat(groupByMajor.get(prevMajor - 1).stream(), result.stream()).collect(Collectors.toList())); - } - return unmodifiableList(result); - } - - public List getWireCompatible() { - List wireCompat = new ArrayList<>(); - int currentMajor = currentVersion.getMajor(); - int lastMajor = currentMajor == 1 ? 6 : currentMajor - 1; - List lastMajorList = groupByMajor.get(lastMajor); - if (lastMajorList == null) { - throw new IllegalStateException("Expected to find a list of versions for version: " + lastMajor); - } - int minor = lastMajorList.get(lastMajorList.size() - 1).getMinor(); - for (int i = lastMajorList.size() - 1; i > 0 && lastMajorList.get(i).getMinor() == minor; --i) { - wireCompat.add(lastMajorList.get(i)); - } - - // if current is OpenSearch 1.0.0 add all of the 7.x line: - if (currentMajor == 1) { - List previousMajor = groupByMajor.get(7); - for (Version v : previousMajor) { - wireCompat.add(v); - } - } - wireCompat.addAll(groupByMajor.get(currentMajor)); - wireCompat.remove(currentVersion); - wireCompat.sort(Version::compareTo); - return unmodifiableList(wireCompat); - } - - public List getUnreleasedIndexCompatible() { - List unreleasedIndexCompatible = new ArrayList<>(getIndexCompatible()); - unreleasedIndexCompatible.retainAll(getUnreleased()); - return unmodifiableList(unreleasedIndexCompatible); - } - - public List getUnreleasedWireCompatible() { - List unreleasedWireCompatible = new ArrayList<>(getWireCompatible()); - unreleasedWireCompatible.retainAll(getUnreleased()); - return unmodifiableList(unreleasedWireCompatible); - } - - private int getPreviousMajor(int currentMajor) { - return currentMajor == 1 ? 7 : currentMajor - 1; - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/ConcatFilesTask.java b/buildSrc/src/main/java/org/opensearch/gradle/ConcatFilesTask.java deleted file mode 100644 index 96e3702d5a729..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/ConcatFilesTask.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.StandardOpenOption; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; - -import org.gradle.api.DefaultTask; -import org.gradle.api.file.FileTree; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.InputFiles; -import org.gradle.api.tasks.Optional; -import org.gradle.api.tasks.OutputFile; -import org.gradle.api.tasks.TaskAction; - -/** - * Concatenates a list of files into one and removes duplicate lines. - */ -public class ConcatFilesTask extends DefaultTask { - - public ConcatFilesTask() { - setDescription("Concat a list of files into one."); - } - - /** List of files to concatenate */ - private FileTree files; - - /** line to add at the top of the target file */ - private String headerLine; - - private File target; - - private List additionalLines = new ArrayList<>(); - - public void setFiles(FileTree files) { - this.files = files; - } - - @InputFiles - public FileTree getFiles() { - return files; - } - - public void setHeaderLine(String headerLine) { - this.headerLine = headerLine; - } - - @Input - @Optional - public String getHeaderLine() { - return headerLine; - } - - public void setTarget(File target) { - this.target = target; - } - - @OutputFile - public File getTarget() { - return target; - } - - @Input - public List getAdditionalLines() { - return additionalLines; - } - - public void setAdditionalLines(List additionalLines) { - this.additionalLines = additionalLines; - } - - @TaskAction - public void concatFiles() throws IOException { - if (getHeaderLine() != null) { - Files.write(getTarget().toPath(), (getHeaderLine() + '\n').getBytes(StandardCharsets.UTF_8)); - } - - // To remove duplicate lines - LinkedHashSet uniqueLines = new LinkedHashSet<>(); - for (File f : getFiles()) { - uniqueLines.addAll(Files.readAllLines(f.toPath(), StandardCharsets.UTF_8)); - } - Files.write(getTarget().toPath(), uniqueLines, StandardCharsets.UTF_8, StandardOpenOption.APPEND); - - for (String additionalLine : additionalLines) { - Files.write(getTarget().toPath(), (additionalLine + '\n').getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND); - } - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/DistributionDependency.java b/buildSrc/src/main/java/org/opensearch/gradle/DistributionDependency.java deleted file mode 100644 index 3ab4fbf2da470..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/DistributionDependency.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -public interface DistributionDependency { - static DistributionDependency of(String dependencyNotation) { - return new StringBasedDistributionDependency(dependencyNotation); - } - - Object getDefaultNotation(); - - Object getExtractedNotation(); - - class StringBasedDistributionDependency implements DistributionDependency { - private final String notation; - - public StringBasedDistributionDependency(String notation) { - this.notation = notation; - } - - @Override - public Object getDefaultNotation() { - return notation; - } - - @Override - public Object getExtractedNotation() { - return notation; - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/DistributionDownloadPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/DistributionDownloadPlugin.java deleted file mode 100644 index 741a6f8620c7c..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/DistributionDownloadPlugin.java +++ /dev/null @@ -1,274 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.opensearch.gradle.OpenSearchDistribution.Platform; -import org.opensearch.gradle.OpenSearchDistribution.Type; -import org.opensearch.gradle.docker.DockerSupportPlugin; -import org.opensearch.gradle.docker.DockerSupportService; -import org.opensearch.gradle.transform.SymbolicLinkPreservingUntarTransform; -import org.opensearch.gradle.transform.UnzipTransform; -import org.opensearch.gradle.util.GradleUtils; -import org.gradle.api.NamedDomainObjectContainer; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.dsl.DependencyHandler; -import org.gradle.api.artifacts.repositories.IvyArtifactRepository; -import org.gradle.api.artifacts.type.ArtifactTypeDefinition; -import org.gradle.api.internal.artifacts.ArtifactAttributes; -import org.gradle.api.provider.Provider; - -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; - -/** - * A plugin to manage getting and extracting distributions of OpenSearch. - *

    - * The plugin provides hooks to register custom distribution resolutions. - * This plugin resolves distributions from the OpenSearch downloads service if - * no registered resolution strategy can resolve to a distribution. - */ -public class DistributionDownloadPlugin implements Plugin { - - static final String RESOLUTION_CONTAINER_NAME = "opensearch_distributions_resolutions"; - private static final String CONTAINER_NAME = "opensearch_distributions"; - private static final String FAKE_IVY_GROUP = "opensearch-distribution"; - private static final String FAKE_SNAPSHOT_IVY_GROUP = "opensearch-distribution-snapshot"; - private static final String DOWNLOAD_REPO_NAME = "opensearch-downloads"; - private static final String SNAPSHOT_REPO_NAME = "opensearch-snapshots"; - public static final String DISTRO_EXTRACTED_CONFIG_PREFIX = "opensearch_distro_extracted_"; - - // for downloading Elasticsearch OSS distributions to run BWC - private static final String FAKE_IVY_GROUP_ES = "elasticsearch-distribution"; - private static final String DOWNLOAD_REPO_NAME_ES = "elasticsearch-downloads"; - private static final String SNAPSHOT_REPO_NAME_ES = "elasticsearch-snapshots"; - private static final String FAKE_SNAPSHOT_IVY_GROUP_ES = "elasticsearch-distribution-snapshot"; - - private static final String RELEASE_PATTERN_LAYOUT = "/core/opensearch/[revision]/[module]-min-[revision](-[classifier]).[ext]"; - private static final String SNAPSHOT_PATTERN_LAYOUT = - "/snapshots/core/opensearch/[revision]/[module]-min-[revision](-[classifier])-latest.[ext]"; - - private NamedDomainObjectContainer distributionsContainer; - private NamedDomainObjectContainer distributionsResolutionStrategiesContainer; - - @Override - public void apply(Project project) { - project.getRootProject().getPluginManager().apply(DockerSupportPlugin.class); - Provider dockerSupport = GradleUtils.getBuildService( - project.getGradle().getSharedServices(), - DockerSupportPlugin.DOCKER_SUPPORT_SERVICE_NAME - ); - - project.getDependencies().registerTransform(UnzipTransform.class, transformSpec -> { - transformSpec.getFrom().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.ZIP_TYPE); - transformSpec.getTo().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.DIRECTORY_TYPE); - }); - - ArtifactTypeDefinition tarArtifactTypeDefinition = project.getDependencies().getArtifactTypes().maybeCreate("tar.gz"); - project.getDependencies().registerTransform(SymbolicLinkPreservingUntarTransform.class, transformSpec -> { - transformSpec.getFrom().attribute(ArtifactAttributes.ARTIFACT_FORMAT, tarArtifactTypeDefinition.getName()); - transformSpec.getTo().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.DIRECTORY_TYPE); - }); - - setupResolutionsContainer(project); - setupDistributionContainer(project, dockerSupport); - setupDownloadServiceRepo(project); - project.afterEvaluate(this::setupDistributions); - } - - private void setupDistributionContainer(Project project, Provider dockerSupport) { - distributionsContainer = project.container(OpenSearchDistribution.class, name -> { - Configuration fileConfiguration = project.getConfigurations().create("opensearch_distro_file_" + name); - Configuration extractedConfiguration = project.getConfigurations().create(DISTRO_EXTRACTED_CONFIG_PREFIX + name); - extractedConfiguration.getAttributes().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.DIRECTORY_TYPE); - return new OpenSearchDistribution(name, project.getObjects(), dockerSupport, fileConfiguration, extractedConfiguration); - }); - project.getExtensions().add(CONTAINER_NAME, distributionsContainer); - } - - private void setupResolutionsContainer(Project project) { - distributionsResolutionStrategiesContainer = project.container(DistributionResolution.class); - // We want this ordered in the same resolution strategies are added - distributionsResolutionStrategiesContainer.whenObjectAdded( - resolveDependencyNotation -> resolveDependencyNotation.setPriority(distributionsResolutionStrategiesContainer.size()) - ); - project.getExtensions().add(RESOLUTION_CONTAINER_NAME, distributionsResolutionStrategiesContainer); - } - - @SuppressWarnings("unchecked") - public static NamedDomainObjectContainer getContainer(Project project) { - return (NamedDomainObjectContainer) project.getExtensions().getByName(CONTAINER_NAME); - } - - @SuppressWarnings("unchecked") - public static NamedDomainObjectContainer getRegistrationsContainer(Project project) { - return (NamedDomainObjectContainer) project.getExtensions().getByName(RESOLUTION_CONTAINER_NAME); - } - - // pkg private for tests - void setupDistributions(Project project) { - for (OpenSearchDistribution distribution : distributionsContainer) { - distribution.finalizeValues(); - DependencyHandler dependencies = project.getDependencies(); - // for the distribution as a file, just depend on the artifact directly - DistributionDependency distributionDependency = resolveDependencyNotation(project, distribution); - dependencies.add(distribution.configuration.getName(), distributionDependency.getDefaultNotation()); - // no extraction allowed for rpm, deb or docker - if (distribution.getType().shouldExtract()) { - // The extracted configuration depends on the artifact directly but has - // an artifact transform registered to resolve it as an unpacked folder. - dependencies.add(distribution.getExtracted().getName(), distributionDependency.getExtractedNotation()); - } - } - } - - private DistributionDependency resolveDependencyNotation(Project p, OpenSearchDistribution distribution) { - return distributionsResolutionStrategiesContainer.stream() - .sorted(Comparator.comparingInt(DistributionResolution::getPriority)) - .map(r -> r.getResolver().resolve(p, distribution)) - .filter(d -> d != null) - .findFirst() - .orElseGet(() -> DistributionDependency.of(dependencyNotation(distribution))); - } - - private static void addIvyRepo(Project project, String name, String url, String group, String... patternLayout) { - final List repos = Arrays.stream(patternLayout).map(pattern -> project.getRepositories().ivy(repo -> { - repo.setName(name); - repo.setUrl(url); - repo.metadataSources(IvyArtifactRepository.MetadataSources::artifact); - repo.patternLayout(layout -> layout.artifact(pattern)); - })).collect(Collectors.toList()); - - project.getRepositories().exclusiveContent(exclusiveContentRepository -> { - exclusiveContentRepository.filter(config -> config.includeGroup(group)); - exclusiveContentRepository.forRepositories(repos.toArray(new IvyArtifactRepository[repos.size()])); - }); - } - - private static void addIvyRepo2(Project project, String name, String url, String group) { - IvyArtifactRepository ivyRepo = project.getRepositories().ivy(repo -> { - repo.setName(name); - repo.setUrl(url); - repo.metadataSources(IvyArtifactRepository.MetadataSources::artifact); - repo.patternLayout(layout -> layout.artifact("/downloads/elasticsearch/elasticsearch-oss-[revision](-[classifier]).[ext]")); - }); - project.getRepositories().exclusiveContent(exclusiveContentRepository -> { - exclusiveContentRepository.filter(config -> config.includeGroup(group)); - exclusiveContentRepository.forRepositories(ivyRepo); - }); - } - - private static void setupDownloadServiceRepo(Project project) { - if (project.getRepositories().findByName(DOWNLOAD_REPO_NAME) != null) { - return; - } - addIvyRepo( - project, - DOWNLOAD_REPO_NAME, - "https://artifacts.opensearch.org", - FAKE_IVY_GROUP, - "/releases" + RELEASE_PATTERN_LAYOUT, - "/release-candidates" + RELEASE_PATTERN_LAYOUT - ); - - addIvyRepo(project, SNAPSHOT_REPO_NAME, "https://artifacts.opensearch.org", FAKE_SNAPSHOT_IVY_GROUP, SNAPSHOT_PATTERN_LAYOUT); - - addIvyRepo2(project, DOWNLOAD_REPO_NAME_ES, "https://artifacts-no-kpi.elastic.co", FAKE_IVY_GROUP_ES); - addIvyRepo2(project, SNAPSHOT_REPO_NAME_ES, "https://snapshots-no-kpi.elastic.co", FAKE_SNAPSHOT_IVY_GROUP_ES); - } - - /** - * Returns a dependency object representing the given distribution. - *

    - * The returned object is suitable to be passed to {@link DependencyHandler}. - * The concrete type of the object will be a set of maven coordinates as a {@link String}. - * Maven coordinates point to either the integ-test-zip coordinates on maven central, or a set of artificial - * coordinates that resolve to the Elastic download service through an ivy repository. - */ - private String dependencyNotation(OpenSearchDistribution distribution) { - Version distroVersion = Version.fromString(distribution.getVersion()); - if (distribution.getType() == Type.INTEG_TEST_ZIP) { - if (distroVersion.onOrAfter("1.0.0")) { - return "org.opensearch.distribution.integ-test-zip:opensearch:" + distribution.getVersion() + "@zip"; - } else { - return "org.elasticsearch.distribution.integ-test-zip:elasticsearch:" + distribution.getVersion() + "@zip"; - } - } - - String extension = distribution.getType().toString(); - String classifier = distroVersion.onOrAfter("1.0.0") ? ":x64" : ":x86_64"; - if (distribution.getType() == Type.ARCHIVE) { - extension = distribution.getPlatform() == Platform.WINDOWS ? "zip" : "tar.gz"; - - if (distroVersion.onOrAfter("1.0.0")) { - switch (distribution.getArchitecture()) { - case ARM64: - classifier = ":" + distribution.getPlatform() + "-arm64"; - break; - case X64: - classifier = ":" + distribution.getPlatform() + "-x64"; - break; - case PPC64LE: - classifier = ":" + distribution.getPlatform() + "-ppc64le"; - break; - default: - throw new IllegalArgumentException("Unsupported architecture: " + distribution.getArchitecture()); - } - } else if (distroVersion.onOrAfter("7.0.0")) { - classifier = ":" + distribution.getPlatform() + "-x86_64"; - } else { - classifier = ""; - } - } else if (distribution.getType() == Type.DEB) { - if (distroVersion.onOrAfter("7.0.0")) { - classifier = ":amd64"; - } else { - classifier = ""; - } - } else if (distribution.getType() == Type.RPM && distroVersion.before("7.0.0")) { - classifier = ""; - } - - String group; - if (distroVersion.onOrAfter("1.0.0")) { - group = distribution.getVersion().endsWith("-SNAPSHOT") ? FAKE_SNAPSHOT_IVY_GROUP : FAKE_IVY_GROUP; - return group + ":opensearch" + ":" + distribution.getVersion() + classifier + "@" + extension; - } else { - group = distribution.getVersion().endsWith("-SNAPSHOT") ? FAKE_SNAPSHOT_IVY_GROUP_ES : FAKE_IVY_GROUP_ES; - return group + ":elasticsearch-oss" + ":" + distribution.getVersion() + classifier + "@" + extension; - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/DistributionResolution.java b/buildSrc/src/main/java/org/opensearch/gradle/DistributionResolution.java deleted file mode 100644 index 4e95210e63c50..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/DistributionResolution.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.gradle.api.Project; - -public class DistributionResolution { - private Resolver resolver; - private String name; - private int priority; - - public DistributionResolution(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public Resolver getResolver() { - return resolver; - } - - public void setResolver(Resolver resolver) { - this.resolver = resolver; - } - - public void setPriority(int priority) { - this.priority = priority; - } - - public int getPriority() { - return priority; - } - - public interface Resolver { - DistributionDependency resolve(Project project, OpenSearchDistribution distribution); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/DockerBase.java b/buildSrc/src/main/java/org/opensearch/gradle/DockerBase.java deleted file mode 100644 index 5fd155400cec7..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/DockerBase.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -/** - * This class models the different Docker base images that are used to build Docker distributions of OpenSearch. - */ -public enum DockerBase { - CENTOS("centos:8"); - - private final String image; - - DockerBase(String image) { - this.image = image; - } - - public String getImage() { - return image; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/EmptyDirTask.java b/buildSrc/src/main/java/org/opensearch/gradle/EmptyDirTask.java deleted file mode 100644 index f16b667f96ed4..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/EmptyDirTask.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import java.io.File; - -import javax.inject.Inject; - -import org.gradle.api.DefaultTask; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.Internal; -import org.gradle.api.tasks.TaskAction; -import org.gradle.internal.file.Chmod; - -/** - * Creates an empty directory. - */ -public class EmptyDirTask extends DefaultTask { - - private File dir; - private int dirMode = 0755; - - /** - * Creates an empty directory with the configured permissions. - */ - @TaskAction - public void create() { - dir.mkdirs(); - getChmod().chmod(dir, dirMode); - } - - @Inject - public Chmod getChmod() { - throw new UnsupportedOperationException(); - } - - @Internal - public File getDir() { - return dir; - } - - @Input - public String getDirPath() { - return dir.getPath(); - } - - /** - * @param dir The directory to create - */ - public void setDir(File dir) { - this.dir = dir; - } - - /** - * @param dir The path of the directory to create. Takes a String and coerces it to a file. - */ - public void setDir(String dir) { - this.dir = getProject().file(dir); - } - - @Input - public int getDirMode() { - return dirMode; - } - - /** - * @param dirMode The permissions to apply to the new directory - */ - public void setDirMode(int dirMode) { - this.dirMode = dirMode; - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/ExportOpenSearchBuildResourcesTask.java b/buildSrc/src/main/java/org/opensearch/gradle/ExportOpenSearchBuildResourcesTask.java deleted file mode 100644 index d00e790c94fcc..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/ExportOpenSearchBuildResourcesTask.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.gradle.api.DefaultTask; -import org.gradle.api.GradleException; -import org.gradle.api.file.DirectoryProperty; -import org.gradle.api.logging.Logger; -import org.gradle.api.logging.Logging; -import org.gradle.api.tasks.Classpath; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.OutputDirectory; -import org.gradle.api.tasks.StopExecutionException; -import org.gradle.api.tasks.TaskAction; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -/** - * Export OpenSearch build resources to configurable paths - *

    - * Wil overwrite existing files and create missing directories. - * Useful for resources that that need to be passed to other processes trough the filesystem or otherwise can't be - * consumed from the classpath. - */ -public class ExportOpenSearchBuildResourcesTask extends DefaultTask { - - private final Logger logger = Logging.getLogger(ExportOpenSearchBuildResourcesTask.class); - - private final Set resources = new HashSet<>(); - - private DirectoryProperty outputDir; - - public ExportOpenSearchBuildResourcesTask() { - outputDir = getProject().getObjects().directoryProperty(); - } - - @OutputDirectory - public DirectoryProperty getOutputDir() { - return outputDir; - } - - @Input - public Set getResources() { - return Collections.unmodifiableSet(resources); - } - - @Classpath - public String getResourcesClasspath() { - // This will make sure the task is not considered up to date if the resources are changed. - logger.info("Classpath: {}", System.getProperty("java.class.path")); - return System.getProperty("java.class.path"); - } - - public void setOutputDir(File outputDir) { - this.outputDir.set(outputDir); - } - - public void copy(String resource) { - if (getState().getExecuted() || getState().getExecuting()) { - throw new GradleException( - "buildResources can't be configured after the task ran. " + "Make sure task is not used after configuration time" - ); - } - resources.add(resource); - } - - @TaskAction - public void doExport() { - if (resources.isEmpty()) { - setDidWork(false); - throw new StopExecutionException(); - } - resources.stream().parallel().forEach(resourcePath -> { - Path destination = outputDir.get().file(resourcePath).getAsFile().toPath(); - try (InputStream is = getClass().getClassLoader().getResourceAsStream(resourcePath)) { - Files.createDirectories(destination.getParent()); - if (is == null) { - throw new GradleException("Can't export `" + resourcePath + "` from build-tools: not found"); - } - Files.copy(is, destination, StandardCopyOption.REPLACE_EXISTING); - } catch (IOException e) { - throw new GradleException("Can't write resource `" + resourcePath + "` to " + destination, e); - } - }); - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/FileSupplier.java b/buildSrc/src/main/java/org/opensearch/gradle/FileSupplier.java deleted file mode 100644 index 1c32b4251afa4..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/FileSupplier.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import java.io.File; -import java.util.function.Supplier; - -public interface FileSupplier extends Supplier {} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/FileSystemOperationsAware.java b/buildSrc/src/main/java/org/opensearch/gradle/FileSystemOperationsAware.java deleted file mode 100644 index e0a16efe9c449..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/FileSystemOperationsAware.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.gradle.api.tasks.WorkResult; - -/** - * An interface for tasks that support basic file operations. - * Methods will be added as needed. - */ -public interface FileSystemOperationsAware { - WorkResult delete(Object... objects); -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/Jdk.java b/buildSrc/src/main/java/org/opensearch/gradle/Jdk.java deleted file mode 100644 index 29aa0ece6c971..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/Jdk.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.gradle.api.Buildable; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.model.ObjectFactory; -import org.gradle.api.provider.Property; -import org.gradle.api.tasks.TaskDependency; - -import java.io.File; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class Jdk implements Buildable, Iterable { - - private static final List ALLOWED_ARCHITECTURES = Collections.unmodifiableList(Arrays.asList("aarch64", "x64", "ppc64le")); - private static final List ALLOWED_VENDORS = Collections.unmodifiableList(Arrays.asList("adoptium", "adoptopenjdk", "openjdk")); - private static final List ALLOWED_PLATFORMS = Collections.unmodifiableList( - Arrays.asList("darwin", "freebsd", "linux", "mac", "windows") - ); - private static final Pattern VERSION_PATTERN = Pattern.compile( - "(\\d+)(\\.\\d+\\.\\d+(?:.\\d+)?)?\\+(\\d+(?:\\.\\d+)?)(@([a-f0-9]{32}))?" - ); - private static final Pattern LEGACY_VERSION_PATTERN = Pattern.compile("(\\d)(u\\d+)(?:\\+|\\-)(b\\d+?)(@([a-f0-9]{32}))?"); - - private final String name; - private final Configuration configuration; - - private final Property vendor; - private final Property version; - private final Property platform; - private final Property architecture; - private String baseVersion; - private String major; - private String build; - private String hash; - - Jdk(String name, Configuration configuration, ObjectFactory objectFactory) { - this.name = name; - this.configuration = configuration; - this.vendor = objectFactory.property(String.class); - this.version = objectFactory.property(String.class); - this.platform = objectFactory.property(String.class); - this.architecture = objectFactory.property(String.class); - } - - public String getName() { - return name; - } - - public String getVendor() { - return vendor.get(); - } - - public void setVendor(final String vendor) { - if (ALLOWED_VENDORS.contains(vendor) == false) { - throw new IllegalArgumentException("unknown vendor [" + vendor + "] for jdk [" + name + "], must be one of " + ALLOWED_VENDORS); - } - this.vendor.set(vendor); - } - - public String getVersion() { - return version.get(); - } - - public void setVersion(String version) { - if (VERSION_PATTERN.matcher(version).matches() == false && LEGACY_VERSION_PATTERN.matcher(version).matches() == false) { - throw new IllegalArgumentException("malformed version [" + version + "] for jdk [" + name + "]"); - } - parseVersion(version); - this.version.set(version); - } - - public String getPlatform() { - return platform.get(); - } - - public void setPlatform(String platform) { - if (ALLOWED_PLATFORMS.contains(platform) == false) { - throw new IllegalArgumentException( - "unknown platform [" + platform + "] for jdk [" + name + "], must be one of " + ALLOWED_PLATFORMS - ); - } - this.platform.set(platform); - } - - public String getArchitecture() { - return architecture.get(); - } - - public void setArchitecture(final String architecture) { - String jdkArchitecture = translateJdkArchitecture(architecture); - if (ALLOWED_ARCHITECTURES.contains(jdkArchitecture) == false) { - throw new IllegalArgumentException( - "unknown architecture [" + jdkArchitecture + "] for jdk [" + name + "], must be one of " + ALLOWED_ARCHITECTURES - ); - } - this.architecture.set(architecture); - } - - public String getBaseVersion() { - return baseVersion; - } - - public String getMajor() { - return major; - } - - public String getBuild() { - return build; - } - - public String getHash() { - return hash; - } - - public String getPath() { - return configuration.getSingleFile().toString(); - } - - public String getConfigurationName() { - return configuration.getName(); - } - - @Override - public String toString() { - return getPath(); - } - - @Override - public TaskDependency getBuildDependencies() { - return configuration.getBuildDependencies(); - } - - public Object getBinJavaPath() { - return new Object() { - @Override - public String toString() { - return getHomeRoot() + "/bin/java"; - } - }; - } - - public Object getJavaHomePath() { - return new Object() { - @Override - public String toString() { - return getHomeRoot(); - } - }; - } - - private String getHomeRoot() { - boolean isOSX = "mac".equals(getPlatform()) || "darwin".equals(getPlatform()); - return getPath() + (isOSX ? "/Contents/Home" : ""); - } - - // internal, make this jdks configuration unmodifiable - void finalizeValues() { - if (version.isPresent() == false) { - throw new IllegalArgumentException("version not specified for jdk [" + name + "]"); - } - if (platform.isPresent() == false) { - throw new IllegalArgumentException("platform not specified for jdk [" + name + "]"); - } - if (vendor.isPresent() == false) { - throw new IllegalArgumentException("vendor not specified for jdk [" + name + "]"); - } - if (architecture.isPresent() == false) { - throw new IllegalArgumentException("architecture not specified for jdk [" + name + "]"); - } - version.finalizeValue(); - platform.finalizeValue(); - vendor.finalizeValue(); - architecture.finalizeValue(); - } - - @Override - public Iterator iterator() { - return configuration.iterator(); - } - - private void parseVersion(String version) { - // decompose the bundled jdk version, broken into elements as: [feature, interim, update, build] - // Note the "patch" version is not yet handled here, as it has not yet been used by java. - Matcher jdkVersionMatcher = VERSION_PATTERN.matcher(version); - if (jdkVersionMatcher.matches() == false) { - // Try again with the pre-Java9 version format - jdkVersionMatcher = LEGACY_VERSION_PATTERN.matcher(version); - - if (jdkVersionMatcher.matches() == false) { - throw new IllegalArgumentException("Malformed jdk version [" + version + "]"); - } - } - - baseVersion = jdkVersionMatcher.group(1) + (jdkVersionMatcher.group(2) != null ? (jdkVersionMatcher.group(2)) : ""); - major = jdkVersionMatcher.group(1); - build = jdkVersionMatcher.group(3); - hash = jdkVersionMatcher.group(5); - } - - private String translateJdkArchitecture(String architecture) { - /* - * Jdk uses aarch64 from ARM. Translating from arm64 to aarch64 which Jdk understands. - */ - return "arm64".equals(architecture) ? "aarch64" : architecture; - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/JdkDownloadPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/JdkDownloadPlugin.java deleted file mode 100644 index f638f1931cf62..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/JdkDownloadPlugin.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.opensearch.gradle.transform.SymbolicLinkPreservingUntarTransform; -import org.opensearch.gradle.transform.UnzipTransform; -import org.gradle.api.GradleException; -import org.gradle.api.NamedDomainObjectContainer; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.dsl.RepositoryHandler; -import org.gradle.api.artifacts.repositories.IvyArtifactRepository; -import org.gradle.api.artifacts.type.ArtifactTypeDefinition; -import org.gradle.api.attributes.Attribute; -import org.gradle.api.internal.artifacts.ArtifactAttributes; - -public class JdkDownloadPlugin implements Plugin { - public static final String VENDOR_ADOPTIUM = "adoptium"; - public static final String VENDOR_ADOPTOPENJDK = "adoptopenjdk"; - public static final String VENDOR_OPENJDK = "openjdk"; - - private static final String REPO_NAME_PREFIX = "jdk_repo_"; - private static final String EXTENSION_NAME = "jdks"; - public static final String JDK_TRIMMED_PREFIX = "jdk-?\\d.*"; - - @Override - public void apply(Project project) { - Attribute jdkAttribute = Attribute.of("jdk", Boolean.class); - project.getDependencies().getAttributesSchema().attribute(jdkAttribute); - project.getDependencies().getArtifactTypes().maybeCreate(ArtifactTypeDefinition.ZIP_TYPE); - project.getDependencies().registerTransform(UnzipTransform.class, transformSpec -> { - transformSpec.getFrom() - .attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.ZIP_TYPE) - .attribute(jdkAttribute, true); - transformSpec.getTo() - .attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.DIRECTORY_TYPE) - .attribute(jdkAttribute, true); - transformSpec.parameters(parameters -> parameters.setTrimmedPrefixPattern(JDK_TRIMMED_PREFIX)); - }); - - ArtifactTypeDefinition tarArtifactTypeDefinition = project.getDependencies().getArtifactTypes().maybeCreate("tar.gz"); - project.getDependencies().registerTransform(SymbolicLinkPreservingUntarTransform.class, transformSpec -> { - transformSpec.getFrom() - .attribute(ArtifactAttributes.ARTIFACT_FORMAT, tarArtifactTypeDefinition.getName()) - .attribute(jdkAttribute, true); - transformSpec.getTo() - .attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.DIRECTORY_TYPE) - .attribute(jdkAttribute, true); - transformSpec.parameters(parameters -> parameters.setTrimmedPrefixPattern(JDK_TRIMMED_PREFIX)); - }); - - NamedDomainObjectContainer jdksContainer = project.container(Jdk.class, name -> { - Configuration configuration = project.getConfigurations().create("jdk_" + name); - configuration.setCanBeConsumed(false); - configuration.getAttributes().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.DIRECTORY_TYPE); - configuration.getAttributes().attribute(jdkAttribute, true); - Jdk jdk = new Jdk(name, configuration, project.getObjects()); - configuration.defaultDependencies(dependencies -> { - jdk.finalizeValues(); - setupRepository(project, jdk); - dependencies.add(project.getDependencies().create(dependencyNotation(jdk))); - }); - return jdk; - }); - project.getExtensions().add(EXTENSION_NAME, jdksContainer); - } - - private void setupRepository(Project project, Jdk jdk) { - RepositoryHandler repositories = project.getRepositories(); - - /* - * Define the appropriate repository for the given JDK vendor and version - * - * For Oracle/OpenJDK/AdoptOpenJDK we define a repository per-version. - */ - String repoName = REPO_NAME_PREFIX + jdk.getVendor() + "_" + jdk.getVersion(); - String repoUrl; - String artifactPattern; - - if (jdk.getVendor().equals(VENDOR_ADOPTIUM)) { - repoUrl = "https://github.com/adoptium/temurin" + jdk.getMajor() + "-binaries/releases/download/"; - - if (jdk.getMajor().equals("8")) { - // JDK-8 updates are always suffixed with 'U' (fe OpenJDK8U). - artifactPattern = "jdk" - + jdk.getBaseVersion() - + "-" - + jdk.getBuild() - + "/OpenJDK" - + jdk.getMajor() - + "U" - + "-jdk_[classifier]_[module]_hotspot_" - + jdk.getBaseVersion() - + jdk.getBuild() - + ".[ext]"; - } else { - // JDK updates are suffixed with 'U' (fe OpenJDK17U), whereas GA releases are not (fe OpenJDK17). - // To distinguish between those, the GA releases have only major version component (fe 17+32), - // the updates always have minor/patch components (fe 17.0.1+12), checking for the presence of - // version separator '.' should be enough. - artifactPattern = "jdk-" - + jdk.getBaseVersion() - + "+" - + jdk.getBuild() - + "/OpenJDK" - + jdk.getMajor() - + (jdk.getBaseVersion().contains(".") ? "U" : "") - + "-jdk_[classifier]_[module]_hotspot_" - + jdk.getBaseVersion() - + "_" - + jdk.getBuild() - + ".[ext]"; - } - } else if (jdk.getVendor().equals(VENDOR_ADOPTOPENJDK)) { - repoUrl = "https://api.adoptopenjdk.net/v3/binary/version/"; - if (jdk.getMajor().equals("8")) { - // legacy pattern for JDK 8 - artifactPattern = "jdk" - + jdk.getBaseVersion() - + "-" - + jdk.getBuild() - + "/[module]/[classifier]/jdk/hotspot/normal/adoptopenjdk"; - } else { - // current pattern since JDK 9 - artifactPattern = "jdk-" - + jdk.getBaseVersion() - + "+" - + jdk.getBuild() - + "/[module]/[classifier]/jdk/hotspot/normal/adoptopenjdk"; - } - } else if (jdk.getVendor().equals(VENDOR_OPENJDK)) { - repoUrl = "https://download.oracle.com"; - if (jdk.getHash() != null) { - // current pattern since 12.0.1 - artifactPattern = "java/GA/jdk" - + jdk.getBaseVersion() - + "/" - + jdk.getHash() - + "/" - + jdk.getBuild() - + "/GPL/openjdk-[revision]_[module]-[classifier]_bin.[ext]"; - } else { - // simpler legacy pattern from JDK 9 to JDK 12 that we are advocating to Oracle to bring back - artifactPattern = "java/GA/jdk" - + jdk.getMajor() - + "/" - + jdk.getBuild() - + "/GPL/openjdk-[revision]_[module]-[classifier]_bin.[ext]"; - } - } else { - throw new GradleException("Unknown JDK vendor [" + jdk.getVendor() + "]"); - } - - // Define the repository if we haven't already - if (repositories.findByName(repoName) == null) { - repositories.ivy(repo -> { - repo.setName(repoName); - repo.setUrl(repoUrl); - repo.metadataSources(IvyArtifactRepository.MetadataSources::artifact); - repo.patternLayout(layout -> layout.artifact(artifactPattern)); - repo.content(repositoryContentDescriptor -> repositoryContentDescriptor.includeGroup(groupName(jdk))); - }); - } - } - - @SuppressWarnings("unchecked") - public static NamedDomainObjectContainer getContainer(Project project) { - return (NamedDomainObjectContainer) project.getExtensions().getByName(EXTENSION_NAME); - } - - private static String dependencyNotation(Jdk jdk) { - String platformDep = jdk.getPlatform().equals("darwin") || jdk.getPlatform().equals("mac") - ? (jdk.getVendor().equals(VENDOR_OPENJDK) ? "osx" : "mac") - : jdk.getPlatform(); - String extension = jdk.getPlatform().equals("windows") ? "zip" : "tar.gz"; - - return groupName(jdk) + ":" + platformDep + ":" + jdk.getBaseVersion() + ":" + jdk.getArchitecture() + "@" + extension; - } - - private static String groupName(Jdk jdk) { - return jdk.getVendor() + "_" + jdk.getMajor(); - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/LazyFileOutputStream.java b/buildSrc/src/main/java/org/opensearch/gradle/LazyFileOutputStream.java deleted file mode 100644 index 61fd3897eacb4..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/LazyFileOutputStream.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -/** - * An outputstream to a File that is lazily opened on the first write. - */ -class LazyFileOutputStream extends OutputStream { - private OutputStream delegate; - - LazyFileOutputStream(File file) { - // use an initial dummy delegate to avoid doing a conditional on every write - this.delegate = new OutputStream() { - private void bootstrap() throws IOException { - file.getParentFile().mkdirs(); - delegate = new FileOutputStream(file); - } - - @Override - public void write(int b) throws IOException { - bootstrap(); - delegate.write(b); - } - - @Override - public void write(byte b[], int off, int len) throws IOException { - bootstrap(); - delegate.write(b, off, len); - } - }; - } - - @Override - public void write(int b) throws IOException { - delegate.write(b); - } - - @Override - public void write(byte b[], int off, int len) throws IOException { - delegate.write(b, off, len); - } - - @Override - public void close() throws IOException { - delegate.close(); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/LazyPropertyList.java b/buildSrc/src/main/java/org/opensearch/gradle/LazyPropertyList.java deleted file mode 100644 index 0ff7f1c23cd30..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/LazyPropertyList.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.gradle.api.tasks.Input; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -public class LazyPropertyList extends AbstractLazyPropertyCollection implements List { - - private final List> delegate = new ArrayList<>(); - - public LazyPropertyList(String name) { - super(name); - } - - public LazyPropertyList(String name, Object owner) { - super(name, owner); - } - - @Override - public int size() { - return delegate.size(); - } - - @Override - public boolean isEmpty() { - return delegate.isEmpty(); - } - - @Override - public boolean contains(Object o) { - return delegate.stream().anyMatch(entry -> entry.getValue().equals(o)); - } - - @Override - public Iterator iterator() { - return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).iterator(); - } - - @Override - public Object[] toArray() { - return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).toArray(); - } - - @Override - public T1[] toArray(T1[] a) { - return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).collect(Collectors.toList()).toArray(a); - } - - @Override - public boolean add(T t) { - return delegate.add(new PropertyListEntry<>(() -> t, PropertyNormalization.DEFAULT)); - } - - public boolean add(Supplier supplier) { - return delegate.add(new PropertyListEntry<>(supplier, PropertyNormalization.DEFAULT)); - } - - public boolean add(Supplier supplier, PropertyNormalization normalization) { - return delegate.add(new PropertyListEntry<>(supplier, normalization)); - } - - @Override - public boolean remove(Object o) { - throw new UnsupportedOperationException(this.getClass().getName() + " does not support remove()"); - } - - @Override - public boolean containsAll(Collection c) { - return delegate.stream().map(PropertyListEntry::getValue).collect(Collectors.toList()).containsAll(c); - } - - @Override - public boolean addAll(Collection c) { - c.forEach(this::add); - return true; - } - - @Override - public boolean addAll(int index, Collection c) { - int i = index; - for (T item : c) { - this.add(i++, item); - } - return true; - } - - @Override - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(this.getClass().getName() + " does not support removeAll()"); - } - - @Override - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(this.getClass().getName() + " does not support retainAll()"); - } - - @Override - public void clear() { - delegate.clear(); - } - - @Override - public T get(int index) { - PropertyListEntry entry = delegate.get(index); - validate(entry); - return entry.getValue(); - } - - @Override - public T set(int index, T element) { - return delegate.set(index, new PropertyListEntry<>(() -> element, PropertyNormalization.DEFAULT)).getValue(); - } - - @Override - public void add(int index, T element) { - delegate.add(index, new PropertyListEntry<>(() -> element, PropertyNormalization.DEFAULT)); - } - - @Override - public T remove(int index) { - return delegate.remove(index).getValue(); - } - - @Override - public int indexOf(Object o) { - for (int i = 0; i < delegate.size(); i++) { - if (delegate.get(i).getValue().equals(o)) { - return i; - } - } - - return -1; - } - - @Override - public int lastIndexOf(Object o) { - int lastIndex = -1; - for (int i = 0; i < delegate.size(); i++) { - if (delegate.get(i).getValue().equals(o)) { - lastIndex = i; - } - } - - return lastIndex; - } - - @Override - public ListIterator listIterator() { - return delegate.stream().map(PropertyListEntry::getValue).collect(Collectors.toList()).listIterator(); - } - - @Override - public ListIterator listIterator(int index) { - return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).collect(Collectors.toList()).listIterator(index); - } - - @Override - public List subList(int fromIndex, int toIndex) { - return delegate.stream() - .peek(this::validate) - .map(PropertyListEntry::getValue) - .collect(Collectors.toList()) - .subList(fromIndex, toIndex); - } - - @Override - public List> getNormalizedCollection() { - return delegate.stream() - .peek(this::validate) - .filter(entry -> entry.getNormalization() != PropertyNormalization.IGNORE_VALUE) - .collect(Collectors.toList()); - } - - /** - * Return a "flattened" collection. This should be used when the collection type is itself a complex type with properties - * annotated as Gradle inputs rather than a simple type like {@link String}. - * - * @return a flattened collection filtered according to normalization strategy - */ - public List getFlatNormalizedCollection() { - return getNormalizedCollection().stream().map(PropertyListEntry::getValue).collect(Collectors.toList()); - } - - private void validate(PropertyListEntry entry) { - assertNotNull(entry.getValue(), "entry"); - } - - private class PropertyListEntry { - private final Supplier supplier; - private final PropertyNormalization normalization; - - PropertyListEntry(Supplier supplier, PropertyNormalization normalization) { - this.supplier = supplier; - this.normalization = normalization; - } - - @Input - public PropertyNormalization getNormalization() { - return normalization; - } - - @Input - public T getValue() { - assertNotNull(supplier, "supplier"); - return supplier.get(); - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/LazyPropertyMap.java b/buildSrc/src/main/java/org/opensearch/gradle/LazyPropertyMap.java deleted file mode 100644 index 61fdff84ce8e9..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/LazyPropertyMap.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.gradle.api.Named; -import org.gradle.api.tasks.Input; - -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.BiFunction; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -public class LazyPropertyMap extends AbstractLazyPropertyCollection implements Map { - - private final Map> delegate = new LinkedHashMap<>(); - private final BiFunction normalizationMapper; - - public LazyPropertyMap(String name) { - this(name, null); - } - - public LazyPropertyMap(String name, Object owner) { - this(name, owner, null); - } - - public LazyPropertyMap(String name, Object owner, BiFunction normalizationMapper) { - super(name, owner); - this.normalizationMapper = normalizationMapper; - } - - @Override - public int size() { - return delegate.size(); - } - - @Override - public boolean isEmpty() { - return delegate.isEmpty(); - } - - @Override - public boolean containsKey(Object key) { - return delegate.containsKey(key); - } - - @Override - public boolean containsValue(Object value) { - return delegate.values().stream().map(PropertyMapEntry::getValue).anyMatch(v -> v.equals(value)); - } - - @Override - public V get(Object key) { - PropertyMapEntry entry = delegate.get(key); - if (entry != null) { - V value = entry.getValue(); - assertNotNull(value, "value for key '" + key + "'"); - return value; - } else { - return null; - } - } - - @Override - public V put(K key, V value) { - return put(key, value, PropertyNormalization.DEFAULT); - } - - public V put(K key, V value, PropertyNormalization normalization) { - assertNotNull(value, "value for key '" + key + "'"); - return put(key, () -> value, normalization); - } - - public V put(K key, Supplier supplier) { - return put(key, supplier, PropertyNormalization.DEFAULT); - } - - public V put(K key, Supplier supplier, PropertyNormalization normalization) { - assertNotNull(supplier, "supplier for key '" + key + "'"); - PropertyMapEntry previous = delegate.put(key, new PropertyMapEntry<>(key, supplier, normalization)); - return previous == null ? null : previous.getValue(); - } - - @Override - public V remove(Object key) { - PropertyMapEntry previous = delegate.remove(key); - return previous == null ? null : previous.getValue(); - } - - @Override - public void putAll(Map m) { - throw new UnsupportedOperationException(this.getClass().getName() + " does not support putAll()"); - } - - @Override - public void clear() { - delegate.clear(); - } - - @Override - public Set keySet() { - return delegate.keySet(); - } - - @Override - public Collection values() { - return delegate.values().stream().peek(this::validate).map(PropertyMapEntry::getValue).collect(Collectors.toList()); - } - - @Override - public Set> entrySet() { - return delegate.entrySet() - .stream() - .peek(this::validate) - .collect(Collectors.toMap(Entry::getKey, entry -> entry.getValue().getValue())) - .entrySet(); - } - - @Override - public List getNormalizedCollection() { - return delegate.values() - .stream() - .peek(this::validate) - .filter(entry -> entry.getNormalization() != PropertyNormalization.IGNORE_VALUE) - .map(entry -> normalizationMapper == null ? entry : normalizationMapper.apply(entry.getKey(), entry.getValue())) - .collect(Collectors.toList()); - } - - private void validate(Map.Entry> entry) { - validate(entry.getValue()); - } - - private void validate(PropertyMapEntry supplier) { - assertNotNull(supplier, "key '" + supplier.getKey() + "' supplier value"); - } - - private static class PropertyMapEntry implements Named { - private final K key; - private final Supplier value; - private final PropertyNormalization normalization; - - PropertyMapEntry(K key, Supplier value, PropertyNormalization normalization) { - this.key = key; - this.value = value; - this.normalization = normalization; - } - - @Input - public PropertyNormalization getNormalization() { - return normalization; - } - - @Override - @Input - public String getName() { - return getKey().toString(); - } - - @Input - public K getKey() { - return key; - } - - @Input - public V getValue() { - return value.get(); - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/LoggedExec.java b/buildSrc/src/main/java/org/opensearch/gradle/LoggedExec.java deleted file mode 100644 index faa962bf372bb..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/LoggedExec.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.gradle.api.Action; -import org.gradle.api.GradleException; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.file.FileSystemOperations; -import org.gradle.api.logging.Logger; -import org.gradle.api.logging.Logging; -import org.gradle.api.tasks.Exec; -import org.gradle.api.tasks.WorkResult; -import org.gradle.process.BaseExecSpec; -import org.gradle.process.ExecOperations; -import org.gradle.process.ExecResult; -import org.gradle.process.ExecSpec; -import org.gradle.process.JavaExecSpec; - -import javax.inject.Inject; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.io.UncheckedIOException; -import java.io.UnsupportedEncodingException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.Arrays; -import java.util.List; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.regex.Pattern; - -/** - * A wrapper around gradle's Exec task to capture output and log on error. - */ -public class LoggedExec extends Exec implements FileSystemOperationsAware { - - private static final Logger LOGGER = Logging.getLogger(LoggedExec.class); - private Consumer outputLogger; - private FileSystemOperations fileSystemOperations; - - @Inject - public LoggedExec(FileSystemOperations fileSystemOperations) { - this.fileSystemOperations = fileSystemOperations; - if (getLogger().isInfoEnabled() == false) { - setIgnoreExitValue(true); - setSpoolOutput(false); - // We use an anonymous inner class here because Gradle cannot properly snapshot this input for the purposes of - // incremental build if we use a lambda. This ensures LoggedExec tasks that declare output can be UP-TO-DATE. - doLast(new Action() { - @Override - public void execute(Task task) { - if (LoggedExec.this.getExecResult().getExitValue() != 0) { - try { - LoggedExec.this.getLogger().error("Output for " + LoggedExec.this.getExecutable() + ":"); - outputLogger.accept(LoggedExec.this.getLogger()); - } catch (Exception e) { - throw new GradleException("Failed to read exec output", e); - } - throw new GradleException( - String.format( - "Process '%s %s' finished with non-zero exit value %d", - LoggedExec.this.getExecutable(), - LoggedExec.this.getArgs(), - LoggedExec.this.getExecResult().getExitValue() - ) - ); - } - } - }); - } - } - - public void setSpoolOutput(boolean spoolOutput) { - final OutputStream out; - if (spoolOutput) { - File spoolFile = new File(getProject().getBuildDir() + "/buffered-output/" + this.getName()); - out = new LazyFileOutputStream(spoolFile); - outputLogger = logger -> { - try { - // the file may not exist if the command never output anything - if (Files.exists(spoolFile.toPath())) { - Files.lines(spoolFile.toPath()).forEach(logger::error); - } - } catch (IOException e) { - throw new RuntimeException("could not log", e); - } - }; - } else { - out = new ByteArrayOutputStream(); - outputLogger = logger -> { - try { - logger.error(((ByteArrayOutputStream) out).toString("UTF-8")); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - }; - } - setStandardOutput(out); - setErrorOutput(out); - } - - public static ExecResult exec(Project project, Action action) { - return genericExec(project::exec, action); - } - - public static ExecResult exec(ExecOperations execOperations, Action action) { - return genericExec(execOperations::exec, action); - } - - public static ExecResult javaexec(Project project, Action action) { - return genericExec(project::javaexec, action); - } - - /** Returns JVM arguments suitable for a short-lived forked task */ - public static final List shortLivedArgs() { - return Arrays.asList(new String[] { "-XX:TieredStopAtLevel=1" }); - } - - private static final Pattern NEWLINE = Pattern.compile(System.lineSeparator()); - - private static ExecResult genericExec(Function, ExecResult> function, Action action) { - if (LOGGER.isInfoEnabled()) { - return function.apply(action); - } - ByteArrayOutputStream output = new ByteArrayOutputStream(); - try { - return function.apply(spec -> { - spec.setStandardOutput(output); - spec.setErrorOutput(output); - // optimize for short-lived process - if (spec instanceof JavaExecSpec) { - ((JavaExecSpec) spec).setJvmArgs(shortLivedArgs()); - } - action.execute(spec); - try { - output.write(("Output for " + spec.getExecutable() + ":").getBytes(StandardCharsets.UTF_8)); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - }); - } catch (Exception e) { - try { - if (output.size() != 0) { - LOGGER.error("Exec output and error:"); - NEWLINE.splitAsStream(output.toString("UTF-8")).forEach(s -> LOGGER.error("| " + s)); - } - } catch (UnsupportedEncodingException ue) { - throw new GradleException("Failed to read exec output", ue); - } - throw e; - } - } - - @Override - public WorkResult delete(Object... objects) { - return fileSystemOperations.delete(d -> d.delete(objects)); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/LoggingOutputStream.java b/buildSrc/src/main/java/org/opensearch/gradle/LoggingOutputStream.java deleted file mode 100644 index 5ae7ad1595e2f..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/LoggingOutputStream.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.Arrays; - -/** - * Writes data passed to this stream as log messages. - * - * The stream will be flushed whenever a newline is detected. - * Allows setting an optional prefix before each line of output. - */ -public abstract class LoggingOutputStream extends OutputStream { - /** The starting length of the buffer */ - private static final int DEFAULT_BUFFER_LENGTH = 4096; - - /** The buffer of bytes sent to the stream */ - private byte[] buffer = new byte[DEFAULT_BUFFER_LENGTH]; - - /** Offset of the start of unwritten data in the buffer */ - private int start = 0; - - /** Offset of the end (semi-open) of unwritten data in the buffer */ - private int end = 0; - - @Override - public void write(final int b) throws IOException { - if (b == 0) { - return; - } - if (b == '\n') { - // always flush with newlines instead of adding to the buffer - flush(); - return; - } - - if (end == buffer.length) { - if (start != 0) { - // first try shifting the used buffer back to the beginning to make space - int len = end - start; - System.arraycopy(buffer, start, buffer, 0, len); - start = 0; - end = len; - } else { - // otherwise extend the buffer - buffer = Arrays.copyOf(buffer, buffer.length + DEFAULT_BUFFER_LENGTH); - } - } - - buffer[end++] = (byte) b; - } - - @Override - public void flush() { - if (end == start) { - return; - } - logLine(new String(buffer, start, end - start)); - start = end; - } - - protected abstract void logLine(String line); -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/OS.java b/buildSrc/src/main/java/org/opensearch/gradle/OS.java deleted file mode 100644 index b5243030cbc71..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/OS.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.function.Supplier; - -public enum OS { - FREEBSD, - LINUX, - MAC, - WINDOWS; - - public static OS current() { - String os = System.getProperty("os.name", ""); - if (os.startsWith("FreeBSD")) { - return OS.FREEBSD; - } - if (os.startsWith("Linux") || os.startsWith("LINUX")) { - return OS.LINUX; - } - if (os.startsWith("Mac")) { - return OS.MAC; - } - if (os.startsWith("Windows")) { - return OS.WINDOWS; - } - throw new IllegalStateException("Can't determine OS from: " + os); - } - - public static class Conditional { - - private final Map> conditions = new HashMap<>(); - - public Conditional onLinux(Supplier supplier) { - conditions.put(LINUX, supplier); - return this; - } - - public Conditional onFreeBSD(Supplier supplier) { - conditions.put(FREEBSD, supplier); - return this; - } - - public Conditional onMac(Supplier supplier) { - conditions.put(MAC, supplier); - return this; - } - - public Conditional onUnix(Supplier supplier) { - conditions.put(FREEBSD, supplier); - conditions.put(LINUX, supplier); - conditions.put(MAC, supplier); - return this; - } - - public Conditional onWindows(Supplier supplier) { - conditions.put(WINDOWS, supplier); - return this; - } - - public T supply() { - HashSet missingOS = new HashSet<>(Arrays.asList(OS.values())); - missingOS.removeAll(conditions.keySet()); - if (missingOS.isEmpty() == false) { - throw new IllegalArgumentException("No condition specified for " + missingOS); - } - return conditions.get(OS.current()).get(); - } - - } - - public static Conditional conditional() { - return new Conditional<>(); - } - - public static Conditional conditionalString() { - return conditional(); - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchDistribution.java b/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchDistribution.java deleted file mode 100644 index 968bd13bd4011..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchDistribution.java +++ /dev/null @@ -1,277 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.opensearch.gradle.docker.DockerSupportService; -import org.gradle.api.Buildable; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.model.ObjectFactory; -import org.gradle.api.provider.Property; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.TaskDependency; - -import java.io.File; -import java.util.Collections; -import java.util.Iterator; -import java.util.Locale; - -public class OpenSearchDistribution implements Buildable, Iterable { - - public enum Platform { - DARWIN, - FREEBSD, - LINUX, - WINDOWS; - - @Override - public String toString() { - return super.toString().toLowerCase(Locale.ROOT); - } - } - - public enum Type { - INTEG_TEST_ZIP, - ARCHIVE, - RPM, - DEB, - DOCKER; - - @Override - public String toString() { - return super.toString().toLowerCase(Locale.ROOT); - } - - public boolean shouldExtract() { - switch (this) { - case DEB: - case DOCKER: - case RPM: - return false; - - default: - return true; - } - } - } - - // package private to tests can use - public static final Platform CURRENT_PLATFORM = OS.conditional() - .onFreeBSD(() -> Platform.FREEBSD) - .onLinux(() -> Platform.LINUX) - .onMac(() -> Platform.DARWIN) - .onWindows(() -> Platform.WINDOWS) - .supply(); - - private final String name; - private final Provider dockerSupport; - // pkg private so plugin can configure - final Configuration configuration; - - private final Property architecture; - private final Property version; - private final Property type; - private final Property platform; - private final Property bundledJdk; - private final Property failIfUnavailable; - private final Configuration extracted; - - OpenSearchDistribution( - String name, - ObjectFactory objectFactory, - Provider dockerSupport, - Configuration fileConfiguration, - Configuration extractedConfiguration - ) { - this.name = name; - this.dockerSupport = dockerSupport; - this.configuration = fileConfiguration; - this.architecture = objectFactory.property(Architecture.class); - this.version = objectFactory.property(String.class).convention(VersionProperties.getOpenSearch()); - this.type = objectFactory.property(Type.class); - this.type.convention(Type.ARCHIVE); - this.platform = objectFactory.property(Platform.class); - this.bundledJdk = objectFactory.property(Boolean.class); - this.failIfUnavailable = objectFactory.property(Boolean.class).convention(true); - this.extracted = extractedConfiguration; - } - - public String getName() { - return name; - } - - public String getVersion() { - return version.get(); - } - - public void setVersion(String version) { - Version.fromString(version); // ensure the version parses, but don't store as Version since that removes -SNAPSHOT - this.version.set(version); - } - - public Platform getPlatform() { - return platform.getOrNull(); - } - - public void setPlatform(Platform platform) { - this.platform.set(platform); - } - - public Type getType() { - return type.get(); - } - - public void setType(Type type) { - this.type.set(type); - } - - public boolean getBundledJdk() { - return bundledJdk.getOrElse(true); - } - - public boolean isDocker() { - final Type type = this.type.get(); - return type == Type.DOCKER; - } - - public void setBundledJdk(Boolean bundledJdk) { - this.bundledJdk.set(bundledJdk); - } - - public boolean getFailIfUnavailable() { - return this.failIfUnavailable.get(); - } - - public void setFailIfUnavailable(boolean failIfUnavailable) { - this.failIfUnavailable.set(failIfUnavailable); - } - - public void setArchitecture(Architecture architecture) { - this.architecture.set(architecture); - } - - public Architecture getArchitecture() { - return this.architecture.get(); - } - - @Override - public String toString() { - return getName() + "_" + getType() + "_" + getVersion(); - } - - public String getFilepath() { - return configuration.getSingleFile().toString(); - } - - public Configuration getExtracted() { - switch (getType()) { - case DEB: - case DOCKER: - case RPM: - throw new UnsupportedOperationException( - "distribution type [" + getType() + "] for " + "opensearch distribution [" + name + "] cannot be extracted" - ); - - default: - return extracted; - } - } - - @Override - public TaskDependency getBuildDependencies() { - // For non-required Docker distributions, skip building the distribution is Docker is unavailable - if (isDocker() && getFailIfUnavailable() == false && dockerSupport.get().getDockerAvailability().isAvailable == false) { - return task -> Collections.emptySet(); - } - - return configuration.getBuildDependencies(); - } - - @Override - public Iterator iterator() { - return configuration.iterator(); - } - - // internal, make this distribution's configuration unmodifiable - void finalizeValues() { - - if (getType() == Type.INTEG_TEST_ZIP) { - if (platform.getOrNull() != null) { - throw new IllegalArgumentException( - "platform cannot be set on opensearch distribution [" + name + "] of type [integ_test_zip]" - ); - } - - if (bundledJdk.getOrNull() != null) { - throw new IllegalArgumentException( - "bundledJdk cannot be set on opensearch distribution [" + name + "] of type [integ_test_zip]" - ); - } - return; - } - - if (isDocker() == false && failIfUnavailable.get() == false) { - throw new IllegalArgumentException( - "failIfUnavailable cannot be 'false' on opensearch distribution [" + name + "] of type [" + getType() + "]" - ); - } - - if (getType() == Type.ARCHIVE) { - // defaults for archive, set here instead of via convention so integ-test-zip can verify they are not set - if (platform.isPresent() == false) { - platform.set(CURRENT_PLATFORM); - } - } else { // rpm, deb or docker - if (platform.isPresent()) { - throw new IllegalArgumentException( - "platform cannot be set on opensearch distribution [" + name + "] of type [" + getType() + "]" - ); - } - if (isDocker()) { - if (bundledJdk.isPresent()) { - throw new IllegalArgumentException( - "bundledJdk cannot be set on opensearch distribution [" + name + "] of type " + "[docker]" - ); - } - } - } - - if (bundledJdk.isPresent() == false) { - bundledJdk.set(true); - } - - version.finalizeValue(); - platform.finalizeValue(); - type.finalizeValue(); - bundledJdk.finalizeValue(); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchJavaPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchJavaPlugin.java deleted file mode 100644 index c701c47f9e68c..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchJavaPlugin.java +++ /dev/null @@ -1,287 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar; -import nebula.plugin.info.InfoBrokerPlugin; -import org.opensearch.gradle.info.BuildParams; -import org.opensearch.gradle.info.GlobalBuildInfoPlugin; -import org.opensearch.gradle.precommit.PrecommitTaskPlugin; -import org.opensearch.gradle.util.Util; -import org.gradle.api.Action; -import org.gradle.api.JavaVersion; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.ModuleDependency; -import org.gradle.api.artifacts.ProjectDependency; -import org.gradle.api.artifacts.ResolutionStrategy; -import org.gradle.api.plugins.BasePlugin; -import org.gradle.api.plugins.JavaLibraryPlugin; -import org.gradle.api.plugins.JavaPlugin; -import org.gradle.api.plugins.JavaPluginExtension; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.TaskProvider; -import org.gradle.api.tasks.bundling.Jar; -import org.gradle.api.tasks.compile.AbstractCompile; -import org.gradle.api.tasks.compile.CompileOptions; -import org.gradle.api.tasks.compile.GroovyCompile; -import org.gradle.api.tasks.compile.JavaCompile; -import org.gradle.api.tasks.javadoc.Javadoc; -import org.gradle.external.javadoc.CoreJavadocOptions; -import org.gradle.language.base.plugins.LifecycleBasePlugin; - -import java.io.File; -import java.util.HashMap; -import java.util.List; -import java.util.function.Consumer; - -import static org.opensearch.gradle.util.Util.toStringable; - -/** - * A wrapper around Gradle's Java plugin that applies our common configuration. - */ -public class OpenSearchJavaPlugin implements Plugin { - @Override - public void apply(Project project) { - // make sure the global build info plugin is applied to the root project - project.getRootProject().getPluginManager().apply(GlobalBuildInfoPlugin.class); - // common repositories setup - project.getPluginManager().apply(RepositoriesSetupPlugin.class); - project.getPluginManager().apply(JavaLibraryPlugin.class); - project.getPluginManager().apply(OpenSearchTestBasePlugin.class); - project.getPluginManager().apply(PrecommitTaskPlugin.class); - - configureConfigurations(project); - configureCompile(project); - configureInputNormalization(project); - configureJars(project); - configureJarManifest(project); - configureJavadoc(project); - - // convenience access to common versions used in dependencies - project.getExtensions().getExtraProperties().set("versions", VersionProperties.getVersions()); - } - - /** - * Makes dependencies non-transitive. - *

    - * Gradle allows setting all dependencies as non-transitive very easily. - * Sadly this mechanism does not translate into maven pom generation. In order - * to effectively make the pom act as if it has no transitive dependencies, - * we must exclude each transitive dependency of each direct dependency. - *

    - * Determining the transitive deps of a dependency which has been resolved as - * non-transitive is difficult because the process of resolving removes the - * transitive deps. To sidestep this issue, we create a configuration per - * direct dependency version. This specially named and unique configuration - * will contain all of the transitive dependencies of this particular - * dependency. We can then use this configuration during pom generation - * to iterate the transitive dependencies and add excludes. - */ - public static void configureConfigurations(Project project) { - // we want to test compileOnly deps! - Configuration compileOnlyConfig = project.getConfigurations().getByName(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME); - Configuration testImplementationConfig = project.getConfigurations().getByName(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME); - testImplementationConfig.extendsFrom(compileOnlyConfig); - - // we are not shipping these jars, we act like dumb consumers of these things - if (project.getPath().startsWith(":test:fixtures") || project.getPath().equals(":build-tools")) { - return; - } - // fail on any conflicting dependency versions - project.getConfigurations().all(configuration -> { - if (configuration.getName().endsWith("Fixture")) { - // just a self contained test-fixture configuration, likely transitive and hellacious - return; - } - configuration.resolutionStrategy(ResolutionStrategy::failOnVersionConflict); - }); - - // force all dependencies added directly to compile/testImplementation to be non-transitive, except for ES itself - Consumer disableTransitiveDeps = configName -> { - Configuration config = project.getConfigurations().getByName(configName); - config.getDependencies().all(dep -> { - if (dep instanceof ModuleDependency - && dep instanceof ProjectDependency == false - && dep.getGroup().startsWith("org.opensearch") == false) { - ((ModuleDependency) dep).setTransitive(false); - } - }); - }; - disableTransitiveDeps.accept(JavaPlugin.API_CONFIGURATION_NAME); - disableTransitiveDeps.accept(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME); - disableTransitiveDeps.accept(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME); - disableTransitiveDeps.accept(JavaPlugin.RUNTIME_ONLY_CONFIGURATION_NAME); - disableTransitiveDeps.accept(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME); - } - - /** - * Adds compiler settings to the project - */ - public static void configureCompile(Project project) { - project.getExtensions().getExtraProperties().set("compactProfile", "full"); - - JavaPluginExtension java = project.getExtensions().getByType(JavaPluginExtension.class); - java.setSourceCompatibility(BuildParams.getMinimumRuntimeVersion()); - java.setTargetCompatibility(BuildParams.getMinimumRuntimeVersion()); - - project.afterEvaluate(p -> { - project.getTasks().withType(JavaCompile.class).configureEach(compileTask -> { - CompileOptions compileOptions = compileTask.getOptions(); - // TODO Discuss moving compileOptions.getCompilerArgs() to use provider api with Gradle team. - List compilerArgs = compileOptions.getCompilerArgs(); - // either disable annotation processor completely (default) or allow to enable them if an annotation processor is explicitly - // defined - if (compilerArgs.contains("-processor") == false) { - compilerArgs.add("-proc:none"); - } - - compileOptions.setEncoding("UTF-8"); - compileOptions.setIncremental(true); - // workaround for https://github.com/gradle/gradle/issues/14141 - compileTask.getConventionMapping().map("sourceCompatibility", () -> java.getSourceCompatibility().toString()); - compileTask.getConventionMapping().map("targetCompatibility", () -> java.getTargetCompatibility().toString()); - // The '--release is available from JDK-9 and above - if (BuildParams.getRuntimeJavaVersion().compareTo(JavaVersion.VERSION_1_8) > 0) { - compileOptions.getRelease().set(releaseVersionProviderFromCompileTask(project, compileTask)); - } - }); - // also apply release flag to groovy, which is used in build-tools - project.getTasks().withType(GroovyCompile.class).configureEach(compileTask -> { - // TODO: this probably shouldn't apply to groovy at all? - compileTask.getOptions().getRelease().set(releaseVersionProviderFromCompileTask(project, compileTask)); - }); - }); - } - - private static Provider releaseVersionProviderFromCompileTask(Project project, AbstractCompile compileTask) { - return project.provider(() -> { - JavaVersion javaVersion = JavaVersion.toVersion(compileTask.getTargetCompatibility()); - return Integer.parseInt(javaVersion.getMajorVersion()); - }); - } - - /** - * Apply runtime classpath input normalization so that changes in JAR manifests don't break build cacheability - */ - public static void configureInputNormalization(Project project) { - project.getNormalization().getRuntimeClasspath().ignore("META-INF/MANIFEST.MF"); - } - - /** - * Adds additional manifest info to jars - */ - static void configureJars(Project project) { - project.getTasks().withType(Jar.class).configureEach(jarTask -> { - // we put all our distributable files under distributions - jarTask.getDestinationDirectory().set(new File(project.getBuildDir(), "distributions")); - // fixup the jar manifest - // Explicitly using an Action interface as java lambdas - // are not supported by Gradle up-to-date checks - jarTask.doFirst(new Action() { - @Override - public void execute(Task task) { - // this doFirst is added before the info plugin, therefore it will run - // after the doFirst added by the info plugin, and we can override attributes - jarTask.getManifest().attributes(new HashMap() { - { - put("Build-Date", BuildParams.getBuildDate()); - put("Build-Java-Version", BuildParams.getGradleJavaVersion()); - } - }); - } - }); - }); - project.getPluginManager().withPlugin("com.github.johnrengelman.shadow", p -> { - project.getTasks().withType(ShadowJar.class).configureEach(shadowJar -> { - /* - * Replace the default "-all" classifier with null - * which will leave the classifier off of the file name. - */ - shadowJar.getArchiveClassifier().set((String) null); - /* - * Not all cases need service files merged but it is - * better to be safe - */ - shadowJar.mergeServiceFiles(); - }); - // Add "original" classifier to the non-shadowed JAR to distinguish it from the shadow JAR - project.getTasks().named(JavaPlugin.JAR_TASK_NAME, Jar.class).configure(jar -> jar.getArchiveClassifier().set("original")); - // Make sure we assemble the shadow jar - project.getTasks().named(BasePlugin.ASSEMBLE_TASK_NAME).configure(task -> task.dependsOn("shadowJar")); - }); - } - - private static void configureJarManifest(Project project) { - project.getPlugins().withType(InfoBrokerPlugin.class).whenPluginAdded(manifestPlugin -> { - manifestPlugin.add("Module-Origin", toStringable(BuildParams::getGitOrigin)); - manifestPlugin.add("Change", toStringable(BuildParams::getGitRevision)); - manifestPlugin.add("X-Compile-OpenSearch-Version", toStringable(VersionProperties::getOpenSearch)); - manifestPlugin.add("X-Compile-Lucene-Version", toStringable(VersionProperties::getLucene)); - manifestPlugin.add( - "X-Compile-OpenSearch-Snapshot", - toStringable(() -> Boolean.toString(VersionProperties.isOpenSearchSnapshot())) - ); - }); - - project.getPluginManager().apply("nebula.info-broker"); - project.getPluginManager().apply("nebula.info-basic"); - project.getPluginManager().apply("nebula.info-java"); - project.getPluginManager().apply("nebula.info-jar"); - } - - private static void configureJavadoc(Project project) { - project.getTasks().withType(Javadoc.class).configureEach(javadoc -> { - - /* - * Generate docs using html5 to suppress a warning from `javadoc` - * that the default will change to html5 in the future. - */ - CoreJavadocOptions javadocOptions = (CoreJavadocOptions) javadoc.getOptions(); - if (BuildParams.getRuntimeJavaVersion().compareTo(JavaVersion.VERSION_1_8) > 0) { - javadocOptions.addBooleanOption("html5", true); - } - }); - - TaskProvider javadoc = project.getTasks().withType(Javadoc.class).named("javadoc"); - javadoc.configure(doc -> - // remove compiled classes from the Javadoc classpath: - // http://mail.openjdk.java.net/pipermail/javadoc-dev/2018-January/000400.html - doc.setClasspath(Util.getJavaMainSourceSet(project).get().getCompileClasspath())); - - // ensure javadoc task is run with 'check' - project.getTasks().named(LifecycleBasePlugin.CHECK_TASK_NAME).configure(t -> t.dependsOn(javadoc)); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchTestBasePlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchTestBasePlugin.java deleted file mode 100644 index 07a4a9f9b66e6..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchTestBasePlugin.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import com.github.jengelman.gradle.plugins.shadow.ShadowBasePlugin; -import org.opensearch.gradle.info.BuildParams; -import org.opensearch.gradle.info.GlobalBuildInfoPlugin; -import org.opensearch.gradle.test.ErrorReportingTestListener; -import org.opensearch.gradle.util.Util; -import org.gradle.api.Action; -import org.gradle.api.JavaVersion; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.file.FileCollection; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.SourceSetContainer; -import org.gradle.api.tasks.testing.Test; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; - -import static org.opensearch.gradle.util.FileUtils.mkdirs; -import static org.opensearch.gradle.util.GradleUtils.maybeConfigure; - -/** - * Applies commonly used settings to all Test tasks in the project - */ -public class OpenSearchTestBasePlugin implements Plugin { - - @Override - public void apply(Project project) { - // for fips mode check - project.getRootProject().getPluginManager().apply(GlobalBuildInfoPlugin.class); - // Default test task should run only unit tests - maybeConfigure(project.getTasks(), "test", Test.class, task -> task.include("**/*Tests.class")); - - // none of this stuff is applicable to the `:buildSrc` project tests - if (project.getPath().equals(":build-tools")) { - return; - } - - File heapdumpDir = new File(project.getBuildDir(), "heapdump"); - - project.getTasks().withType(Test.class).configureEach(test -> { - File testOutputDir = new File(test.getReports().getJunitXml().getDestination(), "output"); - - ErrorReportingTestListener listener = new ErrorReportingTestListener(test.getTestLogging(), test.getLogger(), testOutputDir); - test.getExtensions().add("errorReportingTestListener", listener); - test.addTestOutputListener(listener); - test.addTestListener(listener); - - /* - * We use lazy-evaluated strings in order to configure system properties whose value will not be known until - * execution time (e.g. cluster port numbers). Adding these via the normal DSL doesn't work as these get treated - * as task inputs and therefore Gradle attempts to snapshot them before/after task execution. This fails due - * to the GStrings containing references to non-serializable objects. - * - * We bypass this by instead passing this system properties vi a CommandLineArgumentProvider. This has the added - * side-effect that these properties are NOT treated as inputs, therefore they don't influence things like the - * build cache key or up to date checking. - */ - SystemPropertyCommandLineArgumentProvider nonInputProperties = new SystemPropertyCommandLineArgumentProvider(); - - // We specifically use an anonymous inner class here because lambda task actions break Gradle cacheability - // See: https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:how_does_it_work - test.doFirst(new Action() { - @Override - public void execute(Task t) { - mkdirs(testOutputDir); - mkdirs(heapdumpDir); - mkdirs(test.getWorkingDir()); - mkdirs(test.getWorkingDir().toPath().resolve("temp").toFile()); - - // TODO remove once jvm.options are added to test system properties - if (BuildParams.getRuntimeJavaVersion() == JavaVersion.VERSION_1_8) { - test.systemProperty("java.locale.providers", "SPI,JRE"); - } else { - test.systemProperty("java.locale.providers", "SPI,COMPAT"); - test.jvmArgs("--illegal-access=warn"); - } - } - }); - test.getJvmArgumentProviders().add(nonInputProperties); - test.getExtensions().add("nonInputProperties", nonInputProperties); - - test.setWorkingDir(project.file(project.getBuildDir() + "/testrun/" + test.getName())); - test.setMaxParallelForks(Integer.parseInt(System.getProperty("tests.jvms", BuildParams.getDefaultParallel().toString()))); - - test.exclude("**/*$*.class"); - - test.jvmArgs( - "-Xmx" + System.getProperty("tests.heap.size", "512m"), - "-Xms" + System.getProperty("tests.heap.size", "512m"), - "-XX:+HeapDumpOnOutOfMemoryError" - ); - - test.getJvmArgumentProviders().add(new SimpleCommandLineArgumentProvider("-XX:HeapDumpPath=" + heapdumpDir)); - - String argline = System.getProperty("tests.jvm.argline"); - if (argline != null) { - test.jvmArgs((Object[]) argline.split(" ")); - } - - if (Util.getBooleanProperty("tests.asserts", true)) { - test.jvmArgs("-ea", "-esa"); - } - - Map sysprops = new HashMap() { - { - put("java.awt.headless", "true"); - put("tests.gradle", "true"); - put("tests.artifact", project.getName()); - put("tests.task", test.getPath()); - put("tests.security.manager", "true"); - put("jna.nosys", "true"); - } - }; - test.systemProperties(sysprops); - - // ignore changing test seed when build is passed -Dignore.tests.seed for cacheability experimentation - if (System.getProperty("ignore.tests.seed") != null) { - nonInputProperties.systemProperty("tests.seed", BuildParams.getTestSeed()); - } else { - test.systemProperty("tests.seed", BuildParams.getTestSeed()); - } - - // don't track these as inputs since they contain absolute paths and break cache relocatability - File gradleHome = project.getGradle().getGradleUserHomeDir(); - String gradleVersion = project.getGradle().getGradleVersion(); - nonInputProperties.systemProperty("gradle.dist.lib", new File(project.getGradle().getGradleHomeDir(), "lib")); - nonInputProperties.systemProperty( - "gradle.worker.jar", - gradleHome + "/caches/" + gradleVersion + "/workerMain/gradle-worker.jar" - ); - nonInputProperties.systemProperty("gradle.user.home", gradleHome); - // we use 'temp' relative to CWD since this is per JVM and tests are forbidden from writing to CWD - nonInputProperties.systemProperty("java.io.tmpdir", test.getWorkingDir().toPath().resolve("temp")); - - // TODO: remove setting logging level via system property - test.systemProperty("tests.logger.level", "WARN"); - System.getProperties().entrySet().forEach(entry -> { - if ((entry.getKey().toString().startsWith("tests.") || entry.getKey().toString().startsWith("opensearch."))) { - test.systemProperty(entry.getKey().toString(), entry.getValue()); - } - }); - - // TODO: remove this once ctx isn't added to update script params in 7.0 - test.systemProperty("opensearch.scripting.update.ctx_in_params", "false"); - - // TODO: remove this property in 8.0 - test.systemProperty("opensearch.search.rewrite_sort", "true"); - - // TODO: remove this once cname is prepended to transport.publish_address by default in 8.0 - test.systemProperty("opensearch.transport.cname_in_publish_address", "true"); - - // Set netty system properties to the properties we configure in jvm.options - test.systemProperty("io.netty.noUnsafe", "true"); - test.systemProperty("io.netty.noKeySetOptimization", "true"); - test.systemProperty("io.netty.recycler.maxCapacityPerThread", "0"); - - test.testLogging(logging -> { - logging.setShowExceptions(true); - logging.setShowCauses(true); - logging.setExceptionFormat("full"); - logging.setShowStandardStreams(Util.getBooleanProperty("tests.output", false)); - }); - - if (OS.current().equals(OS.WINDOWS) && System.getProperty("tests.timeoutSuite") == null) { - // override the suite timeout to 30 mins for windows, because it has the most inefficient filesystem known to man - test.systemProperty("tests.timeoutSuite", "1800000!"); - } - - /* - * If this project builds a shadow JAR than any unit tests should test against that artifact instead of - * compiled class output and dependency jars. This better emulates the runtime environment of consumers. - */ - project.getPluginManager().withPlugin("com.github.johnrengelman.shadow", p -> { - // Remove output class files and any other dependencies from the test classpath, since the shadow JAR includes these - FileCollection mainRuntime = project.getExtensions() - .getByType(SourceSetContainer.class) - .getByName(SourceSet.MAIN_SOURCE_SET_NAME) - .getRuntimeClasspath(); - // Add any "shadow" dependencies. These are dependencies that are *not* bundled into the shadow JAR - Configuration shadowConfig = project.getConfigurations().getByName(ShadowBasePlugin.getCONFIGURATION_NAME()); - // Add the shadow JAR artifact itself - FileCollection shadowJar = project.files(project.getTasks().named("shadowJar")); - - test.setClasspath(test.getClasspath().minus(mainRuntime).plus(shadowConfig).plus(shadowJar)); - }); - }); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/PropertyNormalization.java b/buildSrc/src/main/java/org/opensearch/gradle/PropertyNormalization.java deleted file mode 100644 index b856ac1908c87..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/PropertyNormalization.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -public enum PropertyNormalization { - /** - * Uses default strategy based on runtime property type. - */ - DEFAULT, - - /** - * Ignores property value completely for the purposes of input snapshotting. - */ - IGNORE_VALUE -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/PublishPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/PublishPlugin.java deleted file mode 100644 index e2bd3e71f5fc9..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/PublishPlugin.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import com.github.jengelman.gradle.plugins.shadow.ShadowBasePlugin; -import com.github.jengelman.gradle.plugins.shadow.ShadowExtension; -import groovy.util.Node; -import groovy.util.NodeList; -import org.opensearch.gradle.info.BuildParams; -import org.opensearch.gradle.precommit.PomValidationPrecommitPlugin; -import org.opensearch.gradle.util.Util; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.XmlProvider; -import org.gradle.api.artifacts.ProjectDependency; -import org.gradle.api.plugins.BasePlugin; -import org.gradle.api.plugins.BasePluginConvention; -import org.gradle.api.plugins.JavaPlugin; -import org.gradle.api.publish.PublishingExtension; -import org.gradle.api.publish.maven.MavenPublication; -import org.gradle.api.publish.maven.tasks.GenerateMavenPom; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.TaskProvider; -import org.gradle.api.tasks.bundling.Jar; -import org.gradle.language.base.plugins.LifecycleBasePlugin; - -import java.util.concurrent.Callable; - -import static org.opensearch.gradle.util.GradleUtils.maybeConfigure; - -public class PublishPlugin implements Plugin { - - @Override - public void apply(Project project) { - project.getPluginManager().apply("nebula.maven-base-publish"); - project.getPluginManager().apply(PomValidationPrecommitPlugin.class); - - configureJavadocJar(project); - configureSourcesJar(project); - configurePomGeneration(project); - } - - private static String getArchivesBaseName(Project project) { - return project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName(); - } - - /**Configuration generation of maven poms. */ - private static void configurePomGeneration(Project project) { - - TaskProvider generatePomTask = project.getTasks().register("generatePom"); - - maybeConfigure(project.getTasks(), LifecycleBasePlugin.ASSEMBLE_TASK_NAME, assemble -> assemble.dependsOn(generatePomTask)); - - project.getTasks().withType(GenerateMavenPom.class).configureEach(pomTask -> pomTask.setDestination(new Callable() { - @Override - public String call() throws Exception { - return String.format( - "%s/distributions/%s-%s.pom", - project.getBuildDir(), - getArchivesBaseName(project), - project.getVersion() - ); - } - })); - - PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class); - - project.getPluginManager().withPlugin("com.github.johnrengelman.shadow", plugin -> { - MavenPublication publication = publishing.getPublications().maybeCreate("shadow", MavenPublication.class); - ShadowExtension shadow = project.getExtensions().getByType(ShadowExtension.class); - shadow.component(publication); - // Workaround for https://github.com/johnrengelman/shadow/issues/334 - // Here we manually add any project dependencies in the "shadow" configuration to our generated POM - publication.getPom().withXml(xml -> { - Node root = xml.asNode(); - root.appendNode("name", project.getName()); - root.appendNode("description", project.getDescription()); - Node dependenciesNode = (Node) ((NodeList) root.get("dependencies")).get(0); - project.getConfigurations().getByName(ShadowBasePlugin.getCONFIGURATION_NAME()).getAllDependencies().all(dependency -> { - if (dependency instanceof ProjectDependency) { - Node dependencyNode = dependenciesNode.appendNode("dependency"); - dependencyNode.appendNode("groupId", dependency.getGroup()); - ProjectDependency projectDependency = (ProjectDependency) dependency; - String artifactId = getArchivesBaseName(projectDependency.getDependencyProject()); - dependencyNode.appendNode("artifactId", artifactId); - dependencyNode.appendNode("version", dependency.getVersion()); - dependencyNode.appendNode("scope", "compile"); - } - }); - }); - }); - - publishing.getPublications().withType(MavenPublication.class, publication -> { - // Add git origin info to generated POM files - publication.getPom().withXml(PublishPlugin::addScmInfo); - - // have to defer this until archivesBaseName is set - project.afterEvaluate(p -> publication.setArtifactId(getArchivesBaseName(project))); - - // publish sources and javadoc for Java projects. - if (project.getPluginManager().hasPlugin("opensearch.java")) { - publication.artifact(project.getTasks().getByName("sourcesJar")); - publication.artifact(project.getTasks().getByName("javadocJar")); - } - - generatePomTask.configure( - t -> t.dependsOn(String.format("generatePomFileFor%sPublication", Util.capitalize(publication.getName()))) - ); - }); - - } - - private static void addScmInfo(XmlProvider xml) { - Node root = xml.asNode(); - root.appendNode("url", Util.urlFromOrigin(BuildParams.getGitOrigin())); - Node scmNode = root.appendNode("scm"); - scmNode.appendNode("url", BuildParams.getGitOrigin()); - } - - /** Adds a javadocJar task to generate a jar containing javadocs. */ - private static void configureJavadocJar(Project project) { - project.getPlugins().withId("opensearch.java", p -> { - TaskProvider javadocJarTask = project.getTasks().register("javadocJar", Jar.class); - javadocJarTask.configure(jar -> { - jar.getArchiveClassifier().set("javadoc"); - jar.setGroup("build"); - jar.setDescription("Assembles a jar containing javadocs."); - jar.from(project.getTasks().named(JavaPlugin.JAVADOC_TASK_NAME)); - }); - maybeConfigure(project.getTasks(), BasePlugin.ASSEMBLE_TASK_NAME, t -> t.dependsOn(javadocJarTask)); - }); - } - - static void configureSourcesJar(Project project) { - project.getPlugins().withId("opensearch.java", p -> { - TaskProvider sourcesJarTask = project.getTasks().register("sourcesJar", Jar.class); - sourcesJarTask.configure(jar -> { - jar.getArchiveClassifier().set("sources"); - jar.setGroup("build"); - jar.setDescription("Assembles a jar containing source files."); - SourceSet mainSourceSet = Util.getJavaMainSourceSet(project).get(); - jar.from(mainSourceSet.getAllSource()); - }); - maybeConfigure(project.getTasks(), BasePlugin.ASSEMBLE_TASK_NAME, t -> t.dependsOn(sourcesJarTask)); - }); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/ReaperPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/ReaperPlugin.java deleted file mode 100644 index af9dc6e053fb2..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/ReaperPlugin.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.opensearch.gradle.info.GlobalBuildInfoPlugin; -import org.gradle.api.Plugin; -import org.gradle.api.Project; - -import java.lang.management.ManagementFactory; -import java.nio.file.Path; - -/** - * A plugin to handle reaping external services spawned by a build if Gradle dies. - */ -public class ReaperPlugin implements Plugin { - - @Override - public void apply(Project project) { - if (project != project.getRootProject()) { - throw new IllegalArgumentException("ReaperPlugin can only be applied to the root project of a build"); - } - - project.getPlugins().apply(GlobalBuildInfoPlugin.class); - - Path inputDir = project.getRootDir().toPath().resolve(".gradle").resolve("reaper").resolve("build-" + getProcessId("xx")); - ReaperService service = project.getExtensions() - .create("reaper", ReaperService.class, project, project.getBuildDir().toPath(), inputDir); - - project.getGradle().buildFinished(result -> service.shutdown()); - } - - private static String getProcessId(final String fallback) { - // Note: may fail in some JVM implementations - // therefore fallback has to be provided - - // something like '@', at least in SUN / Oracle JVMs - final String jvmName = ManagementFactory.getRuntimeMXBean().getName(); - final int index = jvmName.indexOf('@'); - - if (index < 1) { - // part before '@' empty (index = 0) / '@' not found (index = -1) - return fallback; - } - - try { - return Long.toString(Long.parseLong(jvmName.substring(0, index))); - } catch (NumberFormatException e) { - // ignore - } - return fallback; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/ReaperService.java b/buildSrc/src/main/java/org/opensearch/gradle/ReaperService.java deleted file mode 100644 index 19660c672af3a..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/ReaperService.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.opensearch.gradle.info.BuildParams; -import org.gradle.api.GradleException; -import org.gradle.api.Project; -import org.gradle.api.logging.Logger; -import org.gradle.internal.jvm.Jvm; - -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UncheckedIOException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class ReaperService { - - private static final String REAPER_CLASS = "org/opensearch/gradle/reaper/Reaper.class"; - private static final Pattern REAPER_JAR_PATH_PATTERN = Pattern.compile("file:(.*)!/" + REAPER_CLASS); - private final Logger logger; - private final boolean isInternal; - private final Path buildDir; - private final Path inputDir; - private final Path logFile; - private volatile Process reaperProcess; - - public ReaperService(Project project, Path buildDir, Path inputDir) { - this.logger = project.getLogger(); - this.isInternal = BuildParams.isInternal(); - this.buildDir = buildDir; - this.inputDir = inputDir; - this.logFile = inputDir.resolve("reaper.log"); - } - - /** - * Register a pid that will be killed by the reaper. - */ - public void registerPid(String serviceId, long pid) { - String[] killPidCommand = OS.conditional() - .onWindows(() -> new String[] { "Taskkill", "/F", "/PID", String.valueOf(pid) }) - .onUnix(() -> new String[] { "kill", "-9", String.valueOf(pid) }) - .supply(); - registerCommand(serviceId, killPidCommand); - } - - /** - * Register a system command that will be run by the reaper. - */ - public void registerCommand(String serviceId, String... command) { - ensureReaperStarted(); - - try (FileWriter writer = new FileWriter(getCmdFile(serviceId).toFile())) { - writer.write(String.join(" ", command)); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - private Path getCmdFile(String serviceId) { - return inputDir.resolve(serviceId.replaceAll("[^a-zA-Z0-9]", "-") + ".cmd"); - } - - public void unregister(String serviceId) { - try { - Files.deleteIfExists(getCmdFile(serviceId)); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - void shutdown() { - if (reaperProcess != null) { - ensureReaperAlive(); - try { - reaperProcess.getOutputStream().close(); - logger.info("Waiting for reaper to exit normally"); - if (reaperProcess.waitFor() != 0) { - throw new GradleException("Reaper process failed. Check log at " + inputDir.resolve("error.log") + " for details"); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - - } - } - - private synchronized void ensureReaperStarted() { - if (reaperProcess == null) { - try { - Path jarPath = locateReaperJar(); - - // ensure the input directory exists - Files.createDirectories(inputDir); - - // start the reaper - ProcessBuilder builder = new ProcessBuilder( - Jvm.current().getJavaExecutable().toString(), // same jvm as gradle - "-Xms4m", - "-Xmx16m", // no need for a big heap, just need to read some files and execute - "-jar", - jarPath.toString(), - inputDir.toString() - ); - logger.info("Launching reaper: " + String.join(" ", builder.command())); - // be explicit for stdin, we use closing of the pipe to signal shutdown to the reaper - builder.redirectInput(ProcessBuilder.Redirect.PIPE); - builder.redirectOutput(logFile.toFile()); - builder.redirectError(logFile.toFile()); - reaperProcess = builder.start(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } else { - ensureReaperAlive(); - } - } - - private Path locateReaperJar() { - if (isInternal) { - // when running inside the Elasticsearch build just pull find the jar in the runtime classpath - URL main = this.getClass().getClassLoader().getResource(REAPER_CLASS); - String mainPath = main.getFile(); - Matcher matcher = REAPER_JAR_PATH_PATTERN.matcher(mainPath); - - if (matcher.matches()) { - String path = matcher.group(1); - return Paths.get(OS.conditional().onWindows(() -> path.substring(1)).onUnix(() -> path).supply()); - } else { - throw new RuntimeException("Unable to locate " + REAPER_CLASS + " on build classpath."); - } - } else { - // copy the reaper jar - Path jarPath = buildDir.resolve("reaper").resolve("reaper.jar"); - try { - Files.createDirectories(jarPath.getParent()); - } catch (IOException e) { - throw new UncheckedIOException("Unable to create reaper JAR output directory " + jarPath.getParent(), e); - } - - try ( - OutputStream out = Files.newOutputStream(jarPath); - InputStream jarInput = this.getClass().getResourceAsStream("/META-INF/reaper.jar"); - ) { - logger.info("Copying reaper.jar..."); - byte[] buffer = new byte[4096]; - int len; - while ((len = jarInput.read(buffer)) > 0) { - out.write(buffer, 0, len); - } - } catch (IOException e) { - throw new UncheckedIOException(e); - } - - return jarPath; - } - } - - private void ensureReaperAlive() { - if (reaperProcess.isAlive() == false) { - throw new IllegalStateException("Reaper process died unexpectedly! Check the log at " + logFile.toString()); - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/RepositoriesSetupPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/RepositoriesSetupPlugin.java deleted file mode 100644 index 30847f0648c5c..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/RepositoriesSetupPlugin.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.gradle.api.GradleException; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.artifacts.dsl.RepositoryHandler; -import org.gradle.api.artifacts.repositories.IvyArtifactRepository; -import org.gradle.api.artifacts.repositories.MavenArtifactRepository; - -import java.net.MalformedURLException; -import java.net.URI; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class RepositoriesSetupPlugin implements Plugin { - - private static final List SECURE_URL_SCHEMES = Arrays.asList("file", "https", "s3"); - private static final Pattern LUCENE_SNAPSHOT_REGEX = Pattern.compile("\\w+-snapshot-([a-z0-9]+)"); - - @Override - public void apply(Project project) { - configureRepositories(project); - } - - /** - * Adds repositories used by ES projects and dependencies - */ - public static void configureRepositories(Project project) { - // ensure all repositories use secure urls - // TODO: remove this with gradle 7.0, which no longer allows insecure urls - project.getRepositories().all(repository -> { - if (repository instanceof MavenArtifactRepository) { - final MavenArtifactRepository maven = (MavenArtifactRepository) repository; - assertRepositoryURIIsSecure(maven.getName(), project.getPath(), maven.getUrl()); - for (URI uri : maven.getArtifactUrls()) { - assertRepositoryURIIsSecure(maven.getName(), project.getPath(), uri); - } - } else if (repository instanceof IvyArtifactRepository) { - final IvyArtifactRepository ivy = (IvyArtifactRepository) repository; - assertRepositoryURIIsSecure(ivy.getName(), project.getPath(), ivy.getUrl()); - } - }); - RepositoryHandler repos = project.getRepositories(); - if (System.getProperty("repos.mavenLocal") != null) { - // with -Drepos.mavenLocal=true we can force checking the local .m2 repo which is - // useful for development ie. bwc tests where we install stuff in the local repository - // such that we don't have to pass hardcoded files to gradle - repos.mavenLocal(); - } - repos.mavenCentral(); - - String luceneVersion = VersionProperties.getLucene(); - if (luceneVersion.contains("-snapshot")) { - // extract the revision number from the version with a regex matcher - Matcher matcher = LUCENE_SNAPSHOT_REGEX.matcher(luceneVersion); - if (matcher.find() == false) { - throw new GradleException("Malformed lucene snapshot version: " + luceneVersion); - } - String revision = matcher.group(1); - // TODO(cleanup) - Setup own lucene snapshot repo - MavenArtifactRepository luceneRepo = repos.maven(repo -> { - repo.setName("lucene-snapshots"); - repo.setUrl("https://artifacts.opensearch.org/snapshots/lucene/"); - }); - repos.exclusiveContent(exclusiveRepo -> { - exclusiveRepo.filter( - descriptor -> descriptor.includeVersionByRegex("org\\.apache\\.lucene", ".*", ".*-snapshot-" + revision) - ); - exclusiveRepo.forRepositories(luceneRepo); - }); - } - } - - private static void assertRepositoryURIIsSecure(final String repositoryName, final String projectPath, final URI uri) { - if (uri != null && SECURE_URL_SCHEMES.contains(uri.getScheme()) == false) { - String url; - try { - url = uri.toURL().toString(); - } catch (MalformedURLException e) { - throw new IllegalStateException(e); - } - final String message = String.format( - Locale.ROOT, - "repository [%s] on project with path [%s] is not using a secure protocol for artifacts on [%s]", - repositoryName, - projectPath, - url - ); - throw new GradleException(message); - } - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/SimpleCommandLineArgumentProvider.java b/buildSrc/src/main/java/org/opensearch/gradle/SimpleCommandLineArgumentProvider.java deleted file mode 100644 index 77dc10f635b71..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/SimpleCommandLineArgumentProvider.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.gradle.process.CommandLineArgumentProvider; - -import java.util.Arrays; -import java.util.List; - -/** - * A {@link CommandLineArgumentProvider} implementation that simply returns the given list. This implementation does not track any - * arguments as inputs, so this is useful for passing arguments that should not be used for the purposes of input snapshotting. - */ -public class SimpleCommandLineArgumentProvider implements CommandLineArgumentProvider { - private final List arguments; - - public SimpleCommandLineArgumentProvider(String... arguments) { - this.arguments = Arrays.asList(arguments); - } - - @Override - public Iterable asArguments() { - return arguments; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/SystemPropertyCommandLineArgumentProvider.java b/buildSrc/src/main/java/org/opensearch/gradle/SystemPropertyCommandLineArgumentProvider.java deleted file mode 100644 index f8182deac1489..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/SystemPropertyCommandLineArgumentProvider.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.gradle.api.tasks.Input; -import org.gradle.process.CommandLineArgumentProvider; - -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -public class SystemPropertyCommandLineArgumentProvider implements CommandLineArgumentProvider { - private final Map systemProperties = new LinkedHashMap<>(); - - public void systemProperty(String key, Supplier value) { - systemProperties.put(key, value); - } - - public void systemProperty(String key, Object value) { - systemProperties.put(key, value); - } - - @Override - public Iterable asArguments() { - return systemProperties.entrySet() - .stream() - .map( - entry -> "-D" - + entry.getKey() - + "=" - + (entry.getValue() instanceof Supplier ? ((Supplier) entry.getValue()).get() : entry.getValue()) - ) - .collect(Collectors.toList()); - } - - // Track system property keys as an input so our build cache key will change if we add properties but values are still ignored - @Input - public Iterable getPropertyNames() { - return systemProperties.keySet(); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/Version.java b/buildSrc/src/main/java/org/opensearch/gradle/Version.java deleted file mode 100644 index 8e00b4419f5f3..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/Version.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import java.util.Objects; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Encapsulates comparison and printing logic for an x.y.z version. - */ -public final class Version implements Comparable { - private final int major; - private final int minor; - private final int revision; - private final int id; - // used to identify rebase to OpenSearch 1.0.0 - public static final int MASK = 0x08000000; - - /** - * Specifies how a version string should be parsed. - */ - public enum Mode { - /** - * Strict parsing only allows known suffixes after the patch number: "-alpha", "-beta" or "-rc". The - * suffix "-SNAPSHOT" is also allowed, either after the patch number, or after the other suffices. - */ - STRICT, - - /** - * Relaxed parsing allows any alphanumeric suffix after the patch number. - */ - RELAXED - } - - private static final Pattern pattern = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)(-alpha\\d+|-beta\\d+|-rc\\d+)?(-SNAPSHOT)?"); - - private static final Pattern relaxedPattern = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)(-[a-zA-Z0-9_]+|\\+[a-zA-Z0-9_]+)*?"); - - public Version(int major, int minor, int revision) { - Objects.requireNonNull(major, "major version can't be null"); - Objects.requireNonNull(minor, "minor version can't be null"); - Objects.requireNonNull(revision, "revision version can't be null"); - this.major = major; - this.minor = minor; - this.revision = revision; - - // currently snapshot is not taken into account - int id = major * 10000000 + minor * 100000 + revision * 1000; - // identify if new OpenSearch version 1 - this.id = major == 1 ? id ^ MASK : id; - } - - private static int parseSuffixNumber(String substring) { - if (substring.isEmpty()) { - throw new IllegalArgumentException("Invalid suffix, must contain a number e.x. alpha2"); - } - return Integer.parseInt(substring); - } - - public static Version fromString(final String s) { - return fromString(s, Mode.STRICT); - } - - public static Version fromString(final String s, final Mode mode) { - Objects.requireNonNull(s); - Matcher matcher = mode == Mode.STRICT ? pattern.matcher(s) : relaxedPattern.matcher(s); - if (matcher.matches() == false) { - String expected = mode == Mode.STRICT - ? "major.minor.revision[-(alpha|beta|rc)Number][-SNAPSHOT]" - : "major.minor.revision[-extra]"; - throw new IllegalArgumentException("Invalid version format: '" + s + "'. Should be " + expected); - } - - return new Version(Integer.parseInt(matcher.group(1)), parseSuffixNumber(matcher.group(2)), parseSuffixNumber(matcher.group(3))); - } - - @Override - public String toString() { - return String.valueOf(getMajor()) + "." + String.valueOf(getMinor()) + "." + String.valueOf(getRevision()); - } - - public boolean before(Version compareTo) { - return id < compareTo.getId(); - } - - public boolean before(String compareTo) { - return before(fromString(compareTo)); - } - - public boolean onOrBefore(Version compareTo) { - return id <= compareTo.getId(); - } - - public boolean onOrBefore(String compareTo) { - return onOrBefore(fromString(compareTo)); - } - - public boolean onOrAfter(Version compareTo) { - return id >= compareTo.getId(); - } - - public boolean onOrAfter(String compareTo) { - return onOrAfter(fromString(compareTo)); - } - - public boolean after(Version compareTo) { - return id > compareTo.getId(); - } - - public boolean after(String compareTo) { - return after(fromString(compareTo)); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Version version = (Version) o; - return major == version.major && minor == version.minor && revision == version.revision; - } - - @Override - public int hashCode() { - return Objects.hash(major, minor, revision, id); - } - - public int getMajor() { - return major; - } - - public int getMinor() { - return minor; - } - - public int getRevision() { - return revision; - } - - protected int getId() { - return id; - } - - @Override - public int compareTo(Version other) { - return Integer.compare(getId(), other.getId()); - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/VersionProperties.java b/buildSrc/src/main/java/org/opensearch/gradle/VersionProperties.java deleted file mode 100644 index 2b50e59de04d3..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/VersionProperties.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -/** - * Accessor for shared dependency versions used by opensearch, namely the opensearch and lucene versions. - */ -public class VersionProperties { - - public static String getOpenSearch() { - return opensearch; - } - - public static Version getOpenSearchVersion() { - return Version.fromString(opensearch); - } - - public static String getLucene() { - return lucene; - } - - public static String getBundledJdk(final String platform) { - switch (platform) { - case "darwin": // fall trough - case "mac": - return bundledJdkDarwin; - case "freebsd": - return bundledJdkFreeBSD; - case "linux": - return bundledJdkLinux; - case "windows": - return bundledJdkWindows; - default: - throw new IllegalArgumentException("unknown platform [" + platform + "]"); - } - } - - public static String getBundledJdkVendor() { - return bundledJdkVendor; - } - - public static Map getVersions() { - return versions; - } - - private static final String opensearch; - private static final String lucene; - private static final String bundledJdkDarwin; - private static final String bundledJdkFreeBSD; - private static final String bundledJdkLinux; - private static final String bundledJdkWindows; - private static final String bundledJdkVendor; - private static final Map versions = new HashMap(); - - static { - Properties props = getVersionProperties(); - opensearch = props.getProperty("opensearch"); - lucene = props.getProperty("lucene"); - bundledJdkVendor = props.getProperty("bundled_jdk_vendor"); - final String bundledJdk = props.getProperty("bundled_jdk"); - bundledJdkDarwin = props.getProperty("bundled_jdk_darwin", bundledJdk); - bundledJdkFreeBSD = props.getProperty("bundled_jdk_freebsd", bundledJdk); - bundledJdkLinux = props.getProperty("bundled_jdk_linux", bundledJdk); - bundledJdkWindows = props.getProperty("bundled_jdk_windows", bundledJdk); - - for (String property : props.stringPropertyNames()) { - versions.put(property, props.getProperty(property)); - } - } - - private static Properties getVersionProperties() { - Properties props = new Properties(); - try (InputStream propsStream = VersionProperties.class.getResourceAsStream("/version.properties")) { - if (propsStream == null) { - throw new IllegalStateException("/version.properties resource missing"); - } - props.load(propsStream); - } catch (IOException e) { - throw new IllegalStateException("Failed to load version properties", e); - } - return props; - } - - public static boolean isOpenSearchSnapshot() { - return opensearch.endsWith("-SNAPSHOT"); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/dependencies/CompileOnlyResolvePlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/dependencies/CompileOnlyResolvePlugin.java deleted file mode 100644 index c690367a13b86..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/dependencies/CompileOnlyResolvePlugin.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.dependencies; - -import org.gradle.api.NamedDomainObjectProvider; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.plugins.JavaPlugin; - -public class CompileOnlyResolvePlugin implements Plugin { - public static final String RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME = "resolveableCompileOnly"; - - @Override - public void apply(Project project) { - project.getConfigurations().all(configuration -> { - if (configuration.getName().equals(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME)) { - NamedDomainObjectProvider resolvableCompileOnly = project.getConfigurations() - .register(RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME); - resolvableCompileOnly.configure((c) -> { - c.setCanBeResolved(true); - c.setCanBeConsumed(false); - c.extendsFrom(configuration); - }); - } - }); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/docker/DockerBuildTask.java b/buildSrc/src/main/java/org/opensearch/gradle/docker/DockerBuildTask.java deleted file mode 100644 index bb2a6d37362e1..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/docker/DockerBuildTask.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.docker; - -import org.opensearch.gradle.LoggedExec; -import org.gradle.api.DefaultTask; -import org.gradle.api.GradleException; -import org.gradle.api.file.DirectoryProperty; -import org.gradle.api.file.RegularFileProperty; -import org.gradle.api.logging.Logger; -import org.gradle.api.logging.Logging; -import org.gradle.api.provider.ListProperty; -import org.gradle.api.provider.Property; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.InputDirectory; -import org.gradle.api.tasks.OutputFile; -import org.gradle.api.tasks.PathSensitive; -import org.gradle.api.tasks.PathSensitivity; -import org.gradle.api.tasks.TaskAction; -import org.gradle.process.ExecOperations; -import org.gradle.workers.WorkAction; -import org.gradle.workers.WorkParameters; -import org.gradle.workers.WorkerExecutor; - -import javax.inject.Inject; -import java.io.IOException; -import java.util.Arrays; - -public class DockerBuildTask extends DefaultTask { - private static final Logger LOGGER = Logging.getLogger(DockerBuildTask.class); - - private final WorkerExecutor workerExecutor; - private final RegularFileProperty markerFile = getProject().getObjects().fileProperty(); - private final DirectoryProperty dockerContext = getProject().getObjects().directoryProperty(); - - private String[] tags; - private boolean pull = true; - private boolean noCache = true; - private String[] baseImages; - - @Inject - public DockerBuildTask(WorkerExecutor workerExecutor) { - this.workerExecutor = workerExecutor; - this.markerFile.set(getProject().getLayout().getBuildDirectory().file("markers/" + this.getName() + ".marker")); - } - - @TaskAction - public void build() { - workerExecutor.noIsolation().submit(DockerBuildAction.class, params -> { - params.getDockerContext().set(dockerContext); - params.getMarkerFile().set(markerFile); - params.getTags().set(Arrays.asList(tags)); - params.getPull().set(pull); - params.getNoCache().set(noCache); - params.getBaseImages().set(baseImages); - }); - } - - @InputDirectory - @PathSensitive(PathSensitivity.RELATIVE) - public DirectoryProperty getDockerContext() { - return dockerContext; - } - - @Input - public String[] getTags() { - return tags; - } - - public void setTags(String[] tags) { - this.tags = tags; - } - - @Input - public boolean isPull() { - return pull; - } - - public void setPull(boolean pull) { - this.pull = pull; - } - - @Input - public boolean isNoCache() { - return noCache; - } - - public void setNoCache(boolean noCache) { - this.noCache = noCache; - } - - @Input - public String[] getBaseImages() { - return baseImages; - } - - public void setBaseImages(String[] baseImages) { - this.baseImages = baseImages; - } - - @OutputFile - public RegularFileProperty getMarkerFile() { - return markerFile; - } - - public abstract static class DockerBuildAction implements WorkAction { - private final ExecOperations execOperations; - - @Inject - public DockerBuildAction(ExecOperations execOperations) { - this.execOperations = execOperations; - } - - /** - * Wraps `docker pull` in a retry loop, to try and provide some resilience against - * transient errors - * @param baseImage the image to pull. - */ - private void pullBaseImage(String baseImage) { - final int maxAttempts = 10; - - for (int attempt = 1; attempt <= maxAttempts; attempt++) { - try { - LoggedExec.exec(execOperations, spec -> { - spec.executable("docker"); - spec.args("pull"); - spec.args(baseImage); - }); - - return; - } catch (Exception e) { - LOGGER.warn("Attempt {}/{} to pull Docker base image {} failed", attempt, maxAttempts, baseImage); - } - } - - // If we successfully ran `docker pull` above, we would have returned before this point. - throw new GradleException("Failed to pull Docker base image [" + baseImage + "], all attempts failed"); - } - - @Override - public void execute() { - final Parameters parameters = getParameters(); - - if (parameters.getPull().get()) { - for (String baseImage : parameters.getBaseImages().get()) { - pullBaseImage(baseImage); - } - } - - LoggedExec.exec(execOperations, spec -> { - spec.executable("docker"); - - spec.args("build", parameters.getDockerContext().get().getAsFile().getAbsolutePath()); - - if (parameters.getNoCache().get()) { - spec.args("--no-cache"); - } - - parameters.getTags().get().forEach(tag -> spec.args("--tag", tag)); - }); - - try { - parameters.getMarkerFile().getAsFile().get().createNewFile(); - } catch (IOException e) { - throw new RuntimeException("Failed to create marker file", e); - } - } - } - - interface Parameters extends WorkParameters { - DirectoryProperty getDockerContext(); - - RegularFileProperty getMarkerFile(); - - ListProperty getTags(); - - Property getPull(); - - Property getNoCache(); - - Property getBaseImages(); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/docker/DockerSupportPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/docker/DockerSupportPlugin.java deleted file mode 100644 index 92777638982d2..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/docker/DockerSupportPlugin.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.docker; - -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.provider.Provider; - -import java.io.File; -import java.util.List; -import java.util.stream.Collectors; - -/** - * Plugin providing {@link DockerSupportService} for detecting Docker installations and determining requirements for Docker-based - * OpenSearch build tasks. - */ -public class DockerSupportPlugin implements Plugin { - public static final String DOCKER_SUPPORT_SERVICE_NAME = "dockerSupportService"; - public static final String DOCKER_ON_LINUX_EXCLUSIONS_FILE = ".ci/dockerOnLinuxExclusions"; - - @Override - public void apply(Project project) { - if (project != project.getRootProject()) { - throw new IllegalStateException(this.getClass().getName() + " can only be applied to the root project."); - } - - Provider dockerSupportServiceProvider = project.getGradle() - .getSharedServices() - .registerIfAbsent( - DOCKER_SUPPORT_SERVICE_NAME, - DockerSupportService.class, - spec -> spec.parameters( - params -> { params.setExclusionsFile(new File(project.getRootDir(), DOCKER_ON_LINUX_EXCLUSIONS_FILE)); } - ) - ); - - // Ensure that if we are trying to run any DockerBuildTask tasks, we assert an available Docker installation exists - project.getGradle().getTaskGraph().whenReady(graph -> { - List dockerTasks = graph.getAllTasks() - .stream() - .filter(task -> task instanceof DockerBuildTask) - .map(Task::getPath) - .collect(Collectors.toList()); - - if (dockerTasks.isEmpty() == false) { - dockerSupportServiceProvider.get().failIfDockerUnavailable(dockerTasks); - } - }); - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/docker/DockerSupportService.java b/buildSrc/src/main/java/org/opensearch/gradle/docker/DockerSupportService.java deleted file mode 100644 index 2eb2852e3e55e..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/docker/DockerSupportService.java +++ /dev/null @@ -1,421 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.docker; - -import org.opensearch.gradle.Version; -import org.opensearch.gradle.info.BuildParams; -import org.gradle.api.GradleException; -import org.gradle.api.logging.Logger; -import org.gradle.api.logging.Logging; -import org.gradle.api.services.BuildService; -import org.gradle.api.services.BuildServiceParameters; -import org.gradle.process.ExecOperations; -import org.gradle.process.ExecResult; -import org.apache.tools.ant.taskdefs.condition.Os; - -import javax.inject.Inject; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * Build service for detecting available Docker installation and checking for compatibility with OpenSearch Docker image build - * requirements. This includes a minimum version requirement, as well as the ability to run privileged commands. - */ -public abstract class DockerSupportService implements BuildService { - - private static Logger LOGGER = Logging.getLogger(DockerSupportService.class); - // Defines the possible locations of the Docker CLI. These will be searched in order. - private static String[] DOCKER_BINARIES_UNIX = { "/usr/bin/docker", "/usr/local/bin/docker" }; - - private static String[] DOCKER_BINARIES_WINDOWS = { System.getenv("PROGRAMFILES") + "\\Docker\\Docker\\resources\\bin\\docker.exe" }; - - private static String[] DOCKER_BINARIES = Os.isFamily(Os.FAMILY_WINDOWS) ? DOCKER_BINARIES_WINDOWS : DOCKER_BINARIES_UNIX; - - private static String[] DOCKER_COMPOSE_BINARIES_UNIX = { "/usr/local/bin/docker-compose", "/usr/bin/docker-compose" }; - - private static String[] DOCKER_COMPOSE_BINARIES_WINDOWS = { - System.getenv("PROGRAMFILES") + "\\Docker\\Docker\\resources\\bin\\docker-compose.exe" }; - - private static String[] DOCKER_COMPOSE_BINARIES = Os.isFamily(Os.FAMILY_WINDOWS) - ? DOCKER_COMPOSE_BINARIES_WINDOWS - : DOCKER_COMPOSE_BINARIES_UNIX; - - private static final Version MINIMUM_DOCKER_VERSION = Version.fromString("17.05.0"); - - private final ExecOperations execOperations; - private DockerAvailability dockerAvailability; - - @Inject - public DockerSupportService(ExecOperations execOperations) { - this.execOperations = execOperations; - } - - /** - * Searches for a functional Docker installation, and returns information about the search. - * - * @return the results of the search. - */ - public DockerAvailability getDockerAvailability() { - if (this.dockerAvailability == null) { - String dockerPath = null; - Result lastResult = null; - Version version = null; - boolean isVersionHighEnough = false; - boolean isComposeAvailable = false; - - // Check if the Docker binary exists - final Optional dockerBinary = getDockerPath(); - if (isExcludedOs() == false && dockerBinary.isPresent()) { - dockerPath = dockerBinary.get(); - - // Since we use a multi-stage Docker build, check the Docker version meets minimum requirement - lastResult = runCommand(dockerPath, "version", "--format", "{{.Server.Version}}"); - - if (lastResult.isSuccess()) { - version = Version.fromString(lastResult.stdout.trim(), Version.Mode.RELAXED); - - isVersionHighEnough = version.onOrAfter(MINIMUM_DOCKER_VERSION); - - if (isVersionHighEnough) { - // Check that we can execute a privileged command - lastResult = runCommand(dockerPath, "images"); - - // If docker all checks out, see if docker-compose is available and working - Optional composePath = getDockerComposePath(); - if (lastResult.isSuccess() && composePath.isPresent()) { - isComposeAvailable = runCommand(composePath.get(), "version").isSuccess(); - } - } - } - } - - boolean isAvailable = isVersionHighEnough && lastResult != null && lastResult.isSuccess(); - - this.dockerAvailability = new DockerAvailability( - isAvailable, - isComposeAvailable, - isVersionHighEnough, - dockerPath, - version, - lastResult - ); - } - - return this.dockerAvailability; - } - - /** - * Given a list of tasks that requires Docker, check whether Docker is available, otherwise throw an exception. - * - * @throws GradleException if Docker is not available. The exception message gives the reason. - */ - void failIfDockerUnavailable(List tasks) { - DockerAvailability availability = getDockerAvailability(); - - // Docker installation is available and compatible - if (availability.isAvailable) { - return; - } - - // No Docker binary was located - if (availability.path == null) { - final String message = String.format( - Locale.ROOT, - "Docker (checked [%s]) is required to run the following task%s: \n%s", - String.join(", ", DOCKER_BINARIES), - tasks.size() > 1 ? "s" : "", - String.join("\n", tasks) - ); - throwDockerRequiredException(message); - } - - // Docker binaries were located, but did not meet the minimum version requirement - if (availability.lastCommand.isSuccess() && availability.isVersionHighEnough == false) { - final String message = String.format( - Locale.ROOT, - "building Docker images requires minimum Docker version of %s due to use of multi-stage builds yet was [%s]", - MINIMUM_DOCKER_VERSION, - availability.version - ); - throwDockerRequiredException(message); - } - - // Some other problem, print the error - final String message = String.format( - Locale.ROOT, - "a problem occurred while using Docker from [%s]%s yet it is required to run the following task%s: \n%s\n" - + "the problem is that Docker exited with exit code [%d] with standard error output:\n%s", - availability.path, - availability.version == null ? "" : " v" + availability.version, - tasks.size() > 1 ? "s" : "", - String.join("\n", tasks), - availability.lastCommand.exitCode, - availability.lastCommand.stderr.trim() - ); - throwDockerRequiredException(message); - } - - private boolean isExcludedOs() { - // We don't attempt to check the current flavor and version of Linux unless we're - // running in CI, because we don't want to stop people running the Docker tests in - // their own environments if they really want to. - if (BuildParams.isCi() == false) { - return false; - } - - // Only some hosts in CI are configured with Docker. We attempt to work out the OS - // and version, so that we know whether to expect to find Docker. We don't attempt - // to probe for whether Docker is available, because that doesn't tell us whether - // Docker is unavailable when it should be. - final Path osRelease = Paths.get("/etc/os-release"); - - if (Files.exists(osRelease)) { - Map values; - - try { - final List osReleaseLines = Files.readAllLines(osRelease); - values = parseOsRelease(osReleaseLines); - } catch (IOException e) { - throw new GradleException("Failed to read /etc/os-release", e); - } - - final String id = deriveId(values); - final boolean excluded = getLinuxExclusionList().contains(id); - - if (excluded) { - LOGGER.warn("Linux OS id [{}] is present in the Docker exclude list. Tasks requiring Docker will be disabled.", id); - } - - return excluded; - } - - return false; - } - - private List getLinuxExclusionList() { - File exclusionsFile = getParameters().getExclusionsFile(); - - if (exclusionsFile.exists()) { - try { - return Files.readAllLines(exclusionsFile.toPath()) - .stream() - .map(String::trim) - .filter(line -> (line.isEmpty() || line.startsWith("#")) == false) - .collect(Collectors.toList()); - } catch (IOException e) { - throw new GradleException("Failed to read " + exclusionsFile.getAbsolutePath(), e); - } - } else { - return Collections.emptyList(); - } - } - - // visible for testing - static String deriveId(Map values) { - return values.get("ID") + "-" + values.get("VERSION_ID"); - } - - // visible for testing - static Map parseOsRelease(final List osReleaseLines) { - final Map values = new HashMap<>(); - - osReleaseLines.stream().map(String::trim).filter(line -> (line.isEmpty() || line.startsWith("#")) == false).forEach(line -> { - final String[] parts = line.split("=", 2); - final String key = parts[0]; - // remove optional leading and trailing quotes and whitespace - final String value = parts[1].replaceAll("^['\"]?\\s*", "").replaceAll("\\s*['\"]?$", ""); - - values.put(key, value.toLowerCase()); - }); - - return values; - } - - /** - * Searches the entries in {@link #DOCKER_BINARIES} for the Docker CLI. This method does - * not check whether the Docker installation appears usable, see {@link #getDockerAvailability()} - * instead. - * - * @return the path to a CLI, if available. - */ - private Optional getDockerPath() { - // Check if the Docker binary exists - return Arrays.asList(DOCKER_BINARIES).stream().filter(path -> new File(path).exists()).findFirst(); - } - - /** - * Searches the entries in {@link #DOCKER_COMPOSE_BINARIES} for the Docker Compose CLI. This method does - * not check whether the installation appears usable, see {@link #getDockerAvailability()} instead. - * - * @return the path to a CLI, if available. - */ - private Optional getDockerComposePath() { - // Check if the Docker binary exists - return Arrays.asList(DOCKER_COMPOSE_BINARIES).stream().filter(path -> new File(path).exists()).findFirst(); - } - - private void throwDockerRequiredException(final String message) { - throwDockerRequiredException(message, null); - } - - private void throwDockerRequiredException(final String message, Exception e) { - throw new GradleException( - message + "\nyou can address this by attending to the reported issue, or removing the offending tasks from being executed.", - e - ); - } - - /** - * Runs a command and captures the exit code, standard output and standard error. - * - * @param args the command and any arguments to execute - * @return a object that captures the result of running the command. If an exception occurring - * while running the command, or the process was killed after reaching the 10s timeout, - * then the exit code will be -1. - */ - private Result runCommand(String... args) { - if (args.length == 0) { - throw new IllegalArgumentException("Cannot execute with no command"); - } - - ByteArrayOutputStream stdout = new ByteArrayOutputStream(); - ByteArrayOutputStream stderr = new ByteArrayOutputStream(); - - final ExecResult execResult = execOperations.exec(spec -> { - // The redundant cast is to silence a compiler warning. - spec.setCommandLine((Object[]) args); - spec.setStandardOutput(stdout); - spec.setErrorOutput(stderr); - spec.setIgnoreExitValue(true); - }); - return new Result(execResult.getExitValue(), stdout.toString(), stderr.toString()); - } - - /** - * An immutable class that represents the results of a Docker search from {@link #getDockerAvailability()}}. - */ - public static class DockerAvailability { - /** - * Indicates whether Docker is available and meets the required criteria. - * True if, and only if, Docker is: - *

      - *
    • Installed
    • - *
    • Executable
    • - *
    • Is at least version compatibile with minimum version
    • - *
    • Can execute a command that requires privileges
    • - *
    - */ - public final boolean isAvailable; - - /** - * True if docker-compose is available. - */ - public final boolean isComposeAvailable; - - /** - * True if the installed Docker version is >= 17.05 - */ - public final boolean isVersionHighEnough; - - /** - * The path to the Docker CLI, or null - */ - public final String path; - - /** - * The installed Docker version, or null - */ - public final Version version; - - /** - * Information about the last command executes while probing Docker, or null. - */ - final Result lastCommand; - - DockerAvailability( - boolean isAvailable, - boolean isComposeAvailable, - boolean isVersionHighEnough, - String path, - Version version, - Result lastCommand - ) { - this.isAvailable = isAvailable; - this.isComposeAvailable = isComposeAvailable; - this.isVersionHighEnough = isVersionHighEnough; - this.path = path; - this.version = version; - this.lastCommand = lastCommand; - } - } - - /** - * This class models the result of running a command. It captures the exit code, standard output and standard error. - */ - private static class Result { - final int exitCode; - final String stdout; - final String stderr; - - Result(int exitCode, String stdout, String stderr) { - this.exitCode = exitCode; - this.stdout = stdout; - this.stderr = stderr; - } - - boolean isSuccess() { - return exitCode == 0; - } - - public String toString() { - return "exitCode = [" + exitCode + "] " + "stdout = [" + stdout.trim() + "] " + "stderr = [" + stderr.trim() + "]"; - } - } - - interface Parameters extends BuildServiceParameters { - File getExclusionsFile(); - - void setExclusionsFile(File exclusionsFile); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/http/WaitForHttpResource.java b/buildSrc/src/main/java/org/opensearch/gradle/http/WaitForHttpResource.java deleted file mode 100644 index 41f4054910d97..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/http/WaitForHttpResource.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.http; - -import org.gradle.api.logging.Logger; -import org.gradle.api.logging.Logging; - -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.KeyManager; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManagerFactory; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.security.GeneralSecurityException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.SecureRandom; -import java.security.cert.Certificate; -import java.security.cert.CertificateFactory; -import java.util.Arrays; -import java.util.Base64; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -/** - * A utility to wait for a specific HTTP resource to be available, optionally with customized TLS trusted CAs. - * This is logically similar to using the Ant Get task to retrieve a resource, but with the difference that it can - * access resources that do not use the JRE's default trusted CAs. - */ -public class WaitForHttpResource { - - private static final Logger logger = Logging.getLogger(WaitForHttpResource.class); - - private Set validResponseCodes = Collections.singleton(200); - private URL url; - private Set certificateAuthorities; - private File trustStoreFile; - private String trustStorePassword; - private String username; - private String password; - - public WaitForHttpResource(String protocol, String host, int numberOfNodes) throws MalformedURLException { - this(new URL(protocol + "://" + host + "/_cluster/health?wait_for_nodes=>=" + numberOfNodes + "&wait_for_status=yellow")); - } - - public WaitForHttpResource(URL url) { - this.url = url; - } - - public void setValidResponseCodes(int... validResponseCodes) { - this.validResponseCodes = new HashSet<>(validResponseCodes.length); - for (int rc : validResponseCodes) { - this.validResponseCodes.add(rc); - } - } - - public void setCertificateAuthorities(File... certificateAuthorities) { - this.certificateAuthorities = new HashSet<>(Arrays.asList(certificateAuthorities)); - } - - public void setTrustStoreFile(File trustStoreFile) { - this.trustStoreFile = trustStoreFile; - } - - public void setTrustStorePassword(String trustStorePassword) { - this.trustStorePassword = trustStorePassword; - } - - public void setUsername(String username) { - this.username = username; - } - - public void setPassword(String password) { - this.password = password; - } - - public boolean wait(int durationInMs) throws GeneralSecurityException, InterruptedException, IOException { - final long waitUntil = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(durationInMs); - final long sleep = Long.max(durationInMs / 10, 100); - - final SSLContext ssl; - final KeyStore trustStore = buildTrustStore(); - if (trustStore != null) { - ssl = createSslContext(trustStore); - } else { - ssl = null; - } - IOException failure = null; - while (true) { - try { - checkResource(ssl); - return true; - } catch (IOException e) { - logger.debug("Failed to access resource [{}]", url, e); - failure = e; - } - if (System.nanoTime() < waitUntil) { - Thread.sleep(sleep); - } else { - throw failure; - } - } - } - - protected void checkResource(SSLContext ssl) throws IOException { - final HttpURLConnection connection = buildConnection(ssl); - connection.connect(); - final Integer response = connection.getResponseCode(); - if (validResponseCodes.contains(response)) { - logger.info("Got successful response [{}] from URL [{}]", response, url); - return; - } else { - throw new IOException(response + " " + connection.getResponseMessage()); - } - } - - HttpURLConnection buildConnection(SSLContext ssl) throws IOException { - final HttpURLConnection connection = (HttpURLConnection) this.url.openConnection(); - configureSslContext(connection, ssl); - configureBasicAuth(connection); - connection.setRequestMethod("GET"); - return connection; - } - - private void configureSslContext(HttpURLConnection connection, SSLContext ssl) { - if (ssl != null) { - if (connection instanceof HttpsURLConnection) { - ((HttpsURLConnection) connection).setSSLSocketFactory(ssl.getSocketFactory()); - } else { - throw new IllegalStateException("SSL trust has been configured, but [" + url + "] is not a 'https' URL"); - } - } - } - - private void configureBasicAuth(HttpURLConnection connection) { - if (username != null) { - if (password == null) { - throw new IllegalStateException("Basic Auth user [" + username + "] has been set, but no password has been configured"); - } - connection.setRequestProperty( - "Authorization", - "Basic " + Base64.getEncoder().encodeToString((username + ":" + password).getBytes(StandardCharsets.UTF_8)) - ); - } - } - - KeyStore buildTrustStore() throws GeneralSecurityException, IOException { - if (this.certificateAuthorities != null) { - if (trustStoreFile != null) { - throw new IllegalStateException("Cannot specify both truststore and CAs"); - } - return buildTrustStoreFromCA(); - } else if (trustStoreFile != null) { - return buildTrustStoreFromFile(); - } else { - return null; - } - } - - private KeyStore buildTrustStoreFromFile() throws GeneralSecurityException, IOException { - KeyStore keyStore = KeyStore.getInstance(trustStoreFile.getName().endsWith(".jks") ? "JKS" : "PKCS12"); - try (InputStream input = new FileInputStream(trustStoreFile)) { - keyStore.load(input, trustStorePassword == null ? null : trustStorePassword.toCharArray()); - } - return keyStore; - } - - private KeyStore buildTrustStoreFromCA() throws GeneralSecurityException, IOException { - final KeyStore store = KeyStore.getInstance(KeyStore.getDefaultType()); - store.load(null, null); - final CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); - int counter = 0; - for (File ca : certificateAuthorities) { - try (InputStream input = new FileInputStream(ca)) { - for (Certificate certificate : certFactory.generateCertificates(input)) { - store.setCertificateEntry("cert-" + counter, certificate); - counter++; - } - } - } - return store; - } - - private SSLContext createSslContext(KeyStore trustStore) throws GeneralSecurityException { - checkForTrustEntry(trustStore); - TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - tmf.init(trustStore); - SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); - sslContext.init(new KeyManager[0], tmf.getTrustManagers(), new SecureRandom()); - return sslContext; - } - - private void checkForTrustEntry(KeyStore trustStore) throws KeyStoreException { - Enumeration enumeration = trustStore.aliases(); - while (enumeration.hasMoreElements()) { - if (trustStore.isCertificateEntry(enumeration.nextElement())) { - // found trusted cert entry - return; - } - } - throw new IllegalStateException("Trust-store does not contain any trusted certificate entries"); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/info/BuildParams.java b/buildSrc/src/main/java/org/opensearch/gradle/info/BuildParams.java deleted file mode 100644 index 331794c9c2dd7..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/info/BuildParams.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.info; - -import org.opensearch.gradle.BwcVersions; -import org.gradle.api.JavaVersion; - -import java.io.File; -import java.lang.reflect.Modifier; -import java.time.ZonedDateTime; -import java.util.Arrays; -import java.util.List; -import java.util.function.Consumer; - -import static java.util.Objects.requireNonNull; - -public class BuildParams { - private static File runtimeJavaHome; - private static Boolean isRuntimeJavaHomeSet; - private static List javaVersions; - private static JavaVersion minimumCompilerVersion; - private static JavaVersion minimumRuntimeVersion; - private static JavaVersion gradleJavaVersion; - private static JavaVersion runtimeJavaVersion; - private static String runtimeJavaDetails; - private static Boolean inFipsJvm; - private static String gitRevision; - private static String gitOrigin; - private static ZonedDateTime buildDate; - private static String testSeed; - private static Boolean isCi; - private static Boolean isInternal; - private static Integer defaultParallel; - private static Boolean isSnapshotBuild; - private static BwcVersions bwcVersions; - - /** - * Initialize global build parameters. This method accepts and a initialization function which in turn accepts a - * {@link MutableBuildParams}. Initialization can be done in "stages", therefore changes override existing values, and values from - * previous calls to {@link #init(Consumer)} carry forward. In cases where you want to clear existing values - * {@link MutableBuildParams#reset()} may be used. - * - * @param initializer Build parameter initializer - */ - public static void init(Consumer initializer) { - initializer.accept(MutableBuildParams.INSTANCE); - } - - public static File getRuntimeJavaHome() { - return value(runtimeJavaHome); - } - - public static Boolean getIsRuntimeJavaHomeSet() { - return value(isRuntimeJavaHomeSet); - } - - public static List getJavaVersions() { - return value(javaVersions); - } - - public static JavaVersion getMinimumCompilerVersion() { - return value(minimumCompilerVersion); - } - - public static JavaVersion getMinimumRuntimeVersion() { - return value(minimumRuntimeVersion); - } - - public static JavaVersion getGradleJavaVersion() { - return value(gradleJavaVersion); - } - - public static JavaVersion getRuntimeJavaVersion() { - return value(runtimeJavaVersion); - } - - public static String getRuntimeJavaDetails() { - return value(runtimeJavaDetails); - } - - public static Boolean isInFipsJvm() { - return value(inFipsJvm); - } - - public static String getGitRevision() { - return value(gitRevision); - } - - public static String getGitOrigin() { - return value(gitOrigin); - } - - public static ZonedDateTime getBuildDate() { - return value(buildDate); - } - - public static BwcVersions getBwcVersions() { - return value(bwcVersions); - } - - public static String getTestSeed() { - return value(testSeed); - } - - public static Boolean isCi() { - return value(isCi); - } - - public static Boolean isInternal() { - return value(isInternal); - } - - public static Integer getDefaultParallel() { - return value(defaultParallel); - } - - public static boolean isSnapshotBuild() { - return value(BuildParams.isSnapshotBuild); - } - - private static T value(T object) { - if (object == null) { - String callingMethod = Thread.currentThread().getStackTrace()[2].getMethodName(); - - throw new IllegalStateException( - "Build parameter '" - + propertyName(callingMethod) - + "' has not been initialized.\n" - + "Perhaps the plugin responsible for initializing this property has not been applied." - ); - } - - return object; - } - - private static String propertyName(String methodName) { - String propertyName = methodName.startsWith("is") ? methodName.substring("is".length()) : methodName.substring("get".length()); - return propertyName.substring(0, 1).toLowerCase() + propertyName.substring(1); - } - - public static class MutableBuildParams { - private static MutableBuildParams INSTANCE = new MutableBuildParams(); - - private MutableBuildParams() {} - - /** - * Resets any existing values from previous initializations. - */ - public void reset() { - Arrays.stream(BuildParams.class.getDeclaredFields()).filter(f -> Modifier.isStatic(f.getModifiers())).forEach(f -> { - try { - // Since we are mutating private static fields from a public static inner class we need to suppress - // accessibility controls here. - f.setAccessible(true); - f.set(null, null); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - }); - } - - public void setRuntimeJavaHome(File runtimeJavaHome) { - BuildParams.runtimeJavaHome = requireNonNull(runtimeJavaHome); - } - - public void setIsRutimeJavaHomeSet(boolean isRutimeJavaHomeSet) { - BuildParams.isRuntimeJavaHomeSet = isRutimeJavaHomeSet; - } - - public void setJavaVersions(List javaVersions) { - BuildParams.javaVersions = requireNonNull(javaVersions); - } - - public void setMinimumCompilerVersion(JavaVersion minimumCompilerVersion) { - BuildParams.minimumCompilerVersion = requireNonNull(minimumCompilerVersion); - } - - public void setMinimumRuntimeVersion(JavaVersion minimumRuntimeVersion) { - BuildParams.minimumRuntimeVersion = requireNonNull(minimumRuntimeVersion); - } - - public void setGradleJavaVersion(JavaVersion gradleJavaVersion) { - BuildParams.gradleJavaVersion = requireNonNull(gradleJavaVersion); - } - - public void setRuntimeJavaVersion(JavaVersion runtimeJavaVersion) { - BuildParams.runtimeJavaVersion = requireNonNull(runtimeJavaVersion); - } - - public void setRuntimeJavaDetails(String runtimeJavaDetails) { - BuildParams.runtimeJavaDetails = runtimeJavaDetails; - } - - public void setInFipsJvm(boolean inFipsJvm) { - BuildParams.inFipsJvm = inFipsJvm; - } - - public void setGitRevision(String gitRevision) { - BuildParams.gitRevision = requireNonNull(gitRevision); - } - - public void setGitOrigin(String gitOrigin) { - BuildParams.gitOrigin = requireNonNull(gitOrigin); - } - - public void setBuildDate(ZonedDateTime buildDate) { - BuildParams.buildDate = requireNonNull(buildDate); - } - - public void setTestSeed(String testSeed) { - BuildParams.testSeed = requireNonNull(testSeed); - } - - public void setIsCi(boolean isCi) { - BuildParams.isCi = isCi; - } - - public void setIsInternal(Boolean isInternal) { - BuildParams.isInternal = requireNonNull(isInternal); - } - - public void setDefaultParallel(int defaultParallel) { - BuildParams.defaultParallel = defaultParallel; - } - - public void setIsSnapshotBuild(final boolean isSnapshotBuild) { - BuildParams.isSnapshotBuild = isSnapshotBuild; - } - - public void setBwcVersions(BwcVersions bwcVersions) { - BuildParams.bwcVersions = requireNonNull(bwcVersions); - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/info/GlobalBuildInfoPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/info/GlobalBuildInfoPlugin.java deleted file mode 100644 index 2888bb89e3ece..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/info/GlobalBuildInfoPlugin.java +++ /dev/null @@ -1,436 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.info; - -import org.apache.commons.io.IOUtils; -import org.opensearch.gradle.BwcVersions; -import org.opensearch.gradle.util.Util; -import org.gradle.api.GradleException; -import org.gradle.api.JavaVersion; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.logging.Logger; -import org.gradle.api.logging.Logging; -import org.gradle.api.model.ObjectFactory; -import org.gradle.api.provider.Provider; -import org.gradle.api.provider.ProviderFactory; -import org.gradle.internal.jvm.Jvm; -import org.gradle.jvm.toolchain.JavaInstallation; -import org.gradle.jvm.toolchain.JavaInstallationRegistry; -import org.gradle.util.GradleVersion; - -import javax.inject.Inject; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Optional; -import java.util.Random; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Stream; - -public class GlobalBuildInfoPlugin implements Plugin { - private static final Logger LOGGER = Logging.getLogger(GlobalBuildInfoPlugin.class); - private static final String DEFAULT_LEGACY_VERSION_JAVA_FILE_PATH = "server/src/main/java/org/opensearch/LegacyESVersion.java"; - private static final String DEFAULT_VERSION_JAVA_FILE_PATH = "server/src/main/java/org/opensearch/Version.java"; - private static Integer _defaultParallel = null; - - private final JavaInstallationRegistry javaInstallationRegistry; - private final ObjectFactory objects; - private final ProviderFactory providers; - - @Inject - public GlobalBuildInfoPlugin(JavaInstallationRegistry javaInstallationRegistry, ObjectFactory objects, ProviderFactory providers) { - this.javaInstallationRegistry = javaInstallationRegistry; - this.objects = objects; - this.providers = providers; - } - - @Override - public void apply(Project project) { - if (project != project.getRootProject()) { - throw new IllegalStateException(this.getClass().getName() + " can only be applied to the root project."); - } - GradleVersion minimumGradleVersion = GradleVersion.version(Util.getResourceContents("/minimumGradleVersion")); - if (GradleVersion.current().compareTo(minimumGradleVersion) < 0) { - throw new GradleException("Gradle " + minimumGradleVersion.getVersion() + "+ is required"); - } - - JavaVersion minimumCompilerVersion = JavaVersion.toVersion(Util.getResourceContents("/minimumCompilerVersion")); - JavaVersion minimumRuntimeVersion = JavaVersion.toVersion(Util.getResourceContents("/minimumRuntimeVersion")); - - Optional runtimeJavaHomeOpt = findRuntimeJavaHome(); - File runtimeJavaHome = runtimeJavaHomeOpt.orElse(Jvm.current().getJavaHome()); - - File rootDir = project.getRootDir(); - GitInfo gitInfo = gitInfo(rootDir); - - BuildParams.init(params -> { - // Initialize global build parameters - boolean isInternal = GlobalBuildInfoPlugin.class.getResource("/buildSrc.marker") != null; - - params.reset(); - params.setRuntimeJavaHome(runtimeJavaHome); - params.setRuntimeJavaVersion(determineJavaVersion("runtime java.home", runtimeJavaHome, minimumRuntimeVersion)); - params.setIsRutimeJavaHomeSet(runtimeJavaHomeOpt.isPresent()); - params.setRuntimeJavaDetails(getJavaInstallation(runtimeJavaHome).getImplementationName()); - params.setJavaVersions(getAvailableJavaVersions(minimumCompilerVersion)); - params.setMinimumCompilerVersion(minimumCompilerVersion); - params.setMinimumRuntimeVersion(minimumRuntimeVersion); - params.setGradleJavaVersion(Jvm.current().getJavaVersion()); - params.setGitRevision(gitInfo.getRevision()); - params.setGitOrigin(gitInfo.getOrigin()); - params.setBuildDate(Util.getBuildDate(ZonedDateTime.now(ZoneOffset.UTC))); - params.setTestSeed(getTestSeed()); - params.setIsCi(System.getenv("JENKINS_URL") != null); - params.setIsInternal(isInternal); - params.setDefaultParallel(findDefaultParallel(project)); - params.setInFipsJvm(Util.getBooleanProperty("tests.fips.enabled", false)); - params.setIsSnapshotBuild(Util.getBooleanProperty("build.snapshot", true)); - if (isInternal) { - params.setBwcVersions(resolveBwcVersions(rootDir)); - } - }); - - // Print global build info header just before task execution - project.getGradle().getTaskGraph().whenReady(graph -> logGlobalBuildInfo()); - } - - /* Introspect all versions of ES that may be tested against for backwards - * compatibility. It is *super* important that this logic is the same as the - * logic in VersionUtils.java. */ - private static BwcVersions resolveBwcVersions(File root) { - // todo redesign this terrible unreliable hack; should NEVER rely on parsing a source file - // for now, we hack the hack - File versionsFile = new File(root, DEFAULT_VERSION_JAVA_FILE_PATH); - File legacyVersionsFile = new File(root, DEFAULT_LEGACY_VERSION_JAVA_FILE_PATH); - try (FileInputStream fis = new FileInputStream(versionsFile); FileInputStream fis2 = new FileInputStream(legacyVersionsFile)) { - List versionLines = IOUtils.readLines(fis, "UTF-8"); - versionLines.addAll(IOUtils.readLines(fis2, "UTF-8")); - return new BwcVersions(versionLines); - } catch (IOException e) { - throw new IllegalStateException("Unable to resolve to resolve bwc versions from versionsFile.", e); - } - } - - private void logGlobalBuildInfo() { - final String osName = System.getProperty("os.name"); - final String osVersion = System.getProperty("os.version"); - final String osArch = System.getProperty("os.arch"); - final Jvm gradleJvm = Jvm.current(); - final String gradleJvmDetails = getJavaInstallation(gradleJvm.getJavaHome()).getImplementationName(); - - LOGGER.quiet("======================================="); - LOGGER.quiet("OpenSearch Build Hamster says Hello!"); - LOGGER.quiet(" Gradle Version : " + GradleVersion.current().getVersion()); - LOGGER.quiet(" OS Info : " + osName + " " + osVersion + " (" + osArch + ")"); - if (BuildParams.getIsRuntimeJavaHomeSet()) { - String runtimeJvmDetails = getJavaInstallation(BuildParams.getRuntimeJavaHome()).getImplementationName(); - LOGGER.quiet(" Runtime JDK Version : " + BuildParams.getRuntimeJavaVersion() + " (" + runtimeJvmDetails + ")"); - LOGGER.quiet(" Runtime java.home : " + BuildParams.getRuntimeJavaHome()); - LOGGER.quiet(" Gradle JDK Version : " + gradleJvm.getJavaVersion() + " (" + gradleJvmDetails + ")"); - LOGGER.quiet(" Gradle java.home : " + gradleJvm.getJavaHome()); - } else { - LOGGER.quiet(" JDK Version : " + gradleJvm.getJavaVersion() + " (" + gradleJvmDetails + ")"); - LOGGER.quiet(" JAVA_HOME : " + gradleJvm.getJavaHome()); - } - LOGGER.quiet(" Random Testing Seed : " + BuildParams.getTestSeed()); - LOGGER.quiet(" In FIPS 140 mode : " + BuildParams.isInFipsJvm()); - LOGGER.quiet("======================================="); - } - - private JavaVersion determineJavaVersion(String description, File javaHome, JavaVersion requiredVersion) { - JavaInstallation installation = getJavaInstallation(javaHome); - JavaVersion actualVersion = installation.getJavaVersion(); - if (actualVersion.isCompatibleWith(requiredVersion) == false) { - throwInvalidJavaHomeException( - description, - javaHome, - Integer.parseInt(requiredVersion.getMajorVersion()), - Integer.parseInt(actualVersion.getMajorVersion()) - ); - } - - return actualVersion; - } - - private JavaInstallation getJavaInstallation(File javaHome) { - JavaInstallation installation; - if (isCurrentJavaHome(javaHome)) { - installation = javaInstallationRegistry.getInstallationForCurrentVirtualMachine().get(); - } else { - installation = javaInstallationRegistry.installationForDirectory(objects.directoryProperty().fileValue(javaHome)).get(); - } - - return installation; - } - - private List getAvailableJavaVersions(JavaVersion minimumCompilerVersion) { - final List javaVersions = new ArrayList<>(); - for (int v = 8; v <= Integer.parseInt(minimumCompilerVersion.getMajorVersion()); v++) { - int version = v; - String javaHomeEnvVarName = getJavaHomeEnvVarName(Integer.toString(version)); - if (System.getenv(javaHomeEnvVarName) != null) { - File javaHomeDirectory = new File(findJavaHome(Integer.toString(version))); - Provider javaInstallationProvider = javaInstallationRegistry.installationForDirectory( - objects.directoryProperty().fileValue(javaHomeDirectory) - ); - JavaHome javaHome = JavaHome.of(version, providers.provider(() -> { - int actualVersion = Integer.parseInt(javaInstallationProvider.get().getJavaVersion().getMajorVersion()); - if (actualVersion != version) { - throwInvalidJavaHomeException("env variable " + javaHomeEnvVarName, javaHomeDirectory, version, actualVersion); - } - return javaHomeDirectory; - })); - javaVersions.add(javaHome); - } - } - return javaVersions; - } - - private static boolean isCurrentJavaHome(File javaHome) { - try { - return Files.isSameFile(javaHome.toPath(), Jvm.current().getJavaHome().toPath()); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - private static String getTestSeed() { - String testSeedProperty = System.getProperty("tests.seed"); - final String testSeed; - if (testSeedProperty == null) { - long seed = new Random(System.currentTimeMillis()).nextLong(); - testSeed = Long.toUnsignedString(seed, 16).toUpperCase(Locale.ROOT); - } else { - testSeed = testSeedProperty; - } - return testSeed; - } - - private static void throwInvalidJavaHomeException(String description, File javaHome, int expectedVersion, int actualVersion) { - String message = String.format( - Locale.ROOT, - "The %s must be set to a JDK installation directory for Java %d but is [%s] corresponding to [%s]", - description, - expectedVersion, - javaHome, - actualVersion - ); - - throw new GradleException(message); - } - - private static Optional findRuntimeJavaHome() { - String runtimeJavaProperty = System.getProperty("runtime.java"); - - if (runtimeJavaProperty != null) { - return Optional.of(new File(findJavaHome(runtimeJavaProperty))); - } - - return System.getenv("RUNTIME_JAVA_HOME") == null ? Optional.empty() : Optional.of(new File(System.getenv("RUNTIME_JAVA_HOME"))); - } - - private static String findJavaHome(String version) { - String versionedJavaHome = System.getenv(getJavaHomeEnvVarName(version)); - if (versionedJavaHome == null) { - final String exceptionMessage = String.format( - Locale.ROOT, - "$%s must be set to build OpenSearch. " - + "Note that if the variable was just set you " - + "might have to run `./gradlew --stop` for " - + "it to be picked up. See https://github.com/elastic/elasticsearch/issues/31399 details.", - getJavaHomeEnvVarName(version) - ); - - throw new GradleException(exceptionMessage); - } - return versionedJavaHome; - } - - private static String getJavaHomeEnvVarName(String version) { - return "JAVA" + version + "_HOME"; - } - - private static int findDefaultParallel(Project project) { - // It's safe to store this in a static variable since it's just a primitive so leaking memory isn't an issue - if (_defaultParallel == null) { - _defaultParallel = Math.max(1, Runtime.getRuntime().availableProcessors() / 2); - } - - return _defaultParallel; - } - - public static GitInfo gitInfo(File rootDir) { - try { - /* - * We want to avoid forking another process to run git rev-parse HEAD. Instead, we will read the refs manually. The - * documentation for this follows from https://git-scm.com/docs/gitrepository-layout and https://git-scm.com/docs/git-worktree. - * - * There are two cases to consider: - * - a plain repository with .git directory at the root of the working tree - * - a worktree with a plain text .git file at the root of the working tree - * - * In each case, our goal is to parse the HEAD file to get either a ref or a bare revision (in the case of being in detached - * HEAD state). - * - * In the case of a plain repository, we can read the HEAD file directly, resolved directly from the .git directory. - * - * In the case of a worktree, we read the gitdir from the plain text .git file. This resolves to a directory from which we read - * the HEAD file and resolve commondir to the plain git repository. - */ - final Path dotGit = rootDir.toPath().resolve(".git"); - final String revision; - if (Files.exists(dotGit) == false) { - return new GitInfo("unknown", "unknown"); - } - final Path head; - final Path gitDir; - if (Files.isDirectory(dotGit)) { - // this is a git repository, we can read HEAD directly - head = dotGit.resolve("HEAD"); - gitDir = dotGit; - } else { - // this is a git worktree, follow the pointer to the repository - final Path workTree = Paths.get(readFirstLine(dotGit).substring("gitdir:".length()).trim()); - if (Files.exists(workTree) == false) { - return new GitInfo("unknown", "unknown"); - } - head = workTree.resolve("HEAD"); - final Path commonDir = Paths.get(readFirstLine(workTree.resolve("commondir"))); - if (commonDir.isAbsolute()) { - gitDir = commonDir; - } else { - // this is the common case - gitDir = workTree.resolve(commonDir); - } - } - final String ref = readFirstLine(head); - if (ref.startsWith("ref:")) { - String refName = ref.substring("ref:".length()).trim(); - Path refFile = gitDir.resolve(refName); - if (Files.exists(refFile)) { - revision = readFirstLine(refFile); - } else if (Files.exists(gitDir.resolve("packed-refs"))) { - // Check packed references for commit ID - Pattern p = Pattern.compile("^([a-f0-9]{40}) " + refName + "$"); - try (Stream lines = Files.lines(gitDir.resolve("packed-refs"))) { - revision = lines.map(p::matcher) - .filter(Matcher::matches) - .map(m -> m.group(1)) - .findFirst() - .orElseThrow(() -> new IOException("Packed reference not found for refName " + refName)); - } - } else { - throw new GradleException("Can't find revision for refName " + refName); - } - } else { - // we are in detached HEAD state - revision = ref; - } - return new GitInfo(revision, findOriginUrl(gitDir.resolve("config"))); - } catch (final IOException e) { - // for now, do not be lenient until we have better understanding of real-world scenarios where this happens - throw new GradleException("unable to read the git revision", e); - } - } - - private static String findOriginUrl(final Path configFile) throws IOException { - Map props = new HashMap<>(); - - try (Stream stream = Files.lines(configFile, StandardCharsets.UTF_8)) { - Iterator lines = stream.iterator(); - boolean foundOrigin = false; - while (lines.hasNext()) { - String line = lines.next().trim(); - if (line.startsWith(";") || line.startsWith("#")) { - // ignore comments - continue; - } - if (foundOrigin) { - if (line.startsWith("[")) { - // we're on to the next config item so stop looking - break; - } - String[] pair = line.trim().split("="); - props.put(pair[0].trim(), pair[1].trim()); - } else { - if (line.equals("[remote \"origin\"]")) { - foundOrigin = true; - } - } - } - } - - String originUrl = props.get("url"); - return originUrl == null ? "unknown" : originUrl; - } - - private static String readFirstLine(final Path path) throws IOException { - String firstLine; - try (Stream lines = Files.lines(path, StandardCharsets.UTF_8)) { - firstLine = lines.findFirst().orElseThrow(() -> new IOException("file [" + path + "] is empty")); - } - return firstLine; - } - - public static class GitInfo { - private final String revision; - private final String origin; - - GitInfo(String revision, String origin) { - this.revision = revision; - this.origin = origin; - } - - public String getRevision() { - return revision; - } - - public String getOrigin() { - return origin; - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/info/JavaHome.java b/buildSrc/src/main/java/org/opensearch/gradle/info/JavaHome.java deleted file mode 100644 index 0fe3ea561ab3b..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/info/JavaHome.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.info; - -import org.gradle.api.provider.Provider; - -import java.io.File; - -public class JavaHome { - private Integer version; - private Provider javaHome; - - private JavaHome(int version, Provider javaHome) { - this.version = version; - this.javaHome = javaHome; - } - - public static JavaHome of(int version, Provider javaHome) { - return new JavaHome(version, javaHome); - } - - public Integer getVersion() { - return version; - } - - public Provider getJavaHome() { - return javaHome; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/internal/BwcGitExtension.java b/buildSrc/src/main/java/org/opensearch/gradle/internal/BwcGitExtension.java deleted file mode 100644 index 52956f0cd7446..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/internal/BwcGitExtension.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.internal; - -import org.opensearch.gradle.Version; -import org.gradle.api.provider.Provider; - -import java.io.File; - -public class BwcGitExtension { - - private Provider bwcVersion; - private Provider bwcBranch; - private Provider checkoutDir; - - public Provider getBwcVersion() { - return bwcVersion; - } - - public void setBwcVersion(Provider bwcVersion) { - this.bwcVersion = bwcVersion; - } - - public Provider getBwcBranch() { - return bwcBranch; - } - - public void setBwcBranch(Provider bwcBranch) { - this.bwcBranch = bwcBranch; - } - - public Provider getCheckoutDir() { - return checkoutDir; - } - - public void setCheckoutDir(Provider checkoutDir) { - this.checkoutDir = checkoutDir; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/internal/BwcSetupExtension.java b/buildSrc/src/main/java/org/opensearch/gradle/internal/BwcSetupExtension.java deleted file mode 100644 index 53b89a5d783e8..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/internal/BwcSetupExtension.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.internal; - -import org.apache.commons.io.FileUtils; -import org.apache.tools.ant.taskdefs.condition.Os; -import org.opensearch.gradle.BwcVersions; -import org.opensearch.gradle.LoggedExec; -import org.gradle.api.Action; -import org.gradle.api.GradleException; -import org.gradle.api.Project; -import org.gradle.api.logging.LogLevel; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.TaskProvider; - -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; -import java.util.stream.Collectors; - -import static org.opensearch.gradle.util.JavaUtil.getJavaHome; - -/** - * By registering bwc tasks via this extension we can support declaring custom bwc tasks from the build script - * without relying on groovy closures and sharing common logic for tasks created by the BwcSetup plugin already. - * */ -public class BwcSetupExtension { - - private final Project project; - - private final Provider unreleasedVersionInfo; - private Provider checkoutDir; - - public BwcSetupExtension( - Project project, - Provider unreleasedVersionInfo, - Provider checkoutDir - ) { - this.project = project; - this.unreleasedVersionInfo = unreleasedVersionInfo; - this.checkoutDir = checkoutDir; - } - - TaskProvider bwcTask(String name, Action configuration) { - return createRunBwcGradleTask(project, name, configuration); - } - - private TaskProvider createRunBwcGradleTask(Project project, String name, Action configAction) { - return project.getTasks().register(name, LoggedExec.class, loggedExec -> { - // TODO revisit - loggedExec.dependsOn("checkoutBwcBranch"); - loggedExec.setSpoolOutput(true); - loggedExec.setWorkingDir(checkoutDir.get()); - loggedExec.doFirst(t -> { - // Execution time so that the checkouts are available - String javaVersionsString = readFromFile(new File(checkoutDir.get(), ".ci/java-versions.properties")); - loggedExec.environment( - "JAVA_HOME", - getJavaHome( - Integer.parseInt( - Arrays.asList(javaVersionsString.split("\n")) - .stream() - .filter(l -> l.trim().startsWith("OPENSEARCH_BUILD_JAVA=")) - .map(l -> l.replace("OPENSEARCH_BUILD_JAVA=java", "").trim()) - .map(l -> l.replace("OPENSEARCH_BUILD_JAVA=openjdk", "").trim()) - .collect(Collectors.joining("!!")) - ) - ) - ); - loggedExec.environment( - "RUNTIME_JAVA_HOME", - getJavaHome( - Integer.parseInt( - Arrays.asList(javaVersionsString.split("\n")) - .stream() - .filter(l -> l.trim().startsWith("OPENSEARCH_RUNTIME_JAVA=")) - .map(l -> l.replace("OPENSEARCH_RUNTIME_JAVA=java", "").trim()) - .map(l -> l.replace("OPENSEARCH_RUNTIME_JAVA=openjdk", "").trim()) - .collect(Collectors.joining("!!")) - ) - ) - ); - }); - - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - loggedExec.executable("cmd"); - loggedExec.args("/C", "call", new File(checkoutDir.get(), "gradlew").toString()); - } else { - loggedExec.executable(new File(checkoutDir.get(), "gradlew").toString()); - } - if (project.getGradle().getStartParameter().isOffline()) { - loggedExec.args("--offline"); - } - // TODO resolve - String buildCacheUrl = System.getProperty("org.opensearch.build.cache.url"); - if (buildCacheUrl != null) { - loggedExec.args("-Dorg.opensearch.build.cache.url=" + buildCacheUrl); - } - - loggedExec.args("-Dbuild.snapshot=true"); - loggedExec.args("-Dscan.tag.NESTED"); - final LogLevel logLevel = project.getGradle().getStartParameter().getLogLevel(); - List nonDefaultLogLevels = Arrays.asList(LogLevel.QUIET, LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG); - if (nonDefaultLogLevels.contains(logLevel)) { - loggedExec.args("--" + logLevel.name().toLowerCase(Locale.ENGLISH)); - } - final String showStacktraceName = project.getGradle().getStartParameter().getShowStacktrace().name(); - assert Arrays.asList("INTERNAL_EXCEPTIONS", "ALWAYS", "ALWAYS_FULL").contains(showStacktraceName); - if (showStacktraceName.equals("ALWAYS")) { - loggedExec.args("--stacktrace"); - } else if (showStacktraceName.equals("ALWAYS_FULL")) { - loggedExec.args("--full-stacktrace"); - } - if (project.getGradle().getStartParameter().isParallelProjectExecutionEnabled()) { - loggedExec.args("--parallel"); - } - loggedExec.setStandardOutput(new IndentingOutputStream(System.out, unreleasedVersionInfo.get().version)); - loggedExec.setErrorOutput(new IndentingOutputStream(System.err, unreleasedVersionInfo.get().version)); - configAction.execute(loggedExec); - }); - } - - private static class IndentingOutputStream extends OutputStream { - - public final byte[] indent; - private final OutputStream delegate; - - IndentingOutputStream(OutputStream delegate, Object version) { - this.delegate = delegate; - indent = (" [" + version + "] ").getBytes(StandardCharsets.UTF_8); - } - - @Override - public void write(int b) throws IOException { - int[] arr = { b }; - write(arr, 0, 1); - } - - public void write(int[] bytes, int offset, int length) throws IOException { - for (int i = 0; i < bytes.length; i++) { - delegate.write(bytes[i]); - if (bytes[i] == '\n') { - delegate.write(indent); - } - } - } - } - - private static String readFromFile(File file) { - try { - return FileUtils.readFileToString(file).trim(); - } catch (IOException ioException) { - throw new GradleException("Cannot read java properties file.", ioException); - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/internal/DistributionArchive.java b/buildSrc/src/main/java/org/opensearch/gradle/internal/DistributionArchive.java deleted file mode 100644 index 58b104874f5bb..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/internal/DistributionArchive.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.internal; - -import org.gradle.api.Named; -import org.gradle.api.file.CopySpec; -import org.gradle.api.tasks.Sync; -import org.gradle.api.tasks.TaskProvider; -import org.gradle.api.tasks.bundling.AbstractArchiveTask; - -import java.util.function.Supplier; - -public class DistributionArchive implements Named { - - private TaskProvider archiveTask; - private TaskProvider expandedDistTask; - private final String name; - - public DistributionArchive(TaskProvider archiveTask, TaskProvider expandedDistTask, String name) { - this.archiveTask = archiveTask; - this.expandedDistTask = expandedDistTask; - this.name = name; - } - - public void setArchiveClassifier(String classifier) { - this.archiveTask.configure(abstractArchiveTask -> abstractArchiveTask.getArchiveClassifier().set(classifier)); - } - - public void content(Supplier p) { - this.archiveTask.configure(t -> t.with(p.get())); - this.expandedDistTask.configure(t -> t.with(p.get())); - } - - @Override - public String getName() { - return name; - } - - public TaskProvider getArchiveTask() { - return archiveTask; - } - - public TaskProvider getExpandedDistTask() { - return expandedDistTask; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/internal/DistributionArchiveCheckExtension.java b/buildSrc/src/main/java/org/opensearch/gradle/internal/DistributionArchiveCheckExtension.java deleted file mode 100644 index 004f79d1a0b49..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/internal/DistributionArchiveCheckExtension.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.internal; - -import org.gradle.api.model.ObjectFactory; -import org.gradle.api.provider.ListProperty; - -public class DistributionArchiveCheckExtension { - - ListProperty expectedMlLicenses; - - public DistributionArchiveCheckExtension(ObjectFactory factory) { - this.expectedMlLicenses = factory.listProperty(String.class); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalBwcGitPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalBwcGitPlugin.java deleted file mode 100644 index 11270e5c9a51d..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalBwcGitPlugin.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.internal; - -import org.apache.commons.io.FileUtils; -import org.opensearch.gradle.LoggedExec; -import org.opensearch.gradle.info.GlobalBuildInfoPlugin; -import org.gradle.api.Action; -import org.gradle.api.GradleException; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.logging.Logger; -import org.gradle.api.plugins.ExtraPropertiesExtension; -import org.gradle.api.provider.Provider; -import org.gradle.api.provider.ProviderFactory; -import org.gradle.api.tasks.TaskContainer; -import org.gradle.api.tasks.TaskProvider; -import org.gradle.process.ExecOperations; -import org.gradle.process.ExecResult; -import org.gradle.process.ExecSpec; - -import javax.inject.Inject; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.UncheckedIOException; -import static java.util.Arrays.asList; - -public class InternalBwcGitPlugin implements Plugin { - - private final ProviderFactory providerFactory; - private final ExecOperations execOperations; - - private BwcGitExtension gitExtension; - private Project project; - - @Inject - public InternalBwcGitPlugin(ProviderFactory providerFactory, ExecOperations execOperations) { - this.providerFactory = providerFactory; - this.execOperations = execOperations; - } - - @Override - public void apply(Project project) { - this.project = project; - this.gitExtension = project.getExtensions().create("bwcGitConfig", BwcGitExtension.class); - Provider remote = providerFactory.systemProperty("bwc.remote").forUseAtConfigurationTime().orElse("opensearch-project"); - - TaskContainer tasks = project.getTasks(); - TaskProvider createCloneTaskProvider = tasks.register("createClone", LoggedExec.class, createClone -> { - createClone.onlyIf(task -> this.gitExtension.getCheckoutDir().get().exists() == false); - createClone.setCommandLine(asList("git", "clone", project.getRootDir(), gitExtension.getCheckoutDir().get())); - }); - - TaskProvider findRemoteTaskProvider = tasks.register("findRemote", LoggedExec.class, findRemote -> { - findRemote.dependsOn(createCloneTaskProvider); - // TODO Gradle should provide property based configuration here - findRemote.setWorkingDir(gitExtension.getCheckoutDir().get()); - - findRemote.setCommandLine(asList("git", "remote", "-v")); - ByteArrayOutputStream output = new ByteArrayOutputStream(); - findRemote.setStandardOutput(output); - findRemote.doLast(t -> { - ExtraPropertiesExtension extraProperties = project.getExtensions().getExtraProperties(); - extraProperties.set("remoteExists", isRemoteAvailable(remote, output)); - }); - }); - - TaskProvider addRemoteTaskProvider = tasks.register("addRemote", LoggedExec.class, addRemote -> { - addRemote.dependsOn(findRemoteTaskProvider); - addRemote.onlyIf(task -> ((boolean) project.getExtensions().getExtraProperties().get("remoteExists")) == false); - addRemote.setWorkingDir(gitExtension.getCheckoutDir().get()); - String remoteRepo = remote.get(); - // for testing only we can override the base remote url - String remoteRepoUrl = providerFactory.systemProperty("testRemoteRepo") - .forUseAtConfigurationTime() - .getOrElse("https://github.com/" + remoteRepo + "/OpenSearch.git"); - addRemote.setCommandLine(asList("git", "remote", "add", remoteRepo, remoteRepoUrl)); - }); - - TaskProvider fetchLatestTaskProvider = tasks.register("fetchLatest", LoggedExec.class, fetchLatest -> { - Provider gitFetchLatest = project.getProviders() - .systemProperty("tests.bwc.git_fetch_latest") - .forUseAtConfigurationTime() - .orElse("true") - .map(fetchProp -> { - if ("true".equals(fetchProp)) { - return true; - } - if ("false".equals(fetchProp)) { - return false; - } - throw new GradleException("tests.bwc.git_fetch_latest must be [true] or [false] but was [" + fetchProp + "]"); - }); - fetchLatest.onlyIf(t -> project.getGradle().getStartParameter().isOffline() == false && gitFetchLatest.get() != null); - fetchLatest.dependsOn(addRemoteTaskProvider); - fetchLatest.setWorkingDir(gitExtension.getCheckoutDir().get()); - fetchLatest.setCommandLine(asList("git", "fetch", "--all")); - }); - - tasks.register("checkoutBwcBranch", checkoutBwcBranch -> { - checkoutBwcBranch.dependsOn(fetchLatestTaskProvider); - checkoutBwcBranch.doLast(t -> { - Logger logger = project.getLogger(); - - String bwcBranch = this.gitExtension.getBwcBranch().get(); - final String refspec = providerFactory.systemProperty("bwc.refspec." + bwcBranch) - .orElse(providerFactory.systemProperty("tests.bwc.refspec." + bwcBranch)) - .getOrElse(remote.get() + "/" + bwcBranch); - - String effectiveRefSpec = maybeAlignedRefSpec(logger, refspec); - - logger.lifecycle("Performing checkout of {}...", refspec); - LoggedExec.exec(project, spec -> { - spec.workingDir(gitExtension.getCheckoutDir()); - spec.commandLine("git", "checkout", effectiveRefSpec); - }); - - String checkoutHash = GlobalBuildInfoPlugin.gitInfo(gitExtension.getCheckoutDir().get()).getRevision(); - logger.lifecycle("Checkout hash for {} is {}", project.getPath(), checkoutHash); - writeFile(new File(project.getBuildDir(), "refspec"), checkoutHash); - }); - }); - } - - public BwcGitExtension getGitExtension() { - return gitExtension; - } - - /** - * We use a time based approach to make the bwc versions built deterministic and compatible with the current hash. - * Most of the time we want to test against latest, but when running delayed exhaustive tests or wanting - * reproducible builds we want this to be deterministic by using a hash that was the latest when the current - * commit was made. - *

    - * This approach doesn't work with merge commits as these can introduce commits in the chronological order - * after the fact e.x. a merge done today can add commits dated with yesterday so the result will no longer be - * deterministic. - *

    - * We don't use merge commits, but for additional safety we check that no such commits exist in the time period - * we are interested in. - *

    - * Timestamps are at seconds resolution. rev-parse --before and --after are inclusive w.r.t the second - * passed as input. This means the results might not be deterministic in the current second, but this - * should not matter in practice. - */ - private String maybeAlignedRefSpec(Logger logger, String defaultRefSpec) { - if (providerFactory.systemProperty("bwc.checkout.align").isPresent() == false) { - return defaultRefSpec; - } - - String timeOfCurrent = execInCheckoutDir(execSpec -> { - execSpec.commandLine(asList("git", "show", "--no-patch", "--no-notes", "--pretty='%cD'")); - execSpec.workingDir(project.getRootDir()); - }); - - logger.lifecycle("Commit date of current: {}", timeOfCurrent); - - String mergeCommits = execInCheckoutDir( - spec -> spec.commandLine(asList("git", "rev-list", defaultRefSpec, "--after", timeOfCurrent, "--merges")) - ); - if (mergeCommits.isEmpty() == false) { - throw new IllegalStateException("Found the following merge commits which prevent determining bwc commits: " + mergeCommits); - } - return execInCheckoutDir( - spec -> spec.commandLine(asList("git", "rev-list", defaultRefSpec, "-n", "1", "--before", timeOfCurrent, "--date-order")) - ); - } - - private void writeFile(File file, String content) { - try { - FileUtils.writeStringToFile(file, content); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - private String execInCheckoutDir(Action execSpecConfig) { - ByteArrayOutputStream os = new ByteArrayOutputStream(); - ExecResult exec = execOperations.exec(execSpec -> { - execSpec.setStandardOutput(os); - execSpec.workingDir(gitExtension.getCheckoutDir().get()); - execSpecConfig.execute(execSpec); - }); - exec.assertNormalExitValue(); - return os.toString().trim(); - } - - private static boolean isRemoteAvailable(Provider remote, ByteArrayOutputStream output) { - return new String(output.toByteArray()).contains(remote.get() + "\t"); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPlugin.java deleted file mode 100644 index 96a2928b6e71e..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionArchiveCheckPlugin.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.internal; - -import org.opensearch.gradle.VersionProperties; -import org.gradle.api.Action; -import org.gradle.api.GradleException; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.file.ArchiveOperations; -import org.gradle.api.plugins.BasePlugin; -import org.gradle.api.tasks.Copy; -import org.gradle.api.tasks.TaskProvider; - -import javax.inject.Inject; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.stream.Collectors; - -import static org.opensearch.gradle.util.Util.capitalize; - -public class InternalDistributionArchiveCheckPlugin implements Plugin { - - private ArchiveOperations archiveOperations; - - @Inject - public InternalDistributionArchiveCheckPlugin(ArchiveOperations archiveOperations) { - this.archiveOperations = archiveOperations; - } - - @Override - public void apply(Project project) { - project.getPlugins().apply(BasePlugin.class); - String buildTaskName = calculateBuildTask(project.getName()); - TaskProvider buildDistTask = project.getParent().getTasks().named(buildTaskName); - DistributionArchiveCheckExtension distributionArchiveCheckExtension = project.getExtensions() - .create("distributionArchiveCheck", DistributionArchiveCheckExtension.class); - - File archiveExtractionDir = calculateArchiveExtractionDir(project); - // sanity checks if archives can be extracted - TaskProvider checkExtraction = registerCheckExtractionTask(project, buildDistTask, archiveExtractionDir); - checkExtraction.configure(InternalDistributionArchiveSetupPlugin.configure(buildTaskName)); - TaskProvider checkLicense = registerCheckLicenseTask(project, checkExtraction); - checkLicense.configure(InternalDistributionArchiveSetupPlugin.configure(buildTaskName)); - - TaskProvider checkNotice = registerCheckNoticeTask(project, checkExtraction); - checkNotice.configure(InternalDistributionArchiveSetupPlugin.configure(buildTaskName)); - TaskProvider checkTask = project.getTasks().named("check"); - checkTask.configure(task -> { - task.dependsOn(checkExtraction); - task.dependsOn(checkLicense); - task.dependsOn(checkNotice); - }); - } - - private File calculateArchiveExtractionDir(Project project) { - if (project.getName().contains("tar")) { - return new File(project.getBuildDir(), "tar-extracted"); - } - if (project.getName().contains("zip") == false) { - throw new GradleException("Expecting project name containing 'zip' or 'tar'."); - } - return new File(project.getBuildDir(), "zip-extracted"); - } - - private TaskProvider registerCheckNoticeTask(Project project, TaskProvider checkExtraction) { - return project.getTasks().register("checkNotice", task -> { - task.dependsOn(checkExtraction); - task.doLast(new Action() { - @Override - public void execute(Task task) { - final List noticeLines = Arrays.asList( - "OpenSearch (https://opensearch.org/)", - "Copyright OpenSearch Contributors" - ); - final Path noticePath = checkExtraction.get() - .getDestinationDir() - .toPath() - .resolve("opensearch-" + VersionProperties.getOpenSearch() + "/NOTICE.txt"); - assertLinesInFile(noticePath, noticeLines); - } - }); - }); - } - - private TaskProvider registerCheckLicenseTask(Project project, TaskProvider checkExtraction) { - return project.getTasks().register("checkLicense", task -> { - task.dependsOn(checkExtraction); - task.doLast(new Action() { - @Override - public void execute(Task task) { - String licenseFilename = "APACHE-LICENSE-2.0.txt"; - final List licenseLines; - try { - licenseLines = Files.readAllLines(project.getRootDir().toPath().resolve("licenses/" + licenseFilename)); - final Path licensePath = checkExtraction.get() - .getDestinationDir() - .toPath() - .resolve("opensearch-" + VersionProperties.getOpenSearch() + "/LICENSE.txt"); - assertLinesInFile(licensePath, licenseLines); - } catch (IOException ioException) { - ioException.printStackTrace(); - } - } - }); - }); - } - - private TaskProvider registerCheckExtractionTask(Project project, TaskProvider buildDistTask, File archiveExtractionDir) { - return project.getTasks().register("checkExtraction", Copy.class, t -> { - t.dependsOn(buildDistTask); - if (project.getName().contains("tar")) { - t.from(archiveOperations.tarTree(distTaskOutput(buildDistTask))); - } else { - t.from(archiveOperations.zipTree(distTaskOutput(buildDistTask))); - } - t.into(archiveExtractionDir); - // common sanity checks on extracted archive directly as part of checkExtraction - t.eachFile(fileCopyDetails -> assertNoClassFile(fileCopyDetails.getFile())); - }); - } - - private static void assertLinesInFile(Path path, List expectedLines) { - try { - final List actualLines = Files.readAllLines(path); - int line = 0; - for (final String expectedLine : expectedLines) { - final String actualLine = actualLines.get(line); - if (expectedLine.equals(actualLine) == false) { - throw new GradleException( - "expected line [" + (line + 1) + "] in [" + path + "] to be [" + expectedLine + "] but was [" + actualLine + "]" - ); - } - line++; - } - } catch (IOException ioException) { - throw new GradleException("Unable to read from file " + path, ioException); - } - } - - private static void assertNoClassFile(File file) { - if (file.getName().endsWith(".class")) { - throw new GradleException("Detected class file in distribution ('" + file.getName() + "')"); - } - } - - private Object distTaskOutput(TaskProvider buildDistTask) { - return new Callable() { - @Override - public File call() { - return buildDistTask.get().getOutputs().getFiles().getSingleFile(); - } - - @Override - public String toString() { - return call().getAbsolutePath(); - } - }; - } - - private String calculateBuildTask(String projectName) { - return "build" + Arrays.stream(projectName.split("-")).map(f -> capitalize(f)).collect(Collectors.joining()); - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionArchiveSetupPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionArchiveSetupPlugin.java deleted file mode 100644 index 0944f3960467b..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionArchiveSetupPlugin.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.internal; - -import org.opensearch.gradle.EmptyDirTask; -import org.opensearch.gradle.tar.SymbolicLinkPreservingTar; -import org.gradle.api.Action; -import org.gradle.api.NamedDomainObjectContainer; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.type.ArtifactTypeDefinition; -import org.gradle.api.plugins.BasePlugin; -import org.gradle.api.logging.Logger; -import org.gradle.api.logging.Logging; -import org.gradle.api.tasks.AbstractCopyTask; -import org.gradle.api.tasks.Sync; -import org.gradle.api.tasks.TaskContainer; -import org.gradle.api.tasks.TaskProvider; -import org.gradle.api.tasks.bundling.AbstractArchiveTask; -import org.gradle.api.tasks.bundling.Compression; -import org.gradle.api.tasks.bundling.Zip; -import org.gradle.internal.os.OperatingSystem; -import java.io.File; - -import static org.opensearch.gradle.util.Util.capitalize; -import static org.gradle.api.internal.artifacts.ArtifactAttributes.ARTIFACT_FORMAT; - -/** - * Provides a DSL and common configurations to define different types of - * OpenSearch distribution archives. See ':distribution:archives'. - *

    - * This configures the default artifacts for the distribution specific - * subprojects. We have subprojects for two reasons: - * 1. Gradle project substitutions can only bind to the default - * configuration of a project - * 2. The integ-test-zip and zip distributions have the exact same - * filename, so they must be placed in different directories. - * 3. We provide a packed and an unpacked variant of the distribution - * - the unpacked variant is used by consumers like test cluster definitions - * 4. Having per-distribution sub-projects means we can build them in parallel. - */ -public class InternalDistributionArchiveSetupPlugin implements Plugin { - private static final Logger LOGGER = Logging.getLogger(InternalDistributionArchiveSetupPlugin.class); - - public static final String DEFAULT_CONFIGURATION_NAME = "default"; - public static final String EXTRACTED_CONFIGURATION_NAME = "extracted"; - private NamedDomainObjectContainer container; - - @Override - public void apply(Project project) { - project.getPlugins().apply(BasePlugin.class); - registerAndConfigureDistributionArchivesExtension(project); - registerEmptyDirectoryTasks(project); - configureGeneralTaskDefaults(project); - configureTarDefaults(project); - } - - static Action configure(String name) { - return (Task task) -> task.onlyIf(s -> { - if (OperatingSystem.current().isWindows()) { - // On Windows, include only Windows distributions and integTestZip - final String nameLowerCased = name.toLowerCase(); - final boolean skip = !(nameLowerCased.contains("windows") || nameLowerCased.contains("integtest")); - - if (skip) { - LOGGER.info("Skipping task " + name + " since it does not match current OS platform"); - } - - return !skip; - } else { - return true; - } - }); - } - - private void registerAndConfigureDistributionArchivesExtension(Project project) { - container = project.container(DistributionArchive.class, name -> { - String subProjectDir = archiveToSubprojectName(name); - String copyDistributionTaskName = "build" + capitalize(name.substring(0, name.length() - 3)); - TaskContainer tasks = project.getTasks(); - TaskProvider explodedDist = tasks.register( - copyDistributionTaskName, - Sync.class, - sync -> sync.into(subProjectDir + "/build/install/") - ); - explodedDist.configure(configure(name)); - String archiveTaskName = "build" + capitalize(name); - - TaskProvider archiveTask = name.endsWith("Tar") - ? tasks.register(archiveTaskName, SymbolicLinkPreservingTar.class) - : tasks.register(archiveTaskName, Zip.class); - archiveTask.configure(configure(name)); - - return new DistributionArchive(archiveTask, explodedDist, name); - }); - // Each defined distribution archive is linked to a subproject. - // A distribution archive definition not matching a sub project will result in build failure. - container.whenObjectAdded(distributionArchive -> { - String subProjectName = archiveToSubprojectName(distributionArchive.getName()); - project.project(subProjectName, sub -> { - sub.getPlugins().apply(BasePlugin.class); - sub.getArtifacts().add(DEFAULT_CONFIGURATION_NAME, distributionArchive.getArchiveTask()); - Configuration extractedConfiguration = sub.getConfigurations().create("extracted"); - extractedConfiguration.setCanBeResolved(false); - extractedConfiguration.getAttributes().attribute(ARTIFACT_FORMAT, ArtifactTypeDefinition.DIRECTORY_TYPE); - sub.getArtifacts().add(EXTRACTED_CONFIGURATION_NAME, distributionArchive.getExpandedDistTask()); - - }); - }); - project.getExtensions().add("distribution_archives", container); - } - - private void configureGeneralTaskDefaults(Project project) { - // common config across all copy / archive tasks - project.getTasks().withType(AbstractCopyTask.class).configureEach(t -> { - t.dependsOn(project.getTasks().withType(EmptyDirTask.class)); - t.setIncludeEmptyDirs(true); - t.setDirMode(0755); - t.setFileMode(0644); - }); - - // common config across all archives - project.getTasks().withType(AbstractArchiveTask.class).configureEach(t -> { - String subdir = archiveTaskToSubprojectName(t.getName()); - t.getDestinationDirectory().set(project.file(subdir + "/build/distributions")); - t.getArchiveBaseName().set("opensearch-min"); - }); - } - - private void configureTarDefaults(Project project) { - // common config across all tars - project.getTasks().withType(SymbolicLinkPreservingTar.class).configureEach(t -> { - t.getArchiveExtension().set("tar.gz"); - t.setCompression(Compression.GZIP); - }); - } - - private void registerEmptyDirectoryTasks(Project project) { - // CopySpec does not make it easy to create an empty directory so we - // create the directory that we want, and then point CopySpec to its - // parent to copy to the root of the distribution - File logsDir = new File(project.getBuildDir(), "logs-hack/logs"); - project.getExtensions().getExtraProperties().set("logsDir", new File(project.getBuildDir(), "logs-hack/logs")); - project.getTasks().register("createLogsDir", EmptyDirTask.class, t -> { - t.setDir(logsDir); - t.setDirMode(0755); - }); - - File pluginsDir = new File(project.getBuildDir(), "plugins-hack/plugins"); - project.getExtensions().add("pluginsDir", pluginsDir); - project.getTasks().register("createPluginsDir", EmptyDirTask.class, t -> { - t.setDir(pluginsDir); - t.setDirMode(0755); - }); - - File jvmOptionsDir = new File(project.getBuildDir(), "jvm-options-hack/jvm.options.d"); - project.getExtensions().add("jvmOptionsDir", jvmOptionsDir); - project.getTasks().register("createJvmOptionsDir", EmptyDirTask.class, t -> { - t.setDir(jvmOptionsDir); - t.setDirMode(0750); - }); - } - - private static String archiveTaskToSubprojectName(String taskName) { - return archiveToSubprojectName(taskName).substring("build".length() + 1); - } - - private static String archiveToSubprojectName(String taskName) { - return taskName.replaceAll("[A-Z]", "-$0").toLowerCase(); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin.java deleted file mode 100644 index 36e7adf1ae98e..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.internal; - -import org.opensearch.gradle.BwcVersions; -import org.opensearch.gradle.Version; -import org.opensearch.gradle.info.BuildParams; -import org.opensearch.gradle.info.GlobalBuildInfoPlugin; -import org.gradle.api.InvalidUserDataException; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.provider.Provider; -import org.gradle.api.provider.ProviderFactory; -import org.gradle.api.tasks.TaskProvider; -import org.gradle.language.base.plugins.LifecycleBasePlugin; - -import javax.inject.Inject; -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.stream.Collectors; - -import static java.util.Arrays.asList; -import static java.util.Arrays.stream; - -/** - * We want to be able to do BWC tests for unreleased versions without relying on and waiting for snapshots. - * For this we need to check out and build the unreleased versions. - * Since these depend on the current version, we can't name the Gradle projects statically, and don't know what the - * unreleased versions are when Gradle projects are set up, so we use "build-unreleased-version-*" as placeholders - * and configure them to build various versions here. - */ -public class InternalDistributionBwcSetupPlugin implements Plugin { - - private ProviderFactory providerFactory; - - @Inject - public InternalDistributionBwcSetupPlugin(ProviderFactory providerFactory) { - this.providerFactory = providerFactory; - } - - @Override - public void apply(Project project) { - project.getRootProject().getPluginManager().apply(GlobalBuildInfoPlugin.class); - BuildParams.getBwcVersions() - .forPreviousUnreleased( - (BwcVersions.UnreleasedVersionInfo unreleasedVersion) -> { - configureBwcProject(project.project(unreleasedVersion.gradleProjectPath), unreleasedVersion); - } - ); - } - - private void configureBwcProject(Project project, BwcVersions.UnreleasedVersionInfo versionInfo) { - Provider versionInfoProvider = providerFactory.provider(() -> versionInfo); - Provider checkoutDir = versionInfoProvider.map(info -> new File(project.getBuildDir(), "bwc/checkout-" + info.branch)); - BwcSetupExtension bwcSetupExtension = project.getExtensions() - .create("bwcSetup", BwcSetupExtension.class, project, versionInfoProvider, checkoutDir); - BwcGitExtension gitExtension = project.getPlugins().apply(InternalBwcGitPlugin.class).getGitExtension(); - Provider bwcVersion = versionInfoProvider.map(info -> info.version); - gitExtension.setBwcVersion(versionInfoProvider.map(info -> info.version)); - gitExtension.setBwcBranch(versionInfoProvider.map(info -> info.branch)); - gitExtension.setCheckoutDir(checkoutDir); - - // we want basic lifecycle tasks like `clean` here. - project.getPlugins().apply(LifecycleBasePlugin.class); - - TaskProvider buildBwcTaskProvider = project.getTasks().register("buildBwc"); - List distributionProjects = resolveArchiveProjects(checkoutDir.get(), bwcVersion.get()); - - for (DistributionProject distributionProject : distributionProjects) { - createBuildBwcTask( - bwcSetupExtension, - project, - bwcVersion, - distributionProject.name, - distributionProject.getProjectPath(), - distributionProject.getDistFile(), - buildBwcTaskProvider - ); - - registerBwcArtifacts(project, distributionProject); - } - } - - private void registerBwcArtifacts(Project bwcProject, DistributionProject distributionProject) { - String projectName = distributionProject.name; - String buildBwcTask = buildBwcTaskName(projectName); - - registerDistributionArchiveArtifact(bwcProject, distributionProject, buildBwcTask); - if (distributionProject.getExpandedDistDirectory() != null) { - String expandedDistConfiguration = "expanded-" + projectName; - bwcProject.getConfigurations().create(expandedDistConfiguration); - bwcProject.getArtifacts().add(expandedDistConfiguration, distributionProject.getExpandedDistDirectory(), artifact -> { - artifact.setName("opensearch"); - artifact.builtBy(buildBwcTask); - artifact.setType("directory"); - }); - } - } - - private void registerDistributionArchiveArtifact(Project bwcProject, DistributionProject distributionProject, String buildBwcTask) { - String artifactFileName = distributionProject.getDistFile().getName(); - String artifactName = "opensearch"; - - String suffix = artifactFileName.endsWith("tar.gz") ? "tar.gz" : artifactFileName.substring(artifactFileName.length() - 3); - int archIndex = artifactFileName.indexOf("x64"); - - bwcProject.getConfigurations().create(distributionProject.name); - bwcProject.getArtifacts().add(distributionProject.name, distributionProject.getDistFile(), artifact -> { - artifact.setName(artifactName); - artifact.builtBy(buildBwcTask); - artifact.setType(suffix); - - String classifier = ""; - if (archIndex != -1) { - int osIndex = artifactFileName.lastIndexOf('-', archIndex - 2); - classifier = "-" + artifactFileName.substring(osIndex + 1, archIndex - 1) + "-x64"; - } - artifact.setClassifier(classifier); - }); - } - - private static List resolveArchiveProjects(File checkoutDir, Version bwcVersion) { - List projects = new ArrayList<>(); - // All active BWC branches publish rpm and deb packages - projects.addAll(asList("deb", "rpm")); - - if (bwcVersion.onOrAfter("7.0.0")) { // starting with 7.0 we bundle a jdk which means we have platform-specific archives - projects.addAll( - asList( - "darwin-tar", - "darwin-arm64-tar", - "linux-tar", - "linux-arm64-tar", - "linux-ppc64le-tar", - "linux-s390x-tar", - "windows-zip" - ) - ); - } else { // prior to 7.0 we published only a single zip and tar archives - projects.addAll(asList("zip", "tar")); - } - - return projects.stream().map(name -> { - String baseDir = "distribution" + (name.endsWith("zip") || name.endsWith("tar") ? "/archives" : "/packages"); - String classifier = ""; - String extension = name; - if (bwcVersion.onOrAfter("7.0.0")) { - if (name.contains("zip") || name.contains("tar")) { - int index = name.lastIndexOf('-'); - String baseName = name.substring(0, index); - classifier = "-" + baseName + "-x64"; - extension = name.substring(index + 1); - if (extension.equals("tar")) { - extension += ".gz"; - } - } else if (name.contains("deb")) { - classifier = "-amd64"; - } else if (name.contains("rpm")) { - classifier = "-x64"; - } - } else { - extension = name.substring(4); - } - return new DistributionProject(name, baseDir, bwcVersion, classifier, extension, checkoutDir); - }).collect(Collectors.toList()); - } - - private static String buildBwcTaskName(String projectName) { - return "buildBwc" - + stream(projectName.split("-")).map(i -> i.substring(0, 1).toUpperCase(Locale.ROOT) + i.substring(1)) - .collect(Collectors.joining()); - } - - static void createBuildBwcTask( - BwcSetupExtension bwcSetupExtension, - Project project, - Provider bwcVersion, - String projectName, - String projectPath, - File projectArtifact, - TaskProvider bwcTaskProvider - ) { - String bwcTaskName = buildBwcTaskName(projectName); - bwcSetupExtension.bwcTask(bwcTaskName, c -> { - c.getInputs().file(new File(project.getBuildDir(), "refspec")); - c.getOutputs().files(projectArtifact); - c.getOutputs().cacheIf("BWC distribution caching is disabled on 'master' branch", task -> { - String gitBranch = System.getenv("GIT_BRANCH"); - return BuildParams.isCi() && (gitBranch == null || gitBranch.endsWith("master") == false); - }); - c.args(projectPath.replace('/', ':') + ":assemble"); - if (project.getGradle().getStartParameter().isBuildCacheEnabled()) { - c.args("--build-cache"); - } - c.doLast(task -> { - if (projectArtifact.exists() == false) { - throw new InvalidUserDataException( - "Building " + bwcVersion.get() + " didn't generate expected file " + projectArtifact - ); - } - }); - }); - bwcTaskProvider.configure(t -> t.dependsOn(bwcTaskName)); - } - - /** - * Represents an archive project (distribution/archives/*) - * we build from a bwc Version in a cloned repository - */ - private static class DistributionProject { - private final String name; - private String projectPath; - private File distFile; - private File expandedDistDir; - - DistributionProject(String name, String baseDir, Version version, String classifier, String extension, File checkoutDir) { - this.name = name; - this.projectPath = baseDir + "/" + name; - if (version.onOrAfter("1.1.0")) { - this.distFile = new File( - checkoutDir, - baseDir + "/" + name + "/build/distributions/opensearch-min-" + version + "-SNAPSHOT" + classifier + "." + extension - ); - } else { - this.distFile = new File( - checkoutDir, - baseDir + "/" + name + "/build/distributions/opensearch-" + version + "-SNAPSHOT" + classifier + "." + extension - ); - } - // we only ported this down to the 7.x branch. - if (version.onOrAfter("7.10.0") && (name.endsWith("zip") || name.endsWith("tar"))) { - this.expandedDistDir = new File(checkoutDir, baseDir + "/" + name + "/build/install"); - } - } - - public String getProjectPath() { - return projectPath; - } - - public File getDistFile() { - return distFile; - } - - public File getExpandedDistDirectory() { - return expandedDistDir; - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionDownloadPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionDownloadPlugin.java deleted file mode 100644 index f4368b1cecc59..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionDownloadPlugin.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.internal; - -import org.opensearch.gradle.Architecture; -import org.opensearch.gradle.BwcVersions; -import org.opensearch.gradle.DistributionDependency; -import org.opensearch.gradle.DistributionDownloadPlugin; -import org.opensearch.gradle.DistributionResolution; -import org.opensearch.gradle.OpenSearchDistribution; -import org.opensearch.gradle.Version; -import org.opensearch.gradle.VersionProperties; -import org.opensearch.gradle.info.BuildParams; -import org.opensearch.gradle.info.GlobalBuildInfoPlugin; -import org.gradle.api.GradleException; -import org.gradle.api.NamedDomainObjectContainer; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.artifacts.Dependency; - -import java.util.function.Function; - -import static org.opensearch.gradle.util.GradleUtils.projectDependency; - -/** - * An internal opensearch build plugin that registers additional - * distribution resolution strategies to the 'opensearch.download-distribution' plugin - * to resolve distributions from a local snapshot or a locally built bwc snapshot. - */ -public class InternalDistributionDownloadPlugin implements Plugin { - - private BwcVersions bwcVersions = null; - - @Override - public void apply(Project project) { - // this is needed for isInternal - project.getRootProject().getPluginManager().apply(GlobalBuildInfoPlugin.class); - if (!BuildParams.isInternal()) { - throw new GradleException( - "Plugin 'opensearch.internal-distribution-download' is not supported. " - + "Use 'opensearch.distribution-download' plugin instead." - ); - } - project.getPluginManager().apply(DistributionDownloadPlugin.class); - this.bwcVersions = BuildParams.getBwcVersions(); - registerInternalDistributionResolutions(DistributionDownloadPlugin.getRegistrationsContainer(project)); - } - - /** - * Registers internal distribution resolutions. - *

    - * OpenSearch distributions are resolved as project dependencies either representing - * the current version pointing to a project either under `:distribution:archives` or :distribution:packages`. - *

    - * BWC versions are resolved as project to projects under `:distribution:bwc`. - */ - private void registerInternalDistributionResolutions(NamedDomainObjectContainer resolutions) { - - resolutions.register("localBuild", distributionResolution -> distributionResolution.setResolver((project, distribution) -> { - if (VersionProperties.getOpenSearch().equals(distribution.getVersion())) { - // non-external project, so depend on local build - return new ProjectBasedDistributionDependency( - config -> projectDependency(project, distributionProjectPath(distribution), config) - ); - } - return null; - })); - - resolutions.register("bwc", distributionResolution -> distributionResolution.setResolver((project, distribution) -> { - BwcVersions.UnreleasedVersionInfo unreleasedInfo = bwcVersions.unreleasedInfo(Version.fromString(distribution.getVersion())); - if (unreleasedInfo != null) { - if (!distribution.getBundledJdk()) { - throw new GradleException( - "Configuring a snapshot bwc distribution ('" - + distribution.getName() - + "') " - + "without a bundled JDK is not supported." - ); - } - String projectConfig = getProjectConfig(distribution, unreleasedInfo); - return new ProjectBasedDistributionDependency( - (config) -> projectDependency(project, unreleasedInfo.gradleProjectPath, projectConfig) - ); - } - return null; - })); - } - - /** - * Will be removed once this is backported to all unreleased branches. - */ - private static String getProjectConfig(OpenSearchDistribution distribution, BwcVersions.UnreleasedVersionInfo info) { - String distributionProjectName = distributionProjectName(distribution); - if (distribution.getType().shouldExtract()) { - return (info.gradleProjectPath.equals(":distribution") || info.version.before("7.10.0")) - ? distributionProjectName - : "expanded-" + distributionProjectName; - } else { - return distributionProjectName; - - } - - } - - private static String distributionProjectPath(OpenSearchDistribution distribution) { - String projectPath = ":distribution"; - switch (distribution.getType()) { - case INTEG_TEST_ZIP: - projectPath += ":archives:integ-test-zip"; - break; - - case DOCKER: - projectPath += ":docker:"; - projectPath += distributionProjectName(distribution); - break; - - default: - projectPath += distribution.getType() == OpenSearchDistribution.Type.ARCHIVE ? ":archives:" : ":packages:"; - projectPath += distributionProjectName(distribution); - break; - } - return projectPath; - } - - /** - * Works out the gradle project name that provides a distribution artifact. - * - * @param distribution the distribution from which to derive a project name - * @return the name of a project. It is not the full project path, only the name. - */ - private static String distributionProjectName(OpenSearchDistribution distribution) { - OpenSearchDistribution.Platform platform = distribution.getPlatform(); - Architecture architecture = distribution.getArchitecture(); - String projectName = ""; - - final String archString = platform == OpenSearchDistribution.Platform.WINDOWS || architecture == Architecture.X64 - ? "" - : "-" + architecture.toString().toLowerCase(); - - if (distribution.getBundledJdk() == false) { - projectName += "no-jdk-"; - } - switch (distribution.getType()) { - case ARCHIVE: - if (Version.fromString(distribution.getVersion()).onOrAfter("7.0.0")) { - projectName += platform.toString() + archString + (platform == OpenSearchDistribution.Platform.WINDOWS - ? "-zip" - : "-tar"); - } else { - projectName = "zip"; - } - break; - - case DOCKER: - projectName += "docker" + archString + "-export"; - break; - - default: - projectName += distribution.getType(); - break; - } - return projectName; - } - - private static class ProjectBasedDistributionDependency implements DistributionDependency { - - private Function function; - - ProjectBasedDistributionDependency(Function function) { - this.function = function; - } - - @Override - public Object getDefaultNotation() { - return function.apply("default"); - } - - @Override - public Object getExtractedNotation() { - return function.apply("extracted"); - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/plugin/PluginPropertiesExtension.java b/buildSrc/src/main/java/org/opensearch/gradle/plugin/PluginPropertiesExtension.java deleted file mode 100644 index d6117923973fa..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/plugin/PluginPropertiesExtension.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.plugin; - -import org.gradle.api.Project; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * A container for plugin properties that will be written to the plugin descriptor, for easy - * manipulation in the gradle DSL. - */ -public class PluginPropertiesExtension { - private String name; - - private String version; - - private String description; - - private String classname; - - private String customFolderName = ""; - - /** Other plugins this plugin extends through SPI */ - private List extendedPlugins = new ArrayList<>(); - - private boolean hasNativeController; - - /** True if the plugin requires the opensearch keystore to exist, false otherwise. */ - private boolean requiresKeystore; - - /** A license file that should be included in the built plugin zip. */ - private File licenseFile; - - private boolean hasClientJar = false; - - /** - * A notice file that should be included in the built plugin zip. This will be - * extended with notices from the {@code licenses/} directory. - */ - private File noticeFile; - - private final Project project; - - public PluginPropertiesExtension(Project project) { - this.project = project; - } - - public String getCustomFolderName() { - return customFolderName; - } - - public void setCustomFolderName(String customFolderName) { - this.customFolderName = customFolderName; - } - - public String getName() { - return name == null ? project.getName() : name; - } - - public void setName(String name) { - this.name = name; - } - - public String getVersion() { - return version == null ? project.getVersion().toString() : version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getClassname() { - return classname; - } - - public void setClassname(String classname) { - this.classname = classname; - } - - public List getExtendedPlugins() { - return this.extendedPlugins; - } - - public boolean isHasNativeController() { - return hasNativeController; - } - - public void setHasNativeController(boolean hasNativeController) { - this.hasNativeController = hasNativeController; - } - - public boolean isRequiresKeystore() { - return requiresKeystore; - } - - public void setRequiresKeystore(boolean requiresKeystore) { - this.requiresKeystore = requiresKeystore; - } - - public File getLicenseFile() { - return licenseFile; - } - - public void setLicenseFile(File licenseFile) { - this.project.getExtensions().getExtraProperties().set("licenseFile", licenseFile); - this.licenseFile = licenseFile; - } - - public File getNoticeFile() { - return noticeFile; - } - - public void setNoticeFile(File noticeFile) { - this.project.getExtensions().getExtraProperties().set("noticeFile", noticeFile); - this.noticeFile = noticeFile; - } - - public Project getProject() { - return project; - } - - public void setExtendedPlugins(List extendedPlugins) { - this.extendedPlugins = extendedPlugins; - } - - public boolean isHasClientJar() { - return hasClientJar; - } - - public void setHasClientJar(boolean hasClientJar) { - this.hasClientJar = hasClientJar; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/DependencyLicensesPrecommitPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/DependencyLicensesPrecommitPlugin.java deleted file mode 100644 index d4dcde9d63087..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/DependencyLicensesPrecommitPlugin.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.opensearch.gradle.dependencies.CompileOnlyResolvePlugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.ProjectDependency; -import org.gradle.api.plugins.JavaPlugin; -import org.gradle.api.tasks.TaskProvider; - -public class DependencyLicensesPrecommitPlugin extends PrecommitPlugin { - - @Override - public TaskProvider createTask(Project project) { - project.getPlugins().apply(CompileOnlyResolvePlugin.class); - TaskProvider dependencyLicenses = project.getTasks() - .register("dependencyLicenses", DependencyLicensesTask.class); - - // only require dependency licenses for non-opensearch deps - dependencyLicenses.configure(t -> { - Configuration runtimeClasspath = project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME); - Configuration compileOnly = project.getConfigurations() - .getByName(CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME); - t.setDependencies( - runtimeClasspath.fileCollection(dependency -> dependency instanceof ProjectDependency == false).minus(compileOnly) - ); - }); - - // we also create the updateShas helper task that is associated with dependencyLicenses - project.getTasks().register("updateShas", UpdateShasTask.class, t -> t.setParentTask(dependencyLicenses)); - return dependencyLicenses; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/DependencyLicensesTask.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/DependencyLicensesTask.java deleted file mode 100644 index e801681c5c386..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/DependencyLicensesTask.java +++ /dev/null @@ -1,392 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.apache.commons.codec.binary.Hex; -import org.opensearch.gradle.precommit.LicenseAnalyzer.LicenseInfo; -import org.gradle.api.DefaultTask; -import org.gradle.api.GradleException; -import org.gradle.api.InvalidUserDataException; -import org.gradle.api.file.FileCollection; -import org.gradle.api.logging.Logger; -import org.gradle.api.logging.Logging; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.InputDirectory; -import org.gradle.api.tasks.InputFiles; -import org.gradle.api.tasks.Internal; -import org.gradle.api.tasks.Optional; -import org.gradle.api.tasks.OutputDirectory; -import org.gradle.api.tasks.TaskAction; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -/** - * A task to check licenses for dependencies. - *

    - * There are two parts to the check: - *

      - *
    • LICENSE, NOTICE and SOURCES files
    • - *
    • SHA checksums for each dependency jar
    • - *
    - *

    - * The directory to find the license and sha files in defaults to the dir @{code licenses} - * in the project directory for this task. You can override this directory: - *

    - *   dependencyLicenses {
    - *     licensesDir = getProject().file("mybetterlicensedir")
    - *   }
    - * 
    - *

    - * The jar files to check default to the dependencies from the default configuration. You - * can override this, for example, to only check compile dependencies: - *

    - *   dependencyLicenses {
    - *     dependencies = getProject().configurations.compile
    - *   }
    - * 
    - *

    - * Every jar must have a {@code .sha1} file in the licenses dir. These can be managed - * automatically using the {@code updateShas} helper task that is created along - * with this task. It will add {@code .sha1} files for new jars that are in dependencies - * and remove old {@code .sha1} files that are no longer needed. - *

    - * Every jar must also have a LICENSE and NOTICE file. However, multiple jars can share - * LICENSE and NOTICE files by mapping a pattern to the same name. - *

    - *   dependencyLicenses {
    - *     mapping from: /lucene-.*/, to: "lucene"
    - *   }
    - * 
    - * Dependencies using licenses with stricter distribution requirements (such as LGPL) - * require a SOURCES file as well. The file should include a URL to a source distribution - * for the dependency. This artifact will be redistributed by us with the release to - * comply with the license terms. - */ -public class DependencyLicensesTask extends DefaultTask { - - private final Pattern regex = Pattern.compile("-v?\\d+.*"); - - private final Logger logger = Logging.getLogger(getClass()); - - private static final String SHA_EXTENSION = ".sha1"; - - // TODO: we should be able to default this to eg compile deps, but we need to move the licenses - // check from distribution to core (ie this should only be run on java projects) - /** - * A collection of jar files that should be checked. - */ - private FileCollection dependencies; - - /** - * The directory to find the license and sha files in. - */ - private File licensesDir = new File(getProject().getProjectDir(), "licenses"); - - /** - * A map of patterns to prefix, used to find the LICENSE and NOTICE file. - */ - private Map mappings = new LinkedHashMap<>(); - - /** - * Names of dependencies whose shas should not exist. - */ - private Set ignoreShas = new HashSet<>(); - - /** - * Add a mapping from a regex pattern for the jar name, to a prefix to find - * the LICENSE and NOTICE file for that jar. - */ - public void mapping(Map props) { - String from = props.remove("from"); - if (from == null) { - throw new InvalidUserDataException("Missing \"from\" setting for license name mapping"); - } - String to = props.remove("to"); - if (to == null) { - throw new InvalidUserDataException("Missing \"to\" setting for license name mapping"); - } - if (props.isEmpty() == false) { - throw new InvalidUserDataException("Unknown properties for mapping on dependencyLicenses: " + props.keySet()); - } - mappings.put(from, to); - } - - @InputFiles - public FileCollection getDependencies() { - return dependencies; - } - - public void setDependencies(FileCollection dependencies) { - this.dependencies = dependencies; - } - - @Optional - @InputDirectory - public File getLicensesDir() { - if (licensesDir.exists()) { - return licensesDir; - } - - return null; - } - - public void setLicensesDir(File licensesDir) { - this.licensesDir = licensesDir; - } - - /** - * Add a rule which will skip SHA checking for the given dependency name. This should be used for - * locally build dependencies, which cause the sha to change constantly. - */ - public void ignoreSha(String dep) { - ignoreShas.add(dep); - } - - @TaskAction - public void checkDependencies() throws IOException, NoSuchAlgorithmException { - if (dependencies == null) { - throw new GradleException("No dependencies variable defined."); - } - - if (dependencies.isEmpty()) { - if (licensesDir.exists()) { - throw new GradleException("Licenses dir " + licensesDir + " exists, but there are no dependencies"); - } - return; // no dependencies to check - } else if (licensesDir.exists() == false) { - String deps = ""; - for (File file : dependencies) { - deps += file.getName() + "\n"; - } - throw new GradleException("Licences dir " + licensesDir + " does not exist, but there are dependencies: " + deps); - } - - Map licenses = new HashMap<>(); - Map notices = new HashMap<>(); - Map sources = new HashMap<>(); - Set shaFiles = new HashSet<>(); - - for (File file : licensesDir.listFiles()) { - String name = file.getName(); - if (name.endsWith(SHA_EXTENSION)) { - shaFiles.add(file); - } else if (name.endsWith("-LICENSE") || name.endsWith("-LICENSE.txt")) { - // TODO: why do we support suffix of LICENSE *and* LICENSE.txt?? - licenses.put(name, false); - } else if (name.contains("-NOTICE") || name.contains("-NOTICE.txt")) { - notices.put(name, false); - } else if (name.contains("-SOURCES") || name.contains("-SOURCES.txt")) { - sources.put(name, false); - } - } - - checkDependencies(licenses, notices, sources, shaFiles); - - licenses.forEach((item, exists) -> failIfAnyMissing(item, exists, "license")); - - notices.forEach((item, exists) -> failIfAnyMissing(item, exists, "notice")); - - sources.forEach((item, exists) -> failIfAnyMissing(item, exists, "sources")); - - if (shaFiles.isEmpty() == false) { - throw new GradleException("Unused sha files found: \n" + joinFilenames(shaFiles)); - } - - } - - // This is just a marker output folder to allow this task being up-to-date. - // The check logic is exception driven so a failed tasks will not be defined - // by this output but when successful we can safely mark the task as up-to-date. - @OutputDirectory - public File getOutputMarker() { - return new File(getProject().getBuildDir(), "dependencyLicense"); - } - - private void failIfAnyMissing(String item, Boolean exists, String type) { - if (exists == false) { - throw new GradleException("Unused " + type + " " + item); - } - } - - private void checkDependencies( - Map licenses, - Map notices, - Map sources, - Set shaFiles - ) throws NoSuchAlgorithmException, IOException { - for (File dependency : dependencies) { - String jarName = dependency.getName(); - String depName = regex.matcher(jarName).replaceFirst(""); - - validateSha(shaFiles, dependency, jarName, depName); - - String dependencyName = getDependencyName(mappings, depName); - logger.info("mapped dependency name {} to {} for license/notice check", depName, dependencyName); - checkFile(dependencyName, jarName, licenses, "LICENSE"); - checkFile(dependencyName, jarName, notices, "NOTICE"); - - File licenseFile = new File(licensesDir, getFileName(dependencyName, licenses, "LICENSE")); - LicenseInfo licenseInfo = LicenseAnalyzer.licenseType(licenseFile); - if (licenseInfo.isSourceRedistributionRequired()) { - checkFile(dependencyName, jarName, sources, "SOURCES"); - } - } - } - - private void validateSha(Set shaFiles, File dependency, String jarName, String depName) throws NoSuchAlgorithmException, - IOException { - if (ignoreShas.contains(depName)) { - // local deps should not have sha files! - if (getShaFile(jarName).exists()) { - throw new GradleException("SHA file " + getShaFile(jarName) + " exists for ignored dependency " + depName); - } - } else { - logger.info("Checking sha for {}", jarName); - checkSha(dependency, jarName, shaFiles); - } - } - - private String joinFilenames(Set shaFiles) { - List names = shaFiles.stream().map(File::getName).collect(Collectors.toList()); - return String.join("\n", names); - } - - public static String getDependencyName(Map mappings, String dependencyName) { - // order is the same for keys and values iteration since we use a linked hashmap - List mapped = new ArrayList<>(mappings.values()); - Pattern mappingsPattern = Pattern.compile("(" + String.join(")|(", mappings.keySet()) + ")"); - Matcher match = mappingsPattern.matcher(dependencyName); - if (match.matches()) { - int i = 0; - while (i < match.groupCount() && match.group(i + 1) == null) { - ++i; - } - return mapped.get(i); - } - return dependencyName; - } - - private void checkSha(File jar, String jarName, Set shaFiles) throws NoSuchAlgorithmException, IOException { - File shaFile = getShaFile(jarName); - if (shaFile.exists() == false) { - throw new GradleException("Missing SHA for " + jarName + ". Run \"gradle updateSHAs\" to create them"); - } - - // TODO: shouldn't have to trim, sha files should not have trailing newline - byte[] fileBytes = Files.readAllBytes(shaFile.toPath()); - String expectedSha = new String(fileBytes, StandardCharsets.UTF_8).trim(); - - String sha = getSha1(jar); - - if (expectedSha.equals(sha) == false) { - final String exceptionMessage = String.format( - Locale.ROOT, - "SHA has changed! Expected %s for %s but got %s." - + "\nThis usually indicates a corrupt dependency cache or artifacts changed upstream." - + "\nEither wipe your cache, fix the upstream artifact, or delete %s and run updateShas", - expectedSha, - jarName, - sha, - shaFile - ); - - throw new GradleException(exceptionMessage); - } - shaFiles.remove(shaFile); - } - - private void checkFile(String name, String jarName, Map counters, String type) { - String fileName = getFileName(name, counters, type); - - if (counters.containsKey(fileName) == false) { - throw new GradleException("Missing " + type + " for " + jarName + ", expected in " + fileName); - } - - counters.put(fileName, true); - } - - private String getFileName(String name, Map counters, String type) { - String fileName = name + "-" + type; - - if (counters.containsKey(fileName) == false) { - // try the other suffix...TODO: get rid of this, just support ending in .txt - return fileName + ".txt"; - } - - return fileName; - } - - @Input - public LinkedHashMap getMappings() { - return new LinkedHashMap<>(mappings); - } - - File getShaFile(String jarName) { - return new File(licensesDir, jarName + SHA_EXTENSION); - } - - @Internal - Set getShaFiles() { - File[] array = licensesDir.listFiles(); - if (array == null) { - throw new GradleException("\"" + licensesDir.getPath() + "\" isn't a valid directory"); - } - - return Arrays.stream(array).filter(file -> file.getName().endsWith(SHA_EXTENSION)).collect(Collectors.toSet()); - } - - String getSha1(File file) throws IOException, NoSuchAlgorithmException { - byte[] bytes = Files.readAllBytes(file.toPath()); - - MessageDigest digest = MessageDigest.getInstance("SHA-1"); - char[] encoded = Hex.encodeHex(digest.digest(bytes)); - return String.copyValueOf(encoded); - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/FilePermissionsPrecommitPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/FilePermissionsPrecommitPlugin.java deleted file mode 100644 index 92c87fdff952b..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/FilePermissionsPrecommitPlugin.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.tasks.TaskProvider; - -public class FilePermissionsPrecommitPlugin extends PrecommitPlugin { - @Override - public TaskProvider createTask(Project project) { - return project.getTasks().register("filepermissions", FilePermissionsTask.class); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/FilePermissionsTask.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/FilePermissionsTask.java deleted file mode 100644 index 9ffd472151b4b..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/FilePermissionsTask.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.attribute.PosixFileAttributeView; -import java.nio.file.attribute.PosixFilePermission; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -import org.apache.tools.ant.taskdefs.condition.Os; -import org.opensearch.gradle.util.GradleUtils; -import org.gradle.api.DefaultTask; -import org.gradle.api.GradleException; -import org.gradle.api.file.FileCollection; -import org.gradle.api.file.FileTree; -import org.gradle.api.tasks.InputFiles; -import org.gradle.api.tasks.OutputFile; -import org.gradle.api.tasks.SkipWhenEmpty; -import org.gradle.api.tasks.StopExecutionException; -import org.gradle.api.tasks.TaskAction; -import org.gradle.api.tasks.util.PatternFilterable; -import org.gradle.api.tasks.util.PatternSet; - -/** - * Checks source files for correct file permissions. - */ -public class FilePermissionsTask extends DefaultTask { - - /** - * A pattern set of which files should be checked. - */ - private final PatternFilterable filesFilter = new PatternSet() - // we always include all source files, and exclude what should not be checked - .include("**") - // exclude sh files that might have the executable bit set - .exclude("**/*.sh"); - - private File outputMarker = new File(getProject().getBuildDir(), "markers/filePermissions"); - - public FilePermissionsTask() { - setDescription("Checks java source files for correct file permissions"); - } - - private static boolean isExecutableFile(File file) { - try { - Set permissions = Files.getFileAttributeView(file.toPath(), PosixFileAttributeView.class) - .readAttributes() - .permissions(); - return permissions.contains(PosixFilePermission.OTHERS_EXECUTE) - || permissions.contains(PosixFilePermission.OWNER_EXECUTE) - || permissions.contains(PosixFilePermission.GROUP_EXECUTE); - } catch (IOException e) { - throw new IllegalStateException("unable to read the file " + file + " attributes", e); - } - } - - /** - * Returns the files this task will check - */ - @InputFiles - @SkipWhenEmpty - public FileCollection getFiles() { - return GradleUtils.getJavaSourceSets(getProject()) - .stream() - .map(sourceSet -> sourceSet.getAllSource().matching(filesFilter)) - .reduce(FileTree::plus) - .orElse(getProject().files().getAsFileTree()); - } - - @TaskAction - public void checkInvalidPermissions() throws IOException { - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - throw new StopExecutionException(); - } - List failures = getFiles().getFiles() - .stream() - .filter(FilePermissionsTask::isExecutableFile) - .map(file -> "Source file is executable: " + file) - .collect(Collectors.toList()); - - if (!failures.isEmpty()) { - throw new GradleException("Found invalid file permissions:\n" + String.join("\n", failures)); - } - - outputMarker.getParentFile().mkdirs(); - Files.write(outputMarker.toPath(), "done".getBytes("UTF-8")); - } - - @OutputFile - public File getOutputMarker() { - return outputMarker; - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ForbiddenApisPrecommitPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/ForbiddenApisPrecommitPlugin.java deleted file mode 100644 index 328edda8b1787..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ForbiddenApisPrecommitPlugin.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis; -import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin; -import groovy.lang.Closure; -import org.opensearch.gradle.ExportOpenSearchBuildResourcesTask; -import org.opensearch.gradle.info.BuildParams; -import org.opensearch.gradle.util.GradleUtils; -import org.gradle.api.JavaVersion; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.plugins.ExtraPropertiesExtension; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.SourceSetContainer; -import org.gradle.api.tasks.TaskProvider; - -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; - -public class ForbiddenApisPrecommitPlugin extends PrecommitPlugin { - @Override - public TaskProvider createTask(Project project) { - project.getPluginManager().apply(ForbiddenApisPlugin.class); - - TaskProvider resourcesTask = project.getTasks() - .register("forbiddenApisResources", ExportOpenSearchBuildResourcesTask.class); - Path resourcesDir = project.getBuildDir().toPath().resolve("forbidden-apis-config"); - resourcesTask.configure(t -> { - t.setOutputDir(resourcesDir.toFile()); - t.copy("forbidden/jdk-signatures.txt"); - t.copy("forbidden/opensearch-all-signatures.txt"); - t.copy("forbidden/opensearch-test-signatures.txt"); - t.copy("forbidden/http-signatures.txt"); - t.copy("forbidden/opensearch-server-signatures.txt"); - }); - project.getTasks().withType(CheckForbiddenApis.class).configureEach(t -> { - t.dependsOn(resourcesTask); - - assert t.getName().startsWith(ForbiddenApisPlugin.FORBIDDEN_APIS_TASK_NAME); - String sourceSetName; - if (ForbiddenApisPlugin.FORBIDDEN_APIS_TASK_NAME.equals(t.getName())) { - sourceSetName = "main"; - } else { - // parse out the sourceSetName - char[] chars = t.getName().substring(ForbiddenApisPlugin.FORBIDDEN_APIS_TASK_NAME.length()).toCharArray(); - chars[0] = Character.toLowerCase(chars[0]); - sourceSetName = new String(chars); - } - - SourceSetContainer sourceSets = GradleUtils.getJavaSourceSets(project); - SourceSet sourceSet = sourceSets.getByName(sourceSetName); - t.setClasspath(project.files(sourceSet.getRuntimeClasspath()).plus(sourceSet.getCompileClasspath())); - - t.setTargetCompatibility(BuildParams.getRuntimeJavaVersion().getMajorVersion()); - if (BuildParams.getRuntimeJavaVersion().compareTo(JavaVersion.VERSION_14) > 0) { - // TODO: forbidden apis does not yet support java 15, rethink using runtime version - t.setTargetCompatibility(JavaVersion.VERSION_14.getMajorVersion()); - } - t.setBundledSignatures(new HashSet<>(Arrays.asList("jdk-unsafe", "jdk-deprecated", "jdk-non-portable", "jdk-system-out"))); - t.setSignaturesFiles( - project.files( - resourcesDir.resolve("forbidden/jdk-signatures.txt"), - resourcesDir.resolve("forbidden/opensearch-all-signatures.txt") - ) - ); - t.setSuppressAnnotations(new HashSet<>(Arrays.asList("**.SuppressForbidden"))); - if (t.getName().endsWith("Test")) { - t.setSignaturesFiles( - t.getSignaturesFiles() - .plus( - project.files( - resourcesDir.resolve("forbidden/opensearch-test-signatures.txt"), - resourcesDir.resolve("forbidden/http-signatures.txt") - ) - ) - ); - } else { - t.setSignaturesFiles( - t.getSignaturesFiles().plus(project.files(resourcesDir.resolve("forbidden/opensearch-server-signatures.txt"))) - ); - } - ExtraPropertiesExtension ext = t.getExtensions().getExtraProperties(); - ext.set("replaceSignatureFiles", new Closure(t) { - @Override - public Void call(Object... names) { - List resources = new ArrayList<>(names.length); - for (Object name : names) { - resources.add(resourcesDir.resolve("forbidden/" + name + ".txt")); - } - t.setSignaturesFiles(project.files(resources)); - return null; - } - - }); - ext.set("addSignatureFiles", new Closure(t) { - @Override - public Void call(Object... names) { - List resources = new ArrayList<>(names.length); - for (Object name : names) { - resources.add(resourcesDir.resolve("forbidden/" + name + ".txt")); - } - t.setSignaturesFiles(t.getSignaturesFiles().plus(project.files(resources))); - return null; - } - }); - }); - TaskProvider forbiddenApis = project.getTasks().named("forbiddenApis"); - forbiddenApis.configure(t -> t.setGroup("")); - return forbiddenApis; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ForbiddenPatternsPrecommitPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/ForbiddenPatternsPrecommitPlugin.java deleted file mode 100644 index 6930856ff5517..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ForbiddenPatternsPrecommitPlugin.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.tasks.TaskProvider; - -public class ForbiddenPatternsPrecommitPlugin extends PrecommitPlugin { - @Override - public TaskProvider createTask(Project project) { - return project.getTasks().register("forbiddenPatterns", ForbiddenPatternsTask.class); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ForbiddenPatternsTask.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/ForbiddenPatternsTask.java deleted file mode 100644 index f57c190496452..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ForbiddenPatternsTask.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.gradle.api.DefaultTask; -import org.gradle.api.GradleException; -import org.gradle.api.InvalidUserDataException; -import org.gradle.api.file.FileCollection; -import org.gradle.api.file.FileTree; -import org.gradle.api.plugins.JavaPluginConvention; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.InputFiles; -import org.gradle.api.tasks.OutputFile; -import org.gradle.api.tasks.SkipWhenEmpty; -import org.gradle.api.tasks.TaskAction; -import org.gradle.api.tasks.util.PatternFilterable; -import org.gradle.api.tasks.util.PatternSet; - -import java.io.File; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import java.util.stream.Stream; - -/** - * Checks for patterns in source files for the project which are forbidden. - */ -public class ForbiddenPatternsTask extends DefaultTask { - - /* - * A pattern set of which files should be checked. - */ - private final PatternFilterable filesFilter = new PatternSet() - // we always include all source files, and exclude what should not be checked - .include("**") - // exclude known binary extensions - .exclude("**/*.gz") - .exclude("**/*.ico") - .exclude("**/*.jar") - .exclude("**/*.zip") - .exclude("**/*.jks") - .exclude("**/*.crt") - .exclude("**/*.keystore") - .exclude("**/*.png"); - - /* - * The rules: a map from the rule name, to a rule regex pattern. - */ - private final Map patterns = new HashMap<>(); - - public ForbiddenPatternsTask() { - setDescription("Checks source files for invalid patterns like nocommits or tabs"); - getInputs().property("excludes", filesFilter.getExcludes()); - getInputs().property("rules", patterns); - - // add mandatory rules - patterns.put("nocommit", "nocommit|NOCOMMIT"); - patterns.put("nocommit should be all lowercase or all uppercase", "((?i)nocommit)(? sourceSet.getAllSource().matching(filesFilter)) - .reduce(FileTree::plus) - .orElse(getProject().files().getAsFileTree()); - } - - @TaskAction - public void checkInvalidPatterns() throws IOException { - Pattern allPatterns = Pattern.compile("(" + String.join(")|(", getPatterns().values()) + ")"); - List failures = new ArrayList<>(); - for (File f : getFiles()) { - List lines; - try (Stream stream = Files.lines(f.toPath(), StandardCharsets.UTF_8)) { - lines = stream.collect(Collectors.toList()); - } catch (UncheckedIOException e) { - throw new IllegalArgumentException("Failed to read " + f + " as UTF_8", e); - } - List invalidLines = IntStream.range(0, lines.size()) - .filter(i -> allPatterns.matcher(lines.get(i)).find()) - .boxed() - .collect(Collectors.toList()); - - String path = getProject().getRootProject().getProjectDir().toURI().relativize(f.toURI()).toString(); - failures.addAll( - invalidLines.stream() - .map(l -> new AbstractMap.SimpleEntry<>(l + 1, lines.get(l))) - .flatMap( - kv -> patterns.entrySet() - .stream() - .filter(p -> Pattern.compile(p.getValue()).matcher(kv.getValue()).find()) - .map(p -> "- " + p.getKey() + " on line " + kv.getKey() + " of " + path) - ) - .collect(Collectors.toList()) - ); - } - if (failures.isEmpty() == false) { - throw new GradleException("Found invalid patterns:\n" + String.join("\n", failures)); - } - - File outputMarker = getOutputMarker(); - outputMarker.getParentFile().mkdirs(); - Files.write(outputMarker.toPath(), "done".getBytes(StandardCharsets.UTF_8)); - } - - @OutputFile - public File getOutputMarker() { - return new File(getProject().getBuildDir(), "markers/" + getName()); - } - - @Input - public Map getPatterns() { - return Collections.unmodifiableMap(patterns); - } - - public void exclude(String... excludes) { - filesFilter.exclude(excludes); - } - - public void rule(Map props) { - String name = props.remove("name"); - if (name == null) { - throw new InvalidUserDataException("Missing [name] for invalid pattern rule"); - } - String pattern = props.remove("pattern"); - if (pattern == null) { - throw new InvalidUserDataException("Missing [pattern] for invalid pattern rule"); - } - if (props.isEmpty() == false) { - throw new InvalidUserDataException("Unknown arguments for ForbiddenPatterns rule mapping: " + props.keySet().toString()); - } - // TODO: fail if pattern contains a newline, it won't work (currently) - patterns.put(name, pattern); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/JarHellPrecommitPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/JarHellPrecommitPlugin.java deleted file mode 100644 index 04ae37f92bcc9..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/JarHellPrecommitPlugin.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.opensearch.gradle.info.BuildParams; -import org.opensearch.gradle.util.Util; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.TaskProvider; - -public class JarHellPrecommitPlugin extends PrecommitPlugin { - @Override - public TaskProvider createTask(Project project) { - Configuration jarHellConfig = project.getConfigurations().create("jarHell"); - if (BuildParams.isInternal() && project.getPath().equals(":libs:opensearch-core") == false) { - // External plugins will depend on this already via transitive dependencies. - // Internal projects are not all plugins, so make sure the check is available - // we are not doing this for this project itself to avoid jar hell with itself - project.getDependencies().add("jarHell", project.project(":libs:opensearch-core")); - } - - TaskProvider jarHell = project.getTasks().register("jarHell", JarHellTask.class); - jarHell.configure(t -> { - SourceSet testSourceSet = Util.getJavaTestSourceSet(project).get(); - t.setClasspath(testSourceSet.getRuntimeClasspath().plus(jarHellConfig)); - t.dependsOn(jarHellConfig); - }); - - return jarHell; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/JarHellTask.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/JarHellTask.java deleted file mode 100644 index e642aaee754e7..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/JarHellTask.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.opensearch.gradle.LoggedExec; -import org.gradle.api.file.FileCollection; -import org.gradle.api.tasks.CacheableTask; -import org.gradle.api.tasks.CompileClasspath; -import org.gradle.api.tasks.TaskAction; - -import java.io.File; - -/** - * Runs CheckJarHell on a classpath. - */ -@CacheableTask -public class JarHellTask extends PrecommitTask { - - private FileCollection classpath; - - public JarHellTask() { - setDescription("Runs CheckJarHell on the configured classpath"); - } - - @TaskAction - public void runJarHellCheck() { - LoggedExec.javaexec(getProject(), spec -> { - spec.environment("CLASSPATH", getClasspath().getAsPath()); - spec.setMain("org.opensearch.bootstrap.JarHell"); - }); - } - - // We use compile classpath normalization here because class implementation changes are irrelevant for the purposes of jar hell. - // We only care about the runtime classpath ABI here. - @CompileClasspath - public FileCollection getClasspath() { - return classpath.filter(File::exists); - } - - public void setClasspath(FileCollection classpath) { - this.classpath = classpath; - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/LicenseAnalyzer.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/LicenseAnalyzer.java deleted file mode 100644 index 4c63516126566..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/LicenseAnalyzer.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.apache.commons.io.IOUtils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.regex.Pattern; - -public class LicenseAnalyzer { - /* - * Order here matters. License files can often contain multiple licenses for which the particular piece of software may by used under. - * We should order these in order of most permissive to least permissive such that we identify the license as the most permissive for - * purposes of redistribution. Search order is as defined below so the license will be identified as the first pattern to match. - */ - private static final LicenseMatcher[] matchers = new LicenseMatcher[] { - new LicenseMatcher("Apache-2.0", true, false, Pattern.compile("Apache.*License.*[vV]ersion.*2\\.0", Pattern.DOTALL)), - new LicenseMatcher( - "BSD-2-Clause", - true, - false, - Pattern.compile( - ("Redistribution and use in source and binary forms, with or without\n" - + "modification, are permitted provided that the following conditions\n" - + "are met:\n" - + "\n" - + " 1\\. Redistributions of source code must retain the above copyright\n" - + " notice, this list of conditions and the following disclaimer\\.\n" - + " 2\\. Redistributions in binary form must reproduce the above copyright\n" - + " notice, this list of conditions and the following disclaimer in the\n" - + " documentation and/or other materials provided with the distribution\\.\n" - + "\n" - + "THIS SOFTWARE IS PROVIDED BY .+ (``|''|\")AS IS(''|\") AND ANY EXPRESS OR\n" - + "IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n" - + "OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED\\.\n" - + "IN NO EVENT SHALL .+ BE LIABLE FOR ANY DIRECT, INDIRECT,\n" - + "INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \\(INCLUDING, BUT\n" - + "NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n" - + "DATA, OR PROFITS; OR BUSINESS INTERRUPTION\\) HOWEVER CAUSED AND ON ANY\n" - + "THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" - + "\\(INCLUDING NEGLIGENCE OR OTHERWISE\\) ARISING IN ANY WAY OUT OF THE USE OF\n" - + "THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE\\.").replaceAll("\\s+", "\\\\s*"), - Pattern.DOTALL - ) - ), - new LicenseMatcher( - "BSD-3-Clause", - true, - false, - Pattern.compile( - ("\n" - + "Redistribution and use in source and binary forms, with or without\n" - + "modification, are permitted provided that the following conditions\n" - + "are met:\n" - + "\n" - + " (1\\.)? Redistributions of source code must retain the above copyright\n" - + " notice, this list of conditions and the following disclaimer\\.\n" - + " (2\\.)? Redistributions in binary form must reproduce the above copyright\n" - + " notice, this list of conditions and the following disclaimer in the\n" - + " documentation and/or other materials provided with the distribution\\.\n" - + " ((3\\.)? The name of .+ may not be used to endorse or promote products\n" - + " derived from this software without specific prior written permission\\.|\n" - + " (3\\.)? Neither the name of .+ nor the names of its\n" - + " contributors may be used to endorse or promote products derived from\n" - + " this software without specific prior written permission\\.)\n" - + "\n" - + "THIS SOFTWARE IS PROVIDED BY .+ (``|''|\")AS IS(''|\") AND ANY EXPRESS OR\n" - + "IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n" - + "OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED\\.\n" - + "IN NO EVENT SHALL .+ BE LIABLE FOR ANY DIRECT, INDIRECT,\n" - + "INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \\(INCLUDING, BUT\n" - + "NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n" - + "DATA, OR PROFITS; OR BUSINESS INTERRUPTION\\) HOWEVER CAUSED AND ON ANY\n" - + "THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" - + "\\(INCLUDING NEGLIGENCE OR OTHERWISE\\) ARISING IN ANY WAY OUT OF THE USE OF\n" - + "THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE\\.\n").replaceAll("\\s+", "\\\\s*"), - Pattern.DOTALL - ) - ), - new LicenseMatcher( - "CDDL-1.0", - true, - false, - Pattern.compile("COMMON DEVELOPMENT AND DISTRIBUTION LICENSE.*Version 1.0", Pattern.DOTALL) - ), - new LicenseMatcher( - "CDDL-1.1", - true, - false, - Pattern.compile("COMMON DEVELOPMENT AND DISTRIBUTION LICENSE.*Version 1.1", Pattern.DOTALL) - ), - new LicenseMatcher("ICU", true, false, Pattern.compile("ICU License - ICU 1.8.1 and later", Pattern.DOTALL)), - new LicenseMatcher( - "MIT", - true, - false, - Pattern.compile( - ("\n" - + "Permission is hereby granted, free of charge, to any person obtaining a copy of\n" - + "this software and associated documentation files \\(the \"Software\"\\), to deal in\n" - + "the Software without restriction, including without limitation the rights to\n" - + "use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n" - + "of the Software, and to permit persons to whom the Software is furnished to do\n" - + "so, subject to the following conditions:\n" - + "\n" - + "The above copyright notice and this permission notice shall be included in all\n" - + "copies or substantial portions of the Software\\.\n" - + "\n" - + "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n" - + "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" - + "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT\\. IN NO EVENT SHALL THE\n" - + "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n" - + "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n" - + "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n" - + "SOFTWARE\\.\n").replaceAll("\\s+", "\\\\s*"), - Pattern.DOTALL - ) - ), - new LicenseMatcher("MPL-1.1", true, false, Pattern.compile("Mozilla Public License.*Version 1.1", Pattern.DOTALL)), - new LicenseMatcher("MPL-2.0", true, false, Pattern.compile("Mozilla\\s*Public\\s*License\\s*Version\\s*2\\.0", Pattern.DOTALL)), - new LicenseMatcher("XZ", false, false, Pattern.compile("Licensing of XZ for Java", Pattern.DOTALL)), - new LicenseMatcher("EPL-2.0", true, false, Pattern.compile("Eclipse Public License - v 2.0", Pattern.DOTALL)), - new LicenseMatcher("LGPL-2.1", true, true, Pattern.compile("GNU LESSER GENERAL PUBLIC LICENSE.*Version 2.1", Pattern.DOTALL)), - new LicenseMatcher("LGPL-3.0", true, true, Pattern.compile("GNU LESSER GENERAL PUBLIC LICENSE.*Version 3", Pattern.DOTALL)) }; - - public static LicenseInfo licenseType(File licenseFile) { - for (LicenseMatcher matcher : matchers) { - boolean matches = matcher.matches(licenseFile); - if (matches) { - return new LicenseInfo(matcher.getIdentifier(), matcher.spdxLicense, matcher.sourceRedistributionRequired); - } - } - - throw new IllegalStateException("Unknown license for license file: " + licenseFile); - } - - public static class LicenseInfo { - private final String identifier; - private final boolean spdxLicense; - private final boolean sourceRedistributionRequired; - - public LicenseInfo(String identifier, boolean spdxLicense, boolean sourceRedistributionRequired) { - this.identifier = identifier; - this.spdxLicense = spdxLicense; - this.sourceRedistributionRequired = sourceRedistributionRequired; - } - - public String getIdentifier() { - return identifier; - } - - public boolean isSpdxLicense() { - return spdxLicense; - } - - public boolean isSourceRedistributionRequired() { - return sourceRedistributionRequired; - } - } - - private static class LicenseMatcher { - private final String identifier; - private final boolean spdxLicense; - private final boolean sourceRedistributionRequired; - private final Pattern pattern; - - LicenseMatcher(String identifier, boolean spdxLicense, boolean sourceRedistributionRequired, Pattern pattern) { - this.identifier = identifier; - this.spdxLicense = spdxLicense; - this.sourceRedistributionRequired = sourceRedistributionRequired; - this.pattern = pattern; - } - - public String getIdentifier() { - return identifier; - } - - public boolean matches(File licenseFile) { - try (FileInputStream fis = new FileInputStream(licenseFile)) { - String content = String.join("\n", IOUtils.readLines(fis, "UTF-8")).replaceAll("\\*", " "); - return pattern.matcher(content).find(); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/LoggerUsagePrecommitPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/LoggerUsagePrecommitPlugin.java deleted file mode 100644 index 57deb9facbef7..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/LoggerUsagePrecommitPlugin.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.opensearch.gradle.VersionProperties; -import org.opensearch.gradle.info.BuildParams; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.tasks.TaskProvider; - -public class LoggerUsagePrecommitPlugin extends PrecommitPlugin { - @Override - public TaskProvider createTask(Project project) { - Object dependency = BuildParams.isInternal() - ? project.project(":test:logger-usage") - : ("org.opensearch.test:logger-usage:" + VersionProperties.getOpenSearch()); - - Configuration loggerUsageConfig = project.getConfigurations().create("loggerUsagePlugin"); - project.getDependencies().add("loggerUsagePlugin", dependency); - TaskProvider loggerUsage = project.getTasks().register("loggerUsageCheck", LoggerUsageTask.class); - loggerUsage.configure(t -> t.setClasspath(loggerUsageConfig)); - - return loggerUsage; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/LoggerUsageTask.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/LoggerUsageTask.java deleted file mode 100644 index 7ce0c0cecff81..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/LoggerUsageTask.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.opensearch.gradle.LoggedExec; -import org.gradle.api.file.FileCollection; -import org.gradle.api.plugins.JavaPluginConvention; -import org.gradle.api.tasks.CacheableTask; -import org.gradle.api.tasks.Classpath; -import org.gradle.api.tasks.InputFiles; -import org.gradle.api.tasks.PathSensitive; -import org.gradle.api.tasks.PathSensitivity; -import org.gradle.api.tasks.SkipWhenEmpty; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.TaskAction; - -import java.io.File; - -/** - * Runs LoggerUsageCheck on a set of directories. - */ -@CacheableTask -public class LoggerUsageTask extends PrecommitTask { - - private FileCollection classpath; - - public LoggerUsageTask() { - setDescription("Runs LoggerUsageCheck on output directories of all source sets"); - } - - @TaskAction - public void runLoggerUsageTask() { - LoggedExec.javaexec(getProject(), spec -> { - spec.setMain("org.opensearch.test.loggerusage.OpenSearchLoggerUsageChecker"); - spec.classpath(getClasspath()); - getClassDirectories().forEach(spec::args); - }); - } - - @Classpath - public FileCollection getClasspath() { - return classpath; - } - - public void setClasspath(FileCollection classpath) { - this.classpath = classpath; - } - - @InputFiles - @PathSensitive(PathSensitivity.RELATIVE) - @SkipWhenEmpty - public FileCollection getClassDirectories() { - return getProject().getConvention() - .getPlugin(JavaPluginConvention.class) - .getSourceSets() - .stream() - // Don't pick up all source sets like the java9 ones as logger-check doesn't support the class format - .filter( - sourceSet -> sourceSet.getName().equals(SourceSet.MAIN_SOURCE_SET_NAME) - || sourceSet.getName().equals(SourceSet.TEST_SOURCE_SET_NAME) - ) - .map(sourceSet -> sourceSet.getOutput().getClassesDirs()) - .reduce(FileCollection::plus) - .orElse(getProject().files()) - .filter(File::exists); - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/PomValidationPrecommitPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/PomValidationPrecommitPlugin.java deleted file mode 100644 index 0e7a357dd5d18..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/PomValidationPrecommitPlugin.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.opensearch.gradle.util.Util; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.publish.PublishingExtension; -import org.gradle.api.publish.maven.tasks.GenerateMavenPom; -import org.gradle.api.tasks.TaskProvider; - -/** - * Adds pom validation to every pom generation task. - */ -public class PomValidationPrecommitPlugin extends PrecommitPlugin { - - @Override - public TaskProvider createTask(Project project) { - TaskProvider validatePom = project.getTasks().register("validatePom"); - PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class); - publishing.getPublications().all(publication -> { - String publicationName = Util.capitalize(publication.getName()); - TaskProvider validateTask = project.getTasks() - .register("validate" + publicationName + "Pom", PomValidationTask.class); - validatePom.configure(t -> t.dependsOn(validateTask)); - validateTask.configure(task -> { - GenerateMavenPom generateMavenPom = project.getTasks() - .withType(GenerateMavenPom.class) - .getByName("generatePomFileFor" + publicationName + "Publication"); - task.dependsOn(generateMavenPom); - task.getPomFile().fileValue(generateMavenPom.getDestination()); - }); - }); - - return validatePom; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/PomValidationTask.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/PomValidationTask.java deleted file mode 100644 index aca882fbb6477..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/PomValidationTask.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.apache.maven.model.Model; -import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.gradle.api.GradleException; -import org.gradle.api.file.RegularFileProperty; -import org.gradle.api.tasks.InputFile; -import org.gradle.api.tasks.TaskAction; - -import java.io.FileReader; -import java.util.Collection; -import java.util.function.Consumer; -import java.util.function.Predicate; - -public class PomValidationTask extends PrecommitTask { - - private final RegularFileProperty pomFile = getProject().getObjects().fileProperty(); - - private boolean foundError; - - @InputFile - public RegularFileProperty getPomFile() { - return pomFile; - } - - @TaskAction - public void checkPom() throws Exception { - try (FileReader fileReader = new FileReader(pomFile.getAsFile().get())) { - MavenXpp3Reader reader = new MavenXpp3Reader(); - Model model = reader.read(fileReader); - - validateString("groupId", model.getGroupId()); - validateString("artifactId", model.getArtifactId()); - validateString("version", model.getVersion()); - validateString("name", model.getName()); - validateString("description", model.getDescription()); - validateString("url", model.getUrl()); - - validateCollection("licenses", model.getLicenses(), v -> { - validateString("licenses.name", v.getName()); - validateString("licenses.url", v.getUrl()); - }); - - validateCollection("developers", model.getDevelopers(), v -> { - validateString("developers.name", v.getName()); - validateString("developers.url", v.getUrl()); - }); - - validateNonNull("scm", model.getScm(), () -> validateString("scm.url", model.getScm().getUrl())); - } - if (foundError) { - throw new GradleException("Check failed for task '" + getPath() + "', see console log for details"); - } - } - - private void logError(String element, String message) { - foundError = true; - getLogger().error("{} {} in [{}]", element, message, pomFile.getAsFile().get()); - } - - private void validateNonEmpty(String element, T value, Predicate isEmpty) { - if (isEmpty.test(value)) { - logError(element, "is empty"); - } - } - - private void validateNonNull(String element, T value, Runnable validator) { - if (value == null) { - logError(element, "is missing"); - } else { - validator.run(); - } - } - - private void validateString(String element, String value) { - validateNonNull(element, value, () -> validateNonEmpty(element, value, s -> s.trim().isEmpty())); - } - - private void validateCollection(String element, Collection value, Consumer validator) { - validateNonNull(element, value, () -> { - validateNonEmpty(element, value, Collection::isEmpty); - value.forEach(validator); - }); - - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/PrecommitPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/PrecommitPlugin.java deleted file mode 100644 index 0b4cc20f145ad..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/PrecommitPlugin.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.opensearch.gradle.util.GradleUtils; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.TaskProvider; - -/** - * Base plugin for adding a precommit task. - */ -public abstract class PrecommitPlugin implements Plugin { - - public static final String PRECOMMIT_TASK_NAME = "precommit"; - - @Override - public final void apply(Project project) { - project.getPluginManager().apply(PrecommitTaskPlugin.class); - TaskProvider task = createTask(project); - TaskProvider precommit = project.getTasks().named(PRECOMMIT_TASK_NAME); - precommit.configure(t -> t.dependsOn(task)); - - project.getPluginManager().withPlugin("java", p -> { - // We want to get any compilation error before running the pre-commit checks. - for (SourceSet sourceSet : GradleUtils.getJavaSourceSets(project)) { - task.configure(t -> t.shouldRunAfter(sourceSet.getClassesTaskName())); - } - }); - } - - public abstract TaskProvider createTask(Project project); - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/PrecommitTask.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/PrecommitTask.java deleted file mode 100644 index 52646206e4792..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/PrecommitTask.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.gradle.api.DefaultTask; -import org.gradle.api.tasks.OutputFile; -import org.gradle.api.tasks.TaskAction; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.StandardOpenOption; - -public class PrecommitTask extends DefaultTask { - - @OutputFile - public File getSuccessMarker() { - return new File(getProject().getBuildDir(), "markers/" + this.getName()); - } - - @TaskAction - public void writeMarker() throws IOException { - Files.write(getSuccessMarker().toPath(), new byte[] {}, StandardOpenOption.CREATE); - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/PrecommitTaskPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/PrecommitTaskPlugin.java deleted file mode 100644 index 52cbdbded2f13..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/PrecommitTaskPlugin.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.opensearch.gradle.util.GradleUtils; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.plugins.JavaBasePlugin; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.TaskProvider; -import org.gradle.api.tasks.testing.Test; -import org.gradle.language.base.plugins.LifecycleBasePlugin; - -public class PrecommitTaskPlugin implements Plugin { - - @Override - public void apply(Project project) { - TaskProvider precommit = project.getTasks().register(PrecommitPlugin.PRECOMMIT_TASK_NAME, t -> { - t.setGroup(JavaBasePlugin.VERIFICATION_GROUP); - t.setDescription("Runs all non-test checks"); - }); - - project.getPluginManager() - .withPlugin( - "lifecycle-base", - p -> project.getTasks().named(LifecycleBasePlugin.CHECK_TASK_NAME).configure(t -> t.dependsOn(precommit)) - ); - project.getPluginManager().withPlugin("java", p -> { - // run compilation as part of precommit - for (SourceSet sourceSet : GradleUtils.getJavaSourceSets(project)) { - precommit.configure(t -> t.dependsOn(sourceSet.getClassesTaskName())); - } - - // make sure tests run after all precommit tasks - project.getTasks().withType(Test.class).configureEach(t -> t.mustRunAfter(precommit)); - }); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/TestingConventionRule.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/TestingConventionRule.java deleted file mode 100644 index aa81ef75701fa..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/TestingConventionRule.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import java.io.Serializable; -import java.util.Collection; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; -import java.util.regex.Pattern; - -/** - * Represent rules for tests enforced by the @{link {@link TestingConventionsTasks}} - * - * Rules are identified by name, tests must have this name as a suffix and implement one of the base classes - * and be part of all the specified tasks. - */ -public class TestingConventionRule implements Serializable { - - private final String suffix; - - private Set baseClasses = new HashSet<>(); - - private Set taskNames = new HashSet<>(); - - public TestingConventionRule(String suffix) { - this.suffix = suffix; - } - - public String getSuffix() { - return suffix; - } - - /** - * Alias for @{link getSuffix} as Gradle requires a name property - * - */ - public String getName() { - return suffix; - } - - public void baseClass(String clazz) { - baseClasses.add(clazz); - } - - public void setBaseClasses(Collection baseClasses) { - this.baseClasses.clear(); - this.baseClasses.addAll(baseClasses); - } - - public void taskName(Pattern expression) { - taskNames.add(expression); - } - - public void taskName(String expression) { - taskNames.add(Pattern.compile(expression)); - } - - public void setTaskNames(Collection expressions) { - taskNames.clear(); - taskNames.addAll(expressions); - } - - public Set getBaseClasses() { - return baseClasses; - } - - public Set getTaskNames() { - return taskNames; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TestingConventionRule that = (TestingConventionRule) o; - return Objects.equals(suffix, that.suffix); - } - - @Override - public int hashCode() { - return Objects.hash(suffix); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/TestingConventionsPrecommitPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/TestingConventionsPrecommitPlugin.java deleted file mode 100644 index 4c965d6a0fe90..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/TestingConventionsPrecommitPlugin.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.tasks.TaskProvider; - -public class TestingConventionsPrecommitPlugin extends PrecommitPlugin { - @Override - public TaskProvider createTask(Project project) { - TaskProvider testingConventions = project.getTasks() - .register("testingConventions", TestingConventionsTasks.class); - testingConventions.configure(t -> { - TestingConventionRule testsRule = t.getNaming().maybeCreate("Tests"); - testsRule.baseClass("org.apache.lucene.util.LuceneTestCase"); - TestingConventionRule itRule = t.getNaming().maybeCreate("IT"); - itRule.baseClass("org.opensearch.test.OpenSearchIntegTestCase"); - itRule.baseClass("org.opensearch.test.rest.OpenSearchRestTestCase"); - }); - return testingConventions; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/TestingConventionsTasks.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/TestingConventionsTasks.java deleted file mode 100644 index 5e42cc99dd79e..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/TestingConventionsTasks.java +++ /dev/null @@ -1,437 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import groovy.lang.Closure; -import org.opensearch.gradle.util.GradleUtils; -import org.opensearch.gradle.util.Util; -import org.gradle.api.DefaultTask; -import org.gradle.api.NamedDomainObjectContainer; -import org.gradle.api.Task; -import org.gradle.api.file.FileCollection; -import org.gradle.api.file.FileTree; -import org.gradle.api.tasks.Classpath; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.OutputFile; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.SourceSetContainer; -import org.gradle.api.tasks.TaskAction; -import org.gradle.api.tasks.testing.Test; - -import java.io.File; -import java.io.IOException; -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.nio.file.FileVisitResult; -import java.nio.file.FileVisitor; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.function.Predicate; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class TestingConventionsTasks extends DefaultTask { - - private static final String TEST_METHOD_PREFIX = "test"; - - private Map testClassNames; - - private final NamedDomainObjectContainer naming; - - public TestingConventionsTasks() { - setDescription("Tests various testing conventions"); - // Run only after everything is compiled - GradleUtils.getJavaSourceSets(getProject()).all(sourceSet -> dependsOn(sourceSet.getOutput().getClassesDirs())); - naming = getProject().container(TestingConventionRule.class); - } - - @Input - public Map> getClassFilesPerEnabledTask() { - return getProject().getTasks() - .withType(Test.class) - .stream() - .filter(Task::getEnabled) - .collect(Collectors.toMap(Task::getPath, task -> task.getCandidateClassFiles().getFiles())); - } - - @Input - public Map getTestClassNames() { - if (testClassNames == null) { - testClassNames = Util.getJavaTestSourceSet(getProject()) - .get() - .getOutput() - .getClassesDirs() - .getFiles() - .stream() - .filter(File::exists) - .flatMap(testRoot -> walkPathAndLoadClasses(testRoot).entrySet().stream()) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - } - return testClassNames; - } - - @Input - public NamedDomainObjectContainer getNaming() { - return naming; - } - - @OutputFile - public File getSuccessMarker() { - return new File(getProject().getBuildDir(), "markers/" + getName()); - } - - public void naming(Closure action) { - naming.configure(action); - } - - @Input - public Set getMainClassNamedLikeTests() { - SourceSetContainer javaSourceSets = GradleUtils.getJavaSourceSets(getProject()); - if (javaSourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME) == null) { - // some test projects don't have a main source set - return Collections.emptySet(); - } - return javaSourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME) - .getOutput() - .getClassesDirs() - .getAsFileTree() - .getFiles() - .stream() - .filter(file -> file.getName().endsWith(".class")) - .map(File::getName) - .map(name -> name.substring(0, name.length() - 6)) - .filter(this::implementsNamingConvention) - .collect(Collectors.toSet()); - } - - @TaskAction - public void doCheck() throws IOException { - final String problems; - - try ( - URLClassLoader isolatedClassLoader = new URLClassLoader( - getTestsClassPath().getFiles().stream().map(this::fileToUrl).toArray(URL[]::new) - ) - ) { - Predicate> isStaticClass = clazz -> Modifier.isStatic(clazz.getModifiers()); - Predicate> isPublicClass = clazz -> Modifier.isPublic(clazz.getModifiers()); - Predicate> isAbstractClass = clazz -> Modifier.isAbstract(clazz.getModifiers()); - - final Map> classes = getTestClassNames().entrySet() - .stream() - .collect(Collectors.toMap(Map.Entry::getValue, entry -> loadClassWithoutInitializing(entry.getKey(), isolatedClassLoader))); - - final FileTree allTestClassFiles = getProject().files( - classes.values() - .stream() - .filter(isStaticClass.negate()) - .filter(isPublicClass) - .filter((Predicate>) this::implementsNamingConvention) - .map(clazz -> testClassNames.get(clazz.getName())) - .collect(Collectors.toList()) - ).getAsFileTree(); - - final Map> classFilesPerTask = getClassFilesPerEnabledTask(); - - final Set testSourceSetFiles = Util.getJavaTestSourceSet(getProject()).get().getRuntimeClasspath().getFiles(); - final Map>> testClassesPerTask = classFilesPerTask.entrySet() - .stream() - .filter(entry -> testSourceSetFiles.containsAll(entry.getValue())) - .collect( - Collectors.toMap( - Map.Entry::getKey, - entry -> entry.getValue() - .stream() - .map(classes::get) - .filter(this::implementsNamingConvention) - .collect(Collectors.toSet()) - ) - ); - - final Map>> suffixToBaseClass; - if (classes.isEmpty()) { - // Don't load base classes if we don't have any tests. - // This allows defaults to be configured for projects that don't have any tests - // - suffixToBaseClass = Collections.emptyMap(); - } else { - suffixToBaseClass = naming.stream() - .collect( - Collectors.toMap( - TestingConventionRule::getSuffix, - rule -> rule.getBaseClasses() - .stream() - .map(each -> loadClassWithoutInitializing(each, isolatedClassLoader)) - .collect(Collectors.toSet()) - ) - ); - } - - problems = collectProblems( - checkNoneExists( - "Test classes implemented by inner classes will not run", - classes.values() - .stream() - .filter(isStaticClass) - .filter(isPublicClass) - .filter(((Predicate>) this::implementsNamingConvention).or(this::seemsLikeATest)) - ), - checkNoneExists( - "Seem like test classes but don't match naming convention", - classes.values() - .stream() - .filter(isStaticClass.negate()) - .filter(isPublicClass) - .filter(isAbstractClass.negate()) - .filter(this::seemsLikeATest) // TODO when base classes are set, check for classes that extend them - .filter(((Predicate>) this::implementsNamingConvention).negate()) - ), - // TODO: check for non public classes that seem like tests - // TODO: check for abstract classes that implement the naming conventions - // No empty enabled tasks - collectProblems( - testClassesPerTask.entrySet() - .stream() - .map(entry -> checkAtLeastOneExists("test class included in task " + entry.getKey(), entry.getValue().stream())) - .sorted() - .collect(Collectors.joining("\n")) - ), - checkNoneExists( - "Test classes are not included in any enabled task (" - + classFilesPerTask.keySet().stream().collect(Collectors.joining(",")) - + ")", - allTestClassFiles.getFiles() - .stream() - .filter(testFile -> classFilesPerTask.values().stream().anyMatch(fileSet -> fileSet.contains(testFile)) == false) - .map(classes::get) - ), - collectProblems(suffixToBaseClass.entrySet().stream().filter(entry -> entry.getValue().isEmpty() == false).map(entry -> { - return checkNoneExists( - "Tests classes with suffix `" - + entry.getKey() - + "` should extend " - + entry.getValue().stream().map(Class::getName).collect(Collectors.joining(" or ")) - + " but the following classes do not", - classes.values() - .stream() - .filter(clazz -> clazz.getName().endsWith(entry.getKey())) - .filter(clazz -> entry.getValue().stream().anyMatch(test -> test.isAssignableFrom(clazz)) == false) - ); - }).sorted().collect(Collectors.joining("\n"))), - // TODO: check that the testing tasks are included in the right task based on the name ( from the rule ) - checkNoneExists("Classes matching the test naming convention should be in test not main", getMainClassNamedLikeTests()) - ); - } - - if (problems.isEmpty()) { - getSuccessMarker().getParentFile().mkdirs(); - Files.write(getSuccessMarker().toPath(), new byte[] {}, StandardOpenOption.CREATE); - } else { - getLogger().error(problems); - throw new IllegalStateException(String.format("Testing conventions [%s] are not honored", problems)); - } - } - - private String collectProblems(String... problems) { - return Stream.of(problems).map(String::trim).filter(s -> s.isEmpty() == false).collect(Collectors.joining("\n")); - } - - private String checkNoneExists(String message, Stream> stream) { - String problem = stream.map(each -> " * " + each.getName()).sorted().collect(Collectors.joining("\n")); - if (problem.isEmpty() == false) { - return message + ":\n" + problem; - } else { - return ""; - } - } - - private String checkNoneExists(String message, Set candidates) { - String problem = candidates.stream().map(each -> " * " + each).sorted().collect(Collectors.joining("\n")); - if (problem.isEmpty() == false) { - return message + ":\n" + problem; - } else { - return ""; - } - } - - private String checkAtLeastOneExists(String message, Stream> stream) { - if (stream.findAny().isPresent()) { - return ""; - } else { - return "Expected at least one " + message + ", but found none."; - } - } - - private boolean seemsLikeATest(Class clazz) { - try { - ClassLoader classLoader = clazz.getClassLoader(); - - Class junitTest = loadClassWithoutInitializing("org.junit.Assert", classLoader); - if (junitTest.isAssignableFrom(clazz)) { - getLogger().debug("{} is a test because it extends {}", clazz.getName(), junitTest.getName()); - return true; - } - - Class junitAnnotation = loadClassWithoutInitializing("org.junit.Test", classLoader); - for (Method method : clazz.getMethods()) { - if (matchesTestMethodNamingConvention(method)) { - getLogger().debug("{} is a test because it has method named '{}'", clazz.getName(), method.getName()); - return true; - } - if (isAnnotated(method, junitAnnotation)) { - getLogger().debug( - "{} is a test because it has method '{}' annotated with '{}'", - clazz.getName(), - method.getName(), - junitAnnotation.getName() - ); - return true; - } - } - - return false; - } catch (NoClassDefFoundError e) { - // Include the message to get more info to get more a more useful message when running Gradle without -s - throw new IllegalStateException("Failed to inspect class " + clazz.getName() + ". Missing class? " + e.getMessage(), e); - } - } - - private boolean implementsNamingConvention(Class clazz) { - Objects.requireNonNull(clazz); - return implementsNamingConvention(clazz.getName()); - } - - private boolean implementsNamingConvention(String className) { - if (naming.stream().map(TestingConventionRule::getSuffix).anyMatch(suffix -> className.endsWith(suffix))) { - getLogger().debug("{} is a test because it matches the naming convention", className); - return true; - } - return false; - } - - private boolean matchesTestMethodNamingConvention(Method method) { - return method.getName().startsWith(TEST_METHOD_PREFIX) && Modifier.isStatic(method.getModifiers()) == false; - } - - private boolean isAnnotated(Method method, Class annotation) { - for (Annotation presentAnnotation : method.getAnnotations()) { - if (annotation.isAssignableFrom(presentAnnotation.getClass())) { - return true; - } - } - return false; - } - - @Classpath - public FileCollection getTestsClassPath() { - return Util.getJavaTestSourceSet(getProject()).get().getRuntimeClasspath(); - } - - private Map walkPathAndLoadClasses(File testRoot) { - Map classes = new HashMap<>(); - try { - Files.walkFileTree(testRoot.toPath(), new FileVisitor() { - private String packageName; - - @Override - public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { - // First we visit the root directory - if (packageName == null) { - // And it package is empty string regardless of the directory name - packageName = ""; - } else { - packageName += dir.getFileName() + "."; - } - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { - // Go up one package by jumping back to the second to last '.' - packageName = packageName.substring(0, 1 + packageName.lastIndexOf('.', packageName.length() - 2)); - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - String filename = file.getFileName().toString(); - if (filename.endsWith(".class")) { - String className = filename.substring(0, filename.length() - ".class".length()); - classes.put(packageName + className, file.toFile()); - } - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException { - throw new IOException("Failed to visit " + file, exc); - } - }); - } catch (IOException e) { - throw new IllegalStateException(e); - } - return classes; - } - - private Class loadClassWithoutInitializing(String name, ClassLoader isolatedClassLoader) { - try { - return Class.forName( - name, - // Don't initialize the class to save time. Not needed for this test and this doesn't share a VM with any other tests. - false, - isolatedClassLoader - ); - } catch (ClassNotFoundException e) { - throw new RuntimeException("Failed to load class " + name + ". Incorrect test runtime classpath?", e); - } - } - - private URL fileToUrl(File file) { - try { - return file.toURI().toURL(); - } catch (MalformedURLException e) { - throw new IllegalStateException(e); - } - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ThirdPartyAuditPrecommitPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/ThirdPartyAuditPrecommitPlugin.java deleted file mode 100644 index 5d707ce2b9f28..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ThirdPartyAuditPrecommitPlugin.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.opensearch.gradle.ExportOpenSearchBuildResourcesTask; -import org.opensearch.gradle.dependencies.CompileOnlyResolvePlugin; -import org.opensearch.gradle.info.BuildParams; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.tasks.TaskProvider; - -import java.nio.file.Path; - -public class ThirdPartyAuditPrecommitPlugin extends PrecommitPlugin { - - public static final String JDK_JAR_HELL_CONFIG_NAME = "jdkJarHell"; - public static final String LIBS_OPENSEARCH_CORE_PROJECT_PATH = ":libs:opensearch-core"; - - @Override - public TaskProvider createTask(Project project) { - project.getPlugins().apply(CompileOnlyResolvePlugin.class); - project.getConfigurations().create("forbiddenApisCliJar"); - project.getDependencies().add("forbiddenApisCliJar", "de.thetaphi:forbiddenapis:3.2"); - - Configuration jdkJarHellConfig = project.getConfigurations().create(JDK_JAR_HELL_CONFIG_NAME); - if (BuildParams.isInternal() && project.getPath().equals(":libs:opensearch-core") == false) { - // External plugins will depend on this already via transitive dependencies. - // Internal projects are not all plugins, so make sure the check is available - // we are not doing this for this project itself to avoid jar hell with itself - project.getDependencies().add(JDK_JAR_HELL_CONFIG_NAME, project.project(LIBS_OPENSEARCH_CORE_PROJECT_PATH)); - } - - TaskProvider resourcesTask = project.getTasks() - .register("thirdPartyAuditResources", ExportOpenSearchBuildResourcesTask.class); - Path resourcesDir = project.getBuildDir().toPath().resolve("third-party-audit-config"); - resourcesTask.configure(t -> { - t.setOutputDir(resourcesDir.toFile()); - t.copy("forbidden/third-party-audit.txt"); - }); - TaskProvider audit = project.getTasks().register("thirdPartyAudit", ThirdPartyAuditTask.class); - audit.configure(t -> { - t.dependsOn(resourcesTask); - t.setJavaHome(BuildParams.getRuntimeJavaHome().toString()); - t.getTargetCompatibility().set(project.provider(BuildParams::getRuntimeJavaVersion)); - t.setSignatureFile(resourcesDir.resolve("forbidden/third-party-audit.txt").toFile()); - }); - project.getTasks().withType(ThirdPartyAuditTask.class).configureEach(t -> t.setJdkJarHellClasspath(jdkJarHellConfig)); - return audit; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ThirdPartyAuditTask.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/ThirdPartyAuditTask.java deleted file mode 100644 index 8be3f3b8e9b95..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ThirdPartyAuditTask.java +++ /dev/null @@ -1,418 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import de.thetaphi.forbiddenapis.cli.CliMain; -import org.apache.commons.io.output.NullOutputStream; -import org.opensearch.gradle.LoggedExec; -import org.opensearch.gradle.OS; -import org.opensearch.gradle.dependencies.CompileOnlyResolvePlugin; -import org.gradle.api.DefaultTask; -import org.gradle.api.JavaVersion; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.Dependency; -import org.gradle.api.file.FileCollection; -import org.gradle.api.file.FileTree; -import org.gradle.api.provider.Property; -import org.gradle.api.specs.Spec; -import org.gradle.api.tasks.CacheableTask; -import org.gradle.api.tasks.Classpath; -import org.gradle.api.tasks.CompileClasspath; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.InputFile; -import org.gradle.api.tasks.InputFiles; -import org.gradle.api.tasks.Internal; -import org.gradle.api.tasks.Optional; -import org.gradle.api.tasks.OutputFile; -import org.gradle.api.tasks.PathSensitive; -import org.gradle.api.tasks.PathSensitivity; -import org.gradle.api.tasks.SkipWhenEmpty; -import org.gradle.api.tasks.TaskAction; -import org.gradle.process.ExecResult; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import java.util.stream.Stream; - -@CacheableTask -public class ThirdPartyAuditTask extends DefaultTask { - - private static final Pattern MISSING_CLASS_PATTERN = Pattern.compile( - "WARNING: Class '(.*)' cannot be loaded \\(.*\\)\\. Please fix the classpath!" - ); - - private static final Pattern VIOLATION_PATTERN = Pattern.compile("\\s\\sin ([a-zA-Z0-9$.]+) \\(.*\\)"); - private static final int SIG_KILL_EXIT_VALUE = 137; - private static final List EXPECTED_EXIT_CODES = Arrays.asList( - CliMain.EXIT_SUCCESS, - CliMain.EXIT_VIOLATION, - CliMain.EXIT_UNSUPPORTED_JDK - ); - private static final String JDK_JAR_HELL_MAIN_CLASS = "org.opensearch.bootstrap.JdkJarHellCheck"; - - private Set missingClassExcludes = new TreeSet<>(); - - private Set violationsExcludes = new TreeSet<>(); - - private Set jdkJarHellExcludes = new TreeSet<>(); - - private File signatureFile; - - private String javaHome; - - private FileCollection jdkJarHellClasspath; - - private final Property targetCompatibility = getProject().getObjects().property(JavaVersion.class); - - @Input - public Property getTargetCompatibility() { - return targetCompatibility; - } - - @InputFiles - @PathSensitive(PathSensitivity.NAME_ONLY) - public Configuration getForbiddenAPIsConfiguration() { - return getProject().getConfigurations().getByName("forbiddenApisCliJar"); - } - - @InputFile - @PathSensitive(PathSensitivity.NONE) - public File getSignatureFile() { - return signatureFile; - } - - public void setSignatureFile(File signatureFile) { - this.signatureFile = signatureFile; - } - - @Input - @Optional - public String getJavaHome() { - return javaHome; - } - - public void setJavaHome(String javaHome) { - this.javaHome = javaHome; - } - - @Internal - public File getJarExpandDir() { - return new File(new File(getProject().getBuildDir(), "precommit/thirdPartyAudit"), getName()); - } - - @OutputFile - public File getSuccessMarker() { - return new File(getProject().getBuildDir(), "markers/" + getName()); - } - - // We use compile classpath normalization here because class implementation changes are irrelevant for the purposes of jdk jar hell. - // We only care about the runtime classpath ABI here. - @CompileClasspath - public FileCollection getJdkJarHellClasspath() { - return jdkJarHellClasspath.filter(File::exists); - } - - public void setJdkJarHellClasspath(FileCollection jdkJarHellClasspath) { - this.jdkJarHellClasspath = jdkJarHellClasspath; - } - - public void ignoreMissingClasses(String... classesOrPackages) { - if (classesOrPackages.length == 0) { - missingClassExcludes = null; - return; - } - if (missingClassExcludes == null) { - missingClassExcludes = new TreeSet<>(); - } - for (String each : classesOrPackages) { - missingClassExcludes.add(each); - } - } - - public void ignoreViolations(String... violatingClasses) { - for (String each : violatingClasses) { - violationsExcludes.add(each); - } - } - - public void ignoreJarHellWithJDK(String... classes) { - for (String each : classes) { - jdkJarHellExcludes.add(each); - } - } - - @Input - public Set getJdkJarHellExcludes() { - return jdkJarHellExcludes; - } - - @Input - @Optional - public Set getMissingClassExcludes() { - return missingClassExcludes; - } - - @Classpath - @SkipWhenEmpty - public Set getJarsToScan() { - // These are SelfResolvingDependency, and some of them backed by file collections, like the Gradle API files, - // or dependencies added as `files(...)`, we can't be sure if those are third party or not. - // err on the side of scanning these to make sure we don't miss anything - Spec reallyThirdParty = dep -> dep.getGroup() != null && dep.getGroup().startsWith("org.opensearch") == false; - Set jars = getRuntimeConfiguration().getResolvedConfiguration().getFiles(reallyThirdParty); - Set compileOnlyConfiguration = getProject().getConfigurations() - .getByName(CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME) - .getResolvedConfiguration() - .getFiles(reallyThirdParty); - // don't scan provided dependencies that we already scanned, e.x. don't scan cores dependencies for every plugin - if (compileOnlyConfiguration != null) { - jars.removeAll(compileOnlyConfiguration); - } - return jars; - } - - @TaskAction - public void runThirdPartyAudit() throws IOException { - Set jars = getJarsToScan(); - - extractJars(jars); - - final String forbiddenApisOutput = runForbiddenAPIsCli(); - - final Set missingClasses = new TreeSet<>(); - Matcher missingMatcher = MISSING_CLASS_PATTERN.matcher(forbiddenApisOutput); - while (missingMatcher.find()) { - missingClasses.add(missingMatcher.group(1)); - } - - final Set violationsClasses = new TreeSet<>(); - Matcher violationMatcher = VIOLATION_PATTERN.matcher(forbiddenApisOutput); - while (violationMatcher.find()) { - violationsClasses.add(violationMatcher.group(1)); - } - - Set jdkJarHellClasses = runJdkJarHellCheck(); - - if (missingClassExcludes != null) { - long bogousExcludesCount = Stream.concat(missingClassExcludes.stream(), violationsExcludes.stream()) - .filter(each -> missingClasses.contains(each) == false) - .filter(each -> violationsClasses.contains(each) == false) - .count(); - if (bogousExcludesCount != 0 && bogousExcludesCount == missingClassExcludes.size() + violationsExcludes.size()) { - logForbiddenAPIsOutput(forbiddenApisOutput); - throw new IllegalStateException( - "All excluded classes seem to have no issues. " + "This is sometimes an indication that the check silently failed" - ); - } - assertNoPointlessExclusions("are not missing", missingClassExcludes, missingClasses); - missingClasses.removeAll(missingClassExcludes); - } - assertNoPointlessExclusions("have no violations", violationsExcludes, violationsClasses); - assertNoPointlessExclusions("do not generate jar hell with the JDK", jdkJarHellExcludes, jdkJarHellClasses); - - if (missingClassExcludes == null && (missingClasses.isEmpty() == false)) { - getLogger().info("Found missing classes, but task is configured to ignore all of them:\n {}", formatClassList(missingClasses)); - missingClasses.clear(); - } - - violationsClasses.removeAll(violationsExcludes); - if (missingClasses.isEmpty() && violationsClasses.isEmpty()) { - getLogger().info("Third party audit passed successfully"); - } else { - logForbiddenAPIsOutput(forbiddenApisOutput); - if (missingClasses.isEmpty() == false) { - getLogger().error("Missing classes:\n{}", formatClassList(missingClasses)); - } - if (violationsClasses.isEmpty() == false) { - getLogger().error("Classes with violations:\n{}", formatClassList(violationsClasses)); - } - throw new IllegalStateException("Audit of third party dependencies failed"); - } - - assertNoJarHell(jdkJarHellClasses); - - // Mark successful third party audit check - getSuccessMarker().getParentFile().mkdirs(); - Files.write(getSuccessMarker().toPath(), new byte[] {}); - } - - private void logForbiddenAPIsOutput(String forbiddenApisOutput) { - getLogger().error("Forbidden APIs output:\n{}==end of forbidden APIs==", forbiddenApisOutput); - } - - private void throwNotConfiguredCorrectlyException() { - throw new IllegalArgumentException("Audit of third party dependencies is not configured correctly"); - } - - private void extractJars(Set jars) { - File jarExpandDir = getJarExpandDir(); - // We need to clean up to make sure old dependencies don't linger - getProject().delete(jarExpandDir); - - jars.forEach(jar -> { - FileTree jarFiles = getProject().zipTree(jar); - getProject().copy(spec -> { - spec.from(jarFiles); - spec.into(jarExpandDir); - // exclude classes from multi release jars - spec.exclude("META-INF/versions/**"); - }); - // Deal with multi release jars: - // The order is important, we iterate here so we don't depend on the order in which Gradle executes the spec - // We extract multi release jar classes ( if these exist ) going from 9 - the first to support them, to the - // current `targetCompatibility` version. - // Each extract will overwrite the top level classes that existed before it, the result is that we end up - // with a single version of the class in `jarExpandDir`. - // This will be the closes version to `targetCompatibility`, the same class that would be loaded in a JVM - // that has `targetCompatibility` version. - // This means we only scan classes that would be loaded into `targetCompatibility`, and don't look at any - // pther version specific implementation of said classes. - IntStream.rangeClosed( - Integer.parseInt(JavaVersion.VERSION_1_9.getMajorVersion()), - Integer.parseInt(targetCompatibility.get().getMajorVersion()) - ).forEach(majorVersion -> getProject().copy(spec -> { - spec.from(getProject().zipTree(jar)); - spec.into(jarExpandDir); - String metaInfPrefix = "META-INF/versions/" + majorVersion; - spec.include(metaInfPrefix + "/**"); - // Drop the version specific prefix - spec.eachFile(details -> details.setPath(details.getPath().replace(metaInfPrefix, ""))); - spec.setIncludeEmptyDirs(false); - })); - }); - } - - private void assertNoJarHell(Set jdkJarHellClasses) { - jdkJarHellClasses.removeAll(jdkJarHellExcludes); - if (jdkJarHellClasses.isEmpty() == false) { - throw new IllegalStateException( - "Audit of third party dependencies failed:\n" + " Jar Hell with the JDK:\n" + formatClassList(jdkJarHellClasses) - ); - } - } - - private void assertNoPointlessExclusions(String specifics, Set excludes, Set problematic) { - String notMissing = excludes.stream() - .filter(each -> problematic.contains(each) == false) - .map(each -> " * " + each) - .collect(Collectors.joining("\n")); - if (notMissing.isEmpty() == false) { - getLogger().error("Unnecessary exclusions, following classes " + specifics + ":\n {}", notMissing); - throw new IllegalStateException("Third party audit task is not configured correctly"); - } - } - - private String formatClassList(Set classList) { - return classList.stream().map(name -> " * " + name).sorted().collect(Collectors.joining("\n")); - } - - private String runForbiddenAPIsCli() throws IOException { - ByteArrayOutputStream errorOut = new ByteArrayOutputStream(); - ExecResult result = getProject().javaexec(spec -> { - if (javaHome != null) { - spec.setExecutable(javaHome + "/bin/java"); - } - spec.classpath( - getForbiddenAPIsConfiguration(), - getRuntimeConfiguration(), - getProject().getConfigurations().getByName(CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME) - ); - spec.jvmArgs("-Xmx1g"); - spec.jvmArgs(LoggedExec.shortLivedArgs()); - spec.setMain("de.thetaphi.forbiddenapis.cli.CliMain"); - spec.args("-f", getSignatureFile().getAbsolutePath(), "-d", getJarExpandDir(), "--allowmissingclasses"); - spec.setErrorOutput(errorOut); - if (getLogger().isInfoEnabled() == false) { - spec.setStandardOutput(new NullOutputStream()); - } - spec.setIgnoreExitValue(true); - }); - if (OS.current().equals(OS.LINUX) && result.getExitValue() == SIG_KILL_EXIT_VALUE) { - throw new IllegalStateException("Third party audit was killed buy SIGKILL, could be a victim of the Linux OOM killer"); - } - final String forbiddenApisOutput; - try (ByteArrayOutputStream outputStream = errorOut) { - forbiddenApisOutput = outputStream.toString(StandardCharsets.UTF_8.name()); - } - if (EXPECTED_EXIT_CODES.contains(result.getExitValue()) == false) { - throw new IllegalStateException("Forbidden APIs cli failed: " + forbiddenApisOutput); - } - return forbiddenApisOutput; - } - - private Set runJdkJarHellCheck() throws IOException { - ByteArrayOutputStream standardOut = new ByteArrayOutputStream(); - ExecResult execResult = getProject().javaexec(spec -> { - spec.classpath( - jdkJarHellClasspath, - getRuntimeConfiguration(), - getProject().getConfigurations().getByName(CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME) - ); - - spec.setMain(JDK_JAR_HELL_MAIN_CLASS); - spec.args(getJarExpandDir()); - spec.setIgnoreExitValue(true); - if (javaHome != null) { - spec.setExecutable(javaHome + "/bin/java"); - } - spec.setStandardOutput(standardOut); - }); - if (execResult.getExitValue() == 0) { - return Collections.emptySet(); - } - final String jdkJarHellCheckList; - try (ByteArrayOutputStream outputStream = standardOut) { - jdkJarHellCheckList = outputStream.toString(StandardCharsets.UTF_8.name()); - } - return new TreeSet<>(Arrays.asList(jdkJarHellCheckList.split("\\r?\\n"))); - } - - private Configuration getRuntimeConfiguration() { - Configuration runtime = getProject().getConfigurations().findByName("runtimeClasspath"); - if (runtime == null) { - return getProject().getConfigurations().getByName("testCompileClasspath"); - } - return runtime; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/UpdateShasTask.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/UpdateShasTask.java deleted file mode 100644 index 3fe08888afb09..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/UpdateShasTask.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.gradle.api.DefaultTask; -import org.gradle.api.logging.Logger; -import org.gradle.api.logging.Logging; -import org.gradle.api.tasks.Internal; -import org.gradle.api.tasks.TaskAction; -import org.gradle.api.tasks.TaskProvider; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.StandardOpenOption; -import java.security.NoSuchAlgorithmException; -import java.util.Set; - -/** - * A task to update shas used by {@code DependencyLicensesCheck} - */ -public class UpdateShasTask extends DefaultTask { - - private final Logger logger = Logging.getLogger(getClass()); - - /** The parent dependency licenses task to use configuration from */ - private TaskProvider parentTask; - - public UpdateShasTask() { - setDescription("Updates the sha files for the dependencyLicenses check"); - setOnlyIf(element -> parentTask.get().getLicensesDir() != null); - } - - @TaskAction - public void updateShas() throws NoSuchAlgorithmException, IOException { - Set shaFiles = parentTask.get().getShaFiles(); - - for (File dependency : parentTask.get().getDependencies()) { - String jarName = dependency.getName(); - File shaFile = parentTask.get().getShaFile(jarName); - - if (shaFile.exists() == false) { - createSha(dependency, jarName, shaFile); - } else { - shaFiles.remove(shaFile); - } - } - - for (File shaFile : shaFiles) { - logger.lifecycle("Removing unused sha " + shaFile.getName()); - shaFile.delete(); - } - } - - private void createSha(File dependency, String jarName, File shaFile) throws IOException, NoSuchAlgorithmException { - logger.lifecycle("Adding sha for " + jarName); - - String sha = parentTask.get().getSha1(dependency); - - Files.write(shaFile.toPath(), sha.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE); - } - - @Internal - public DependencyLicensesTask getParentTask() { - return parentTask.get(); - } - - public void setParentTask(TaskProvider parentTask) { - this.parentTask = parentTask; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ValidateJsonAgainstSchemaTask.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/ValidateJsonAgainstSchemaTask.java deleted file mode 100644 index ff28197feb02b..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ValidateJsonAgainstSchemaTask.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.networknt.schema.JsonSchema; -import com.networknt.schema.JsonSchemaException; -import com.networknt.schema.JsonSchemaFactory; -import com.networknt.schema.SchemaValidatorsConfig; -import com.networknt.schema.SpecVersion; -import com.networknt.schema.ValidationMessage; -import org.gradle.api.DefaultTask; -import org.gradle.api.UncheckedIOException; -import org.gradle.api.file.FileCollection; -import org.gradle.api.tasks.InputFile; -import org.gradle.api.tasks.InputFiles; -import org.gradle.api.tasks.OutputFile; -import org.gradle.api.tasks.TaskAction; -import org.gradle.work.ChangeType; -import org.gradle.work.Incremental; -import org.gradle.work.InputChanges; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; -import java.util.stream.StreamSupport; - -/** - * Incremental task to validate a set of JSON files against against a schema. - */ -public class ValidateJsonAgainstSchemaTask extends DefaultTask { - - private final ObjectMapper mapper = new ObjectMapper(); - private File jsonSchema; - private File report; - private FileCollection inputFiles; - - @Incremental - @InputFiles - public FileCollection getInputFiles() { - return inputFiles; - } - - public void setInputFiles(FileCollection inputFiles) { - this.inputFiles = inputFiles; - } - - @InputFile - public File getJsonSchema() { - return jsonSchema; - } - - public void setJsonSchema(File jsonSchema) { - this.jsonSchema = jsonSchema; - } - - public void setReport(File report) { - this.report = report; - } - - @OutputFile - public File getReport() { - return this.report; - } - - @TaskAction - public void validate(InputChanges inputChanges) throws IOException { - File jsonSchemaOnDisk = getJsonSchema(); - getLogger().debug("JSON schema : [{}]", jsonSchemaOnDisk.getAbsolutePath()); - SchemaValidatorsConfig config = new SchemaValidatorsConfig(); - JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); - JsonSchema jsonSchema = factory.getSchema(mapper.readTree(jsonSchemaOnDisk), config); - Map> errors = new LinkedHashMap<>(); - // incrementally evaluate input files - StreamSupport.stream(inputChanges.getFileChanges(getInputFiles()).spliterator(), false) - .filter(f -> f.getChangeType() != ChangeType.REMOVED) - .forEach(fileChange -> { - File file = fileChange.getFile(); - if (file.isDirectory() == false) { - // validate all files and hold on to errors for a complete report if there are failures - getLogger().debug("Validating JSON [{}]", file.getName()); - try { - Set validationMessages = jsonSchema.validate(mapper.readTree(file)); - maybeLogAndCollectError(validationMessages, errors, file); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - }); - if (errors.isEmpty()) { - try (PrintWriter printWriter = new PrintWriter(getReport())) { - printWriter.println("Success! No validation errors found."); - } - } else { - try (PrintWriter printWriter = new PrintWriter(getReport())) { - printWriter.printf("Schema: %s%n", jsonSchemaOnDisk); - printWriter.println("----------Validation Errors-----------"); - errors.values().stream().flatMap(Collection::stream).forEach(printWriter::println); - } - StringBuilder sb = new StringBuilder(); - sb.append("Error validating JSON. See the report at: "); - sb.append(getReport().toURI().toASCIIString()); - sb.append(System.lineSeparator()); - sb.append( - String.format("JSON validation failed: %d files contained %d violations", errors.keySet().size(), errors.values().size()) - ); - throw new JsonSchemaException(sb.toString()); - } - } - - private void maybeLogAndCollectError(Set messages, Map> errors, File file) { - for (ValidationMessage message : messages) { - getLogger().error("[validate JSON][ERROR][{}][{}]", file.getName(), message.toString()); - errors.computeIfAbsent(file, k -> new LinkedHashSet<>()) - .add(String.format("%s: %s", file.getAbsolutePath(), message.toString())); - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ValidateJsonNoKeywordsTask.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/ValidateJsonNoKeywordsTask.java deleted file mode 100644 index b3ac804566e29..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ValidateJsonNoKeywordsTask.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.gradle.api.DefaultTask; -import org.gradle.api.GradleException; -import org.gradle.api.file.FileCollection; -import org.gradle.api.tasks.InputFile; -import org.gradle.api.tasks.InputFiles; -import org.gradle.api.tasks.OutputFile; -import org.gradle.api.tasks.TaskAction; -import org.gradle.work.ChangeType; -import org.gradle.work.Incremental; -import org.gradle.work.InputChanges; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import java.util.stream.StreamSupport; - -/** - * Incremental task to validate that the API names in set of JSON files do not contain - * programming language keywords. - *

    - * The keywords are defined in a JSON file, although it's worth noting that what is and isn't a - * keyword depends on the language and sometimes the context in which a keyword is used. For example, - * `delete` is an operator in JavaScript, but it isn't in the keywords list for JavaScript or - * TypeScript because it's OK to use `delete` as a method name. - */ -public class ValidateJsonNoKeywordsTask extends DefaultTask { - - private final ObjectMapper mapper = new ObjectMapper().configure(JsonParser.Feature.ALLOW_COMMENTS, true); - private File jsonKeywords; - private File report; - private FileCollection inputFiles; - - @Incremental - @InputFiles - public FileCollection getInputFiles() { - return inputFiles; - } - - public void setInputFiles(FileCollection inputFiles) { - this.inputFiles = inputFiles; - } - - @InputFile - public File getJsonKeywords() { - return jsonKeywords; - } - - public void setJsonKeywords(File jsonKeywords) { - this.jsonKeywords = jsonKeywords; - } - - public void setReport(File report) { - this.report = report; - } - - @OutputFile - public File getReport() { - return report; - } - - @TaskAction - public void validate(InputChanges inputChanges) { - final Map> errors = new LinkedHashMap<>(); - - getLogger().debug("Loading keywords from {}", jsonKeywords.getName()); - - final Map> languagesByKeyword = loadKeywords(); - - // incrementally evaluate input files - StreamSupport.stream(inputChanges.getFileChanges(getInputFiles()).spliterator(), false) - .filter(f -> f.getChangeType() != ChangeType.REMOVED) - .forEach(fileChange -> { - File file = fileChange.getFile(); - if (file.isDirectory()) { - return; - } - - getLogger().debug("Checking {}", file.getName()); - - try { - final JsonNode jsonNode = mapper.readTree(file); - - if (jsonNode.isObject() == false) { - errors.put(file, new HashSet<>(Arrays.asList("Expected an object, but found: " + jsonNode.getNodeType()))); - return; - } - - final ObjectNode rootNode = (ObjectNode) jsonNode; - - if (rootNode.size() != 1) { - errors.put( - file, - new HashSet<>(Arrays.asList("Expected an object with exactly 1 key, but found " + rootNode.size() + " keys")) - ); - return; - } - - final String apiName = rootNode.fieldNames().next(); - - for (String component : apiName.split("\\.")) { - if (languagesByKeyword.containsKey(component)) { - final Set errorsForFile = errors.computeIfAbsent(file, _file -> new HashSet<>()); - errorsForFile.add( - component + " is a reserved keyword in these languages: " + languagesByKeyword.get(component) - ); - } - } - } catch (IOException e) { - errors.put(file, new HashSet<>(Arrays.asList("Failed to load file: " + e.getMessage()))); - } - }); - - if (errors.isEmpty()) { - return; - } - - try { - try (PrintWriter pw = new PrintWriter(getReport())) { - pw.println("---------- Validation Report -----------"); - pw.println("Some API names were found that, when client code is generated for these APIS,"); - pw.println("could conflict with the reserved words in some programming languages. It may"); - pw.println("still be possible to use these API names, but you will need to verify whether"); - pw.println("the API name (and its components) can be used as method names, and update the"); - pw.println("list of keywords below. The safest action is to rename the API to avoid conflicts."); - pw.println(); - pw.printf("Keywords source: %s%n", getJsonKeywords()); - pw.println(); - pw.println("---------- Validation Errors -----------"); - pw.println(); - errors.forEach((file, errorsForFile) -> { - pw.printf("File: %s%n", file); - errorsForFile.forEach(err -> pw.printf("\t%s%n", err)); - pw.println(); - }); - } - } catch (FileNotFoundException e) { - throw new GradleException("Failed to write keywords report", e); - } - - String message = String.format( - Locale.ROOT, - "Error validating JSON. See the report at: %s%s%s", - getReport().toURI().toASCIIString(), - System.lineSeparator(), - String.format("JSON validation failed: %d files contained %d violations", errors.keySet().size(), errors.values().size()) - ); - throw new GradleException(message); - } - - /** - * Loads the known keywords. Although the JSON on disk maps from language to keywords, this method - * inverts this to map from keyword to languages. This is because the same keywords are found in - * multiple languages, so it is easier and more useful to have a single map of keywords. - * - * @return a mapping from keyword to languages. - */ - private Map> loadKeywords() { - Map> languagesByKeyword = new HashMap<>(); - - try { - final ObjectNode keywordsNode = ((ObjectNode) mapper.readTree(this.jsonKeywords)); - - keywordsNode.fieldNames().forEachRemaining(eachLanguage -> { - keywordsNode.get(eachLanguage).elements().forEachRemaining(e -> { - final String eachKeyword = e.textValue(); - final Set languages = languagesByKeyword.computeIfAbsent(eachKeyword, _keyword -> new HashSet<>()); - languages.add(eachLanguage); - }); - }); - } catch (IOException e) { - throw new GradleException("Failed to load keywords JSON from " + jsonKeywords.getName() + " - " + e.getMessage(), e); - } - - return languagesByKeyword; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ValidateRestSpecPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/ValidateRestSpecPlugin.java deleted file mode 100644 index 5d51e2ef994d4..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ValidateRestSpecPlugin.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.opensearch.gradle.util.Util; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.provider.Provider; - -import java.io.File; - -public class ValidateRestSpecPlugin implements Plugin { - private static final String DOUBLE_STAR = "**"; // checkstyle thinks these are javadocs :( - - @Override - public void apply(Project project) { - Provider validateRestSpecTask = project.getTasks() - .register("validateRestSpec", ValidateJsonAgainstSchemaTask.class, task -> { - task.setInputFiles(Util.getJavaTestAndMainSourceResources(project, filter -> { - filter.include(DOUBLE_STAR + "/rest-api-spec/api/" + DOUBLE_STAR + "/*.json"); - filter.exclude(DOUBLE_STAR + "/_common.json"); - })); - // This must always be specified precisely, so that - // projects other than `rest-api-spec` can use this task. - task.setJsonSchema(new File(project.getRootDir(), "rest-api-spec/src/main/resources/schema.json")); - task.setReport(new File(project.getBuildDir(), "reports/validateJson.txt")); - }); - - Provider validateNoKeywordsTask = project.getTasks() - .register("validateNoKeywords", ValidateJsonNoKeywordsTask.class, task -> { - task.setInputFiles(Util.getJavaTestAndMainSourceResources(project, filter -> { - filter.include(DOUBLE_STAR + "/rest-api-spec/api/" + DOUBLE_STAR + "/*.json"); - filter.exclude(DOUBLE_STAR + "/_common.json"); - })); - task.setJsonKeywords(new File(project.getRootDir(), "rest-api-spec/keywords.json")); - task.setReport(new File(project.getBuildDir(), "reports/validateKeywords.txt")); - // There's no point running this task if the schema validation fails - task.mustRunAfter(validateRestSpecTask); - }); - - project.getTasks().named("precommit").configure(t -> t.dependsOn(validateRestSpecTask, validateNoKeywordsTask)); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/tar/SymbolicLinkPreservingTar.java b/buildSrc/src/main/java/org/opensearch/gradle/tar/SymbolicLinkPreservingTar.java deleted file mode 100644 index 7b8e9c9c925ba..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/tar/SymbolicLinkPreservingTar.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.tar; - -import org.apache.commons.compress.archivers.tar.TarArchiveEntry; -import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; -import org.apache.commons.compress.archivers.tar.TarConstants; -import org.apache.commons.compress.archivers.zip.UnixStat; -import org.gradle.api.GradleException; -import org.gradle.api.file.FileCopyDetails; -import org.gradle.api.file.RegularFile; -import org.gradle.api.internal.file.CopyActionProcessingStreamAction; -import org.gradle.api.internal.file.archive.compression.ArchiveOutputStreamFactory; -import org.gradle.api.internal.file.archive.compression.Bzip2Archiver; -import org.gradle.api.internal.file.archive.compression.GzipArchiver; -import org.gradle.api.internal.file.archive.compression.SimpleCompressor; -import org.gradle.api.internal.file.copy.CopyAction; -import org.gradle.api.internal.file.copy.CopyActionProcessingStream; -import org.gradle.api.internal.file.copy.FileCopyDetailsInternal; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.WorkResult; -import org.gradle.api.tasks.WorkResults; -import org.gradle.api.tasks.bundling.Tar; - -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.file.Files; -import java.util.HashSet; -import java.util.Set; - -/** - * A custom archive task that assembles a tar archive that preserves symbolic links. - * - * This task is necessary because the built-in task {@link org.gradle.api.tasks.bundling.Tar} does not preserve symbolic links. - */ -public class SymbolicLinkPreservingTar extends Tar { - - @Override - protected CopyAction createCopyAction() { - final ArchiveOutputStreamFactory compressor; - switch (getCompression()) { - case BZIP2: - compressor = Bzip2Archiver.getCompressor(); - break; - case GZIP: - compressor = GzipArchiver.getCompressor(); - break; - default: - compressor = new SimpleCompressor(); - break; - } - return new SymbolicLinkPreservingTarCopyAction(getArchiveFile(), compressor, isPreserveFileTimestamps()); - } - - private static class SymbolicLinkPreservingTarCopyAction implements CopyAction { - - private final Provider tarFile; - private final ArchiveOutputStreamFactory compressor; - private final boolean isPreserveFileTimestamps; - - SymbolicLinkPreservingTarCopyAction( - final Provider tarFile, - final ArchiveOutputStreamFactory compressor, - final boolean isPreserveFileTimestamps - ) { - this.tarFile = tarFile; - this.compressor = compressor; - this.isPreserveFileTimestamps = isPreserveFileTimestamps; - } - - @Override - public WorkResult execute(final CopyActionProcessingStream stream) { - try ( - OutputStream out = compressor.createArchiveOutputStream(tarFile.get().getAsFile()); - TarArchiveOutputStream tar = new TarArchiveOutputStream(out) - ) { - tar.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU); - stream.process(new SymbolicLinkPreservingTarStreamAction(tar)); - } catch (final IOException e) { - throw new GradleException("failed writing tar file [" + tarFile + "]", e); - } - - return WorkResults.didWork(true); - } - - private class SymbolicLinkPreservingTarStreamAction implements CopyActionProcessingStreamAction { - - private final TarArchiveOutputStream tar; - - /* - * When Gradle walks the file tree, it will follow symbolic links. This means that if there is a symbolic link to a directory - * in the source file tree, we could otherwise end up duplicating the entries below that directory in the resulting tar archive. - * To avoid this, we track which symbolic links we have visited, and skip files that are children of symbolic links that we have - * already visited. - */ - private final Set visitedSymbolicLinks = new HashSet<>(); - - SymbolicLinkPreservingTarStreamAction(final TarArchiveOutputStream tar) { - this.tar = tar; - } - - @Override - public void processFile(final FileCopyDetailsInternal details) { - if (isChildOfVisitedSymbolicLink(details) == false) { - if (isSymbolicLink(details)) { - visitSymbolicLink(details); - } else if (details.isDirectory()) { - visitDirectory(details); - } else { - visitFile(details); - } - } - } - - private boolean isChildOfVisitedSymbolicLink(final FileCopyDetailsInternal details) { - final File file; - try { - file = details.getFile(); - } catch (final UnsupportedOperationException e) { - // we get invoked with stubbed details, there is no way to introspect this other than catching this exception - return false; - } - for (final File symbolicLink : visitedSymbolicLinks) { - if (isChildOf(symbolicLink, file)) return true; - } - return false; - } - - private boolean isChildOf(final File directory, final File file) { - return file.toPath().startsWith(directory.toPath()); - } - - private boolean isSymbolicLink(final FileCopyDetailsInternal details) { - final File file; - try { - file = details.getFile(); - } catch (final UnsupportedOperationException e) { - // we get invoked with stubbed details, there is no way to introspect this other than catching this exception - return false; - } - return Files.isSymbolicLink(file.toPath()); - } - - private void visitSymbolicLink(final FileCopyDetailsInternal details) { - visitedSymbolicLinks.add(details.getFile()); - final TarArchiveEntry entry = new TarArchiveEntry(details.getRelativePath().getPathString(), TarConstants.LF_SYMLINK); - entry.setModTime(getModTime(details)); - entry.setMode(UnixStat.LINK_FLAG | details.getMode()); - try { - entry.setLinkName(Files.readSymbolicLink(details.getFile().toPath()).toString()); - tar.putArchiveEntry(entry); - tar.closeArchiveEntry(); - } catch (final IOException e) { - handleProcessingException(details, e); - } - } - - private void visitDirectory(final FileCopyDetailsInternal details) { - final TarArchiveEntry entry = new TarArchiveEntry(details.getRelativePath().getPathString() + "/"); - entry.setModTime(getModTime(details)); - entry.setMode(UnixStat.DIR_FLAG | details.getMode()); - try { - tar.putArchiveEntry(entry); - tar.closeArchiveEntry(); - } catch (final IOException e) { - handleProcessingException(details, e); - } - } - - private void visitFile(final FileCopyDetailsInternal details) { - final TarArchiveEntry entry = new TarArchiveEntry(details.getRelativePath().getPathString()); - entry.setModTime(getModTime(details)); - entry.setMode(UnixStat.FILE_FLAG | details.getMode()); - entry.setSize(details.getSize()); - try { - tar.putArchiveEntry(entry); - details.copyTo(tar); - tar.closeArchiveEntry(); - } catch (final IOException e) { - handleProcessingException(details, e); - } - } - - private void handleProcessingException(final FileCopyDetailsInternal details, final IOException e) { - throw new GradleException("could not add [" + details + "] to tar file [" + tarFile + "]", e); - } - - } - - private long getModTime(final FileCopyDetails details) { - return isPreserveFileTimestamps ? details.getLastModified() : 0; - } - - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/tar/SymoblicLinkPreservingTarPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/tar/SymoblicLinkPreservingTarPlugin.java deleted file mode 100644 index 4dd27f148e290..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/tar/SymoblicLinkPreservingTarPlugin.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.tar; - -import org.gradle.api.Plugin; -import org.gradle.api.Project; - -public class SymoblicLinkPreservingTarPlugin implements Plugin { - - @Override - public void apply(final Project target) { - - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/test/DistroTestPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/test/DistroTestPlugin.java deleted file mode 100644 index 7d8d888723bf0..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/test/DistroTestPlugin.java +++ /dev/null @@ -1,499 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test; - -import org.opensearch.gradle.Architecture; -import org.opensearch.gradle.DistributionDownloadPlugin; -import org.opensearch.gradle.OpenSearchDistribution; -import org.opensearch.gradle.Jdk; -import org.opensearch.gradle.JdkDownloadPlugin; -import org.opensearch.gradle.SystemPropertyCommandLineArgumentProvider; -import org.opensearch.gradle.Version; -import org.opensearch.gradle.VersionProperties; -import org.opensearch.gradle.docker.DockerSupportPlugin; -import org.opensearch.gradle.docker.DockerSupportService; -import org.opensearch.gradle.info.BuildParams; -import org.opensearch.gradle.internal.InternalDistributionDownloadPlugin; -import org.opensearch.gradle.util.GradleUtils; -import org.opensearch.gradle.util.Util; -import org.opensearch.gradle.vagrant.VagrantBasePlugin; -import org.opensearch.gradle.vagrant.VagrantExtension; -import org.gradle.api.Action; -import org.gradle.api.NamedDomainObjectContainer; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.dsl.DependencyHandler; -import org.gradle.api.plugins.JavaBasePlugin; -import org.gradle.api.provider.Provider; -import org.gradle.api.specs.Specs; -import org.gradle.api.tasks.Copy; -import org.gradle.api.tasks.TaskProvider; -import org.gradle.api.tasks.testing.Test; -import org.opensearch.gradle.vagrant.VagrantMachine; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Map.Entry; -import java.util.function.Supplier; -import java.util.stream.Stream; - -public class DistroTestPlugin implements Plugin { - private static final String SYSTEM_JDK_VERSION = "8u432-b06"; - private static final String SYSTEM_JDK_VENDOR = "adoptium"; - private static final String GRADLE_JDK_VERSION = "11.0.25+9"; - private static final String GRADLE_JDK_VENDOR = "adoptium"; - - // all distributions used by distro tests. this is temporary until tests are per distribution - private static final String EXAMPLE_PLUGIN_CONFIGURATION = "examplePlugin"; - private static final String IN_VM_SYSPROP = "tests.inVM"; - private static final String DISTRIBUTION_SYSPROP = "tests.distribution"; - private static final String BWC_DISTRIBUTION_SYSPROP = "tests.bwc-distribution"; - private static final String EXAMPLE_PLUGIN_SYSPROP = "tests.example-plugin"; - - @Override - public void apply(Project project) { - project.getRootProject().getPluginManager().apply(DockerSupportPlugin.class); - project.getPlugins().apply(InternalDistributionDownloadPlugin.class); - project.getPlugins().apply(JdkDownloadPlugin.class); - project.getPluginManager().apply("opensearch.build"); - - Provider dockerSupport = GradleUtils.getBuildService( - project.getGradle().getSharedServices(), - DockerSupportPlugin.DOCKER_SUPPORT_SERVICE_NAME - ); - - // TODO: it would be useful to also have the SYSTEM_JAVA_HOME setup in the root project, so that running from GCP only needs - // a java for gradle to run, and the tests are self sufficient and consistent with the java they use - NamedDomainObjectContainer allDistributions = DistributionDownloadPlugin.getContainer(project); - List testDistributions = configureDistributions(project); - - Map> lifecycleTasks = lifecycleTasks(project, "destructiveDistroTest"); - Map> versionTasks = versionTasks(project, "destructiveDistroUpgradeTest"); - TaskProvider destructiveDistroTest = project.getTasks().register("destructiveDistroTest"); - - Configuration examplePlugin = configureExamplePlugin(project); - - List> windowsTestTasks = new ArrayList<>(); - Map>> linuxTestTasks = new HashMap<>(); - Map>> upgradeTestTasks = new HashMap<>(); - Map> depsTasks = new HashMap<>(); - for (OpenSearchDistribution distribution : testDistributions) { - String taskname = destructiveDistroTestTaskName(distribution); - TaskProvider depsTask = project.getTasks().register(taskname + "#deps"); - depsTask.configure(t -> t.dependsOn(distribution, examplePlugin)); - depsTasks.put(taskname, depsTask); - // TODO - suppressing failure temporarily where duplicate tasks are created for docker. - try { - TaskProvider destructiveTask = configureTestTask(project, taskname, distribution, t -> { - t.onlyIf(t2 -> distribution.isDocker() == false || dockerSupport.get().getDockerAvailability().isAvailable); - addSysprop(t, DISTRIBUTION_SYSPROP, distribution::getFilepath); - addSysprop(t, EXAMPLE_PLUGIN_SYSPROP, () -> examplePlugin.getSingleFile().toString()); - t.exclude("**/PackageUpgradeTests.class"); - }, depsTask); - if (distribution.getPlatform() == OpenSearchDistribution.Platform.WINDOWS) { - windowsTestTasks.add(destructiveTask); - } else { - linuxTestTasks.computeIfAbsent(distribution.getType(), k -> new ArrayList<>()).add(destructiveTask); - } - destructiveDistroTest.configure(t -> t.dependsOn(destructiveTask)); - lifecycleTasks.get(distribution.getType()).configure(t -> t.dependsOn(destructiveTask)); - } catch (Exception ex) { - System.out.println(ex.getMessage()); - } - - if ((distribution.getType() == OpenSearchDistribution.Type.DEB || distribution.getType() == OpenSearchDistribution.Type.RPM) - && distribution.getBundledJdk()) { - for (Version version : BuildParams.getBwcVersions().getIndexCompatible()) { - if (version.before("6.3.0")) { - continue; // before opening xpack - } - final OpenSearchDistribution bwcDistro; - if (version.equals(Version.fromString(distribution.getVersion()))) { - // this is the same as the distribution we are testing - bwcDistro = distribution; - } else { - bwcDistro = createDistro( - allDistributions, - distribution.getArchitecture(), - distribution.getType(), - distribution.getPlatform(), - distribution.getBundledJdk(), - version.toString() - ); - - } - String upgradeTaskname = destructiveDistroUpgradeTestTaskName(distribution, version.toString()); - TaskProvider upgradeDepsTask = project.getTasks().register(upgradeTaskname + "#deps"); - upgradeDepsTask.configure(t -> t.dependsOn(distribution, bwcDistro)); - depsTasks.put(upgradeTaskname, upgradeDepsTask); - TaskProvider upgradeTest = configureTestTask(project, upgradeTaskname, distribution, t -> { - addSysprop(t, DISTRIBUTION_SYSPROP, distribution::getFilepath); - addSysprop(t, BWC_DISTRIBUTION_SYSPROP, bwcDistro::getFilepath); - t.include("**/PackageUpgradeTests.class"); - }, upgradeDepsTask); - versionTasks.get(version.toString()).configure(t -> t.dependsOn(upgradeTest)); - upgradeTestTasks.computeIfAbsent(version.toString(), k -> new ArrayList<>()).add(upgradeTest); - } - } - } - - // setup jdks used by no-jdk tests, and by gradle executing - TaskProvider linuxGradleJdk = createJdk(project, "gradle", GRADLE_JDK_VENDOR, GRADLE_JDK_VERSION, "linux", "x64"); - TaskProvider linuxSystemJdk = createJdk(project, "system", SYSTEM_JDK_VENDOR, SYSTEM_JDK_VERSION, "linux", "x64"); - TaskProvider windowsGradleJdk = createJdk(project, "gradle", GRADLE_JDK_VENDOR, GRADLE_JDK_VERSION, "windows", "x64"); - TaskProvider windowsSystemJdk = createJdk(project, "system", SYSTEM_JDK_VENDOR, SYSTEM_JDK_VERSION, "windows", "x64"); - - project.subprojects(vmProject -> { - vmProject.getPluginManager().apply(VagrantBasePlugin.class); - TaskProvider gradleJdk = isWindows(vmProject) ? windowsGradleJdk : linuxGradleJdk; - TaskProvider systemJdk = isWindows(vmProject) ? windowsSystemJdk : linuxSystemJdk; - configureVM(vmProject, gradleJdk, systemJdk); - List vmDependencies = Arrays.asList( - gradleJdk, - systemJdk, - project.getConfigurations().getByName("testRuntimeClasspath") - ); - - Map> vmLifecyleTasks = lifecycleTasks(vmProject, "distroTest"); - Map> vmVersionTasks = versionTasks(vmProject, "distroUpgradeTest"); - TaskProvider distroTest = vmProject.getTasks().register("distroTest"); - - // windows boxes get windows distributions, and linux boxes get linux distributions - if (isWindows(vmProject)) { - configureVMWrapperTasks( - vmProject, - windowsTestTasks, - depsTasks, - wrapperTask -> { vmLifecyleTasks.get(OpenSearchDistribution.Type.ARCHIVE).configure(t -> t.dependsOn(wrapperTask)); }, - vmDependencies - ); - } else { - for (Entry>> entry : linuxTestTasks.entrySet()) { - OpenSearchDistribution.Type type = entry.getKey(); - TaskProvider vmLifecycleTask = vmLifecyleTasks.get(type); - configureVMWrapperTasks(vmProject, entry.getValue(), depsTasks, wrapperTask -> { - vmLifecycleTask.configure(t -> t.dependsOn(wrapperTask)); - - // Only VM sub-projects that are specifically opted-in to testing Docker should - // have the Docker task added as a dependency. Although we control whether Docker - // is installed in the VM via `Vagrantfile` and we could auto-detect its presence - // in the VM, the test tasks e.g. `destructiveDistroTest.default-docker` are defined - // on the host during Gradle's configuration phase and not in the VM, so - // auto-detection doesn't work. - // - // The shouldTestDocker property could be null, hence we use Boolean.TRUE.equals() - boolean shouldExecute = (type != OpenSearchDistribution.Type.DOCKER) - || Boolean.TRUE.equals(vmProject.findProperty("shouldTestDocker")); - - if (shouldExecute) { - distroTest.configure(t -> t.dependsOn(wrapperTask)); - } - }, vmDependencies); - } - - for (Entry>> entry : upgradeTestTasks.entrySet()) { - String version = entry.getKey(); - TaskProvider vmVersionTask = vmVersionTasks.get(version); - configureVMWrapperTasks( - vmProject, - entry.getValue(), - depsTasks, - wrapperTask -> { vmVersionTask.configure(t -> t.dependsOn(wrapperTask)); }, - vmDependencies - ); - } - } - }); - } - - private static Map> lifecycleTasks(Project project, String taskPrefix) { - Map> lifecyleTasks = new HashMap<>(); - - lifecyleTasks.put(OpenSearchDistribution.Type.DOCKER, project.getTasks().register(taskPrefix + ".docker")); - lifecyleTasks.put(OpenSearchDistribution.Type.ARCHIVE, project.getTasks().register(taskPrefix + ".archives")); - lifecyleTasks.put(OpenSearchDistribution.Type.DEB, project.getTasks().register(taskPrefix + ".packages")); - lifecyleTasks.put(OpenSearchDistribution.Type.RPM, lifecyleTasks.get(OpenSearchDistribution.Type.DEB)); - - return lifecyleTasks; - } - - private static Map> versionTasks(Project project, String taskPrefix) { - Map> versionTasks = new HashMap<>(); - - for (Version version : BuildParams.getBwcVersions().getIndexCompatible()) { - versionTasks.put(version.toString(), project.getTasks().register(taskPrefix + ".v" + version)); - } - - return versionTasks; - } - - private static TaskProvider createJdk( - Project project, - String purpose, - String vendor, - String version, - String platform, - String architecture - ) { - Jdk jdk = JdkDownloadPlugin.getContainer(project).create(platform + "-" + purpose); - jdk.setVendor(vendor); - jdk.setVersion(version); - jdk.setPlatform(platform); - jdk.setArchitecture(architecture); - - String taskname = "copy" + Util.capitalize(platform) + Util.capitalize(purpose) + "Jdk"; - TaskProvider copyTask = project.getTasks().register(taskname, Copy.class); - copyTask.configure(t -> { - t.from(jdk); - t.into(new File(project.getBuildDir(), "jdks/" + platform + "-" + architecture + "-" + vendor + "-" + version)); - }); - return copyTask; - } - - private static void configureVM(Project project, TaskProvider gradleJdkProvider, TaskProvider systemJdkProvider) { - String box = project.getName(); - - // setup VM used by these tests - VagrantExtension vagrant = project.getExtensions().getByType(VagrantExtension.class); - vagrant.setBox(box); - vagrant.vmEnv("SYSTEM_JAVA_HOME", convertPath(project, vagrant, systemJdkProvider, "", "")); - // set java home for gradle to use. package tests will overwrite/remove this for each test case - vagrant.vmEnv("JAVA_HOME", convertPath(project, vagrant, gradleJdkProvider, "", "")); - if (System.getenv("JENKINS_URL") != null) { - Stream.of("JOB_NAME", "JENKINS_URL", "BUILD_NUMBER", "BUILD_URL").forEach(name -> vagrant.vmEnv(name, System.getenv(name))); - } - vagrant.setIsWindowsVM(isWindows(project)); - } - - private static Object convertPath( - Project project, - VagrantExtension vagrant, - TaskProvider jdkProvider, - String additionaLinux, - String additionalWindows - ) { - return Util.toStringable(() -> { - String hostPath = jdkProvider.get().getDestinationDir().toString(); - if (vagrant.isWindowsVM()) { - return VagrantMachine.convertWindowsPath(project, hostPath) + additionalWindows; - } else { - return VagrantMachine.convertLinuxPath(project, hostPath) + additionaLinux; - } - }); - } - - private static Configuration configureExamplePlugin(Project project) { - Configuration examplePlugin = project.getConfigurations().create(EXAMPLE_PLUGIN_CONFIGURATION); - DependencyHandler deps = project.getDependencies(); - Map examplePluginProject = new HashMap() { - { - put("path", ":example-plugins:custom-settings"); - put("configuration", "zip"); - } - }; - deps.add(EXAMPLE_PLUGIN_CONFIGURATION, deps.project(examplePluginProject)); - return examplePlugin; - } - - private static void configureVMWrapperTasks( - Project project, - List> destructiveTasks, - Map> depsTasks, - Action> configure, - Object... additionalDeps - ) { - for (TaskProvider destructiveTask : destructiveTasks) { - String destructiveTaskName = destructiveTask.getName(); - String taskname = destructiveTaskName.substring("destructive".length()); - taskname = taskname.substring(0, 1).toLowerCase(Locale.ROOT) + taskname.substring(1); - TaskProvider vmTask = project.getTasks().register(taskname, GradleDistroTestTask.class, t -> { - t.setGroup(JavaBasePlugin.VERIFICATION_GROUP); - t.setDescription("Runs " + destructiveTaskName.split("\\.", 2)[1] + " tests within vagrant"); - t.setTaskName(destructiveTaskName); - t.extraArg("-D'" + IN_VM_SYSPROP + "'"); - t.dependsOn(depsTasks.get(destructiveTaskName)); - t.dependsOn(additionalDeps); - }); - configure.execute(vmTask); - } - } - - private static TaskProvider configureTestTask( - Project project, - String taskname, - OpenSearchDistribution distribution, - Action configure, - Object... deps - ) { - return project.getTasks().register(taskname, Test.class, t -> { - // Only run tests for the current architecture - t.onlyIf(t3 -> distribution.getArchitecture() == Architecture.current()); - t.getOutputs().doNotCacheIf("Build cache is disabled for packaging tests", Specs.satisfyAll()); - t.setMaxParallelForks(1); - t.setWorkingDir(project.getProjectDir()); - if (System.getProperty(IN_VM_SYSPROP) == null) { - t.dependsOn(deps); - } - configure.execute(t); - }); - } - - private List configureDistributions(Project project) { - NamedDomainObjectContainer distributions = DistributionDownloadPlugin.getContainer(project); - List currentDistros = new ArrayList<>(); - - for (Architecture architecture : Architecture.values()) { - for (OpenSearchDistribution.Type type : Arrays.asList( - OpenSearchDistribution.Type.DEB, - OpenSearchDistribution.Type.RPM, - OpenSearchDistribution.Type.DOCKER - )) { - for (boolean bundledJdk : Arrays.asList(true, false)) { - if (bundledJdk == false) { - // We'll never publish an ARM (arm64) build without a bundled JDK. - if (architecture == Architecture.ARM64) { - continue; - } - // All our Docker images include a bundled JDK so it doesn't make sense to test without one. - if (type == OpenSearchDistribution.Type.DOCKER) { - continue; - } - } - - currentDistros.add( - createDistro(distributions, architecture, type, null, bundledJdk, VersionProperties.getOpenSearch()) - ); - } - } - } - - for (Architecture architecture : Architecture.values()) { - for (OpenSearchDistribution.Platform platform : Arrays.asList( - OpenSearchDistribution.Platform.LINUX, - OpenSearchDistribution.Platform.WINDOWS - )) { - for (boolean bundledJdk : Arrays.asList(true, false)) { - if (bundledJdk == false && architecture != Architecture.X64) { - // We will never publish distributions for non-x86 (amd64) platforms - // without a bundled JDK - continue; - } - - currentDistros.add( - createDistro( - distributions, - architecture, - OpenSearchDistribution.Type.ARCHIVE, - platform, - bundledJdk, - VersionProperties.getOpenSearch() - ) - ); - } - } - } - - return currentDistros; - } - - private static OpenSearchDistribution createDistro( - NamedDomainObjectContainer distributions, - Architecture architecture, - OpenSearchDistribution.Type type, - OpenSearchDistribution.Platform platform, - boolean bundledJdk, - String version - ) { - String name = distroId(type, platform, bundledJdk, architecture) + "-" + version; - boolean isDocker = type == OpenSearchDistribution.Type.DOCKER; - OpenSearchDistribution distro = distributions.create(name, d -> { - d.setArchitecture(architecture); - d.setType(type); - if (type == OpenSearchDistribution.Type.ARCHIVE) { - d.setPlatform(platform); - } - if (isDocker == false) { - d.setBundledJdk(bundledJdk); - } - d.setVersion(version); - }); - - // Allow us to gracefully omit building Docker distributions if Docker is not available on the system. - // In such a case as we can't build the Docker images we'll simply skip the corresponding tests. - if (isDocker) { - distro.setFailIfUnavailable(false); - } - - return distro; - } - - // return true if the project is for a windows VM, false otherwise - private static boolean isWindows(Project project) { - return project.getName().contains("windows"); - } - - private static String distroId( - OpenSearchDistribution.Type type, - OpenSearchDistribution.Platform platform, - boolean bundledJdk, - Architecture architecture - ) { - return (type == OpenSearchDistribution.Type.ARCHIVE ? platform + "-" : "") + type + (bundledJdk ? "" : "-no-jdk") - + (architecture == Architecture.X64 ? "" : "-" + architecture.toString().toLowerCase()); - } - - private static String destructiveDistroTestTaskName(OpenSearchDistribution distro) { - OpenSearchDistribution.Type type = distro.getType(); - return "destructiveDistroTest." + distroId(type, distro.getPlatform(), distro.getBundledJdk(), distro.getArchitecture()); - } - - private static String destructiveDistroUpgradeTestTaskName(OpenSearchDistribution distro, String bwcVersion) { - OpenSearchDistribution.Type type = distro.getType(); - return "destructiveDistroUpgradeTest.v" - + bwcVersion - + "." - + distroId(type, distro.getPlatform(), distro.getBundledJdk(), distro.getArchitecture()); - } - - private static void addSysprop(Test task, String sysprop, Supplier valueSupplier) { - SystemPropertyCommandLineArgumentProvider props = task.getExtensions().getByType(SystemPropertyCommandLineArgumentProvider.class); - props.systemProperty(sysprop, valueSupplier); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/test/ErrorReportingTestListener.java b/buildSrc/src/main/java/org/opensearch/gradle/test/ErrorReportingTestListener.java deleted file mode 100644 index aff9198e15772..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/test/ErrorReportingTestListener.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test; - -import org.gradle.api.internal.tasks.testing.logging.FullExceptionFormatter; -import org.gradle.api.internal.tasks.testing.logging.TestExceptionFormatter; -import org.gradle.api.logging.Logger; -import org.gradle.api.tasks.testing.TestDescriptor; -import org.gradle.api.tasks.testing.TestListener; -import org.gradle.api.tasks.testing.TestOutputEvent; -import org.gradle.api.tasks.testing.TestOutputListener; -import org.gradle.api.tasks.testing.TestResult; -import org.gradle.api.tasks.testing.logging.TestLogging; - -import java.io.BufferedOutputStream; -import java.io.BufferedReader; -import java.io.Closeable; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.PrintStream; -import java.io.PrintWriter; -import java.io.UncheckedIOException; -import java.io.Writer; -import java.util.Deque; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -public class ErrorReportingTestListener implements TestOutputListener, TestListener { - private static final String REPRODUCE_WITH_PREFIX = "REPRODUCE WITH"; - - private final TestExceptionFormatter formatter; - private final File outputDirectory; - private final Logger taskLogger; - private Map eventWriters = new ConcurrentHashMap<>(); - private Map> reproductionLines = new ConcurrentHashMap<>(); - private Set failedTests = new LinkedHashSet<>(); - - public ErrorReportingTestListener(TestLogging testLogging, Logger taskLogger, File outputDirectory) { - this.formatter = new FullExceptionFormatter(testLogging); - this.taskLogger = taskLogger; - this.outputDirectory = outputDirectory; - } - - @Override - public void onOutput(TestDescriptor testDescriptor, TestOutputEvent outputEvent) { - TestDescriptor suite = testDescriptor.getParent(); - - // Check if this is output from the test suite itself (e.g. afterTest or beforeTest) - if (testDescriptor.isComposite()) { - suite = testDescriptor; - } - - // Hold on to any repro messages so we can report them immediately on test case failure - if (outputEvent.getMessage().startsWith(REPRODUCE_WITH_PREFIX)) { - Deque lines = reproductionLines.computeIfAbsent(Descriptor.of(suite), d -> new LinkedList<>()); - lines.add(outputEvent.getMessage()); - } - - EventWriter eventWriter = eventWriters.computeIfAbsent(Descriptor.of(suite), EventWriter::new); - eventWriter.write(outputEvent); - } - - @Override - public void beforeSuite(TestDescriptor suite) { - - } - - @Override - public void afterSuite(final TestDescriptor suite, TestResult result) { - Descriptor descriptor = Descriptor.of(suite); - - try { - // if the test suite failed, report all captured output - if (result.getResultType().equals(TestResult.ResultType.FAILURE)) { - EventWriter eventWriter = eventWriters.get(descriptor); - - if (eventWriter != null) { - // It's not explicit what the threading guarantees are for TestListener method execution so we'll - // be explicitly safe here to avoid interleaving output from multiple test suites - synchronized (this) { - // make sure we've flushed everything to disk before reading - eventWriter.flush(); - - System.err.println("\n\nSuite: " + suite); - - try (BufferedReader reader = eventWriter.reader()) { - PrintStream out = System.out; - for (String message = reader.readLine(); message != null; message = reader.readLine()) { - if (message.startsWith(" 1> ")) { - out = System.out; - } else if (message.startsWith(" 2> ")) { - out = System.err; - } - - out.println(message); - } - } - } - } - } - if (suite.getParent() == null) { - // per test task top level gradle test run suite finished - if (getFailedTests().size() > 0) { - taskLogger.lifecycle("\nTests with failures:"); - for (ErrorReportingTestListener.Descriptor failure : getFailedTests()) { - taskLogger.lifecycle(" - " + failure.getFullName()); - } - } - } - } catch (IOException e) { - throw new UncheckedIOException("Error reading test suite output", e); - } finally { - reproductionLines.remove(descriptor); - EventWriter writer = eventWriters.remove(descriptor); - if (writer != null) { - try { - writer.close(); - } catch (IOException e) { - taskLogger.error("Failed to close test suite output stream", e); - } - } - } - } - - @Override - public void beforeTest(TestDescriptor testDescriptor) { - - } - - @Override - public void afterTest(TestDescriptor testDescriptor, TestResult result) { - if (result.getResultType() == TestResult.ResultType.FAILURE) { - failedTests.add(Descriptor.of(testDescriptor)); - - if (testDescriptor.getParent() != null) { - // go back and fetch the reproduction line for this test failure - Deque lines = reproductionLines.get(Descriptor.of(testDescriptor.getParent())); - if (lines != null) { - String line = lines.getLast(); - if (line != null) { - System.err.print('\n' + line); - } - } - - // include test failure exception stacktraces in test suite output log - if (result.getExceptions().size() > 0) { - String message = formatter.format(testDescriptor, result.getExceptions()).substring(4); - EventWriter eventWriter = eventWriters.computeIfAbsent(Descriptor.of(testDescriptor.getParent()), EventWriter::new); - - eventWriter.write(new TestOutputEvent() { - @Override - public Destination getDestination() { - return Destination.StdErr; - } - - @Override - public String getMessage() { - return message; - } - }); - } - } - } - } - - public Set getFailedTests() { - return failedTests; - } - - /** - * Class for identifying test output sources. We use this rather than Gradle's {@link TestDescriptor} as we want - * to avoid any nasty memory leak issues that come from keeping Gradle implementation types in memory. Since we - * use this a the key for our HashMap, it's best to control the implementation as there's no guarantee that Gradle's - * various {@link TestDescriptor} implementations reliably implement equals and hashCode. - */ - public static class Descriptor { - private final String name; - private final String className; - private final String parent; - - private Descriptor(String name, String className, String parent) { - this.name = name; - this.className = className; - this.parent = parent; - } - - public static Descriptor of(TestDescriptor d) { - return new Descriptor(d.getName(), d.getClassName(), d.getParent() == null ? null : d.getParent().toString()); - } - - public String getClassName() { - return className; - } - - public String getFullName() { - return className + "." + name; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Descriptor that = (Descriptor) o; - return Objects.equals(name, that.name) && Objects.equals(className, that.className) && Objects.equals(parent, that.parent); - } - - @Override - public int hashCode() { - return Objects.hash(name, className, parent); - } - } - - private class EventWriter implements Closeable { - private final File outputFile; - private final Writer writer; - - EventWriter(Descriptor descriptor) { - this.outputFile = new File(outputDirectory, descriptor.getClassName() + ".out"); - - FileOutputStream fos; - try { - fos = new FileOutputStream(this.outputFile); - } catch (IOException e) { - throw new UncheckedIOException("Unable to create test suite output file", e); - } - - this.writer = new PrintWriter(new BufferedOutputStream(fos)); - } - - public void write(TestOutputEvent event) { - String prefix; - if (event.getDestination() == TestOutputEvent.Destination.StdOut) { - prefix = " 1> "; - } else { - prefix = " 2> "; - } - - try { - if (event.getMessage().equals("\n")) { - writer.write(event.getMessage()); - } else { - writer.write(prefix + event.getMessage()); - } - } catch (IOException e) { - throw new UncheckedIOException("Unable to write test suite output", e); - } - } - - public void flush() throws IOException { - writer.flush(); - } - - public BufferedReader reader() { - try { - return new BufferedReader(new FileReader(outputFile)); - } catch (IOException e) { - throw new UncheckedIOException("Unable to read test suite output file", e); - } - } - - @Override - public void close() throws IOException { - writer.close(); - - // there's no need to keep this stuff on disk after suite execution - outputFile.delete(); - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/test/Fixture.java b/buildSrc/src/main/java/org/opensearch/gradle/test/Fixture.java deleted file mode 100644 index daa7ab637f32e..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/test/Fixture.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test; - -/** - * Any object that can produce an accompanying stop task, meant to tear down - * a previously instantiated service. - */ -public interface Fixture { - - /** A task which will stop this fixture. This should be used as a finalizedBy for any tasks that use the fixture. */ - Object getStopTask(); - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/test/GradleDistroTestTask.java b/buildSrc/src/main/java/org/opensearch/gradle/test/GradleDistroTestTask.java deleted file mode 100644 index 2443a30fc05fb..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/test/GradleDistroTestTask.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test; - -import org.opensearch.gradle.vagrant.VagrantShellTask; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.options.Option; -import org.opensearch.gradle.vagrant.VagrantMachine; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Run a gradle task of the current build, within the configured vagrant VM. - */ -public class GradleDistroTestTask extends VagrantShellTask { - - private String taskName; - private String testClass; - private List extraArgs = new ArrayList<>(); - - public void setTaskName(String taskName) { - this.taskName = taskName; - } - - @Input - public String getTaskName() { - return taskName; - } - - @Option(option = "tests", description = "Sets test class or method name to be included, '*' is supported.") - public void setTestClass(String testClass) { - this.testClass = testClass; - } - - @Input - public List getExtraArgs() { - return extraArgs; - } - - public void extraArg(String arg) { - this.extraArgs.add(arg); - } - - @Override - protected List getWindowsScript() { - return getScript(true); - } - - @Override - protected List getLinuxScript() { - return getScript(false); - } - - private List getScript(boolean isWindows) { - String cacheDir = getProject().getBuildDir() + "/gradle-cache"; - StringBuilder line = new StringBuilder(); - line.append(isWindows ? "& .\\gradlew " : "./gradlew "); - line.append(taskName); - line.append(" --project-cache-dir "); - line.append( - isWindows ? VagrantMachine.convertWindowsPath(getProject(), cacheDir) : VagrantMachine.convertLinuxPath(getProject(), cacheDir) - ); - line.append(" -S"); - line.append(" --parallel"); - line.append(" -D'org.gradle.logging.level'=" + getProject().getGradle().getStartParameter().getLogLevel()); - if (testClass != null) { - line.append(" --tests="); - line.append(testClass); - } - extraArgs.stream().map(s -> " " + s).forEach(line::append); - return Collections.singletonList(line.toString()); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/test/InternalClusterTestPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/test/InternalClusterTestPlugin.java deleted file mode 100644 index ee18fe44961fd..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/test/InternalClusterTestPlugin.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test; - -import org.opensearch.gradle.util.GradleUtils; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.tasks.SourceSet; - -public class InternalClusterTestPlugin implements Plugin { - - public static final String SOURCE_SET_NAME = "internalClusterTest"; - - @Override - public void apply(Project project) { - GradleUtils.addTestSourceSet(project, SOURCE_SET_NAME); - - // TODO: fix usages of IT tests depending on Tests methods so this extension is not necessary - GradleUtils.extendSourceSet(project, SourceSet.TEST_SOURCE_SET_NAME, SOURCE_SET_NAME); - - // add alias task that is easier to type - project.getTasks().register("icTest").configure(alias -> alias.dependsOn(SOURCE_SET_NAME)); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/test/JNAKernel32Library.java b/buildSrc/src/main/java/org/opensearch/gradle/test/JNAKernel32Library.java deleted file mode 100644 index 9d575364f5546..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/test/JNAKernel32Library.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test; - -import com.sun.jna.Native; -import com.sun.jna.WString; -import org.apache.tools.ant.taskdefs.condition.Os; - -public class JNAKernel32Library { - - private static final class Holder { - private static final JNAKernel32Library instance = new JNAKernel32Library(); - } - - static JNAKernel32Library getInstance() { - return Holder.instance; - } - - private JNAKernel32Library() { - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - Native.register("kernel32"); - } - } - - native int GetShortPathNameW(WString lpszLongPath, char[] lpszShortPath, int cchBuffer); - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/test/RestIntegTestTask.java b/buildSrc/src/main/java/org/opensearch/gradle/test/RestIntegTestTask.java deleted file mode 100644 index d1671146d0b77..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/test/RestIntegTestTask.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test; - -import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask; -import org.gradle.api.tasks.CacheableTask; - -/** - * Sub typed version of {@link StandaloneRestIntegTestTask} that is used to differentiate between plain standalone - * integ test tasks based on {@link StandaloneRestIntegTestTask} and - * conventional configured tasks of {@link RestIntegTestTask} - */ -@CacheableTask -public class RestIntegTestTask extends StandaloneRestIntegTestTask {} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/test/RestTestBasePlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/test/RestTestBasePlugin.java deleted file mode 100644 index ce5210482c055..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/test/RestTestBasePlugin.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test; - -import org.opensearch.gradle.OpenSearchTestBasePlugin; -import org.opensearch.gradle.SystemPropertyCommandLineArgumentProvider; -import org.opensearch.gradle.testclusters.OpenSearchCluster; -import org.opensearch.gradle.testclusters.TestClustersPlugin; -import org.gradle.api.NamedDomainObjectContainer; -import org.gradle.api.Plugin; -import org.gradle.api.Project; - -public class RestTestBasePlugin implements Plugin { - private static final String TESTS_REST_CLUSTER = "tests.rest.cluster"; - private static final String TESTS_CLUSTER = "tests.cluster"; - private static final String TESTS_CLUSTER_NAME = "tests.clustername"; - - @Override - public void apply(Project project) { - project.getPluginManager().apply(TestClustersPlugin.class); - project.getPluginManager().apply(OpenSearchTestBasePlugin.class); - project.getTasks().withType(RestIntegTestTask.class).configureEach(restIntegTestTask -> { - @SuppressWarnings("unchecked") - NamedDomainObjectContainer testClusters = (NamedDomainObjectContainer) project - .getExtensions() - .getByName(TestClustersPlugin.EXTENSION_NAME); - OpenSearchCluster cluster = testClusters.maybeCreate(restIntegTestTask.getName()); - restIntegTestTask.useCluster(cluster); - restIntegTestTask.include("**/*IT.class"); - restIntegTestTask.systemProperty("tests.rest.load_packaged", Boolean.FALSE.toString()); - if (System.getProperty(TESTS_REST_CLUSTER) == null) { - if (System.getProperty(TESTS_CLUSTER) != null || System.getProperty(TESTS_CLUSTER_NAME) != null) { - throw new IllegalArgumentException( - String.format("%s, %s, and %s must all be null or non-null", TESTS_REST_CLUSTER, TESTS_CLUSTER, TESTS_CLUSTER_NAME) - ); - } - SystemPropertyCommandLineArgumentProvider runnerNonInputProperties = - (SystemPropertyCommandLineArgumentProvider) restIntegTestTask.getExtensions().getByName("nonInputProperties"); - runnerNonInputProperties.systemProperty(TESTS_REST_CLUSTER, () -> String.join(",", cluster.getAllHttpSocketURI())); - runnerNonInputProperties.systemProperty(TESTS_CLUSTER, () -> String.join(",", cluster.getAllTransportPortURI())); - runnerNonInputProperties.systemProperty(TESTS_CLUSTER_NAME, cluster::getName); - } else { - if (System.getProperty(TESTS_CLUSTER) == null || System.getProperty(TESTS_CLUSTER_NAME) == null) { - throw new IllegalArgumentException( - String.format("%s, %s, and %s must all be null or non-null", TESTS_REST_CLUSTER, TESTS_CLUSTER, TESTS_CLUSTER_NAME) - ); - } - } - }); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/test/rest/CopyRestApiTask.java b/buildSrc/src/main/java/org/opensearch/gradle/test/rest/CopyRestApiTask.java deleted file mode 100644 index 399cd39d236d7..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/test/rest/CopyRestApiTask.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test.rest; - -import org.opensearch.gradle.VersionProperties; -import org.opensearch.gradle.info.BuildParams; -import org.opensearch.gradle.util.GradleUtils; -import org.gradle.api.DefaultTask; -import org.gradle.api.Project; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.file.ArchiveOperations; -import org.gradle.api.file.ConfigurableFileCollection; -import org.gradle.api.file.FileSystemOperations; -import org.gradle.api.file.FileTree; -import org.gradle.api.plugins.JavaPluginConvention; -import org.gradle.api.provider.ListProperty; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.InputFiles; -import org.gradle.api.tasks.OutputDirectory; -import org.gradle.api.tasks.SkipWhenEmpty; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.TaskAction; -import org.gradle.api.tasks.util.PatternFilterable; -import org.gradle.api.tasks.util.PatternSet; -import org.gradle.internal.Factory; - -import javax.inject.Inject; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * Copies the files needed for the Rest YAML specs to the current projects test resources output directory. - * This is intended to be be used from {@link RestResourcesPlugin} since the plugin wires up the needed - * configurations and custom extensions. - * @see RestResourcesPlugin - */ -public class CopyRestApiTask extends DefaultTask { - private static final String REST_API_PREFIX = "rest-api-spec/api"; - final ListProperty includeCore = getProject().getObjects().listProperty(String.class); - String sourceSetName; - boolean skipHasRestTestCheck; - Configuration coreConfig; - Configuration additionalConfig; - - private final PatternFilterable corePatternSet; - - public CopyRestApiTask() { - corePatternSet = getPatternSetFactory().create(); - } - - @Inject - protected Factory getPatternSetFactory() { - throw new UnsupportedOperationException(); - } - - @Inject - protected FileSystemOperations getFileSystemOperations() { - throw new UnsupportedOperationException(); - } - - @Inject - protected ArchiveOperations getArchiveOperations() { - throw new UnsupportedOperationException(); - } - - @Input - public ListProperty getIncludeCore() { - return includeCore; - } - - @Input - String getSourceSetName() { - return sourceSetName; - } - - @Input - public boolean isSkipHasRestTestCheck() { - return skipHasRestTestCheck; - } - - @SkipWhenEmpty - @InputFiles - public FileTree getInputDir() { - FileTree coreFileTree = null; - boolean projectHasYamlRestTests = skipHasRestTestCheck || projectHasYamlRestTests(); - if (includeCore.get().isEmpty() == false || projectHasYamlRestTests) { - if (BuildParams.isInternal()) { - corePatternSet.setIncludes(includeCore.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList())); - coreFileTree = coreConfig.getAsFileTree().matching(corePatternSet); // directory on disk - } else { - coreFileTree = coreConfig.getAsFileTree(); // jar file - } - } - - ConfigurableFileCollection fileCollection = additionalConfig == null - ? getProject().files(coreFileTree) - : getProject().files(coreFileTree, additionalConfig.getAsFileTree()); - - // if project has rest tests or the includes are explicitly configured execute the task, else NO-SOURCE due to the null input - return projectHasYamlRestTests || includeCore.get().isEmpty() == false ? fileCollection.getAsFileTree() : null; - } - - @OutputDirectory - public File getOutputDir() { - return new File( - getSourceSet().orElseThrow(() -> new IllegalArgumentException("could not find source set [" + sourceSetName + "]")) - .getOutput() - .getResourcesDir(), - REST_API_PREFIX - ); - } - - @TaskAction - void copy() { - // always copy the core specs if the task executes - String projectPath = GradleUtils.getProjectPathFromTask(getPath()); - if (BuildParams.isInternal()) { - getLogger().debug("Rest specs for project [{}] will be copied to the test resources.", projectPath); - getFileSystemOperations().copy(c -> { - c.from(coreConfig.getAsFileTree()); - c.into(getOutputDir()); - c.include(corePatternSet.getIncludes()); - }); - } else { - getLogger().debug( - "Rest specs for project [{}] will be copied to the test resources from the published jar (version: [{}]).", - projectPath, - VersionProperties.getOpenSearch() - ); - getFileSystemOperations().copy(c -> { - c.from(getArchiveOperations().zipTree(coreConfig.getSingleFile())); - // this ends up as the same dir as outputDir - c.into(Objects.requireNonNull(getSourceSet().get().getOutput().getResourcesDir())); - if (includeCore.get().isEmpty()) { - c.include(REST_API_PREFIX + "/**"); - } else { - c.include( - includeCore.get().stream().map(prefix -> REST_API_PREFIX + "/" + prefix + "*/**").collect(Collectors.toList()) - ); - } - }); - } - // TODO: once https://github.com/elastic/elasticsearch/pull/62968 lands ensure that this uses `getFileSystemOperations()` - // copy any additional config - if (additionalConfig != null) { - getFileSystemOperations().copy(c -> { - c.from(additionalConfig.getAsFileTree()); - c.into(getOutputDir()); - }); - } - } - - /** - * Returns true if any files with a .yml extension exist the test resources rest-api-spec/test directory (from source or output dir) - */ - private boolean projectHasYamlRestTests() { - File testSourceResourceDir = getTestSourceResourceDir(); - File testOutputResourceDir = getTestOutputResourceDir(); // check output for cases where tests are copied programmatically - - if (testSourceResourceDir == null && testOutputResourceDir == null) { - return false; - } - try { - if (testSourceResourceDir != null && new File(testSourceResourceDir, "rest-api-spec/test").exists()) { - return Files.walk(testSourceResourceDir.toPath().resolve("rest-api-spec/test")) - .anyMatch(p -> p.getFileName().toString().endsWith("yml")); - } - if (testOutputResourceDir != null && new File(testOutputResourceDir, "rest-api-spec/test").exists()) { - return Files.walk(testOutputResourceDir.toPath().resolve("rest-api-spec/test")) - .anyMatch(p -> p.getFileName().toString().endsWith("yml")); - } - } catch (IOException e) { - throw new IllegalStateException(String.format("Error determining if this project [%s] has rest tests.", getProject()), e); - } - return false; - } - - private File getTestSourceResourceDir() { - Optional testSourceSet = getSourceSet(); - if (testSourceSet.isPresent()) { - SourceSet testSources = testSourceSet.get(); - Set resourceDir = testSources.getResources() - .getSrcDirs() - .stream() - .filter(f -> f.isDirectory() && f.getParentFile().getName().equals(getSourceSetName()) && f.getName().equals("resources")) - .collect(Collectors.toSet()); - assert resourceDir.size() <= 1; - if (resourceDir.size() == 0) { - return null; - } - return resourceDir.iterator().next(); - } else { - return null; - } - } - - private File getTestOutputResourceDir() { - Optional testSourceSet = getSourceSet(); - return testSourceSet.map(sourceSet -> sourceSet.getOutput().getResourcesDir()).orElse(null); - } - - private Optional getSourceSet() { - Project project = getProject(); - return project.getConvention().findPlugin(JavaPluginConvention.class) == null - ? Optional.empty() - : Optional.ofNullable(GradleUtils.getJavaSourceSets(project).findByName(getSourceSetName())); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/test/rest/CopyRestTestsTask.java b/buildSrc/src/main/java/org/opensearch/gradle/test/rest/CopyRestTestsTask.java deleted file mode 100644 index 56ce449f4cf6f..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/test/rest/CopyRestTestsTask.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test.rest; - -import org.opensearch.gradle.VersionProperties; -import org.opensearch.gradle.info.BuildParams; -import org.opensearch.gradle.util.GradleUtils; -import org.gradle.api.DefaultTask; -import org.gradle.api.Project; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.file.ArchiveOperations; -import org.gradle.api.file.ConfigurableFileCollection; -import org.gradle.api.file.FileSystemOperations; -import org.gradle.api.file.FileTree; -import org.gradle.api.plugins.JavaPluginConvention; -import org.gradle.api.provider.ListProperty; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.InputFiles; -import org.gradle.api.tasks.OutputDirectory; -import org.gradle.api.tasks.SkipWhenEmpty; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.TaskAction; -import org.gradle.api.tasks.util.PatternFilterable; -import org.gradle.api.tasks.util.PatternSet; -import org.gradle.internal.Factory; - -import javax.inject.Inject; -import java.io.File; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * Copies the Rest YAML test to the current projects test resources output directory. - * This is intended to be be used from {@link RestResourcesPlugin} since the plugin wires up the needed - * configurations and custom extensions. - * @see RestResourcesPlugin - */ -public class CopyRestTestsTask extends DefaultTask { - private static final String REST_TEST_PREFIX = "rest-api-spec/test"; - final ListProperty includeCore = getProject().getObjects().listProperty(String.class); - - String sourceSetName; - Configuration coreConfig; - Configuration additionalConfig; - - private final PatternFilterable corePatternSet; - - public CopyRestTestsTask() { - corePatternSet = getPatternSetFactory().create(); - } - - @Inject - protected Factory getPatternSetFactory() { - throw new UnsupportedOperationException(); - } - - @Inject - protected FileSystemOperations getFileSystemOperations() { - throw new UnsupportedOperationException(); - } - - @Inject - protected ArchiveOperations getArchiveOperations() { - throw new UnsupportedOperationException(); - } - - @Input - public ListProperty getIncludeCore() { - return includeCore; - } - - @Input - String getSourceSetName() { - return sourceSetName; - } - - @SkipWhenEmpty - @InputFiles - public FileTree getInputDir() { - FileTree coreFileTree = null; - if (includeCore.get().isEmpty() == false) { - if (BuildParams.isInternal()) { - corePatternSet.setIncludes(includeCore.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList())); - coreFileTree = coreConfig.getAsFileTree().matching(corePatternSet); // directory on disk - } else { - coreFileTree = coreConfig.getAsFileTree(); // jar file - } - } - ConfigurableFileCollection fileCollection = additionalConfig == null - ? getProject().files(coreFileTree) - : getProject().files(coreFileTree, additionalConfig.getAsFileTree()); - - // copy tests only if explicitly requested - return includeCore.get().isEmpty() == false || additionalConfig != null ? fileCollection.getAsFileTree() : null; - } - - @OutputDirectory - public File getOutputDir() { - return new File( - getSourceSet().orElseThrow(() -> new IllegalArgumentException("could not find source set [" + sourceSetName + "]")) - .getOutput() - .getResourcesDir(), - REST_TEST_PREFIX - ); - } - - @TaskAction - void copy() { - String projectPath = GradleUtils.getProjectPathFromTask(getPath()); - // only copy core tests if explicitly instructed - if (includeCore.get().isEmpty() == false) { - if (BuildParams.isInternal()) { - getLogger().debug("Rest tests for project [{}] will be copied to the test resources.", projectPath); - getFileSystemOperations().copy(c -> { - c.from(coreConfig.getAsFileTree()); - c.into(getOutputDir()); - c.include(corePatternSet.getIncludes()); - }); - } else { - getLogger().debug( - "Rest tests for project [{}] will be copied to the test resources from the published jar (version: [{}]).", - projectPath, - VersionProperties.getOpenSearch() - ); - getFileSystemOperations().copy(c -> { - c.from(getArchiveOperations().zipTree(coreConfig.getSingleFile())); - // this ends up as the same dir as outputDir - c.into(Objects.requireNonNull(getSourceSet().get().getOutput().getResourcesDir())); - c.include( - includeCore.get().stream().map(prefix -> REST_TEST_PREFIX + "/" + prefix + "*/**").collect(Collectors.toList()) - ); - }); - } - } - // copy any additional config - if (additionalConfig != null) { - getFileSystemOperations().copy(c -> { - c.from(additionalConfig.getAsFileTree()); - c.into(getOutputDir()); - }); - } - } - - private Optional getSourceSet() { - Project project = getProject(); - return project.getConvention().findPlugin(JavaPluginConvention.class) == null - ? Optional.empty() - : Optional.ofNullable(GradleUtils.getJavaSourceSets(project).findByName(getSourceSetName())); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/test/rest/JavaRestTestPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/test/rest/JavaRestTestPlugin.java deleted file mode 100644 index f59eda3d4b982..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/test/rest/JavaRestTestPlugin.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test.rest; - -import org.opensearch.gradle.OpenSearchJavaPlugin; -import org.opensearch.gradle.test.RestIntegTestTask; -import org.opensearch.gradle.test.RestTestBasePlugin; -import org.opensearch.gradle.testclusters.TestClustersPlugin; -import org.opensearch.gradle.util.GradleUtils; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.plugins.JavaBasePlugin; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.SourceSetContainer; - -import static org.opensearch.gradle.test.rest.RestTestUtil.createTestCluster; -import static org.opensearch.gradle.test.rest.RestTestUtil.registerTask; -import static org.opensearch.gradle.test.rest.RestTestUtil.setupDependencies; - -/** - * Apply this plugin to run the Java based REST tests. - */ -public class JavaRestTestPlugin implements Plugin { - - public static final String SOURCE_SET_NAME = "javaRestTest"; - - @Override - public void apply(Project project) { - - project.getPluginManager().apply(OpenSearchJavaPlugin.class); - project.getPluginManager().apply(RestTestBasePlugin.class); - project.getPluginManager().apply(TestClustersPlugin.class); - - // create source set - SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet javaTestSourceSet = sourceSets.create(SOURCE_SET_NAME); - - // create the test cluster container - createTestCluster(project, javaTestSourceSet); - - // setup the javaRestTest task - Provider javaRestTestTask = registerTask(project, javaTestSourceSet); - - // setup dependencies - setupDependencies(project, javaTestSourceSet); - - // setup IDE - GradleUtils.setupIdeForTestSourceSet(project, javaTestSourceSet); - - // wire this task into check - project.getTasks().named(JavaBasePlugin.CHECK_TASK_NAME).configure(check -> check.dependsOn(javaRestTestTask)); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/test/rest/RestResourcesExtension.java b/buildSrc/src/main/java/org/opensearch/gradle/test/rest/RestResourcesExtension.java deleted file mode 100644 index 0fe2dfd7f68a2..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/test/rest/RestResourcesExtension.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test.rest; - -import org.gradle.api.Action; -import org.gradle.api.model.ObjectFactory; -import org.gradle.api.provider.ListProperty; - -import javax.inject.Inject; - -/** - * Custom extension to configure the {@link CopyRestApiTask} - */ -public class RestResourcesExtension { - - final RestResourcesSpec restApi; - final RestResourcesSpec restTests; - - @Inject - public RestResourcesExtension(ObjectFactory objects) { - restApi = new RestResourcesSpec(objects); - restTests = new RestResourcesSpec(objects); - } - - void restApi(Action spec) { - spec.execute(restApi); - } - - void restTests(Action spec) { - spec.execute(restTests); - } - - static class RestResourcesSpec { - - private final ListProperty includeCore; - - RestResourcesSpec(ObjectFactory objects) { - includeCore = objects.listProperty(String.class); - } - - public void includeCore(String... include) { - this.includeCore.addAll(include); - } - - public ListProperty getIncludeCore() { - return includeCore; - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/test/rest/RestResourcesPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/test/rest/RestResourcesPlugin.java deleted file mode 100644 index 728e36ce98bff..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/test/rest/RestResourcesPlugin.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test.rest; - -import org.opensearch.gradle.VersionProperties; -import org.opensearch.gradle.info.BuildParams; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.Dependency; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.SourceSetContainer; - -import java.util.HashMap; - -/** - *

    - * Gradle plugin to help configure {@link CopyRestApiTask}'s and {@link CopyRestTestsTask} that copies the artifacts needed for the Rest API - * spec and YAML based rest tests. - *

    - * Rest API specification:
    - * When the {@link RestResourcesPlugin} has been applied the {@link CopyRestApiTask} will automatically copy the core Rest API specification - * if there are any Rest YAML tests present in source, or copied from {@link CopyRestTestsTask} output. - * It is recommended (but not required) to also explicitly declare which core specs your project depends on to help optimize the caching - * behavior. - * For example: - *
    - * restResources {
    - *   restApi {
    - *     includeCore 'index', 'cat'
    - *   }
    - * }
    - * 
    - *
    - * Rest YAML tests :
    - * When the {@link RestResourcesPlugin} has been applied the {@link CopyRestTestsTask} will copy the Rest YAML tests if explicitly - * configured with `includeCore` through the `restResources.restTests` extension. - * - * Additionally you can specify which sourceSetName resources should be copied to. The default is the yamlRestTest source set. - * @see CopyRestApiTask - * @see CopyRestTestsTask - */ -public class RestResourcesPlugin implements Plugin { - - private static final String EXTENSION_NAME = "restResources"; - - @Override - public void apply(Project project) { - RestResourcesExtension extension = project.getExtensions().create(EXTENSION_NAME, RestResourcesExtension.class); - - // tests - Configuration testConfig = project.getConfigurations().create("restTestConfig"); - project.getConfigurations().create("restTests"); - Provider copyRestYamlTestTask = project.getTasks() - .register("copyYamlTestsTask", CopyRestTestsTask.class, task -> { - task.includeCore.set(extension.restTests.getIncludeCore()); - task.coreConfig = testConfig; - task.sourceSetName = SourceSet.TEST_SOURCE_SET_NAME; - if (BuildParams.isInternal()) { - // core - Dependency restTestdependency = project.getDependencies().project(new HashMap() { - { - put("path", ":rest-api-spec"); - put("configuration", "restTests"); - } - }); - project.getDependencies().add(task.coreConfig.getName(), restTestdependency); - } else { - Dependency dependency = project.getDependencies() - .create("org.opensearch:rest-api-spec:" + VersionProperties.getOpenSearch()); - project.getDependencies().add(task.coreConfig.getName(), dependency); - } - task.dependsOn(task.coreConfig); - }); - - // api - Configuration specConfig = project.getConfigurations().create("restSpec"); // name chosen for passivity - project.getConfigurations().create("restSpecs"); - Provider copyRestYamlSpecTask = project.getTasks() - .register("copyRestApiSpecsTask", CopyRestApiTask.class, task -> { - task.includeCore.set(extension.restApi.getIncludeCore()); - task.dependsOn(copyRestYamlTestTask); - task.coreConfig = specConfig; - task.sourceSetName = SourceSet.TEST_SOURCE_SET_NAME; - if (BuildParams.isInternal()) { - Dependency restSpecDependency = project.getDependencies().project(new HashMap() { - { - put("path", ":rest-api-spec"); - put("configuration", "restSpecs"); - } - }); - project.getDependencies().add(task.coreConfig.getName(), restSpecDependency); - } else { - Dependency dependency = project.getDependencies() - .create("org.opensearch:rest-api-spec:" + VersionProperties.getOpenSearch()); - project.getDependencies().add(task.coreConfig.getName(), dependency); - } - task.dependsOn(task.coreConfig); - }); - - project.afterEvaluate(p -> { - SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet testSourceSet = sourceSets.findByName(SourceSet.TEST_SOURCE_SET_NAME); - if (testSourceSet != null) { - project.getTasks().named(testSourceSet.getProcessResourcesTaskName()).configure(t -> t.dependsOn(copyRestYamlSpecTask)); - } - }); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/test/rest/RestTestUtil.java b/buildSrc/src/main/java/org/opensearch/gradle/test/rest/RestTestUtil.java deleted file mode 100644 index 061c477fab086..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/test/rest/RestTestUtil.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test.rest; - -import org.opensearch.gradle.VersionProperties; -import org.opensearch.gradle.info.BuildParams; -import org.opensearch.gradle.test.RestIntegTestTask; -import org.opensearch.gradle.testclusters.OpenSearchCluster; -import org.opensearch.gradle.testclusters.TestClustersPlugin; -import org.gradle.api.NamedDomainObjectContainer; -import org.gradle.api.Project; -import org.gradle.api.plugins.JavaBasePlugin; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.bundling.Zip; - -/** - * Utility class to configure the necessary tasks and dependencies. - */ -public class RestTestUtil { - - private RestTestUtil() {} - - static OpenSearchCluster createTestCluster(Project project, SourceSet sourceSet) { - // eagerly create the testCluster container so it is easily available for configuration - @SuppressWarnings("unchecked") - NamedDomainObjectContainer testClusters = (NamedDomainObjectContainer) project.getExtensions() - .getByName(TestClustersPlugin.EXTENSION_NAME); - return testClusters.create(sourceSet.getName()); - } - - /** - * Creates a task with the source set name of type {@link RestIntegTestTask} - */ - static Provider registerTask(Project project, SourceSet sourceSet) { - // lazily create the test task - Provider testProvider = project.getTasks().register(sourceSet.getName(), RestIntegTestTask.class, testTask -> { - testTask.setGroup(JavaBasePlugin.VERIFICATION_GROUP); - testTask.setDescription("Runs the REST tests against an external cluster"); - testTask.mustRunAfter(project.getTasks().named("test")); - testTask.setTestClassesDirs(sourceSet.getOutput().getClassesDirs()); - testTask.setClasspath(sourceSet.getRuntimeClasspath()); - // if this a module or plugin, it may have an associated zip file with it's contents, add that to the test cluster - project.getPluginManager().withPlugin("opensearch.opensearchplugin", plugin -> { - Zip bundle = (Zip) project.getTasks().getByName("bundlePlugin"); - testTask.dependsOn(bundle); - if (project.getPath().contains("modules:")) { - testTask.getClusters().forEach(c -> c.module(bundle.getArchiveFile())); - } else { - testTask.getClusters().forEach(c -> c.plugin(project.getObjects().fileProperty().value(bundle.getArchiveFile()))); - } - }); - }); - - return testProvider; - } - - /** - * Setup the dependencies needed for the REST tests. - */ - static void setupDependencies(Project project, SourceSet sourceSet) { - if (BuildParams.isInternal()) { - project.getDependencies().add(sourceSet.getImplementationConfigurationName(), project.project(":test:framework")); - } else { - project.getDependencies() - .add(sourceSet.getImplementationConfigurationName(), "org.opensearch.test:framework:" + VersionProperties.getOpenSearch()); - // The log4j-core is optional dependency of the org.opensearch.test:framework. needs explicit introduction - project.getDependencies() - .add( - sourceSet.getImplementationConfigurationName(), - "org.apache.logging.log4j:log4j-core:" + VersionProperties.getVersions().get("log4j") - ); - } - - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/test/rest/YamlRestTestPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/test/rest/YamlRestTestPlugin.java deleted file mode 100644 index e35365ee9105b..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/test/rest/YamlRestTestPlugin.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test.rest; - -import org.opensearch.gradle.OpenSearchJavaPlugin; -import org.opensearch.gradle.test.RestIntegTestTask; -import org.opensearch.gradle.test.RestTestBasePlugin; -import org.opensearch.gradle.testclusters.TestClustersPlugin; -import org.opensearch.gradle.util.GradleUtils; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.plugins.JavaBasePlugin; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.SourceSetContainer; - -/** - * Apply this plugin to run the YAML based REST tests. - */ -public class YamlRestTestPlugin implements Plugin { - - public static final String SOURCE_SET_NAME = "yamlRestTest"; - - @Override - public void apply(Project project) { - - project.getPluginManager().apply(OpenSearchJavaPlugin.class); - project.getPluginManager().apply(TestClustersPlugin.class); - project.getPluginManager().apply(RestTestBasePlugin.class); - project.getPluginManager().apply(RestResourcesPlugin.class); - - // create source set - SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet yamlTestSourceSet = sourceSets.create(SOURCE_SET_NAME); - - // create the test cluster container - RestTestUtil.createTestCluster(project, yamlTestSourceSet); - - // setup the yamlRestTest task - Provider yamlRestTestTask = RestTestUtil.registerTask(project, yamlTestSourceSet); - - // setup the dependencies - RestTestUtil.setupDependencies(project, yamlTestSourceSet); - - // setup the copy for the rest resources - project.getTasks().withType(CopyRestApiTask.class, copyRestApiTask -> { - copyRestApiTask.sourceSetName = SOURCE_SET_NAME; - project.getTasks().named(yamlTestSourceSet.getProcessResourcesTaskName()).configure(t -> t.dependsOn(copyRestApiTask)); - }); - project.getTasks().withType(CopyRestTestsTask.class, copyRestTestTask -> { copyRestTestTask.sourceSetName = SOURCE_SET_NAME; }); - - // setup IDE - GradleUtils.setupIdeForTestSourceSet(project, yamlTestSourceSet); - - // wire this task into check - project.getTasks().named(JavaBasePlugin.CHECK_TASK_NAME).configure(check -> check.dependsOn(yamlRestTestTask)); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/DefaultTestClustersTask.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/DefaultTestClustersTask.java deleted file mode 100644 index df0b84fcd14dd..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/DefaultTestClustersTask.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testclusters; - -import org.gradle.api.DefaultTask; - -import java.util.Collection; -import java.util.HashSet; - -public class DefaultTestClustersTask extends DefaultTask implements TestClustersAware { - - private Collection clusters = new HashSet<>(); - - @Override - public Collection getClusters() { - return clusters; - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java deleted file mode 100644 index 1e3d714fe186b..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java +++ /dev/null @@ -1,568 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testclusters; - -import org.opensearch.gradle.FileSupplier; -import org.opensearch.gradle.Jdk; -import org.opensearch.gradle.PropertyNormalization; -import org.opensearch.gradle.ReaperService; -import org.opensearch.gradle.http.WaitForHttpResource; -import org.gradle.api.Named; -import org.gradle.api.NamedDomainObjectContainer; -import org.gradle.api.Project; -import org.gradle.api.file.ArchiveOperations; -import org.gradle.api.file.FileSystemOperations; -import org.gradle.api.file.RegularFile; -import org.gradle.api.logging.Logger; -import org.gradle.api.logging.Logging; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.Internal; -import org.gradle.api.tasks.Nested; - -import java.io.File; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.security.GeneralSecurityException; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -public class OpenSearchCluster implements TestClusterConfiguration, Named { - - private static final Logger LOGGER = Logging.getLogger(OpenSearchNode.class); - private static final int CLUSTER_UP_TIMEOUT = 40; - private static final TimeUnit CLUSTER_UP_TIMEOUT_UNIT = TimeUnit.SECONDS; - - private final AtomicBoolean configurationFrozen = new AtomicBoolean(false); - private final String path; - private final String clusterName; - private final NamedDomainObjectContainer nodes; - private final Jdk bwcJdk; - private final File workingDirBase; - private final LinkedHashMap> waitConditions = new LinkedHashMap<>(); - private final Project project; - private final ReaperService reaper; - private final FileSystemOperations fileSystemOperations; - private final ArchiveOperations archiveOperations; - private int nodeIndex = 0; - - public OpenSearchCluster( - String clusterName, - Project project, - ReaperService reaper, - File workingDirBase, - FileSystemOperations fileSystemOperations, - ArchiveOperations archiveOperations, - Jdk bwcJdk - ) { - this.path = project.getPath(); - this.clusterName = clusterName; - this.project = project; - this.reaper = reaper; - this.fileSystemOperations = fileSystemOperations; - this.archiveOperations = archiveOperations; - this.workingDirBase = workingDirBase; - this.nodes = project.container(OpenSearchNode.class); - this.bwcJdk = bwcJdk; - - this.nodes.add( - new OpenSearchNode(path, clusterName + "-0", project, reaper, fileSystemOperations, archiveOperations, workingDirBase, bwcJdk) - ); - // configure the cluster name eagerly so nodes know about it - this.nodes.all((node) -> node.defaultConfig.put("cluster.name", safeName(clusterName))); - - addWaitForClusterHealth(); - } - - public void setNumberOfNodes(int numberOfNodes) { - checkFrozen(); - - if (numberOfNodes < 1) { - throw new IllegalArgumentException("Number of nodes should be >= 1 but was " + numberOfNodes + " for " + this); - } - - if (numberOfNodes <= nodes.size()) { - throw new IllegalArgumentException( - "Cannot shrink " + this + " to have " + numberOfNodes + " nodes as it already has " + getNumberOfNodes() - ); - } - - for (int i = nodes.size(); i < numberOfNodes; i++) { - this.nodes.add( - new OpenSearchNode( - path, - clusterName + "-" + i, - project, - reaper, - fileSystemOperations, - archiveOperations, - workingDirBase, - bwcJdk - ) - ); - } - } - - @Internal - OpenSearchNode getFirstNode() { - return nodes.getAt(clusterName + "-0"); - } - - @Internal - public int getNumberOfNodes() { - return nodes.size(); - } - - @Internal - public String getName() { - return clusterName; - } - - @Internal - public String getPath() { - return path; - } - - @Override - public void setVersion(String version) { - nodes.all(each -> each.setVersion(version)); - } - - @Override - public void setVersions(List version) { - nodes.all(each -> each.setVersions(version)); - } - - @Override - public void setTestDistribution(TestDistribution distribution) { - nodes.all(each -> each.setTestDistribution(distribution)); - } - - @Override - public void plugin(Provider plugin) { - nodes.all(each -> each.plugin(plugin)); - } - - @Override - public void plugin(String pluginProjectPath) { - nodes.all(each -> each.plugin(pluginProjectPath)); - } - - @Override - public void upgradePlugin(List> plugins) { - nodes.all(each -> each.upgradePlugin(plugins)); - } - - @Override - public void module(Provider module) { - nodes.all(each -> each.module(module)); - } - - @Override - public void module(String moduleProjectPath) { - nodes.all(each -> each.module(moduleProjectPath)); - } - - @Override - public void keystore(String key, String value) { - nodes.all(each -> each.keystore(key, value)); - } - - @Override - public void keystore(String key, Supplier valueSupplier) { - nodes.all(each -> each.keystore(key, valueSupplier)); - } - - @Override - public void keystore(String key, File value) { - nodes.all(each -> each.keystore(key, value)); - } - - @Override - public void keystore(String key, File value, PropertyNormalization normalization) { - nodes.all(each -> each.keystore(key, value, normalization)); - } - - @Override - public void keystore(String key, FileSupplier valueSupplier) { - nodes.all(each -> each.keystore(key, valueSupplier)); - } - - @Override - public void keystorePassword(String password) { - nodes.all(each -> each.keystorePassword(password)); - } - - @Override - public void cliSetup(String binTool, CharSequence... args) { - nodes.all(each -> each.cliSetup(binTool, args)); - } - - @Override - public void setting(String key, String value) { - nodes.all(each -> each.setting(key, value)); - } - - @Override - public void setting(String key, String value, PropertyNormalization normalization) { - nodes.all(each -> each.setting(key, value, normalization)); - } - - @Override - public void setting(String key, Supplier valueSupplier) { - nodes.all(each -> each.setting(key, valueSupplier)); - } - - @Override - public void setting(String key, Supplier valueSupplier, PropertyNormalization normalization) { - nodes.all(each -> each.setting(key, valueSupplier, normalization)); - } - - @Override - public void systemProperty(String key, String value) { - nodes.all(each -> each.systemProperty(key, value)); - } - - @Override - public void systemProperty(String key, Supplier valueSupplier) { - nodes.all(each -> each.systemProperty(key, valueSupplier)); - } - - @Override - public void systemProperty(String key, Supplier valueSupplier, PropertyNormalization normalization) { - nodes.all(each -> each.systemProperty(key, valueSupplier, normalization)); - } - - @Override - public void environment(String key, String value) { - nodes.all(each -> each.environment(key, value)); - } - - @Override - public void environment(String key, Supplier valueSupplier) { - nodes.all(each -> each.environment(key, valueSupplier)); - } - - @Override - public void environment(String key, Supplier valueSupplier, PropertyNormalization normalization) { - nodes.all(each -> each.environment(key, valueSupplier, normalization)); - } - - @Override - public void jvmArgs(String... values) { - nodes.all(each -> each.jvmArgs(values)); - } - - @Internal - public boolean isPreserveDataDir() { - return nodes.stream().anyMatch(node -> node.isPreserveDataDir()); - } - - @Override - public void setPreserveDataDir(boolean preserveDataDir) { - nodes.all(each -> each.setPreserveDataDir(preserveDataDir)); - } - - @Override - public void freeze() { - nodes.forEach(OpenSearchNode::freeze); - configurationFrozen.set(true); - } - - private void checkFrozen() { - if (configurationFrozen.get()) { - throw new IllegalStateException("Configuration for " + this + " can not be altered, already locked"); - } - } - - @Override - public void start() { - commonNodeConfig(); - nodes.stream().filter(node -> { - if (node.getVersion().onOrAfter("6.5.0")) { - return true; - } else { - // We already started it to set seed nodes - return node.equals(nodes.iterator().next()) == false; - } - }).forEach(OpenSearchNode::start); - } - - private void commonNodeConfig() { - final String nodeNames; - if (nodes.stream().map(OpenSearchNode::getName).anyMatch(name -> name == null)) { - nodeNames = null; - } else { - nodeNames = nodes.stream().map(OpenSearchNode::getName).map(this::safeName).collect(Collectors.joining(",")); - } - OpenSearchNode firstNode = null; - for (OpenSearchNode node : nodes) { - // Can only configure master nodes if we have node names defined - if (nodeNames != null) { - commonNodeConfig(node, nodeNames, firstNode); - } - if (firstNode == null) { - firstNode = node; - if (node.getVersion().before("6.5.0")) { - // We need to start the first node early to be able to provide unicast.hosts - firstNode.start(); - } - } - } - } - - private void commonNodeConfig(OpenSearchNode node, String nodeNames, OpenSearchNode firstNode) { - if (node.getVersion().onOrAfter("7.0.0")) { - node.defaultConfig.keySet() - .stream() - .filter(name -> name.startsWith("discovery.zen.")) - .collect(Collectors.toList()) - .forEach(node.defaultConfig::remove); - if (nodeNames != null && node.settings.getOrDefault("discovery.type", "anything").equals("single-node") == false) { - node.defaultConfig.put("cluster.initial_master_nodes", "[" + nodeNames + "]"); - } - node.defaultConfig.put("discovery.seed_providers", "file"); - node.defaultConfig.put("discovery.seed_hosts", "[]"); - } else { - node.defaultConfig.put("discovery.zen.master_election.wait_for_joins_timeout", "5s"); - if (nodes.size() > 1) { - node.defaultConfig.put("discovery.zen.minimum_master_nodes", Integer.toString(nodes.size() / 2 + 1)); - } - if (node.getVersion().onOrAfter("6.5.0")) { - node.defaultConfig.put("discovery.zen.hosts_provider", "file"); - node.defaultConfig.put("discovery.zen.ping.unicast.hosts", "[]"); - } else { - if (firstNode == null) { - node.defaultConfig.put("discovery.zen.ping.unicast.hosts", "[]"); - } else { - firstNode.waitForAllConditions(); - node.defaultConfig.put("discovery.zen.ping.unicast.hosts", "[\"" + firstNode.getTransportPortURI() + "\"]"); - } - } - } - } - - @Override - public void restart() { - nodes.forEach(OpenSearchNode::restart); - } - - public void goToNextVersion() { - stop(false); - nodes.all(OpenSearchNode::goToNextVersion); - start(); - writeUnicastHostsFiles(); - } - - public void upgradeAllNodesAndPluginsToNextVersion(List> plugins) { - stop(false); - nodes.all(OpenSearchNode::goToNextVersion); - upgradePlugin(plugins); - start(); - writeUnicastHostsFiles(); - } - - public void fullRestart() { - stop(false); - start(); - } - - public void nextNodeToNextVersion() { - OpenSearchNode node = upgradeNodeToNextVersion(); - node.start(); - } - - public void upgradeNodeAndPluginToNextVersion(List> plugins) { - OpenSearchNode node = upgradeNodeToNextVersion(); - node.upgradePlugin(plugins); - node.start(); - } - - @Override - public void extraConfigFile(String destination, File from) { - nodes.all(node -> node.extraConfigFile(destination, from)); - } - - @Override - public void extraConfigFile(String destination, File from, PropertyNormalization normalization) { - nodes.all(node -> node.extraConfigFile(destination, from, normalization)); - } - - @Override - public void extraJarFile(File from) { - nodes.all(node -> node.extraJarFile(from)); - } - - @Override - public void user(Map userSpec) { - nodes.all(node -> node.user(userSpec)); - } - - private void writeUnicastHostsFiles() { - String unicastUris = nodes.stream().flatMap(node -> node.getAllTransportPortURI().stream()).collect(Collectors.joining("\n")); - nodes.forEach(node -> { - try { - Files.write(node.getConfigDir().resolve("unicast_hosts.txt"), unicastUris.getBytes(StandardCharsets.UTF_8)); - } catch (IOException e) { - throw new UncheckedIOException("Failed to write unicast_hosts for " + this, e); - } - }); - } - - private OpenSearchNode upgradeNodeToNextVersion() { - if (nodeIndex + 1 > nodes.size()) { - throw new TestClustersException("Ran out of nodes to take to the next version"); - } - OpenSearchNode node = nodes.getByName(clusterName + "-" + nodeIndex); - node.stop(false); - node.goToNextVersion(); - commonNodeConfig(node, null, null); - nodeIndex += 1; - return node; - } - - @Override - @Internal - public String getHttpSocketURI() { - waitForAllConditions(); - return getFirstNode().getHttpSocketURI(); - } - - @Override - @Internal - public String getTransportPortURI() { - waitForAllConditions(); - return getFirstNode().getTransportPortURI(); - } - - @Override - @Internal - public List getAllHttpSocketURI() { - waitForAllConditions(); - return nodes.stream().flatMap(each -> each.getAllHttpSocketURI().stream()).collect(Collectors.toList()); - } - - @Override - @Internal - public List getAllTransportPortURI() { - waitForAllConditions(); - return nodes.stream().flatMap(each -> each.getAllTransportPortURI().stream()).collect(Collectors.toList()); - } - - public void waitForAllConditions() { - writeUnicastHostsFiles(); - - LOGGER.info("Starting to wait for cluster to form"); - waitForConditions(waitConditions, System.currentTimeMillis(), CLUSTER_UP_TIMEOUT, CLUSTER_UP_TIMEOUT_UNIT, this); - } - - @Override - public void stop(boolean tailLogs) { - nodes.forEach(each -> each.stop(tailLogs)); - } - - @Override - public void setNameCustomization(Function nameCustomization) { - nodes.all(each -> each.setNameCustomization(nameCustomization)); - } - - @Override - @Internal - public boolean isProcessAlive() { - return nodes.stream().noneMatch(node -> node.isProcessAlive() == false); - } - - public OpenSearchNode singleNode() { - if (nodes.size() != 1) { - throw new IllegalStateException("Can't treat " + this + " as single node as it has " + nodes.size() + " nodes"); - } - return getFirstNode(); - } - - private void addWaitForClusterHealth() { - waitConditions.put("cluster health yellow", (node) -> { - try { - WaitForHttpResource wait = new WaitForHttpResource("http", getFirstNode().getHttpSocketURI(), nodes.size()); - - List> credentials = getFirstNode().getCredentials(); - if (getFirstNode().getCredentials().isEmpty() == false) { - wait.setUsername(credentials.get(0).get("useradd")); - wait.setPassword(credentials.get(0).get("-p")); - } - return wait.wait(500); - } catch (IOException e) { - throw new UncheckedIOException("IO error while waiting cluster", e); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new TestClustersException("Interrupted while waiting for " + this, e); - } catch (GeneralSecurityException e) { - throw new RuntimeException("security exception", e); - } - }); - } - - @Nested - public NamedDomainObjectContainer getNodes() { - return nodes; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - OpenSearchCluster that = (OpenSearchCluster) o; - return Objects.equals(clusterName, that.clusterName) && Objects.equals(path, that.path); - } - - @Override - public int hashCode() { - return Objects.hash(clusterName, path); - } - - @Override - public String toString() { - return "cluster{" + path + ":" + clusterName + "}"; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java deleted file mode 100644 index ec4cbe484c40e..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java +++ /dev/null @@ -1,1597 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testclusters; - -import org.apache.commons.io.FileUtils; -import org.opensearch.gradle.Architecture; -import org.opensearch.gradle.DistributionDownloadPlugin; -import org.opensearch.gradle.OpenSearchDistribution; -import org.opensearch.gradle.FileSupplier; -import org.opensearch.gradle.Jdk; -import org.opensearch.gradle.LazyPropertyList; -import org.opensearch.gradle.LazyPropertyMap; -import org.opensearch.gradle.LoggedExec; -import org.opensearch.gradle.OS; -import org.opensearch.gradle.PropertyNormalization; -import org.opensearch.gradle.ReaperService; -import org.opensearch.gradle.Version; -import org.opensearch.gradle.VersionProperties; -import org.opensearch.gradle.info.BuildParams; -import org.gradle.api.Action; -import org.gradle.api.Named; -import org.gradle.api.NamedDomainObjectContainer; -import org.gradle.api.Project; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.file.ArchiveOperations; -import org.gradle.api.file.FileSystemOperations; -import org.gradle.api.file.FileTree; -import org.gradle.api.file.RegularFile; -import org.gradle.api.logging.Logger; -import org.gradle.api.logging.Logging; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.Classpath; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.InputFile; -import org.gradle.api.tasks.InputFiles; -import org.gradle.api.tasks.Internal; -import org.gradle.api.tasks.Nested; -import org.gradle.api.tasks.Optional; -import org.gradle.api.tasks.PathSensitive; -import org.gradle.api.tasks.PathSensitivity; -import org.gradle.api.tasks.util.PatternFilterable; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.LineNumberReader; -import java.io.UncheckedIOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.nio.file.StandardOpenOption; -import java.time.Instant; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.BiConsumer; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static java.util.Objects.requireNonNull; - -public class OpenSearchNode implements TestClusterConfiguration { - - private static final Logger LOGGER = Logging.getLogger(OpenSearchNode.class); - private static final int OPENSEARCH_DESTROY_TIMEOUT = 20; - private static final TimeUnit OPENSEARCH_DESTROY_TIMEOUT_UNIT = TimeUnit.SECONDS; - - private static final int NODE_UP_TIMEOUT = 2; - private static final TimeUnit NODE_UP_TIMEOUT_UNIT = TimeUnit.MINUTES; - private static final int ADDITIONAL_CONFIG_TIMEOUT = 15; - private static final TimeUnit ADDITIONAL_CONFIG_TIMEOUT_UNIT = TimeUnit.SECONDS; - private static final List OVERRIDABLE_SETTINGS = Arrays.asList( - "path.repo", - "discovery.seed_providers" - - ); - - private static final int TAIL_LOG_MESSAGES_COUNT = 40; - private static final List MESSAGES_WE_DONT_CARE_ABOUT = Arrays.asList( - "Option UseConcMarkSweepGC was deprecated", - "is a pre-release version of OpenSearch", - "max virtual memory areas vm.max_map_count" - ); - private static final String HOSTNAME_OVERRIDE = "LinuxDarwinHostname"; - private static final String COMPUTERNAME_OVERRIDE = "WindowsComputername"; - - private final String path; - private final String name; - private final Project project; - private final ReaperService reaper; - private final Jdk bwcJdk; - private final FileSystemOperations fileSystemOperations; - private final ArchiveOperations archiveOperations; - - private final AtomicBoolean configurationFrozen = new AtomicBoolean(false); - private final Path workingDir; - - private final LinkedHashMap> waitConditions = new LinkedHashMap<>(); - private final Map pluginAndModuleConfigurations = new HashMap<>(); - private final List> plugins = new ArrayList<>(); - private final List> modules = new ArrayList<>(); - final LazyPropertyMap settings = new LazyPropertyMap<>("Settings", this); - private final LazyPropertyMap keystoreSettings = new LazyPropertyMap<>("Keystore", this); - private final LazyPropertyMap keystoreFiles = new LazyPropertyMap<>("Keystore files", this, FileEntry::new); - private final LazyPropertyList cliSetup = new LazyPropertyList<>("CLI setup commands", this); - private final LazyPropertyMap systemProperties = new LazyPropertyMap<>("System properties", this); - private final LazyPropertyMap environment = new LazyPropertyMap<>("Environment", this); - private final LazyPropertyList jvmArgs = new LazyPropertyList<>("JVM arguments", this); - private final LazyPropertyMap extraConfigFiles = new LazyPropertyMap<>("Extra config files", this, FileEntry::new); - private final LazyPropertyList extraJarFiles = new LazyPropertyList<>("Extra jar files", this); - private final List> credentials = new ArrayList<>(); - final LinkedHashMap defaultConfig = new LinkedHashMap<>(); - - private final Path confPathRepo; - private final Path confPathLogs; - private final Path transportPortFile; - private final Path httpPortsFile; - private final Path tmpDir; - - private int currentDistro = 0; - private TestDistribution testDistribution; - private List distributions = new ArrayList<>(); - private volatile Process opensearchProcess; - private Function nameCustomization = Function.identity(); - private boolean isWorkingDirConfigured = false; - private String httpPort = "0"; - private String transportPort = "0"; - private Path confPathData; - private String keystorePassword = ""; - private boolean preserveDataDir = false; - private final Config opensearchConfig; - private final Config legacyESConfig; - private Config currentConfig; - - OpenSearchNode( - String path, - String name, - Project project, - ReaperService reaper, - FileSystemOperations fileSystemOperations, - ArchiveOperations archiveOperations, - File workingDirBase, - Jdk bwcJdk - ) { - this.path = path; - this.name = name; - this.project = project; - this.reaper = reaper; - this.fileSystemOperations = fileSystemOperations; - this.archiveOperations = archiveOperations; - this.bwcJdk = bwcJdk; - workingDir = workingDirBase.toPath().resolve(safeName(name)).toAbsolutePath(); - confPathRepo = workingDir.resolve("repo"); - confPathData = workingDir.resolve("data"); - confPathLogs = workingDir.resolve("logs"); - transportPortFile = confPathLogs.resolve("transport.ports"); - httpPortsFile = confPathLogs.resolve("http.ports"); - tmpDir = workingDir.resolve("tmp"); - waitConditions.put("ports files", this::checkPortsFilesExistWithDelay); - setTestDistribution(TestDistribution.INTEG_TEST); - setVersion(VersionProperties.getOpenSearch()); - opensearchConfig = Config.getOpenSearchConfig(workingDir); - legacyESConfig = Config.getLegacyESConfig(workingDir); - currentConfig = opensearchConfig; - } - - /* - * An object to contain the configuration needed to install - * either an OpenSearch or an elasticsearch distribution on - * this test node. - * - * This is added to be able to run BWC testing against a - * cluster running elasticsearch. - * - * legacyESConfig will be removed in a future release. - */ - private static class Config { - final String distroName; - final String command; - final String keystoreTool; - final String pluginTool; - final String envTempDir; - final String envJavaOpts; - final String envPathConf; - final Path configFile; - final Path stdoutFile; - final Path stderrFile; - final Path stdinFile; - - Config( - String distroName, - String command, - String keystoreTool, - String pluginTool, - String envTempDir, - String envJavaOpts, - String envPathConf, - Path configFile, - Path stdoutFile, - Path stderrFile, - Path stdinFile - ) { - this.distroName = distroName; - this.command = command; - this.keystoreTool = keystoreTool; - this.pluginTool = pluginTool; - this.envTempDir = envTempDir; - this.envJavaOpts = envJavaOpts; - this.envPathConf = envPathConf; - this.configFile = configFile; - this.stdoutFile = stdoutFile; - this.stderrFile = stderrFile; - this.stdinFile = stdinFile; - } - - static Config getOpenSearchConfig(Path workingDir) { - Path confPathLogs = workingDir.resolve("logs"); - return new Config( - "OpenSearch", - "opensearch", - "opensearch-keystore", - "opensearch-plugin", - "OPENSEARCH_TMPDIR", - "OPENSEARCH_JAVA_OPTS", - "OPENSEARCH_PATH_CONF", - workingDir.resolve("config/opensearch.yml"), - confPathLogs.resolve("opensearch.stdout.log"), - confPathLogs.resolve("opensearch.stderr.log"), - workingDir.resolve("opensearch.stdin") - ); - } - - static Config getLegacyESConfig(Path workingDir) { - Path confPathLogs = workingDir.resolve("logs"); - return new Config( - "Elasticsearch", - "elasticsearch", - "elasticsearch-keystore", - "elasticsearch-plugin", - "ES_TMPDIR", - "ES_JAVA_OPTS", - "ES_PATH_CONF", - workingDir.resolve("config/elasticsearch.yml"), - confPathLogs.resolve("es.stdout.log"), - confPathLogs.resolve("es.stderr.log"), - workingDir.resolve("es.stdin") - ); - } - } - - private void applyConfig() { - if (getVersion().onOrAfter("1.0.0")) { - currentConfig = opensearchConfig; - } else { - currentConfig = legacyESConfig; - } - } - - @Input - @Optional - public String getName() { - return nameCustomization.apply(name); - } - - @Internal - public Version getVersion() { - return Version.fromString(distributions.get(currentDistro).getVersion()); - } - - @Override - public void setVersion(String version) { - requireNonNull(version, "null version passed when configuring test cluster `" + this + "`"); - checkFrozen(); - distributions.clear(); - doSetVersion(version); - applyConfig(); - } - - @Override - public void setVersions(List versions) { - requireNonNull(versions, "null version list passed when configuring test cluster `" + this + "`"); - distributions.clear(); - for (String version : versions) { - doSetVersion(version); - } - applyConfig(); - } - - private void doSetVersion(String version) { - String distroName = "testclusters" + path.replace(":", "-") + "-" + this.name + "-" + version + "-"; - NamedDomainObjectContainer container = DistributionDownloadPlugin.getContainer(project); - if (container.findByName(distroName) == null) { - container.create(distroName); - } - OpenSearchDistribution distro = container.getByName(distroName); - distro.setVersion(version); - distro.setArchitecture(Architecture.current()); - setDistributionType(distro, testDistribution); - distributions.add(distro); - } - - @Internal - public TestDistribution getTestDistribution() { - return testDistribution; - } - - // package private just so test clusters plugin can access to wire up task dependencies - @Internal - List getDistributions() { - return distributions; - } - - @Override - public void setTestDistribution(TestDistribution testDistribution) { - requireNonNull(testDistribution, "null distribution passed when configuring test cluster `" + this + "`"); - checkFrozen(); - this.testDistribution = testDistribution; - for (OpenSearchDistribution distribution : distributions) { - setDistributionType(distribution, testDistribution); - } - } - - private void setDistributionType(OpenSearchDistribution distribution, TestDistribution testDistribution) { - if (testDistribution == TestDistribution.INTEG_TEST) { - distribution.setType(OpenSearchDistribution.Type.INTEG_TEST_ZIP); - // we change the underlying distribution when changing the test distribution of the cluster. - distribution.setPlatform(null); - distribution.setBundledJdk(null); - } else { - distribution.setType(OpenSearchDistribution.Type.ARCHIVE); - } - } - - // package protected so only TestClustersAware can access - @Internal - Collection getPluginAndModuleConfigurations() { - return pluginAndModuleConfigurations.values(); - } - - // creates a configuration to depend on the given plugin project, then wraps that configuration - // to grab the zip as a file provider - private Provider maybeCreatePluginOrModuleDependency(String path) { - Configuration configuration = pluginAndModuleConfigurations.computeIfAbsent( - path, - key -> project.getConfigurations().detachedConfiguration(project.getDependencies().project(new HashMap() { - { - put("path", path); - put("configuration", "zip"); - } - })) - ); - Provider fileProvider = configuration.getElements() - .map( - s -> s.stream() - .findFirst() - .orElseThrow(() -> new IllegalStateException("zip configuration of project " + path + " had no files")) - .getAsFile() - ); - return project.getLayout().file(fileProvider); - } - - @Override - public void plugin(Provider plugin) { - checkFrozen(); - this.plugins.add(plugin.map(RegularFile::getAsFile)); - } - - @Override - public void upgradePlugin(List> plugins) { - this.plugins.clear(); - for (Provider plugin : plugins) { - this.plugins.add(plugin.map(RegularFile::getAsFile)); - } - } - - @Override - public void plugin(String pluginProjectPath) { - plugin(maybeCreatePluginOrModuleDependency(pluginProjectPath)); - } - - @Override - public void module(Provider module) { - checkFrozen(); - this.modules.add(module.map(RegularFile::getAsFile)); - } - - @Override - public void module(String moduleProjectPath) { - module(maybeCreatePluginOrModuleDependency(moduleProjectPath)); - } - - @Override - public void keystore(String key, String value) { - keystoreSettings.put(key, value); - } - - @Override - public void keystore(String key, Supplier valueSupplier) { - keystoreSettings.put(key, valueSupplier); - } - - @Override - public void keystore(String key, File value) { - keystoreFiles.put(key, value); - } - - @Override - public void keystore(String key, File value, PropertyNormalization normalization) { - keystoreFiles.put(key, value, normalization); - } - - @Override - public void keystore(String key, FileSupplier valueSupplier) { - keystoreFiles.put(key, valueSupplier); - } - - @Override - public void keystorePassword(String password) { - keystorePassword = password; - } - - @Override - public void cliSetup(String binTool, CharSequence... args) { - cliSetup.add(new CliEntry(binTool, args)); - } - - @Override - public void setting(String key, String value) { - settings.put(key, value); - } - - @Override - public void setting(String key, String value, PropertyNormalization normalization) { - settings.put(key, value, normalization); - } - - @Override - public void setting(String key, Supplier valueSupplier) { - settings.put(key, valueSupplier); - } - - @Override - public void setting(String key, Supplier valueSupplier, PropertyNormalization normalization) { - settings.put(key, valueSupplier, normalization); - } - - @Override - public void systemProperty(String key, String value) { - systemProperties.put(key, value); - } - - @Override - public void systemProperty(String key, Supplier valueSupplier) { - systemProperties.put(key, valueSupplier); - } - - @Override - public void systemProperty(String key, Supplier valueSupplier, PropertyNormalization normalization) { - systemProperties.put(key, valueSupplier, normalization); - } - - @Override - public void environment(String key, String value) { - environment.put(key, value); - } - - @Override - public void environment(String key, Supplier valueSupplier) { - environment.put(key, valueSupplier); - } - - @Override - public void environment(String key, Supplier valueSupplier, PropertyNormalization normalization) { - environment.put(key, valueSupplier, normalization); - } - - public void jvmArgs(String... values) { - jvmArgs.addAll(Arrays.asList(values)); - } - - @Internal - public Path getConfigDir() { - return currentConfig.configFile.getParent(); - } - - @Override - @Input - public boolean isPreserveDataDir() { - return preserveDataDir; - } - - @Override - public void setPreserveDataDir(boolean preserveDataDir) { - this.preserveDataDir = preserveDataDir; - } - - @Override - public void freeze() { - requireNonNull(testDistribution, "null testDistribution passed when configuring test cluster `" + this + "`"); - LOGGER.info("Locking configuration of `{}`", this); - configurationFrozen.set(true); - } - - /** - * Returns a stream of lines in the generated logs similar to Files.lines - * - * @return stream of log lines - */ - public Stream logLines() throws IOException { - return Files.lines(currentConfig.stdoutFile, StandardCharsets.UTF_8); - } - - @Override - public synchronized void start() { - LOGGER.info("Starting `{}`", this); - if (Files.exists(getExtractedDistributionDir()) == false) { - throw new TestClustersException("Can not start " + this + ", missing: " + getExtractedDistributionDir()); - } - if (Files.isDirectory(getExtractedDistributionDir()) == false) { - throw new TestClustersException("Can not start " + this + ", is not a directory: " + getExtractedDistributionDir()); - } - - try { - if (isWorkingDirConfigured == false) { - logToProcessStdout("Configuring working directory: " + workingDir); - // make sure we always start fresh - if (Files.exists(workingDir)) { - if (preserveDataDir) { - Files.list(workingDir) - .filter(path -> path.equals(confPathData) == false) - .forEach(path -> fileSystemOperations.delete(d -> d.delete(path))); - } else { - fileSystemOperations.delete(d -> d.delete(workingDir)); - } - } - isWorkingDirConfigured = true; - } - setupNodeDistribution(getExtractedDistributionDir()); - createWorkingDir(); - } catch (IOException e) { - throw new UncheckedIOException("Failed to create working directory for " + this, e); - } - - copyExtraJars(); - - copyExtraConfigFiles(); - - createConfiguration(); - - final List pluginsToInstall = new ArrayList<>(); - if (plugins.isEmpty() == false) { - pluginsToInstall.addAll(plugins.stream().map(Provider::get).map(p -> p.toURI().toString()).collect(Collectors.toList())); - } - - if (pluginsToInstall.isEmpty() == false) { - if (getVersion().onOrAfter("7.6.0")) { - logToProcessStdout("installing " + pluginsToInstall.size() + " plugins in a single transaction"); - final String[] arguments = Stream.concat(Stream.of("install", "--batch"), pluginsToInstall.stream()).toArray(String[]::new); - runOpenSearchBinScript(currentConfig.pluginTool, arguments); - logToProcessStdout("installed plugins"); - } else { - logToProcessStdout("installing " + pluginsToInstall.size() + " plugins sequentially"); - pluginsToInstall.forEach(plugin -> runOpenSearchBinScript(currentConfig.pluginTool, "install", "--batch", plugin)); - logToProcessStdout("installed plugins"); - } - } - - logToProcessStdout("Creating " + currentConfig.command + " keystore with password set to [" + keystorePassword + "]"); - if (keystorePassword.length() > 0) { - runOpenSearchBinScriptWithInput(keystorePassword + "\n" + keystorePassword, currentConfig.keystoreTool, "create", "-p"); - } else { - runOpenSearchBinScript(currentConfig.keystoreTool, "-v", "create"); - } - - if (keystoreSettings.isEmpty() == false || keystoreFiles.isEmpty() == false) { - logToProcessStdout("Adding " + keystoreSettings.size() + " keystore settings and " + keystoreFiles.size() + " keystore files"); - - keystoreSettings.forEach((key, value) -> runKeystoreCommandWithPassword(keystorePassword, value.toString(), "add", "-x", key)); - - for (Map.Entry entry : keystoreFiles.entrySet()) { - File file = entry.getValue(); - requireNonNull(file, "supplied keystoreFile was null when configuring " + this); - if (file.exists() == false) { - throw new TestClustersException("supplied keystore file " + file + " does not exist, require for " + this); - } - runKeystoreCommandWithPassword(keystorePassword, "", "add-file", entry.getKey(), file.getAbsolutePath()); - } - } - - installModules(); - - if (cliSetup.isEmpty() == false) { - logToProcessStdout("Running " + cliSetup.size() + " setup commands"); - - for (CliEntry entry : cliSetup) { - runOpenSearchBinScript(entry.executable, entry.args); - } - } - - logToProcessStdout("Starting " + currentConfig.distroName + " process"); - startOpenSearchProcess(); - } - - private boolean canUseSharedDistribution() { - // using original location can be too long due to MAX_PATH restrictions on windows CI - // TODO revisit when moving to shorter paths on CI by using Teamcity - return OS.current() != OS.WINDOWS && extraJarFiles.size() == 0 && modules.size() == 0 && plugins.size() == 0; - } - - private void logToProcessStdout(String message) { - try { - if (Files.exists(currentConfig.stdoutFile.getParent()) == false) { - Files.createDirectories(currentConfig.stdoutFile.getParent()); - } - Files.write( - currentConfig.stdoutFile, - ("[" + Instant.now().toString() + "] [BUILD] " + message + "\n").getBytes(StandardCharsets.UTF_8), - StandardOpenOption.CREATE, - StandardOpenOption.APPEND - ); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - @Override - public void restart() { - LOGGER.info("Restarting {}", this); - stop(false); - start(); - } - - void goToNextVersion() { - if (currentDistro + 1 >= distributions.size()) { - throw new TestClustersException("Ran out of versions to go to for " + this); - } - logToProcessStdout("Switch version from " + getVersion() + " to " + distributions.get(currentDistro + 1).getVersion()); - currentDistro += 1; - applyConfig(); - setting("node.attr.upgraded", "true"); - } - - private void copyExtraConfigFiles() { - if (extraConfigFiles.isEmpty() == false) { - logToProcessStdout("Setting up " + extraConfigFiles.size() + " additional config files"); - } - extraConfigFiles.forEach((destination, from) -> { - if (Files.exists(from.toPath()) == false) { - throw new TestClustersException("Can't create extra config file from " + from + " for " + this + " as it does not exist"); - } - Path dst = currentConfig.configFile.getParent().resolve(destination); - try { - Files.createDirectories(dst.getParent()); - Files.copy(from.toPath(), dst, StandardCopyOption.REPLACE_EXISTING); - LOGGER.info("Added extra config file {} for {}", destination, this); - } catch (IOException e) { - throw new UncheckedIOException("Can't create extra config file for", e); - } - }); - } - - /** - * Copies extra jars to the `/lib` directory. - * //TODO: Remove this when system modules are available - */ - private void copyExtraJars() { - if (extraJarFiles.isEmpty() == false) { - logToProcessStdout("Setting up " + extraJarFiles.size() + " additional jar dependencies"); - } - extraJarFiles.forEach(from -> { - Path destination = getDistroDir().resolve("lib").resolve(from.getName()); - try { - Files.copy(from.toPath(), destination, StandardCopyOption.REPLACE_EXISTING); - LOGGER.info("Added extra jar {} to {}", from.getName(), destination); - } catch (IOException e) { - throw new UncheckedIOException("Can't copy extra jar dependency " + from.getName() + " to " + destination.toString(), e); - } - }); - } - - private void installModules() { - if (testDistribution == TestDistribution.INTEG_TEST) { - logToProcessStdout("Installing " + modules.size() + "modules"); - for (Provider module : modules) { - Path destination = getDistroDir().resolve("modules") - .resolve(module.get().getName().replace(".zip", "").replace("-" + getVersion(), "").replace("-SNAPSHOT", "")); - // only install modules that are not already bundled with the integ-test distribution - if (Files.exists(destination) == false) { - fileSystemOperations.copy(spec -> { - if (module.get().getName().toLowerCase().endsWith(".zip")) { - spec.from(archiveOperations.zipTree(module)); - } else if (module.get().isDirectory()) { - spec.from(module); - } else { - throw new IllegalArgumentException("Not a valid module " + module + " for " + this); - } - spec.into(destination); - }); - } - } - } else { - LOGGER.info("Not installing " + modules.size() + "(s) since the " + distributions + " distribution already " + "has them"); - } - } - - @Override - public void extraConfigFile(String destination, File from) { - if (destination.contains("..")) { - throw new IllegalArgumentException("extra config file destination can't be relative, was " + destination + " for " + this); - } - extraConfigFiles.put(destination, from); - } - - @Override - public void extraConfigFile(String destination, File from, PropertyNormalization normalization) { - if (destination.contains("..")) { - throw new IllegalArgumentException("extra config file destination can't be relative, was " + destination + " for " + this); - } - extraConfigFiles.put(destination, from, normalization); - } - - @Override - public void extraJarFile(File from) { - if (from.toString().endsWith(".jar") == false) { - throw new IllegalArgumentException("extra jar file " + from.toString() + " doesn't appear to be a JAR"); - } - extraJarFiles.add(from); - } - - @Override - public void user(Map userSpec) {} - - private void runOpenSearchBinScriptWithInput(String input, String tool, CharSequence... args) { - if (Files.exists(getDistroDir().resolve("bin").resolve(tool)) == false - && Files.exists(getDistroDir().resolve("bin").resolve(tool + ".bat")) == false) { - throw new TestClustersException( - "Can't run bin script: `" + tool + "` does not exist. Is this the distribution you expect it to be ?" - ); - } - try (InputStream byteArrayInputStream = new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8))) { - LoggedExec.exec(project, spec -> { - spec.setEnvironment(getOpenSearchEnvironment()); - spec.workingDir(getDistroDir()); - spec.executable(OS.conditionalString().onUnix(() -> "./bin/" + tool).onWindows(() -> "cmd").supply()); - spec.args(OS.>conditional().onWindows(() -> { - ArrayList result = new ArrayList<>(); - result.add("/c"); - result.add("bin\\" + tool + ".bat"); - for (CharSequence arg : args) { - result.add(arg); - } - return result; - }).onUnix(() -> Arrays.asList(args)).supply()); - spec.setStandardInput(byteArrayInputStream); - - }); - } catch (IOException e) { - throw new UncheckedIOException("Failed to run " + tool + " for " + this, e); - } - } - - private void runKeystoreCommandWithPassword(String keystorePassword, String input, CharSequence... args) { - final String actualInput = keystorePassword.length() > 0 ? keystorePassword + "\n" + input : input; - runOpenSearchBinScriptWithInput(actualInput, currentConfig.keystoreTool, args); - } - - private void runOpenSearchBinScript(String tool, CharSequence... args) { - runOpenSearchBinScriptWithInput("", tool, args); - } - - private Map getOpenSearchEnvironment() { - Map defaultEnv = new HashMap<>(); - getRequiredJavaHome().ifPresent(javaHome -> defaultEnv.put("JAVA_HOME", javaHome)); - defaultEnv.put(currentConfig.envPathConf, currentConfig.configFile.getParent().toString()); - String systemPropertiesString = ""; - if (systemProperties.isEmpty() == false) { - systemPropertiesString = " " - + systemProperties.entrySet() - .stream() - .map(entry -> "-D" + entry.getKey() + "=" + entry.getValue()) - // OPENSEARCH_PATH_CONF is also set as an environment variable and for a reference to ${OPENSEARCH_PATH_CONF} - // to work OPENSEARCH_JAVA_OPTS, we need to make sure that OPENSEARCH_PATH_CONF before OPENSEARCH_JAVA_OPTS. Instead, - // we replace the reference with the actual value in other environment variables - .map(p -> p.replace("${" + currentConfig.envPathConf + "}", currentConfig.configFile.getParent().toString())) - .collect(Collectors.joining(" ")); - } - String jvmArgsString = ""; - if (jvmArgs.isEmpty() == false) { - jvmArgsString = " " + jvmArgs.stream().peek(argument -> { - if (argument.toString().startsWith("-D")) { - throw new TestClustersException( - "Invalid jvm argument `" + argument + "` configure as systemProperty instead for " + this - ); - } - }).collect(Collectors.joining(" ")); - } - String heapSize = System.getProperty("tests.heap.size", "512m"); - defaultEnv.put( - currentConfig.envJavaOpts, - "-Xms" + heapSize + " -Xmx" + heapSize + " -ea -esa " + systemPropertiesString + " " + jvmArgsString + " " + - // Support passing in additional JVM arguments - System.getProperty("tests.jvm.argline", "") - ); - defaultEnv.put(currentConfig.envTempDir, tmpDir.toString()); - // Windows requires this as it defaults to `c:\windows` despite OPENSEARCH_TMPDIR - defaultEnv.put("TMP", tmpDir.toString()); - - // Override the system hostname variables for testing - defaultEnv.put("HOSTNAME", HOSTNAME_OVERRIDE); - defaultEnv.put("COMPUTERNAME", COMPUTERNAME_OVERRIDE); - - Set commonKeys = new HashSet<>(environment.keySet()); - commonKeys.retainAll(defaultEnv.keySet()); - if (commonKeys.isEmpty() == false) { - throw new IllegalStateException("testcluster does not allow overwriting the following env vars " + commonKeys + " for " + this); - } - - environment.forEach((key, value) -> defaultEnv.put(key, value.toString())); - return defaultEnv; - } - - private java.util.Optional getRequiredJavaHome() { - // If we are testing the current version of Elasticsearch, use the configured runtime Java - if (getTestDistribution() == TestDistribution.INTEG_TEST || getVersion().equals(VersionProperties.getOpenSearchVersion())) { - return java.util.Optional.of(BuildParams.getRuntimeJavaHome()).map(File::getAbsolutePath); - } else if (getVersion().before("7.0.0")) { - return java.util.Optional.of(bwcJdk.getJavaHomePath().toString()); - } else { // otherwise use the bundled JDK - return java.util.Optional.empty(); - } - } - - @Internal - Jdk getBwcJdk() { - return getVersion().before("7.0.0") ? bwcJdk : null; - } - - private void startOpenSearchProcess() { - final ProcessBuilder processBuilder = new ProcessBuilder(); - Path effectiveDistroDir = getDistroDir(); - List command = OS.>conditional() - .onUnix(() -> Arrays.asList(effectiveDistroDir.resolve("./bin/" + currentConfig.command).toString())) - .onWindows(() -> Arrays.asList("cmd", "/c", effectiveDistroDir.resolve("bin\\" + currentConfig.command + ".bat").toString())) - .supply(); - processBuilder.command(command); - processBuilder.directory(workingDir.toFile()); - Map environment = processBuilder.environment(); - // Don't inherit anything from the environment for as that would lack reproducibility - environment.clear(); - environment.putAll(getOpenSearchEnvironment()); - - // don't buffer all in memory, make sure we don't block on the default pipes - processBuilder.redirectError(ProcessBuilder.Redirect.appendTo(currentConfig.stderrFile.toFile())); - processBuilder.redirectOutput(ProcessBuilder.Redirect.appendTo(currentConfig.stdoutFile.toFile())); - - if (keystorePassword != null && keystorePassword.length() > 0) { - try { - Files.write(currentConfig.stdinFile, (keystorePassword + "\n").getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE); - processBuilder.redirectInput(currentConfig.stdinFile.toFile()); - } catch (IOException e) { - throw new TestClustersException("Failed to set the keystore password for " + this, e); - } - } - LOGGER.info("Running `{}` in `{}` for {} env: {}", command, workingDir, this, environment); - try { - opensearchProcess = processBuilder.start(); - } catch (IOException e) { - throw new TestClustersException("Failed to start " + currentConfig.command + " process for " + this, e); - } - // reaper.registerPid(toString(), opensearchProcess.pid()); - } - - @Internal - public Path getDistroDir() { - return canUseSharedDistribution() - ? getExtractedDistributionDir().toFile().listFiles()[0].toPath() - : workingDir.resolve("distro").resolve(getVersion() + "-" + testDistribution); - } - - @Override - @Internal - public String getHttpSocketURI() { - return getHttpPortInternal().get(0); - } - - @Override - @Internal - public String getTransportPortURI() { - return getTransportPortInternal().get(0); - } - - @Override - @Internal - public List getAllHttpSocketURI() { - waitForAllConditions(); - return getHttpPortInternal(); - } - - @Override - @Internal - public List getAllTransportPortURI() { - waitForAllConditions(); - return getTransportPortInternal(); - } - - @Internal - public File getServerLog() { - return confPathLogs.resolve(defaultConfig.get("cluster.name") + "_server.json").toFile(); - } - - @Internal - public File getAuditLog() { - return confPathLogs.resolve(defaultConfig.get("cluster.name") + "_audit.json").toFile(); - } - - @Override - public synchronized void stop(boolean tailLogs) { - logToProcessStdout("Stopping node"); - try { - if (Files.exists(httpPortsFile)) { - Files.delete(httpPortsFile); - } - if (Files.exists(transportPortFile)) { - Files.delete(transportPortFile); - } - } catch (IOException e) { - throw new UncheckedIOException(e); - } - if (opensearchProcess == null && tailLogs) { - // This is a special case. If start() throws an exception the plugin will still call stop - // Another exception here would eat the orriginal. - return; - } - LOGGER.info("Stopping `{}`, tailLogs: {}", this, tailLogs); - requireNonNull(opensearchProcess, "Can't stop `" + this + "` as it was not started or already stopped."); - // Test clusters are not reused, don't spend time on a graceful shutdown - stopHandle(opensearchProcess, true); - reaper.unregister(toString()); - if (tailLogs) { - logFileContents("Standard output of node", currentConfig.stdoutFile); - logFileContents("Standard error of node", currentConfig.stderrFile); - } - opensearchProcess = null; - // Clean up the ports file in case this is started again. - try { - if (Files.exists(httpPortsFile)) { - Files.delete(httpPortsFile); - } - if (Files.exists(transportPortFile)) { - Files.delete(transportPortFile); - } - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - @Override - public void setNameCustomization(Function nameCustomizer) { - this.nameCustomization = nameCustomizer; - } - - private void stopHandle(Process process, boolean forcibly) { - // No-op if the process has already exited by itself. - if (process.isAlive() == false) { - LOGGER.info("Process was not running when we tried to terminate it."); - return; - } - - // Stop all children last - if the ML processes are killed before the ES JVM then - // they'll be recorded as having failed and won't restart when the cluster restarts. - // ES could actually be a child when there's some wrapper process like on Windows, - // and in that case the ML processes will be grandchildren of the wrapper. - // List children = process.children().collect(Collectors.toList()); - try { - // logProcessInfo( - // "Terminating " + currentConfig.command + " process" + (forcibly ? " forcibly " : "gracefully") + ":", - // process.info() - // ); - - if (forcibly) { - process.destroyForcibly(); - } else { - process.destroy(); - waitForProcessToExit(process); - if (process.isAlive() == false) { - return; - } - LOGGER.info( - "process did not terminate after {} {}, stopping it forcefully", - OPENSEARCH_DESTROY_TIMEOUT, - OPENSEARCH_DESTROY_TIMEOUT_UNIT - ); - process.destroyForcibly(); - } - - waitForProcessToExit(process); - if (process.isAlive()) { - throw new TestClustersException("Was not able to terminate " + currentConfig.command + " process for " + this); - } - } finally { - // children.forEach(each -> stopHandle(each, forcibly)); - } - - // waitForProcessToExit(process); - // if (process.isAlive()) { - // throw new TestClustersException("Was not able to terminate " + currentConfig.command + " process for " + this); - // } - } - - /* - private void logProcessInfo(String prefix, Process info) { - LOGGER.info( - prefix + " commandLine:`{}` command:`{}` args:`{}`", - info.commandLine().orElse("-"), - info.command().orElse("-"), - Arrays.stream(info.arguments().orElse(new String[] {})).map(each -> "'" + each + "'").collect(Collectors.joining(" ")) - ); - } - */ - - private void logFileContents(String description, Path from) { - final Map errorsAndWarnings = new LinkedHashMap<>(); - LinkedList ring = new LinkedList<>(); - try (LineNumberReader reader = new LineNumberReader(Files.newBufferedReader(from))) { - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - final String lineToAdd; - if (ring.isEmpty()) { - lineToAdd = line; - } else { - if (line.startsWith("[")) { - lineToAdd = line; - // check to see if the previous message (possibly combined from multiple lines) was an error or - // warning as we want to show all of them - String previousMessage = normalizeLogLine(ring.getLast()); - if (MESSAGES_WE_DONT_CARE_ABOUT.stream().noneMatch(previousMessage::contains) - && (previousMessage.contains("ERROR") || previousMessage.contains("WARN"))) { - errorsAndWarnings.put(previousMessage, errorsAndWarnings.getOrDefault(previousMessage, 0) + 1); - } - } else { - // We combine multi line log messages to make sure we never break exceptions apart - lineToAdd = ring.removeLast() + "\n" + line; - } - } - ring.add(lineToAdd); - if (ring.size() >= TAIL_LOG_MESSAGES_COUNT) { - ring.removeFirst(); - } - } - } catch (IOException e) { - throw new UncheckedIOException("Failed to tail log " + this, e); - } - - if (errorsAndWarnings.isEmpty() == false || ring.isEmpty() == false) { - LOGGER.error("\n=== {} `{}` ===", description, this); - } - if (errorsAndWarnings.isEmpty() == false) { - LOGGER.lifecycle("\n» ↓ errors and warnings from " + from + " ↓"); - errorsAndWarnings.forEach((message, count) -> { - LOGGER.lifecycle("» " + message.replace("\n", "\n» ")); - if (count > 1) { - LOGGER.lifecycle("» ↑ repeated " + count + " times ↑"); - } - }); - } - - ring.removeIf(line -> MESSAGES_WE_DONT_CARE_ABOUT.stream().anyMatch(line::contains)); - - if (ring.isEmpty() == false) { - LOGGER.lifecycle("» ↓ last " + TAIL_LOG_MESSAGES_COUNT + " non error or warning messages from " + from + " ↓"); - ring.forEach(message -> { - if (errorsAndWarnings.containsKey(normalizeLogLine(message)) == false) { - LOGGER.lifecycle("» " + message.replace("\n", "\n» ")); - } - }); - } - } - - private String normalizeLogLine(String line) { - if (line.contains("ERROR")) { - return line.substring(line.indexOf("ERROR")); - } - if (line.contains("WARN")) { - return line.substring(line.indexOf("WARN")); - } - return line; - } - - private void waitForProcessToExit(Process process) { - try { - process.waitFor(OPENSEARCH_DESTROY_TIMEOUT, OPENSEARCH_DESTROY_TIMEOUT_UNIT); - } catch (InterruptedException e) { - LOGGER.info("Interrupted while waiting for {} process", currentConfig.command, e); - Thread.currentThread().interrupt(); - } catch (NullPointerException e) { - LOGGER.info("Failure while waiting for process to exist", e); - } - } - - private void createWorkingDir() throws IOException { - // Start configuration from scratch in case of a restart - fileSystemOperations.delete(d -> d.delete(currentConfig.configFile.getParent())); - Files.createDirectories(currentConfig.configFile.getParent()); - Files.createDirectories(confPathRepo); - Files.createDirectories(confPathData); - Files.createDirectories(confPathLogs); - Files.createDirectories(tmpDir); - } - - private void setupNodeDistribution(Path distroExtractDir) throws IOException { - if (canUseSharedDistribution() == false) { - logToProcessStdout("Configuring custom cluster specific distro directory: " + getDistroDir()); - if (Files.exists(getDistroDir()) == false) { - try { - syncWithLinks(distroExtractDir, getDistroDir()); - } catch (LinkCreationException e) { - // Note does not work for network drives, e.g. Vagrant - LOGGER.info("Failed to create working dir using hard links. Falling back to copy", e); - // ensure we get a clean copy - FileUtils.deleteDirectory(getDistroDir().toFile()); - syncWithCopy(distroExtractDir, getDistroDir()); - } - } - } - } - - /** - * Does the equivalent of `cp -lr` and `chmod -r a-w` to save space and improve speed. - * We remove write permissions to make sure files are note mistakenly edited ( e.x. the config file ) and changes - * reflected across all copies. Permissions are retained to be able to replace the links. - * - * @param sourceRoot where to copy from - * @param destinationRoot destination to link to - */ - private void syncWithLinks(Path sourceRoot, Path destinationRoot) { - sync(sourceRoot, destinationRoot, (Path d, Path s) -> { - try { - Files.createLink(d, s); - } catch (IOException e) { - // Note does not work for network drives, e.g. Vagrant - throw new LinkCreationException("Failed to create hard link " + d + " pointing to " + s, e); - } - }); - } - - private void syncWithCopy(Path sourceRoot, Path destinationRoot) { - sync(sourceRoot, destinationRoot, (Path d, Path s) -> { - try { - Files.copy(s, d); - } catch (IOException e) { - throw new UncheckedIOException("Failed to copy " + s + " to " + d, e); - } - }); - } - - private void sync(Path sourceRoot, Path destinationRoot, BiConsumer syncMethod) { - assert Files.exists(destinationRoot) == false; - try (Stream stream = Files.walk(sourceRoot)) { - stream.forEach(source -> { - Path relativeDestination = sourceRoot.relativize(source); - if (relativeDestination.getNameCount() <= 1) { - return; - } - // Throw away the first name as the archives have everything in a single top level folder we are not interested in - relativeDestination = relativeDestination.subpath(1, relativeDestination.getNameCount()); - - Path destination = destinationRoot.resolve(relativeDestination); - if (Files.isDirectory(source)) { - try { - Files.createDirectories(destination); - } catch (IOException e) { - throw new UncheckedIOException("Can't create directory " + destination.getParent(), e); - } - } else { - try { - Files.createDirectories(destination.getParent()); - } catch (IOException e) { - throw new UncheckedIOException("Can't create directory " + destination.getParent(), e); - } - syncMethod.accept(destination, source); - - } - }); - } catch (IOException e) { - throw new UncheckedIOException("Can't walk source " + sourceRoot, e); - } - } - - private void createConfiguration() { - String nodeName = nameCustomization.apply(safeName(name)); - Map baseConfig = new HashMap<>(defaultConfig); - if (nodeName != null) { - baseConfig.put("node.name", nodeName); - } - baseConfig.put("path.repo", confPathRepo.toAbsolutePath().toString()); - baseConfig.put("path.data", confPathData.toAbsolutePath().toString()); - baseConfig.put("path.logs", confPathLogs.toAbsolutePath().toString()); - baseConfig.put("path.shared_data", workingDir.resolve("sharedData").toString()); - baseConfig.put("node.attr.testattr", "test"); - baseConfig.put("node.portsfile", "true"); - baseConfig.put("http.port", httpPort); - if (getVersion().onOrAfter(Version.fromString("6.7.0"))) { - baseConfig.put("transport.port", transportPort); - } else { - baseConfig.put("transport.tcp.port", transportPort); - } - // Default the watermarks to absurdly low to prevent the tests from failing on nodes without enough disk space - baseConfig.put("cluster.routing.allocation.disk.watermark.low", "1b"); - baseConfig.put("cluster.routing.allocation.disk.watermark.high", "1b"); - // increase script compilation limit since tests can rapid-fire script compilations - if (getVersion().onOrAfter(Version.fromString("7.9.0"))) { - baseConfig.put("script.disable_max_compilations_rate", "true"); - } else { - baseConfig.put("script.max_compilations_rate", "2048/1m"); - } - if (getVersion().onOrAfter("6.0.0")) { - baseConfig.put("cluster.routing.allocation.disk.watermark.flood_stage", "1b"); - } - // Temporarily disable the real memory usage circuit breaker. It depends on real memory usage which we have no full control - // over and the REST client will not retry on circuit breaking exceptions yet (see #31986 for details). Once the REST client - // can retry on circuit breaking exceptions, we can revert again to the default configuration. - if (getVersion().onOrAfter("7.0.0")) { - baseConfig.put("indices.breaker.total.use_real_memory", "false"); - } - // Don't wait for state, just start up quickly. This will also allow new and old nodes in the BWC case to become the master - baseConfig.put("discovery.initial_state_timeout", "0s"); - - // TODO: Remove these once https://github.com/elastic/elasticsearch/issues/46091 is fixed - if (getVersion().onOrAfter("1.0.0")) { - baseConfig.put("logger.org.opensearch.action.support.master", "DEBUG"); - baseConfig.put("logger.org.opensearch.cluster.coordination", "DEBUG"); - } else { - baseConfig.put("logger.org.elasticsearch.action.support.master", "DEBUG"); - baseConfig.put("logger.org.elasticsearch.cluster.coordination", "DEBUG"); - } - - HashSet overriden = new HashSet<>(baseConfig.keySet()); - overriden.retainAll(settings.keySet()); - overriden.removeAll(OVERRIDABLE_SETTINGS); - if (overriden.isEmpty() == false) { - throw new IllegalArgumentException( - "Testclusters does not allow the following settings to be changed:" + overriden + " for " + this - ); - } - // Make sure no duplicate config keys - settings.keySet().stream().filter(OVERRIDABLE_SETTINGS::contains).forEach(baseConfig::remove); - - final Path configFileRoot = currentConfig.configFile.getParent(); - try { - Files.write( - currentConfig.configFile, - Stream.concat(settings.entrySet().stream(), baseConfig.entrySet().stream()) - .map(entry -> entry.getKey() + ": " + entry.getValue()) - .collect(Collectors.joining("\n")) - .getBytes(StandardCharsets.UTF_8), - StandardOpenOption.TRUNCATE_EXISTING, - StandardOpenOption.CREATE - ); - - final List configFiles; - try (Stream stream = Files.list(getDistroDir().resolve("config"))) { - configFiles = stream.collect(Collectors.toList()); - } - logToProcessStdout("Copying additional config files from distro " + configFiles); - for (Path file : configFiles) { - Path dest = currentConfig.configFile.getParent().resolve(file.getFileName()); - if (Files.exists(dest) == false) { - Files.copy(file, dest); - } - } - } catch (IOException e) { - throw new UncheckedIOException("Could not write config file: " + currentConfig.configFile, e); - } - - tweakJvmOptions(configFileRoot); - LOGGER.info("Written config file:{} for {}", currentConfig.configFile, this); - } - - private void tweakJvmOptions(Path configFileRoot) { - LOGGER.info("Tweak jvm options {}.", configFileRoot.resolve("jvm.options")); - Path jvmOptions = configFileRoot.resolve("jvm.options"); - try { - String content = new String(Files.readAllBytes(jvmOptions)); - Map expansions = jvmOptionExpansions(); - for (String origin : expansions.keySet()) { - if (!content.contains(origin)) { - throw new IOException("template property " + origin + " not found in template."); - } - content = content.replace(origin, expansions.get(origin)); - } - Files.write(jvmOptions, content.getBytes()); - } catch (IOException ioException) { - throw new UncheckedIOException(ioException); - } - } - - private Map jvmOptionExpansions() { - Map expansions = new HashMap<>(); - Version version = getVersion(); - String heapDumpOrigin = getVersion().onOrAfter("6.3.0") ? "-XX:HeapDumpPath=data" : "-XX:HeapDumpPath=/heap/dump/path"; - Path relativeLogPath = workingDir.relativize(confPathLogs); - expansions.put(heapDumpOrigin, "-XX:HeapDumpPath=" + relativeLogPath.toString()); - if (version.onOrAfter("6.2.0")) { - expansions.put("logs/gc.log", relativeLogPath.resolve("gc.log").toString()); - } - if (getVersion().onOrAfter("7.0.0")) { - expansions.put( - "-XX:ErrorFile=logs/hs_err_pid%p.log", - "-XX:ErrorFile=" + relativeLogPath.resolve("hs_err_pid%p.log").toString() - ); - } - return expansions; - } - - private void checkFrozen() { - if (configurationFrozen.get()) { - throw new IllegalStateException("Configuration for " + this + " can not be altered, already locked"); - } - } - - private List getTransportPortInternal() { - try { - return readPortsFile(transportPortFile); - } catch (IOException e) { - throw new UncheckedIOException("Failed to read transport ports file: " + transportPortFile + " for " + this, e); - } - } - - private List getHttpPortInternal() { - try { - return readPortsFile(httpPortsFile); - } catch (IOException e) { - throw new UncheckedIOException("Failed to read http ports file: " + httpPortsFile + " for " + this, e); - } - } - - private List readPortsFile(Path file) throws IOException { - try (Stream lines = Files.lines(file, StandardCharsets.UTF_8)) { - return lines.map(String::trim).collect(Collectors.toList()); - } - } - - private Path getExtractedDistributionDir() { - return distributions.get(currentDistro).getExtracted().getSingleFile().toPath(); - } - - private List getInstalledFileSet(Action filter) { - return Stream.concat(plugins.stream().map(Provider::get), modules.stream().map(Provider::get)) - .filter(File::exists) - // TODO: We may be able to simplify this with Gradle 5.6 - // https://docs.gradle.org/nightly/release-notes.html#improved-handling-of-zip-archives-on-classpaths - .map(zipFile -> archiveOperations.zipTree(zipFile).matching(filter)) - .flatMap(tree -> tree.getFiles().stream()) - .sorted(Comparator.comparing(File::getName)) - .collect(Collectors.toList()); - } - - @Classpath - public List getInstalledClasspath() { - return getInstalledFileSet(filter -> filter.include("**/*.jar")); - } - - @InputFiles - @PathSensitive(PathSensitivity.RELATIVE) - public List getInstalledFiles() { - return getInstalledFileSet(filter -> filter.exclude("**/*.jar")); - } - - @Classpath - public List getDistributionClasspath() { - return getDistributionFiles(filter -> filter.include("**/*.jar")); - } - - @InputFiles - @PathSensitive(PathSensitivity.RELATIVE) - public List getDistributionFiles() { - return getDistributionFiles(filter -> filter.exclude("**/*.jar")); - } - - private List getDistributionFiles(Action patternFilter) { - List files = new ArrayList<>(); - for (OpenSearchDistribution distribution : distributions) { - files.add(distribution.getExtracted().getAsFileTree().matching(patternFilter)); - } - return files; - } - - @Nested - public List getKeystoreSettings() { - return keystoreSettings.getNormalizedCollection(); - } - - @Nested - public List getKeystoreFiles() { - return keystoreFiles.getNormalizedCollection(); - } - - @Nested - public List getCliSetup() { - return cliSetup.getFlatNormalizedCollection(); - } - - @Nested - public List getSettings() { - return settings.getNormalizedCollection(); - } - - @Nested - public List getSystemProperties() { - return systemProperties.getNormalizedCollection(); - } - - @Nested - public List getEnvironment() { - return environment.getNormalizedCollection(); - } - - @Nested - public List getJvmArgs() { - return jvmArgs.getNormalizedCollection(); - } - - @Nested - public List getExtraConfigFiles() { - return extraConfigFiles.getNormalizedCollection(); - } - - @Override - @Internal - public boolean isProcessAlive() { - requireNonNull(opensearchProcess, "Can't wait for `" + this + "` as it's not started. Does the task have `useCluster` ?"); - return opensearchProcess.isAlive(); - } - - void waitForAllConditions() { - waitForConditions(waitConditions, System.currentTimeMillis(), NODE_UP_TIMEOUT_UNIT.toMillis(NODE_UP_TIMEOUT) + - // Installing plugins at config time and loading them when nods start requires additional time we need to - // account for - ADDITIONAL_CONFIG_TIMEOUT_UNIT.toMillis( - ADDITIONAL_CONFIG_TIMEOUT * (plugins.size() + keystoreFiles.size() + keystoreSettings.size() + credentials.size()) - ), TimeUnit.MILLISECONDS, this); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - OpenSearchNode that = (OpenSearchNode) o; - return Objects.equals(name, that.name) && Objects.equals(path, that.path); - } - - @Override - public int hashCode() { - return Objects.hash(name, path); - } - - @Override - public String toString() { - return "node{" + path + ":" + name + "}"; - } - - @Input - List> getCredentials() { - return credentials; - } - - private boolean checkPortsFilesExistWithDelay(TestClusterConfiguration node) { - if (Files.exists(httpPortsFile) && Files.exists(transportPortFile)) { - return true; - } - try { - Thread.sleep(500); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new TestClustersException("Interrupted while waiting for ports files", e); - } - return Files.exists(httpPortsFile) && Files.exists(transportPortFile); - } - - void setHttpPort(String httpPort) { - this.httpPort = httpPort; - } - - void setTransportPort(String transportPort) { - this.transportPort = transportPort; - } - - void setDataPath(Path dataPath) { - this.confPathData = dataPath; - } - - @Internal - Path getOpensearchStdoutFile() { - return currentConfig.stdoutFile; - } - - @Internal - Path getOpensearchStderrFile() { - return currentConfig.stderrFile; - } - - private static class FileEntry implements Named { - private String name; - private File file; - - FileEntry(String name, File file) { - this.name = name; - this.file = file; - } - - @Input - @Override - public String getName() { - return name; - } - - @InputFile - @PathSensitive(PathSensitivity.NONE) - public File getFile() { - return file; - } - } - - private static class CliEntry { - private String executable; - private CharSequence[] args; - - CliEntry(String executable, CharSequence[] args) { - this.executable = executable; - this.args = args; - } - - @Input - public String getExecutable() { - return executable; - } - - @Input - public CharSequence[] getArgs() { - return args; - } - } - - private static class LinkCreationException extends UncheckedIOException { - LinkCreationException(String message, IOException cause) { - super(message, cause); - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/RunTask.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/RunTask.java deleted file mode 100644 index af23fdce7dcd8..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/RunTask.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testclusters; - -import org.gradle.api.GradleException; -import org.gradle.api.logging.Logger; -import org.gradle.api.logging.Logging; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.Optional; -import org.gradle.api.tasks.TaskAction; -import org.gradle.api.tasks.options.Option; - -import java.io.BufferedReader; -import java.io.Closeable; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.function.BooleanSupplier; -import java.util.function.Function; -import java.util.stream.Collectors; - -public class RunTask extends DefaultTestClustersTask { - - private static final Logger logger = Logging.getLogger(RunTask.class); - public static final String CUSTOM_SETTINGS_PREFIX = "tests.opensearch."; - - private Boolean debug = false; - - private Boolean debugServer = false; - - private Boolean preserveData = false; - - private Path dataDir = null; - - private String keystorePassword = ""; - - @Option(option = "debug-jvm", description = "Run OpenSearch as a debug client, where it will try to connect to a debugging server at startup.") - public void setDebug(boolean enabled) { - if (debugServer != null && debugServer == true) { - throw new IllegalStateException("Either --debug-jvm or --debug-server-jvm option should be specified (but not both)"); - } - this.debug = enabled; - } - - @Option(option = "debug-server-jvm", description = "Run OpenSearch as a debug server that will accept connections from a debugging client.") - public void setDebugServer(boolean enabled) { - if (debug != null && debug == true) { - throw new IllegalStateException("Either --debug-jvm or --debug-server-jvm option should be specified (but not both)"); - } - this.debugServer = enabled; - } - - @Input - public Boolean getDebug() { - return debug; - } - - @Input - public Boolean getDebugServer() { - return debugServer; - } - - @Option(option = "data-dir", description = "Override the base data directory used by the testcluster") - public void setDataDir(String dataDirStr) { - dataDir = Paths.get(dataDirStr).toAbsolutePath(); - } - - @Input - public Boolean getPreserveData() { - return preserveData; - } - - @Option(option = "preserve-data", description = "Preserves data directory contents (path provided to --data-dir is always preserved)") - public void setPreserveData(Boolean preserveData) { - this.preserveData = preserveData; - } - - @Option(option = "keystore-password", description = "Set the opensearch keystore password") - public void setKeystorePassword(String password) { - keystorePassword = password; - } - - @Input - @Optional - public String getKeystorePassword() { - return keystorePassword; - } - - @Input - @Optional - public String getDataDir() { - if (dataDir == null) { - return null; - } - return dataDir.toString(); - } - - @Override - public void beforeStart() { - int debugPort = 5005; - int httpPort = 9200; - int transportPort = 9300; - Map additionalSettings = System.getProperties() - .entrySet() - .stream() - .filter(entry -> entry.getKey().toString().startsWith(CUSTOM_SETTINGS_PREFIX)) - .collect( - Collectors.toMap( - entry -> entry.getKey().toString().substring(CUSTOM_SETTINGS_PREFIX.length()), - entry -> entry.getValue().toString() - ) - ); - boolean singleNode = getClusters().stream().flatMap(c -> c.getNodes().stream()).count() == 1; - final Function getDataPath; - if (singleNode) { - getDataPath = n -> dataDir; - } else { - getDataPath = n -> dataDir.resolve(n.getName()); - } - - for (OpenSearchCluster cluster : getClusters()) { - cluster.getFirstNode().setHttpPort(String.valueOf(httpPort)); - httpPort++; - cluster.getFirstNode().setTransportPort(String.valueOf(transportPort)); - transportPort++; - cluster.setPreserveDataDir(preserveData); - for (OpenSearchNode node : cluster.getNodes()) { - additionalSettings.forEach(node::setting); - if (dataDir != null) { - node.setDataPath(getDataPath.apply(node)); - } - if (debug) { - logger.lifecycle( - "Running opensearch in debug mode (client), {} expecting running debug server on port {}", - node, - debugPort - ); - node.jvmArgs("-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=" + debugPort); - debugPort += 1; - } else if (debugServer) { - logger.lifecycle("Running opensearch in debug mode (server), {} running server with debug port {}", node, debugPort); - node.jvmArgs("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=" + debugPort); - debugPort += 1; - } - if (keystorePassword.length() > 0) { - node.keystorePassword(keystorePassword); - } - } - } - } - - @TaskAction - public void runAndWait() throws IOException { - List toRead = new ArrayList<>(); - List aliveChecks = new ArrayList<>(); - try { - for (OpenSearchCluster cluster : getClusters()) { - for (OpenSearchNode node : cluster.getNodes()) { - BufferedReader reader = Files.newBufferedReader(node.getOpensearchStdoutFile()); - toRead.add(reader); - aliveChecks.add(node::isProcessAlive); - } - } - - while (Thread.currentThread().isInterrupted() == false) { - boolean readData = false; - for (BufferedReader bufferedReader : toRead) { - if (bufferedReader.ready()) { - readData = true; - logger.lifecycle(bufferedReader.readLine()); - } - } - - if (aliveChecks.stream().allMatch(BooleanSupplier::getAsBoolean) == false) { - throw new GradleException("OpenSearch cluster died"); - } - - if (readData == false) { - // no data was ready to be consumed and rather than continuously spinning, pause - // for some time to avoid excessive CPU usage. Ideally we would use the JDK - // WatchService to receive change notifications but the WatchService does not have - // a native MacOS implementation and instead relies upon polling with possible - // delays up to 10s before a notification is received. See JDK-7133447. - try { - Thread.sleep(100L); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - return; - } - } - } - } finally { - Exception thrown = null; - for (Closeable closeable : toRead) { - try { - closeable.close(); - } catch (Exception e) { - if (thrown == null) { - thrown = e; - } else { - thrown.addSuppressed(e); - } - } - } - - if (thrown != null) { - logger.debug("exception occurred during close of stdout file readers", thrown); - } - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/StandaloneRestIntegTestTask.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/StandaloneRestIntegTestTask.java deleted file mode 100644 index bf17daa6e2e6f..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/StandaloneRestIntegTestTask.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testclusters; - -import groovy.lang.Closure; -import org.opensearch.gradle.FileSystemOperationsAware; -import org.opensearch.gradle.test.Fixture; -import org.opensearch.gradle.util.GradleUtils; -import org.gradle.api.Task; -import org.gradle.api.provider.Provider; -import org.gradle.api.services.internal.BuildServiceRegistryInternal; -import org.gradle.api.tasks.CacheableTask; -import org.gradle.api.tasks.Internal; -import org.gradle.api.tasks.Nested; -import org.gradle.api.tasks.WorkResult; -import org.gradle.api.tasks.testing.Test; -import org.gradle.internal.resources.ResourceLock; -import org.gradle.internal.resources.SharedResource; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; - -/** - * Customized version of Gradle {@link Test} task which tracks a collection of {@link OpenSearchCluster} as a task input. We must do this - * as a custom task type because the current {@link org.gradle.api.tasks.TaskInputs} runtime API does not have a way to register - * {@link Nested} inputs. - */ -@CacheableTask -public class StandaloneRestIntegTestTask extends Test implements TestClustersAware, FileSystemOperationsAware { - - private Collection clusters = new HashSet<>(); - private Closure beforeStart; - - public StandaloneRestIntegTestTask() { - this.getOutputs() - .doNotCacheIf( - "Caching disabled for this task since it uses a cluster shared by other tasks", - /* - * Look for any other tasks which use the same cluster as this task. Since tests often have side effects for the cluster - * they execute against, this state can cause issues when trying to cache tests results of tasks that share a cluster. To - * avoid any undesired behavior we simply disable the cache if we detect that this task uses a cluster shared between - * multiple tasks. - */ - t -> getProject().getTasks() - .withType(StandaloneRestIntegTestTask.class) - .stream() - .filter(task -> task != this) - .anyMatch(task -> Collections.disjoint(task.getClusters(), getClusters()) == false) - ); - - this.getOutputs() - .doNotCacheIf( - "Caching disabled for this task since it is configured to preserve data directory", - // Don't cache the output of this task if it's not running from a clean data directory. - t -> getClusters().stream().anyMatch(cluster -> cluster.isPreserveDataDir()) - ); - } - - // Hook for executing any custom logic before starting the task. - public void setBeforeStart(Closure closure) { - beforeStart = closure; - } - - @Override - public void beforeStart() { - if (beforeStart != null) { - beforeStart.call(this); - } - } - - @Override - public int getMaxParallelForks() { - return 1; - } - - @Nested - @Override - public Collection getClusters() { - return clusters; - } - - @Override - @Internal - public List getSharedResources() { - List locks = new ArrayList<>(super.getSharedResources()); - BuildServiceRegistryInternal serviceRegistry = getServices().get(BuildServiceRegistryInternal.class); - Provider throttleProvider = GradleUtils.getBuildService( - serviceRegistry, - TestClustersPlugin.THROTTLE_SERVICE_NAME - ); - SharedResource resource = serviceRegistry.forService(throttleProvider); - - int nodeCount = clusters.stream().mapToInt(cluster -> cluster.getNodes().size()).sum(); - if (nodeCount > 0) { - locks.add(resource.getResourceLock(Math.min(nodeCount, resource.getMaxUsages()))); - } - - return Collections.unmodifiableList(locks); - } - - @Override - public Task dependsOn(Object... dependencies) { - super.dependsOn(dependencies); - for (Object dependency : dependencies) { - if (dependency instanceof Fixture) { - finalizedBy(((Fixture) dependency).getStopTask()); - } - } - return this; - } - - @Override - public void setDependsOn(Iterable dependencies) { - super.setDependsOn(dependencies); - for (Object dependency : dependencies) { - if (dependency instanceof Fixture) { - finalizedBy(((Fixture) dependency).getStopTask()); - } - } - } - - public WorkResult delete(Object... objects) { - return getFileSystemOperations().delete(d -> d.delete(objects)); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClusterConfiguration.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClusterConfiguration.java deleted file mode 100644 index b27f205291269..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClusterConfiguration.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testclusters; - -import org.opensearch.gradle.FileSupplier; -import org.opensearch.gradle.PropertyNormalization; -import org.gradle.api.file.RegularFile; -import org.gradle.api.logging.Logging; -import org.gradle.api.provider.Provider; -import org.slf4j.Logger; - -import java.io.File; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.function.Supplier; - -public interface TestClusterConfiguration { - - void setVersion(String version); - - void setVersions(List version); - - void setTestDistribution(TestDistribution distribution); - - void plugin(Provider plugin); - - void plugin(String pluginProjectPath); - - void upgradePlugin(List> plugins); - - void module(Provider module); - - void module(String moduleProjectPath); - - void keystore(String key, String value); - - void keystore(String key, Supplier valueSupplier); - - void keystore(String key, File value); - - void keystore(String key, File value, PropertyNormalization normalization); - - void keystore(String key, FileSupplier valueSupplier); - - void keystorePassword(String password); - - void cliSetup(String binTool, CharSequence... args); - - void setting(String key, String value); - - void setting(String key, String value, PropertyNormalization normalization); - - void setting(String key, Supplier valueSupplier); - - void setting(String key, Supplier valueSupplier, PropertyNormalization normalization); - - void systemProperty(String key, String value); - - void systemProperty(String key, Supplier valueSupplier); - - void systemProperty(String key, Supplier valueSupplier, PropertyNormalization normalization); - - void environment(String key, String value); - - void environment(String key, Supplier valueSupplier); - - void environment(String key, Supplier valueSupplier, PropertyNormalization normalization); - - void jvmArgs(String... values); - - boolean isPreserveDataDir(); - - void setPreserveDataDir(boolean preserveDataDir); - - void freeze(); - - void start(); - - void restart(); - - void extraConfigFile(String destination, File from); - - void extraConfigFile(String destination, File from, PropertyNormalization normalization); - - void extraJarFile(File from); - - void user(Map userSpec); - - String getHttpSocketURI(); - - String getTransportPortURI(); - - List getAllHttpSocketURI(); - - List getAllTransportPortURI(); - - void stop(boolean tailLogs); - - void setNameCustomization(Function nameSupplier); - - default void waitForConditions( - LinkedHashMap> waitConditions, - long startedAtMillis, - long nodeUpTimeout, - TimeUnit nodeUpTimeoutUnit, - TestClusterConfiguration context - ) { - Logger logger = Logging.getLogger(TestClusterConfiguration.class); - waitConditions.forEach((description, predicate) -> { - long thisConditionStartedAt = System.currentTimeMillis(); - boolean conditionMet = false; - Throwable lastException = null; - while (System.currentTimeMillis() - startedAtMillis < TimeUnit.MILLISECONDS.convert(nodeUpTimeout, nodeUpTimeoutUnit)) { - if (context.isProcessAlive() == false) { - throw new TestClustersException("process was found dead while waiting for " + description + ", " + this); - } - - try { - if (predicate.test(context)) { - conditionMet = true; - break; - } - } catch (TestClustersException e) { - throw e; - } catch (Exception e) { - lastException = e; - } - } - if (conditionMet == false) { - String message = String.format( - "`%s` failed to wait for %s after %d %s", - context, - description, - nodeUpTimeout, - nodeUpTimeoutUnit - ); - if (lastException == null) { - throw new TestClustersException(message); - } else { - String extraCause = ""; - Throwable cause = lastException; - while (cause != null) { - if (cause.getMessage() != null && cause.getMessage().isEmpty() == false) { - extraCause += "\n" + " " + cause.getMessage(); - } - cause = cause.getCause(); - } - throw new TestClustersException(message + extraCause, lastException); - } - } - logger.info("{}: {} took {} seconds", this, description, (System.currentTimeMillis() - thisConditionStartedAt) / 1000.0); - }); - } - - default String safeName(String name) { - return name.replaceAll("^[^a-zA-Z0-9]+", "").replaceAll("[^a-zA-Z0-9\\.]+", "-"); - } - - boolean isProcessAlive(); -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClustersAware.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClustersAware.java deleted file mode 100644 index e5d264121b0aa..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClustersAware.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testclusters; - -import org.opensearch.gradle.Jdk; -import org.gradle.api.Task; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.tasks.Nested; - -import java.util.Collection; -import java.util.concurrent.Callable; - -public interface TestClustersAware extends Task { - - @Nested - Collection getClusters(); - - default void useCluster(OpenSearchCluster cluster) { - if (cluster.getPath().equals(getProject().getPath()) == false) { - throw new TestClustersException("Task " + getPath() + " can't use test cluster from" + " another project " + cluster); - } - - // Add configured distributions as task dependencies so they are built before starting the cluster - cluster.getNodes().stream().flatMap(node -> node.getDistributions().stream()).forEach(distro -> dependsOn(distro.getExtracted())); - - // Add legacy BWC JDK runtime as a dependency so it's downloaded before starting the cluster if necessary - cluster.getNodes().stream().map(node -> (Callable) node::getBwcJdk).forEach(this::dependsOn); - - cluster.getNodes().forEach(node -> dependsOn((Callable>) node::getPluginAndModuleConfigurations)); - getClusters().add(cluster); - } - - default void beforeStart() {} - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClustersException.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClustersException.java deleted file mode 100644 index 2aae205088191..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClustersException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testclusters; - -class TestClustersException extends RuntimeException { - TestClustersException(String message) { - super(message); - } - - TestClustersException(String message, Throwable cause) { - super(message, cause); - } - - TestClustersException(Throwable cause) { - super(cause); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClustersPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClustersPlugin.java deleted file mode 100644 index 2ef14a39b6669..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClustersPlugin.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testclusters; - -import org.opensearch.gradle.Architecture; -import org.opensearch.gradle.DistributionDownloadPlugin; -import org.opensearch.gradle.Jdk; -import org.opensearch.gradle.JdkDownloadPlugin; -import org.opensearch.gradle.OS; -import org.opensearch.gradle.ReaperPlugin; -import org.opensearch.gradle.ReaperService; -import org.opensearch.gradle.info.BuildParams; -import org.opensearch.gradle.info.GlobalBuildInfoPlugin; -import org.opensearch.gradle.internal.InternalDistributionDownloadPlugin; -import org.opensearch.gradle.util.GradleUtils; -import org.gradle.api.NamedDomainObjectContainer; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.execution.TaskActionListener; -import org.gradle.api.execution.TaskExecutionListener; -import org.gradle.api.file.ArchiveOperations; -import org.gradle.api.file.FileSystemOperations; -import org.gradle.api.invocation.Gradle; -import org.gradle.api.logging.Logger; -import org.gradle.api.logging.Logging; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.TaskState; - -import javax.inject.Inject; -import java.io.File; - -import static org.opensearch.gradle.util.GradleUtils.noop; - -public class TestClustersPlugin implements Plugin { - - public static final String EXTENSION_NAME = "testClusters"; - public static final String THROTTLE_SERVICE_NAME = "testClustersThrottle"; - - private static final String LIST_TASK_NAME = "listTestClusters"; - private static final String REGISTRY_SERVICE_NAME = "testClustersRegistry"; - private static final String LEGACY_JAVA_VENDOR = "adoptopenjdk"; - private static final String LEGACY_JAVA_VERSION = "8u242+b08"; - private static final Logger logger = Logging.getLogger(TestClustersPlugin.class); - - @Inject - protected FileSystemOperations getFileSystemOperations() { - throw new UnsupportedOperationException(); - } - - @Inject - protected ArchiveOperations getArchiveOperations() { - throw new UnsupportedOperationException(); - } - - @Override - public void apply(Project project) { - project.getPluginManager().apply(JdkDownloadPlugin.class); - project.getRootProject().getPluginManager().apply(GlobalBuildInfoPlugin.class); - if (BuildParams.isInternal()) { - project.getPlugins().apply(InternalDistributionDownloadPlugin.class); - } else { - project.getPlugins().apply(DistributionDownloadPlugin.class); - } - project.getRootProject().getPluginManager().apply(ReaperPlugin.class); - - ReaperService reaper = project.getRootProject().getExtensions().getByType(ReaperService.class); - - // register legacy jdk distribution for testing pre-7.0 BWC clusters - Jdk bwcJdk = JdkDownloadPlugin.getContainer(project).create("bwc_jdk", jdk -> { - jdk.setVendor(LEGACY_JAVA_VENDOR); - jdk.setVersion(LEGACY_JAVA_VERSION); - jdk.setPlatform(OS.current().name().toLowerCase()); - jdk.setArchitecture(Architecture.current().name().toLowerCase()); - }); - - // enable the DSL to describe clusters - NamedDomainObjectContainer container = createTestClustersContainerExtension(project, reaper, bwcJdk); - - // provide a task to be able to list defined clusters. - createListClustersTask(project, container); - - // register cluster registry as a global build service - project.getGradle().getSharedServices().registerIfAbsent(REGISTRY_SERVICE_NAME, TestClustersRegistry.class, noop()); - - // register throttle so we only run at most max-workers/2 nodes concurrently - project.getGradle() - .getSharedServices() - .registerIfAbsent( - THROTTLE_SERVICE_NAME, - TestClustersThrottle.class, - spec -> spec.getMaxParallelUsages().set(Math.max(1, project.getGradle().getStartParameter().getMaxWorkerCount() / 2)) - ); - - // register cluster hooks - project.getRootProject().getPluginManager().apply(TestClustersHookPlugin.class); - } - - private NamedDomainObjectContainer createTestClustersContainerExtension( - Project project, - ReaperService reaper, - Jdk bwcJdk - ) { - // Create an extensions that allows describing clusters - NamedDomainObjectContainer container = project.container( - OpenSearchCluster.class, - name -> new OpenSearchCluster( - name, - project, - reaper, - new File(project.getBuildDir(), "testclusters"), - getFileSystemOperations(), - getArchiveOperations(), - bwcJdk - ) - ); - project.getExtensions().add(EXTENSION_NAME, container); - return container; - } - - private void createListClustersTask(Project project, NamedDomainObjectContainer container) { - // Task is never up to date so we can pass an lambda for the task action - project.getTasks().register(LIST_TASK_NAME, task -> { - task.setGroup("OpenSearch cluster formation"); - task.setDescription("Lists all OpenSearch clusters configured for this project"); - task.doLast( - (Task t) -> container.forEach(cluster -> logger.lifecycle(" * {}: {}", cluster.getName(), cluster.getNumberOfNodes())) - ); - }); - - } - - static class TestClustersHookPlugin implements Plugin { - @Override - public void apply(Project project) { - if (project != project.getRootProject()) { - throw new IllegalStateException(this.getClass().getName() + " can only be applied to the root project."); - } - - Provider registryProvider = GradleUtils.getBuildService( - project.getGradle().getSharedServices(), - REGISTRY_SERVICE_NAME - ); - TestClustersRegistry registry = registryProvider.get(); - - // When we know what tasks will run, we claim the clusters of those task to differentiate between clusters - // that are defined in the build script and the ones that will actually be used in this invocation of gradle - // we use this information to determine when the last task that required the cluster executed so that we can - // terminate the cluster right away and free up resources. - configureClaimClustersHook(project.getGradle(), registry); - - // Before each task, we determine if a cluster needs to be started for that task. - configureStartClustersHook(project.getGradle(), registry); - - // After each task we determine if there are clusters that are no longer needed. - configureStopClustersHook(project.getGradle(), registry); - } - - private static void configureClaimClustersHook(Gradle gradle, TestClustersRegistry registry) { - // Once we know all the tasks that need to execute, we claim all the clusters that belong to those and count the - // claims so we'll know when it's safe to stop them. - gradle.getTaskGraph().whenReady(taskExecutionGraph -> { - taskExecutionGraph.getAllTasks() - .stream() - .filter(task -> task instanceof TestClustersAware) - .map(task -> (TestClustersAware) task) - .flatMap(task -> task.getClusters().stream()) - .forEach(registry::claimCluster); - }); - } - - private static void configureStartClustersHook(Gradle gradle, TestClustersRegistry registry) { - gradle.addListener(new TaskActionListener() { - @Override - public void beforeActions(Task task) { - if (task instanceof TestClustersAware == false) { - return; - } - // we only start the cluster before the actions, so we'll not start it if the task is up-to-date - TestClustersAware awareTask = (TestClustersAware) task; - awareTask.beforeStart(); - awareTask.getClusters().forEach(registry::maybeStartCluster); - } - - @Override - public void afterActions(Task task) {} - }); - } - - private static void configureStopClustersHook(Gradle gradle, TestClustersRegistry registry) { - gradle.addListener(new TaskExecutionListener() { - @Override - public void afterExecute(Task task, TaskState state) { - if (task instanceof TestClustersAware == false) { - return; - } - // always unclaim the cluster, even if _this_ task is up-to-date, as others might not have been - // and caused the cluster to start. - ((TestClustersAware) task).getClusters().forEach(cluster -> registry.stopCluster(cluster, state.getFailure() != null)); - } - - @Override - public void beforeExecute(Task task) {} - }); - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClustersRegistry.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClustersRegistry.java deleted file mode 100644 index 73e0a84470ec9..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClustersRegistry.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testclusters; - -import org.gradle.api.logging.Logger; -import org.gradle.api.logging.Logging; -import org.gradle.api.services.BuildService; -import org.gradle.api.services.BuildServiceParameters; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -public abstract class TestClustersRegistry implements BuildService { - private static final Logger logger = Logging.getLogger(TestClustersRegistry.class); - private static final String TESTCLUSTERS_INSPECT_FAILURE = "testclusters.inspect.failure"; - private final Boolean allowClusterToSurvive = Boolean.valueOf(System.getProperty(TESTCLUSTERS_INSPECT_FAILURE, "false")); - private final Map claimsInventory = new HashMap<>(); - private final Set runningClusters = new HashSet<>(); - - public void claimCluster(OpenSearchCluster cluster) { - cluster.freeze(); - claimsInventory.put(cluster, claimsInventory.getOrDefault(cluster, 0) + 1); - } - - public void maybeStartCluster(OpenSearchCluster cluster) { - if (runningClusters.contains(cluster)) { - return; - } - runningClusters.add(cluster); - cluster.start(); - } - - public void stopCluster(OpenSearchCluster cluster, boolean taskFailed) { - if (taskFailed) { - // If the task fails, and other tasks use this cluster, the other task will likely never be - // executed at all, so we will never be called again to un-claim and terminate it. - if (allowClusterToSurvive) { - logger.info("Not stopping clusters, disabled by property"); - // task failed or this is the last one to stop - for (int i = 1;; i += i) { - logger.lifecycle( - "No more test clusters left to run, going to sleep because {} was set," + " interrupt (^C) to stop clusters.", - TESTCLUSTERS_INSPECT_FAILURE - ); - try { - Thread.sleep(1000 * i); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - return; - } - } - } else { - cluster.stop(true); - runningClusters.remove(cluster); - } - } else { - int currentClaims = claimsInventory.getOrDefault(cluster, 0) - 1; - claimsInventory.put(cluster, currentClaims); - - if (currentClaims <= 0 && runningClusters.contains(cluster)) { - cluster.stop(false); - runningClusters.remove(cluster); - } - } - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClustersThrottle.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClustersThrottle.java deleted file mode 100644 index efb4eb4b075ae..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClustersThrottle.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testclusters; - -import org.gradle.api.services.BuildService; -import org.gradle.api.services.BuildServiceParameters; - -public abstract class TestClustersThrottle implements BuildService {} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestDistribution.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestDistribution.java deleted file mode 100644 index 660d402ff6ffd..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestDistribution.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testclusters; - -/** - * An enumeration of the distributions that may be used in test clusters. - */ -public enum TestDistribution { - INTEG_TEST, - ARCHIVE -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testfixtures/DockerComposeThrottle.java b/buildSrc/src/main/java/org/opensearch/gradle/testfixtures/DockerComposeThrottle.java deleted file mode 100644 index afadc254fcbef..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/testfixtures/DockerComposeThrottle.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testfixtures; - -import org.gradle.api.services.BuildService; -import org.gradle.api.services.BuildServiceParameters; - -public abstract class DockerComposeThrottle implements BuildService {} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testfixtures/TestFixtureExtension.java b/buildSrc/src/main/java/org/opensearch/gradle/testfixtures/TestFixtureExtension.java deleted file mode 100644 index 57a74322774a1..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/testfixtures/TestFixtureExtension.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testfixtures; - -import org.gradle.api.GradleException; -import org.gradle.api.NamedDomainObjectContainer; -import org.gradle.api.Project; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -public class TestFixtureExtension { - - private final Project project; - final NamedDomainObjectContainer fixtures; - final Map serviceToProjectUseMap = new HashMap<>(); - - public TestFixtureExtension(Project project) { - this.project = project; - this.fixtures = project.container(Project.class); - } - - public void useFixture() { - useFixture(this.project.getPath()); - } - - public void useFixture(String path) { - addFixtureProject(path); - serviceToProjectUseMap.put(path, this.project.getPath()); - } - - public void useFixture(String path, String serviceName) { - addFixtureProject(path); - String key = getServiceNameKey(path, serviceName); - serviceToProjectUseMap.put(key, this.project.getPath()); - - Optional otherProject = this.findOtherProjectUsingService(key); - if (otherProject.isPresent()) { - String exceptionMessage = String.format( - "Projects %s and %s both claim the %s service defined in the docker-compose.yml of %s. This is not supported because it " - + "breaks running in parallel. Configure dedicated services for each project and use those instead.", - otherProject.get(), - this.project.getPath(), - serviceName, - path - ); - - throw new GradleException(exceptionMessage); - } - } - - private String getServiceNameKey(String fixtureProjectPath, String serviceName) { - return fixtureProjectPath + "::" + serviceName; - } - - private Optional findOtherProjectUsingService(String serviceName) { - return this.project.getRootProject() - .getAllprojects() - .stream() - .filter(p -> p.equals(this.project) == false) - .filter(p -> p.getExtensions().findByType(TestFixtureExtension.class) != null) - .map(project -> project.getExtensions().getByType(TestFixtureExtension.class)) - .flatMap(ext -> ext.serviceToProjectUseMap.entrySet().stream()) - .filter(entry -> entry.getKey().equals(serviceName)) - .map(Map.Entry::getValue) - .findAny(); - } - - private void addFixtureProject(String path) { - Project fixtureProject = this.project.findProject(path); - if (fixtureProject == null) { - throw new IllegalArgumentException("Could not find test fixture " + fixtureProject); - } - if (fixtureProject.file(TestFixturesPlugin.DOCKER_COMPOSE_YML).exists() == false) { - throw new IllegalArgumentException( - "Project " + path + " is not a valid test fixture: missing " + TestFixturesPlugin.DOCKER_COMPOSE_YML - ); - } - fixtures.add(fixtureProject); - // Check for exclusive access - Optional otherProject = this.findOtherProjectUsingService(path); - if (otherProject.isPresent()) { - final String exceptionMessage = String.format( - "Projects %s and %s both claim all services from %s. This is not supported because it breaks running in parallel. " - + "Configure specific services in docker-compose.yml for each and add the service name to `useFixture`", - otherProject.get(), - this.project.getPath(), - path - ); - - throw new GradleException(exceptionMessage); - } - } - - boolean isServiceRequired(String serviceName, String fixtureProject) { - if (serviceToProjectUseMap.containsKey(fixtureProject)) { - return true; - } - return serviceToProjectUseMap.containsKey(getServiceNameKey(fixtureProject, serviceName)); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testfixtures/TestFixturesPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/testfixtures/TestFixturesPlugin.java deleted file mode 100644 index 1902f673dc653..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/testfixtures/TestFixturesPlugin.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testfixtures; - -import com.avast.gradle.dockercompose.ComposeExtension; -import com.avast.gradle.dockercompose.DockerComposePlugin; -import com.avast.gradle.dockercompose.ServiceInfo; -import com.avast.gradle.dockercompose.tasks.ComposeDown; -import com.avast.gradle.dockercompose.tasks.ComposePull; -import com.avast.gradle.dockercompose.tasks.ComposeUp; -import org.opensearch.gradle.SystemPropertyCommandLineArgumentProvider; -import org.opensearch.gradle.docker.DockerSupportPlugin; -import org.opensearch.gradle.docker.DockerSupportService; -import org.opensearch.gradle.info.BuildParams; -import org.opensearch.gradle.precommit.TestingConventionsTasks; -import org.opensearch.gradle.util.GradleUtils; -import org.gradle.api.Action; -import org.gradle.api.DefaultTask; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.file.FileSystemOperations; -import org.gradle.api.logging.Logger; -import org.gradle.api.logging.Logging; -import org.gradle.api.plugins.BasePlugin; -import org.gradle.api.plugins.ExtraPropertiesExtension; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.TaskContainer; -import org.gradle.api.tasks.TaskProvider; -import org.gradle.api.tasks.testing.Test; -import org.apache.tools.ant.taskdefs.condition.Os; - -import javax.inject.Inject; -import java.io.File; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.nio.file.Files; -import java.util.Arrays; -import java.util.Collections; -import java.util.function.BiConsumer; -import java.util.Optional; - -public class TestFixturesPlugin implements Plugin { - - private static final Logger LOGGER = Logging.getLogger(TestFixturesPlugin.class); - private static final String DOCKER_COMPOSE_THROTTLE = "dockerComposeThrottle"; - static final String DOCKER_COMPOSE_YML = "docker-compose.yml"; - - private static String[] DOCKER_COMPOSE_BINARIES_UNIX = { "/usr/local/bin/docker-compose", "/usr/bin/docker-compose" }; - - private static String[] DOCKER_COMPOSE_BINARIES_WINDOWS = { - System.getenv("PROGRAMFILES") + "\\Docker\\Docker\\resources\\bin\\docker-compose.exe" }; - - private static String[] DOCKER_COMPOSE_BINARIES = Os.isFamily(Os.FAMILY_WINDOWS) - ? DOCKER_COMPOSE_BINARIES_WINDOWS - : DOCKER_COMPOSE_BINARIES_UNIX; - - @Inject - protected FileSystemOperations getFileSystemOperations() { - throw new UnsupportedOperationException(); - } - - @Override - public void apply(Project project) { - project.getRootProject().getPluginManager().apply(DockerSupportPlugin.class); - - TaskContainer tasks = project.getTasks(); - TestFixtureExtension extension = project.getExtensions().create("testFixtures", TestFixtureExtension.class, project); - Provider dockerComposeThrottle = project.getGradle() - .getSharedServices() - .registerIfAbsent(DOCKER_COMPOSE_THROTTLE, DockerComposeThrottle.class, spec -> spec.getMaxParallelUsages().set(1)); - - Provider dockerSupport = GradleUtils.getBuildService( - project.getGradle().getSharedServices(), - DockerSupportPlugin.DOCKER_SUPPORT_SERVICE_NAME - ); - - ExtraPropertiesExtension ext = project.getExtensions().getByType(ExtraPropertiesExtension.class); - File testfixturesDir = project.file("testfixtures_shared"); - ext.set("testFixturesDir", testfixturesDir); - - if (project.file(DOCKER_COMPOSE_YML).exists()) { - project.getPluginManager().apply(BasePlugin.class); - project.getPluginManager().apply(DockerComposePlugin.class); - - TaskProvider preProcessFixture = project.getTasks().register("preProcessFixture", t -> { - t.getOutputs().dir(testfixturesDir); - t.doFirst(t2 -> { - try { - Files.createDirectories(testfixturesDir.toPath()); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - }); - }); - TaskProvider buildFixture = project.getTasks() - .register("buildFixture", t -> t.dependsOn(preProcessFixture, tasks.named("composeUp"))); - - TaskProvider postProcessFixture = project.getTasks().register("postProcessFixture", task -> { - task.dependsOn(buildFixture); - configureServiceInfoForTask( - task, - project, - false, - (name, port) -> task.getExtensions().getByType(ExtraPropertiesExtension.class).set(name, port) - ); - }); - - maybeSkipTask(dockerSupport, preProcessFixture); - maybeSkipTask(dockerSupport, postProcessFixture); - maybeSkipTask(dockerSupport, buildFixture); - - ComposeExtension composeExtension = project.getExtensions().getByType(ComposeExtension.class); - composeExtension.getUseComposeFiles().set(Collections.singletonList(DOCKER_COMPOSE_YML)); - composeExtension.getRemoveContainers().set(true); - - Optional dockerCompose = Arrays.asList(DOCKER_COMPOSE_BINARIES) - .stream() - .filter(path -> project.file(path).exists()) - .findFirst(); - - composeExtension.getExecutable().set(dockerCompose.isPresent() ? dockerCompose.get() : "/usr/bin/docker"); - - tasks.named("composeUp").configure(t -> { - // Avoid running docker-compose tasks in parallel in CI due to some issues on certain Linux distributions - if (BuildParams.isCi()) { - t.usesService(dockerComposeThrottle); - } - t.mustRunAfter(preProcessFixture); - }); - tasks.named("composePull").configure(t -> t.mustRunAfter(preProcessFixture)); - tasks.named("composeDown").configure(t -> t.doLast(t2 -> getFileSystemOperations().delete(d -> d.delete(testfixturesDir)))); - } else { - project.afterEvaluate(spec -> { - if (extension.fixtures.isEmpty()) { - // if only one fixture is used, that's this one, but without a compose file that's not a valid configuration - throw new IllegalStateException( - "No " + DOCKER_COMPOSE_YML + " found for " + project.getPath() + " nor does it use other fixtures." - ); - } - }); - } - - extension.fixtures.matching(fixtureProject -> fixtureProject.equals(project) == false) - .all(fixtureProject -> project.evaluationDependsOn(fixtureProject.getPath())); - - // Skip docker compose tasks if it is unavailable - maybeSkipTasks(tasks, dockerSupport, Test.class); - maybeSkipTasks(tasks, dockerSupport, getTaskClass("org.opensearch.gradle.test.RestIntegTestTask")); - maybeSkipTasks(tasks, dockerSupport, TestingConventionsTasks.class); - maybeSkipTasks(tasks, dockerSupport, getTaskClass("org.opensearch.gradle.test.AntFixture")); - maybeSkipTasks(tasks, dockerSupport, ComposeUp.class); - maybeSkipTasks(tasks, dockerSupport, ComposePull.class); - maybeSkipTasks(tasks, dockerSupport, ComposeDown.class); - - tasks.withType(Test.class).configureEach(task -> extension.fixtures.all(fixtureProject -> { - task.dependsOn(fixtureProject.getTasks().named("postProcessFixture")); - task.finalizedBy(fixtureProject.getTasks().named("composeDown")); - configureServiceInfoForTask( - task, - fixtureProject, - true, - (name, host) -> task.getExtensions().getByType(SystemPropertyCommandLineArgumentProvider.class).systemProperty(name, host) - ); - })); - } - - private void maybeSkipTasks(TaskContainer tasks, Provider dockerSupport, Class taskClass) { - tasks.withType(taskClass).configureEach(t -> maybeSkipTask(dockerSupport, t)); - } - - private void maybeSkipTask(Provider dockerSupport, TaskProvider task) { - task.configure(t -> maybeSkipTask(dockerSupport, t)); - } - - private void maybeSkipTask(Provider dockerSupport, Task task) { - task.onlyIf(spec -> { - boolean isComposeAvailable = dockerSupport.get().getDockerAvailability().isComposeAvailable; - if (isComposeAvailable == false) { - LOGGER.info("Task {} requires docker-compose but it is unavailable. Task will be skipped.", task.getPath()); - } - return isComposeAvailable; - }); - } - - private void configureServiceInfoForTask( - Task task, - Project fixtureProject, - boolean enableFilter, - BiConsumer consumer - ) { - // Configure ports for the tests as system properties. - // We only know these at execution time so we need to do it in doFirst - task.doFirst(new Action() { - @Override - public void execute(Task theTask) { - TestFixtureExtension extension = theTask.getProject().getExtensions().getByType(TestFixtureExtension.class); - - fixtureProject.getExtensions() - .getByType(ComposeExtension.class) - .getServicesInfos() - .entrySet() - .stream() - .filter(entry -> enableFilter == false || extension.isServiceRequired(entry.getKey(), fixtureProject.getPath())) - .forEach(entry -> { - String service = entry.getKey(); - ServiceInfo infos = entry.getValue(); - infos.getTcpPorts().forEach((container, host) -> { - String name = "test.fixtures." + service + ".tcp." + container; - theTask.getLogger().info("port mapping property: {}={}", name, host); - consumer.accept(name, host); - }); - infos.getUdpPorts().forEach((container, host) -> { - String name = "test.fixtures." + service + ".udp." + container; - theTask.getLogger().info("port mapping property: {}={}", name, host); - consumer.accept(name, host); - }); - }); - } - }); - } - - @SuppressWarnings("unchecked") - private Class getTaskClass(String type) { - Class aClass; - try { - aClass = Class.forName(type); - if (DefaultTask.class.isAssignableFrom(aClass) == false) { - throw new IllegalArgumentException("Not a task type: " + type); - } - } catch (ClassNotFoundException e) { - throw new IllegalArgumentException("No such task: " + type); - } - return (Class) aClass; - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/transform/SymbolicLinkPreservingUntarTransform.java b/buildSrc/src/main/java/org/opensearch/gradle/transform/SymbolicLinkPreservingUntarTransform.java deleted file mode 100644 index 4b3e92e23925e..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/transform/SymbolicLinkPreservingUntarTransform.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.transform; - -import org.apache.commons.compress.archivers.tar.TarArchiveEntry; -import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; -import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream; -import org.gradle.api.logging.Logging; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.function.Function; - -import static org.opensearch.gradle.util.PermissionUtils.chmod; - -public abstract class SymbolicLinkPreservingUntarTransform implements UnpackTransform { - - private static final Path CURRENT_DIR_PATH = Paths.get("."); - - public void unpack(File tarFile, File targetDir) throws IOException { - Logging.getLogger(SymbolicLinkPreservingUntarTransform.class) - .info("Unpacking " + tarFile.getName() + " using " + SymbolicLinkPreservingUntarTransform.class.getSimpleName() + "."); - Function pathModifier = pathResolver(); - - try ( - FileInputStream fis = new FileInputStream(tarFile); - GzipCompressorInputStream gzip = new GzipCompressorInputStream(fis); - TarArchiveInputStream tar = new TarArchiveInputStream(gzip) - ) { - final Path destinationPath = targetDir.toPath(); - TarArchiveEntry entry = tar.getNextTarEntry(); - while (entry != null) { - final Path relativePath = pathModifier.apply(entry.getName()); - if (relativePath == null || relativePath.getFileName().equals(CURRENT_DIR_PATH)) { - entry = tar.getNextTarEntry(); - continue; - } - - final Path destination = destinationPath.resolve(relativePath); - final Path parent = destination.getParent(); - if (Files.exists(parent) == false) { - Files.createDirectories(parent); - } - if (entry.isDirectory()) { - Files.createDirectory(destination); - } else if (entry.isSymbolicLink()) { - Files.createSymbolicLink(destination, Paths.get(entry.getLinkName())); - } else { - // copy the file from the archive using a small buffer to avoid heaping - Files.createFile(destination); - try (FileOutputStream fos = new FileOutputStream(destination.toFile())) { - byte[] buffer = new byte[4096]; - int len; - while ((len = tar.read(buffer)) > 0) { - fos.write(buffer, 0, len); - } - } - } - if (entry.isSymbolicLink() == false) { - // check if the underlying file system supports POSIX permissions - chmod(destination, entry.getMode()); - } - entry = tar.getNextTarEntry(); - } - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/transform/UnpackTransform.java b/buildSrc/src/main/java/org/opensearch/gradle/transform/UnpackTransform.java deleted file mode 100644 index ba654ab46f551..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/transform/UnpackTransform.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.transform; - -import org.gradle.api.artifacts.transform.InputArtifact; -import org.gradle.api.artifacts.transform.TransformAction; -import org.gradle.api.artifacts.transform.TransformOutputs; -import org.gradle.api.artifacts.transform.TransformParameters; -import org.gradle.api.file.FileSystemLocation; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.Optional; -import org.gradle.api.tasks.PathSensitive; -import org.gradle.api.tasks.PathSensitivity; -import org.gradle.internal.UncheckedException; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.function.Function; - -public interface UnpackTransform extends TransformAction { - - interface Parameters extends TransformParameters { - @Input - @Optional - String getTrimmedPrefixPattern(); - - void setTrimmedPrefixPattern(String pattern); - } - - @PathSensitive(PathSensitivity.NAME_ONLY) - @InputArtifact - Provider getArchiveFile(); - - @Override - default void transform(TransformOutputs outputs) { - File archiveFile = getArchiveFile().get().getAsFile(); - File extractedDir = outputs.dir(archiveFile.getName()); - try { - unpack(archiveFile, extractedDir); - } catch (IOException e) { - throw UncheckedException.throwAsUncheckedException(e); - } - } - - void unpack(File archiveFile, File targetDir) throws IOException; - - default Function pathResolver() { - String trimmedPrefixPattern = getParameters().getTrimmedPrefixPattern(); - return trimmedPrefixPattern != null ? (i) -> trimArchiveExtractPath(trimmedPrefixPattern, i) : (i) -> Paths.get(i); - } - - /* - * We want to be able to trim off certain prefixes when transforming archives. - * - * E.g We want to remove up to the and including the jdk-.* relative paths. That is a JDK archive is structured as: - * jdk-12.0.1/ - * jdk-12.0.1/Contents - * ... - * - * and we want to remove the leading jdk-12.0.1. Note however that there could also be a leading ./ as in - * ./ - * ./jdk-12.0.1/ - * ./jdk-12.0.1/Contents - * - * so we account for this and search the path components until we find the jdk-12.0.1, and strip the leading components. - */ - static Path trimArchiveExtractPath(String ignoredPattern, String relativePath) { - final Path entryName = Paths.get(relativePath); - int index = 0; - for (; index < entryName.getNameCount(); index++) { - if (entryName.getName(index).toString().matches(ignoredPattern)) { - break; - } - } - if (index + 1 >= entryName.getNameCount()) { - // this happens on the top-level directories in the archive, which we are removing - return null; - } - // finally remove the top-level directories from the output path - return entryName.subpath(index + 1, entryName.getNameCount()); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/transform/UnzipTransform.java b/buildSrc/src/main/java/org/opensearch/gradle/transform/UnzipTransform.java deleted file mode 100644 index e4e090390ef7d..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/transform/UnzipTransform.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.transform; - -import org.apache.commons.io.IOUtils; -import org.apache.tools.zip.ZipEntry; -import org.apache.tools.zip.ZipFile; -import org.gradle.api.logging.Logging; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.file.Path; -import java.util.Enumeration; -import java.util.function.Function; - -import static org.opensearch.gradle.util.PermissionUtils.chmod; - -public abstract class UnzipTransform implements UnpackTransform { - - public void unpack(File zipFile, File targetDir) throws IOException { - Logging.getLogger(UnzipTransform.class) - .info("Unpacking " + zipFile.getName() + " using " + UnzipTransform.class.getSimpleName() + "."); - Function pathModifier = pathResolver(); - ZipFile zip = new ZipFile(zipFile); - try { - Enumeration entries = zip.getEntries(); - while (entries.hasMoreElements()) { - ZipEntry zipEntry = entries.nextElement(); - Path child = pathModifier.apply(zipEntry.getName()); - if (child == null) { - continue; - } - Path outputPath = targetDir.toPath().resolve(child); - if (zipEntry.isDirectory()) { - outputPath.toFile().mkdirs(); - chmod(outputPath, zipEntry.getUnixMode()); - continue; - } - try (FileOutputStream outputStream = new FileOutputStream(outputPath.toFile())) { - IOUtils.copyLarge(zip.getInputStream(zipEntry), outputStream); - } - chmod(outputPath, zipEntry.getUnixMode()); - } - } finally { - zip.close(); - } - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/util/FileUtils.java b/buildSrc/src/main/java/org/opensearch/gradle/util/FileUtils.java deleted file mode 100644 index 23cc670a4b021..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/util/FileUtils.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.util; - -import org.gradle.api.UncheckedIOException; - -import java.io.File; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -public final class FileUtils { - - /** - * Like {@link java.io.File#mkdirs()}, except throws an informative error if a dir cannot be created. - * - * @param dir The dir to create, including any non existent parent dirs. - */ - public static void mkdirs(File dir) { - dir = dir.getAbsoluteFile(); - if (dir.isDirectory()) { - return; - } - - if (dir.exists() && !dir.isDirectory()) { - throw new UncheckedIOException(String.format("Cannot create directory '%s' as it already exists, but is not a directory", dir)); - } - - List toCreate = new LinkedList(); - File parent = dir.getParentFile(); - while (!parent.exists()) { - toCreate.add(parent); - parent = parent.getParentFile(); - } - Collections.reverse(toCreate); - for (File parentDirToCreate : toCreate) { - if (parentDirToCreate.isDirectory()) { - continue; - } - File parentDirToCreateParent = parentDirToCreate.getParentFile(); - if (!parentDirToCreateParent.isDirectory()) { - throw new UncheckedIOException( - String.format( - "Cannot create parent directory '%s' when creating directory '%s' as '%s' is not a directory", - parentDirToCreate, - dir, - parentDirToCreateParent - ) - ); - } - if (!parentDirToCreate.mkdir() && !parentDirToCreate.isDirectory()) { - throw new UncheckedIOException( - String.format("Failed to create parent directory '%s' when creating directory '%s'", parentDirToCreate, dir) - ); - } - } - if (!dir.mkdir() && !dir.isDirectory()) { - throw new UncheckedIOException(String.format("Failed to create directory '%s'", dir)); - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/util/GradleUtils.java b/buildSrc/src/main/java/org/opensearch/gradle/util/GradleUtils.java deleted file mode 100644 index 91e37fc1de3ca..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/util/GradleUtils.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.util; - -import org.opensearch.gradle.OpenSearchJavaPlugin; -import org.gradle.api.Action; -import org.gradle.api.GradleException; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.UnknownTaskException; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.Dependency; -import org.gradle.api.plugins.JavaBasePlugin; -import org.gradle.api.plugins.JavaPluginConvention; -import org.gradle.api.provider.Provider; -import org.gradle.api.services.BuildService; -import org.gradle.api.services.BuildServiceRegistration; -import org.gradle.api.services.BuildServiceRegistry; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.SourceSetContainer; -import org.gradle.api.tasks.TaskContainer; -import org.gradle.api.tasks.TaskProvider; -import org.gradle.api.tasks.testing.Test; -import org.gradle.plugins.ide.eclipse.model.EclipseModel; -import org.gradle.plugins.ide.idea.model.IdeaModel; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - -public abstract class GradleUtils { - - public static Action noop() { - return t -> {}; - } - - public static SourceSetContainer getJavaSourceSets(Project project) { - return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets(); - } - - public static TaskProvider maybeRegister(TaskContainer tasks, String name, Class clazz, Action action) { - try { - return tasks.named(name, clazz); - } catch (UnknownTaskException e) { - return tasks.register(name, clazz, action); - } - } - - public static void maybeConfigure(TaskContainer tasks, String name, Action config) { - TaskProvider task; - try { - task = tasks.named(name); - } catch (UnknownTaskException e) { - return; - } - - task.configure(config); - } - - public static void maybeConfigure( - TaskContainer tasks, - String name, - Class type, - Action config - ) { - tasks.withType(type).configureEach(task -> { - if (task.getName().equals(name)) { - config.execute(task); - } - }); - } - - public static TaskProvider findByName(TaskContainer tasks, String name) { - TaskProvider task; - try { - task = tasks.named(name); - } catch (UnknownTaskException e) { - return null; - } - - return task; - } - - @SuppressWarnings("unchecked") - public static > Provider getBuildService(BuildServiceRegistry registry, String name) { - BuildServiceRegistration registration = registry.getRegistrations().findByName(name); - if (registration == null) { - throw new GradleException("Unable to find build service with name '" + name + "'."); - } - - return (Provider) registration.getService(); - } - - /** - * Add a source set and task of the same name that runs tests. - *

    - * IDEs are also configured if setup, and the test task is added to check. The new test source - * set extends from the normal test source set to allow sharing of utilities. - * - * @return A task provider for the newly created test task - */ - public static TaskProvider addTestSourceSet(Project project, String sourceSetName) { - project.getPluginManager().apply(OpenSearchJavaPlugin.class); - - // create our test source set and task - SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet testSourceSet = sourceSets.create(sourceSetName); - TaskProvider testTask = project.getTasks().register(sourceSetName, Test.class); - testTask.configure(task -> { - task.setGroup(JavaBasePlugin.VERIFICATION_GROUP); - task.setTestClassesDirs(testSourceSet.getOutput().getClassesDirs()); - task.setClasspath(testSourceSet.getRuntimeClasspath()); - // make the new test run after unit tests - task.mustRunAfter(project.getTasks().named("test")); - }); - - Configuration testCompileConfig = project.getConfigurations().getByName(testSourceSet.getCompileClasspathConfigurationName()); - Configuration testRuntimeConfig = project.getConfigurations().getByName(testSourceSet.getRuntimeClasspathConfigurationName()); - testSourceSet.setCompileClasspath(testCompileConfig); - testSourceSet.setRuntimeClasspath(project.getObjects().fileCollection().from(testSourceSet.getOutput(), testRuntimeConfig)); - - extendSourceSet(project, SourceSet.MAIN_SOURCE_SET_NAME, sourceSetName); - - setupIdeForTestSourceSet(project, testSourceSet); - - // add to the check task - project.getTasks().named(JavaBasePlugin.CHECK_TASK_NAME).configure(check -> check.dependsOn(testTask)); - - return testTask; - } - - public static void setupIdeForTestSourceSet(Project project, SourceSet testSourceSet) { - // setup IDEs - String runtimeClasspathName = testSourceSet.getRuntimeClasspathConfigurationName(); - Configuration runtimeClasspathConfiguration = project.getConfigurations().getByName(runtimeClasspathName); - project.getPluginManager().withPlugin("idea", p -> { - IdeaModel idea = project.getExtensions().getByType(IdeaModel.class); - idea.getModule().setTestSourceDirs(testSourceSet.getJava().getSrcDirs()); - idea.getModule().getScopes().put(testSourceSet.getName(), new HashMap>() { - { - put("plus", Arrays.asList(runtimeClasspathConfiguration)); - } - }); - }); - project.getPluginManager().withPlugin("eclipse", p -> { - EclipseModel eclipse = project.getExtensions().getByType(EclipseModel.class); - List eclipseSourceSets = new ArrayList<>(); - for (SourceSet old : eclipse.getClasspath().getSourceSets()) { - eclipseSourceSets.add(old); - } - eclipseSourceSets.add(testSourceSet); - eclipse.getClasspath().setSourceSets(project.getExtensions().getByType(SourceSetContainer.class)); - eclipse.getClasspath().getPlusConfigurations().add(runtimeClasspathConfiguration); - }); - } - - /** - * Extend the configurations of one source set from another. - */ - public static void extendSourceSet(Project project, String parentSourceSetName, String childSourceSetName) { - final List> configNameFunctions = Arrays.asList( - SourceSet::getCompileConfigurationName, - SourceSet::getImplementationConfigurationName, - SourceSet::getRuntimeConfigurationName, - SourceSet::getRuntimeOnlyConfigurationName - ); - SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet parent = sourceSets.getByName(parentSourceSetName); - SourceSet child = sourceSets.getByName(childSourceSetName); - - for (Function configNameFunction : configNameFunctions) { - String parentConfigName = configNameFunction.apply(parent); - String childConfigName = configNameFunction.apply(child); - Configuration parentConfig = project.getConfigurations().getByName(parentConfigName); - Configuration childConfig = project.getConfigurations().getByName(childConfigName); - childConfig.extendsFrom(parentConfig); - } - - // tie this new test source set to the main and test source sets - child.setCompileClasspath(project.getObjects().fileCollection().from(child.getCompileClasspath(), parent.getOutput())); - child.setRuntimeClasspath(project.getObjects().fileCollection().from(child.getRuntimeClasspath(), parent.getOutput())); - } - - /** - * Extends one configuration from another and refreshes the classpath of a provided Test. - * The Test parameter is only needed for eagerly defined test tasks. - */ - public static void extendSourceSet(Project project, String parentSourceSetName, String childSourceSetName, Test test) { - extendSourceSet(project, parentSourceSetName, childSourceSetName); - if (test != null) { - SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet child = sourceSets.getByName(childSourceSetName); - test.setClasspath(child.getRuntimeClasspath()); - } - } - - public static Dependency projectDependency(Project project, String projectPath, String projectConfig) { - if (project.findProject(projectPath) == null) { - throw new GradleException("no project [" + projectPath + "], project names: " + project.getRootProject().getAllprojects()); - } - Map depConfig = new HashMap<>(); - depConfig.put("path", projectPath); - depConfig.put("configuration", projectConfig); - return project.getDependencies().project(depConfig); - } - - /** - * To calculate the project path from a task path without relying on Task#getProject() which is discouraged during - * task execution time. - */ - public static String getProjectPathFromTask(String taskPath) { - int lastDelimiterIndex = taskPath.lastIndexOf(":"); - return lastDelimiterIndex == 0 ? ":" : taskPath.substring(0, lastDelimiterIndex); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/util/JavaUtil.java b/buildSrc/src/main/java/org/opensearch/gradle/util/JavaUtil.java deleted file mode 100644 index 18001fb6b86ae..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/util/JavaUtil.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.util; - -import org.opensearch.gradle.info.BuildParams; -import org.opensearch.gradle.info.JavaHome; -import org.gradle.api.GradleException; - -import java.util.List; -import java.util.Optional; - -public class JavaUtil { - - /** A convenience method for getting java home for a version of java and requiring that version for the given task to execute */ - public static String getJavaHome(final int version) { - List javaHomes = BuildParams.getJavaVersions(); - Optional java = javaHomes.stream().filter(j -> j.getVersion() == version).findFirst(); - return java.orElseThrow(() -> new GradleException("JAVA" + version + "_HOME required")).getJavaHome().get().getAbsolutePath(); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/util/PermissionUtils.java b/buildSrc/src/main/java/org/opensearch/gradle/util/PermissionUtils.java deleted file mode 100644 index 285e41fc7a24a..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/util/PermissionUtils.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.util; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.attribute.PosixFileAttributeView; -import java.nio.file.attribute.PosixFilePermission; -import java.nio.file.attribute.PosixFilePermissions; -import java.util.Set; - -public class PermissionUtils { - - public static void chmod(Path path, int mode) throws IOException { - final PosixFileAttributeView view = Files.getFileAttributeView(path, PosixFileAttributeView.class); - if (view != null && (mode != 0)) { - final Set permissions = permissionsFromInt(mode); - Files.setPosixFilePermissions(path, permissions); - } - } - - private static Set permissionsFromInt(int mode) { - return PosixFilePermissions.fromString( - permissions((mode >> 6) & 07) + permissions((mode >> 3) & 07) + permissions((mode >> 0) & 07) - ); - } - - private static String permissions(final int permissions) { - if (permissions < 0 || permissions > 7) { - throw new IllegalArgumentException("permissions [" + permissions + "] out of range"); - } - final StringBuilder sb = new StringBuilder(3); - if ((permissions & 4) == 4) { - sb.append('r'); - } else { - sb.append('-'); - } - if ((permissions & 2) == 2) { - sb.append('w'); - } else { - sb.append('-'); - } - if ((permissions & 1) == 1) { - sb.append('x'); - } else { - sb.append('-'); - } - return sb.toString(); - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/util/Util.java b/buildSrc/src/main/java/org/opensearch/gradle/util/Util.java deleted file mode 100644 index 71b1e5040340d..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/util/Util.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.util; - -import org.opensearch.gradle.info.GlobalBuildInfoPlugin; -import org.gradle.api.Action; -import org.gradle.api.GradleException; -import org.gradle.api.Project; -import org.gradle.api.file.FileTree; -import org.gradle.api.plugins.JavaPluginConvention; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.util.PatternFilterable; - -import javax.annotation.Nullable; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.UncheckedIOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.time.Instant; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.Locale; -import java.util.Optional; -import java.util.function.Supplier; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class Util { - - public static boolean getBooleanProperty(String property, boolean defaultValue) { - String propertyValue = System.getProperty(property); - if (propertyValue == null) { - return defaultValue; - } - if ("true".equals(propertyValue)) { - return true; - } else if ("false".equals(propertyValue)) { - return false; - } else { - throw new GradleException("Sysprop [" + property + "] must be [true] or [false] but was [" + propertyValue + "]"); - } - } - - public static String getResourceContents(String resourcePath) { - try ( - BufferedReader reader = new BufferedReader(new InputStreamReader(GlobalBuildInfoPlugin.class.getResourceAsStream(resourcePath))) - ) { - StringBuilder b = new StringBuilder(); - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - if (b.length() != 0) { - b.append('\n'); - } - b.append(line); - } - - return b.toString(); - } catch (IOException e) { - throw new UncheckedIOException("Error trying to read classpath resource: " + resourcePath, e); - } - } - - public static String capitalize(String s) { - return s.substring(0, 1).toUpperCase(Locale.ROOT) + s.substring(1); - } - - public static URI getBuildSrcCodeSource() { - try { - return Util.class.getProtectionDomain().getCodeSource().getLocation().toURI(); - } catch (URISyntaxException e) { - throw new GradleException("Error determining build tools JAR location", e); - } - } - - /** - * @param project The project to look for resources. - * @param filter Optional filter function to filter the returned resources - * @return Returns the {@link FileTree} for main resources from Java projects. Returns null if no files exist. - */ - @Nullable - public static FileTree getJavaMainSourceResources(Project project, Action filter) { - final Optional mainFileTree = getJavaMainSourceSet(project).map(SourceSet::getResources).map(FileTree::getAsFileTree); - return mainFileTree.map(files -> files.matching(filter)).orElse(null); - } - - /** - * @param project The project to look for resources. - * @param filter Optional filter function to filter the returned resources - * @return Returns the {@link FileTree} for test resources from Java projects. Returns null if no files exist. - */ - @Nullable - public static FileTree getJavaTestSourceResources(Project project, Action filter) { - final Optional testFileTree = getJavaTestSourceSet(project).map(SourceSet::getResources).map(FileTree::getAsFileTree); - return testFileTree.map(files -> files.matching(filter)).orElse(null); - } - - /** - * @param project The project to look for resources. - * @param filter Optional filter function to filter the returned resources - * @return Returns the combined {@link FileTree} for test and main resources from Java projects. Returns null if no files exist. - */ - @Nullable - public static FileTree getJavaTestAndMainSourceResources(Project project, Action filter) { - final Optional testFileTree = getJavaTestSourceSet(project).map(SourceSet::getResources).map(FileTree::getAsFileTree); - final Optional mainFileTree = getJavaMainSourceSet(project).map(SourceSet::getResources).map(FileTree::getAsFileTree); - if (testFileTree.isPresent() && mainFileTree.isPresent()) { - return testFileTree.get().plus(mainFileTree.get()).matching(filter); - } else if (mainFileTree.isPresent()) { - return mainFileTree.get().matching(filter); - } else if (testFileTree.isPresent()) { - return testFileTree.get().matching(filter); - } - return null; - } - - /** - * @param project The project to look for test Java resources. - * @return An Optional that contains the Java test SourceSet if it exists. - */ - public static Optional getJavaTestSourceSet(Project project) { - return project.getConvention().findPlugin(JavaPluginConvention.class) == null - ? Optional.empty() - : Optional.ofNullable(GradleUtils.getJavaSourceSets(project).findByName(SourceSet.TEST_SOURCE_SET_NAME)); - } - - /** - * @param project The project to look for main Java resources. - * @return An Optional that contains the Java main SourceSet if it exists. - */ - public static Optional getJavaMainSourceSet(Project project) { - return project.getConvention().findPlugin(JavaPluginConvention.class) == null - ? Optional.empty() - : Optional.ofNullable(GradleUtils.getJavaSourceSets(project).findByName(SourceSet.MAIN_SOURCE_SET_NAME)); - } - - static final Pattern GIT_PATTERN = Pattern.compile("git@([^:]+):([^\\.]+)\\.git"); - - /** Find the reponame. */ - public static String urlFromOrigin(String origin) { - if (origin == null) { - return null; // best effort, the url doesnt really matter, it is just required by maven central - } - if (origin.startsWith("https")) { - return origin; - } - Matcher matcher = GIT_PATTERN.matcher(origin); - if (matcher.matches()) { - return String.format("https://%s/%s", matcher.group(1), matcher.group(2)); - } else { - return origin; // best effort, the url doesnt really matter, it is just required by maven central - } - } - - public static Object toStringable(Supplier getter) { - return new Object() { - @Override - public String toString() { - return getter.get(); - } - }; - } - - public static ZonedDateTime getBuildDate(ZonedDateTime defaultValue) { - final String sourceDateEpoch = System.getenv("SOURCE_DATE_EPOCH"); - if (sourceDateEpoch != null) { - try { - return ZonedDateTime.ofInstant(Instant.ofEpochSecond(Long.parseLong(sourceDateEpoch)), ZoneOffset.UTC); - } catch (NumberFormatException e) { - throw new GradleException("Sysprop [SOURCE_DATE_EPOCH] must be of type [long]", e); - } - } else { - return defaultValue; - } - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/vagrant/VagrantBasePlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/vagrant/VagrantBasePlugin.java deleted file mode 100644 index 4b918bb38e3c2..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/vagrant/VagrantBasePlugin.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.vagrant; - -import org.opensearch.gradle.ReaperPlugin; -import org.opensearch.gradle.ReaperService; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.execution.TaskActionListener; -import org.gradle.api.execution.TaskExecutionListener; -import org.gradle.api.tasks.TaskState; - -import java.io.ByteArrayOutputStream; -import java.util.List; -import java.util.function.Consumer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class VagrantBasePlugin implements Plugin { - - @Override - public void apply(Project project) { - project.getRootProject().getPluginManager().apply(VagrantSetupCheckerPlugin.class); - project.getRootProject().getPluginManager().apply(VagrantManagerPlugin.class); - project.getRootProject().getPluginManager().apply(ReaperPlugin.class); - - ReaperService reaper = project.getRootProject().getExtensions().getByType(ReaperService.class); - VagrantExtension extension = project.getExtensions().create("vagrant", VagrantExtension.class, project); - VagrantMachine service = project.getExtensions().create("vagrantService", VagrantMachine.class, project, extension, reaper); - - project.getGradle() - .getTaskGraph() - .whenReady( - graph -> service.refs = graph.getAllTasks() - .stream() - .filter(t -> t instanceof VagrantShellTask) - .filter(t -> t.getProject() == project) - .count() - ); - } - - /** - * Check vagrant and virtualbox versions, if any vagrant test tasks will be run. - */ - static class VagrantSetupCheckerPlugin implements Plugin { - - private static final Pattern VAGRANT_VERSION = Pattern.compile("Vagrant (\\d+\\.\\d+\\.\\d+)"); - private static final Pattern VIRTUAL_BOX_VERSION = Pattern.compile("(\\d+\\.\\d+)"); - - @Override - public void apply(Project project) { - if (project != project.getRootProject()) { - throw new IllegalArgumentException("VagrantSetupCheckerPlugin can only be applied to the root project of a build"); - } - - project.getGradle().getTaskGraph().whenReady(graph -> { - boolean needsVagrant = graph.getAllTasks().stream().anyMatch(t -> t instanceof VagrantShellTask); - if (needsVagrant) { - checkVersion(project, "vagrant", VAGRANT_VERSION, 1, 8, 6); - checkVersion(project, "vboxmanage", VIRTUAL_BOX_VERSION, 5, 1); - } - }); - } - - void checkVersion(Project project, String tool, Pattern versionRegex, int... minVersion) { - ByteArrayOutputStream pipe = new ByteArrayOutputStream(); - project.exec(spec -> { - spec.setCommandLine(tool, "--version"); - spec.setStandardOutput(pipe); - }); - String output = pipe.toString().trim(); - Matcher matcher = versionRegex.matcher(output); - if (matcher.find() == false) { - throw new IllegalStateException( - tool + " version output [" + output + "] did not match regex [" + versionRegex.pattern() + "]" - ); - } - - String version = matcher.group(1); - List versionParts = Stream.of(version.split("\\.")).map(Integer::parseInt).collect(Collectors.toList()); - for (int i = 0; i < minVersion.length; ++i) { - int found = versionParts.get(i); - if (found > minVersion[i]) { - break; // most significant version is good - } else if (found < minVersion[i]) { - String exceptionMessage = String.format( - "Unsupported version of %s. Found [%s], expected [%s+", - tool, - version, - Stream.of(minVersion).map(String::valueOf).collect(Collectors.joining(".")) - ); - - throw new IllegalStateException(exceptionMessage); - } // else equal, so check next element - } - } - } - - /** - * Adds global hooks to manage destroying, starting and updating VMs. - */ - static class VagrantManagerPlugin implements Plugin, TaskActionListener, TaskExecutionListener { - - @Override - public void apply(Project project) { - if (project != project.getRootProject()) { - throw new IllegalArgumentException("VagrantManagerPlugin can only be applied to the root project of a build"); - } - project.getGradle().addListener(this); - } - - private void callIfVagrantTask(Task task, Consumer method) { - if (task instanceof VagrantShellTask) { - VagrantMachine service = task.getProject().getExtensions().getByType(VagrantMachine.class); - method.accept(service); - } - } - - @Override - public void beforeExecute(Task task) { /* nothing to do */} - - @Override - public void afterActions(Task task) { /* nothing to do */ } - - @Override - public void beforeActions(Task task) { - callIfVagrantTask(task, VagrantMachine::maybeStartVM); - } - - @Override - public void afterExecute(Task task, TaskState state) { - callIfVagrantTask(task, service -> service.maybeStopVM(state.getFailure() != null)); - } - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/vagrant/VagrantExtension.java b/buildSrc/src/main/java/org/opensearch/gradle/vagrant/VagrantExtension.java deleted file mode 100644 index 5f1b20f9eb917..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/vagrant/VagrantExtension.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.vagrant; - -import org.gradle.api.Project; -import org.gradle.api.file.RegularFileProperty; -import org.gradle.api.provider.MapProperty; -import org.gradle.api.provider.Property; -import org.gradle.api.tasks.Input; - -import java.io.File; -import java.util.Map; - -public class VagrantExtension { - - private final Property box; - private final MapProperty hostEnv; - private final MapProperty vmEnv; - private final RegularFileProperty vagrantfile; - private boolean isWindowsVM; - - public VagrantExtension(Project project) { - this.box = project.getObjects().property(String.class); - this.hostEnv = project.getObjects().mapProperty(String.class, Object.class); - this.vmEnv = project.getObjects().mapProperty(String.class, Object.class); - this.vagrantfile = project.getObjects().fileProperty(); - this.vagrantfile.convention(project.getRootProject().getLayout().getProjectDirectory().file("Vagrantfile")); - this.isWindowsVM = false; - } - - @Input - public String getBox() { - return box.get(); - } - - public void setBox(String box) { - // TODO: should verify this against the Vagrantfile, but would need to do so in afterEvaluate once vagrantfile is unmodifiable - this.box.set(box); - } - - @Input - public Map getHostEnv() { - return hostEnv.get(); - } - - public void hostEnv(String name, Object value) { - hostEnv.put(name, value); - } - - @Input - public Map getVmEnv() { - return vmEnv.get(); - } - - public void vmEnv(String name, Object value) { - vmEnv.put(name, value); - } - - @Input - public boolean isWindowsVM() { - return isWindowsVM; - } - - public void setIsWindowsVM(boolean isWindowsVM) { - this.isWindowsVM = isWindowsVM; - } - - @Input - public File getVagrantfile() { - return this.vagrantfile.get().getAsFile(); - } - - public void setVagrantfile(File file) { - vagrantfile.set(file); - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/vagrant/VagrantMachine.java b/buildSrc/src/main/java/org/opensearch/gradle/vagrant/VagrantMachine.java deleted file mode 100644 index 75827922fa007..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/vagrant/VagrantMachine.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.vagrant; - -import org.apache.commons.io.output.TeeOutputStream; -import org.opensearch.gradle.LoggedExec; -import org.opensearch.gradle.LoggingOutputStream; -import org.opensearch.gradle.ReaperService; -import org.opensearch.gradle.util.Util; -import org.gradle.api.Action; -import org.gradle.api.Project; -import org.gradle.internal.logging.progress.ProgressLogger; -import org.gradle.internal.logging.progress.ProgressLoggerFactory; - -import javax.inject.Inject; -import java.io.File; -import java.io.OutputStream; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Objects; -import java.util.function.UnaryOperator; - -/** - * An helper to manage a vagrant box. - * - * This is created alongside a {@link VagrantExtension} for a project to manage starting and - * stopping a single vagrant box. - */ -public class VagrantMachine { - - private final Project project; - private final VagrantExtension extension; - private final ReaperService reaper; - // pkg private so plugin can set this after construction - long refs; - private boolean isVMStarted = false; - - public VagrantMachine(Project project, VagrantExtension extension, ReaperService reaper) { - this.project = project; - this.extension = extension; - this.reaper = reaper; - } - - @Inject - protected ProgressLoggerFactory getProgressLoggerFactory() { - throw new UnsupportedOperationException(); - } - - public void execute(Action action) { - VagrantExecSpec vagrantSpec = new VagrantExecSpec(); - action.execute(vagrantSpec); - - Objects.requireNonNull(vagrantSpec.command); - - LoggedExec.exec(project, execSpec -> { - execSpec.setExecutable("vagrant"); - File vagrantfile = extension.getVagrantfile(); - execSpec.setEnvironment(System.getenv()); // pass through env - execSpec.environment("VAGRANT_CWD", vagrantfile.getParentFile().toString()); - execSpec.environment("VAGRANT_VAGRANTFILE", vagrantfile.getName()); - extension.getHostEnv().forEach(execSpec::environment); - - execSpec.args(vagrantSpec.command); - if (vagrantSpec.subcommand != null) { - execSpec.args(vagrantSpec.subcommand); - } - execSpec.args(extension.getBox()); - if (vagrantSpec.args != null) { - execSpec.args(Arrays.asList(vagrantSpec.args)); - } - - UnaryOperator progressHandler = vagrantSpec.progressHandler; - if (progressHandler == null) { - progressHandler = new VagrantProgressLogger("==> " + extension.getBox() + ": "); - } - OutputStream output = execSpec.getStandardOutput(); - // output from vagrant needs to be manually curated because --machine-readable isn't actually "readable" - OutputStream progressStream = new ProgressOutputStream(vagrantSpec.command, progressHandler); - execSpec.setStandardOutput(new TeeOutputStream(output, progressStream)); - }); - } - - // start the configuration VM if it hasn't been started yet - void maybeStartVM() { - if (isVMStarted) { - return; - } - - execute(spec -> { - spec.setCommand("box"); - spec.setSubcommand("update"); - }); - - // Destroying before every execution can be annoying while iterating on tests locally. Therefore, we provide a flag that defaults - // to true that can be used to control whether or not to destroy any test boxes before test execution. - boolean destroyVM = Util.getBooleanProperty("vagrant.destroy", true); - if (destroyVM) { - execute(spec -> { - spec.setCommand("destroy"); - spec.setArgs("--force"); - }); - } - - // register box to be shutdown if gradle dies - reaper.registerCommand(extension.getBox(), "vagrant", "halt", "-f", extension.getBox()); - - // We lock the provider to virtualbox because the Vagrantfile specifies lots of boxes that only work - // properly in virtualbox. Virtualbox is vagrant's default but its possible to change that default and folks do. - execute(spec -> { - spec.setCommand("up"); - spec.setArgs("--provision", "--provider", "virtualbox"); - }); - isVMStarted = true; - } - - // stops the VM if refs are down to 0, or force was called - void maybeStopVM(boolean force) { - assert refs >= 1; - this.refs--; - if ((refs == 0 || force) && isVMStarted) { - execute(spec -> spec.setCommand("halt")); - reaper.unregister(extension.getBox()); - } - } - - // convert the given path from an opensearch repo path to a VM path - public static String convertLinuxPath(Project project, String path) { - return "/opensearch/" + project.getRootDir().toPath().relativize(Paths.get(path)); - } - - public static String convertWindowsPath(Project project, String path) { - return "C:\\opensearch\\" + project.getRootDir().toPath().relativize(Paths.get(path)).toString().replace('/', '\\'); - } - - public static class VagrantExecSpec { - private String command; - private String subcommand; - private String[] args; - private UnaryOperator progressHandler; - - private VagrantExecSpec() {} - - public void setCommand(String command) { - this.command = command; - } - - public void setSubcommand(String subcommand) { - this.subcommand = subcommand; - } - - public void setArgs(String... args) { - this.args = args; - } - - /** - * A function to translate output from the vagrant command execution to the progress line. - * - * The function takes the current line of output from vagrant, and returns a new - * progress line, or {@code null} if there is no update. - */ - public void setProgressHandler(UnaryOperator progressHandler) { - this.progressHandler = progressHandler; - } - } - - private class ProgressOutputStream extends LoggingOutputStream { - - private ProgressLogger progressLogger; - private UnaryOperator progressHandler; - - ProgressOutputStream(String command, UnaryOperator progressHandler) { - this.progressHandler = progressHandler; - this.progressLogger = getProgressLoggerFactory().newOperation("vagrant"); - progressLogger.start(extension.getBox() + "> " + command, "hello"); - } - - @Override - protected void logLine(String line) { - String progress = progressHandler.apply(line); - if (progress != null) { - progressLogger.progress(progress); - } - } - - @Override - public void close() { - progressLogger.completed(); - } - } - -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/vagrant/VagrantProgressLogger.java b/buildSrc/src/main/java/org/opensearch/gradle/vagrant/VagrantProgressLogger.java deleted file mode 100644 index 59e59b03e85f2..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/vagrant/VagrantProgressLogger.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.vagrant; - -import java.util.function.UnaryOperator; - -public class VagrantProgressLogger implements UnaryOperator { - - private static final String HEADING_PREFIX = "==> "; - - private final String squashedPrefix; - private String lastLine = ""; - private String heading = ""; - private boolean inProgressReport = false; - - public VagrantProgressLogger(String squashedPrefix) { - this.squashedPrefix = squashedPrefix; - } - - @Override - public String apply(String line) { - if (line.startsWith("\r\u001b")) { - /* We don't want to try to be a full terminal emulator but we want to - keep the escape sequences from leaking and catch _some_ of the - meaning. */ - line = line.substring(2); - if ("[K".equals(line)) { - inProgressReport = true; - } - return null; - } - if (line.startsWith(squashedPrefix)) { - line = line.substring(squashedPrefix.length()); - inProgressReport = false; - lastLine = line; - if (line.startsWith(HEADING_PREFIX)) { - line = line.substring(HEADING_PREFIX.length()); - heading = line + " > "; - } else { - line = heading + line; - } - } else if (inProgressReport) { - inProgressReport = false; - line = lastLine + line; - } else { - return null; - } - return line; - } -} diff --git a/buildSrc/src/main/java/org/opensearch/gradle/vagrant/VagrantShellTask.java b/buildSrc/src/main/java/org/opensearch/gradle/vagrant/VagrantShellTask.java deleted file mode 100644 index 85d3e340c50e7..0000000000000 --- a/buildSrc/src/main/java/org/opensearch/gradle/vagrant/VagrantShellTask.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.vagrant; - -import org.gradle.api.DefaultTask; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.TaskAction; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.function.UnaryOperator; -import java.util.stream.Collectors; - -import static org.opensearch.gradle.vagrant.VagrantMachine.convertLinuxPath; -import static org.opensearch.gradle.vagrant.VagrantMachine.convertWindowsPath; - -/** - * A shell script to run within a vagrant VM. - * - * The script is run as root within the VM. - */ -public abstract class VagrantShellTask extends DefaultTask { - - private final VagrantExtension extension; - private final VagrantMachine service; - private UnaryOperator progressHandler = UnaryOperator.identity(); - - public VagrantShellTask() { - extension = getProject().getExtensions().findByType(VagrantExtension.class); - if (extension == null) { - throw new IllegalStateException("opensearch.vagrant-base must be applied to create " + getClass().getName()); - } - service = getProject().getExtensions().getByType(VagrantMachine.class); - } - - @Input - protected abstract List getWindowsScript(); - - @Input - protected abstract List getLinuxScript(); - - @Input - public UnaryOperator getProgressHandler() { - return progressHandler; - } - - public void setProgressHandler(UnaryOperator progressHandler) { - this.progressHandler = progressHandler; - } - - @TaskAction - public void runScript() { - String rootDir = getProject().getRootDir().toString(); - if (extension.isWindowsVM()) { - service.execute(spec -> { - spec.setCommand("winrm"); - - List script = new ArrayList<>(); - script.add("try {"); - script.add("cd " + convertWindowsPath(getProject(), rootDir)); - extension.getVmEnv().forEach((k, v) -> script.add("$Env:" + k + " = \"" + v + "\"")); - script.addAll(getWindowsScript().stream().map(s -> " " + s).collect(Collectors.toList())); - script.addAll( - Arrays.asList( - " exit $LASTEXITCODE", - "} catch {", - // catch if we have a failure to even run the script at all above, equivalent to set -e, sort of - " echo $_.Exception.Message", - " exit 1", - "}" - ) - ); - spec.setArgs("--elevated", "--command", String.join("\n", script)); - spec.setProgressHandler(progressHandler); - }); - } else { - service.execute(spec -> { - spec.setCommand("ssh"); - - List script = new ArrayList<>(); - script.add("sudo bash -c '"); // start inline bash script - script.add("pwd"); - script.add("cd " + convertLinuxPath(getProject(), rootDir)); - extension.getVmEnv().forEach((k, v) -> script.add("export " + k + "=" + v)); - script.addAll(getLinuxScript()); - script.add("'"); // end inline bash script - spec.setArgs("--command", String.join("\n", script)); - spec.setProgressHandler(progressHandler); - }); - } - } - -} diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.build.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.build.properties deleted file mode 100644 index 3266dd46d125a..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.build.properties +++ /dev/null @@ -1,12 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -implementation-class=org.opensearch.gradle.BuildPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.distribution-download.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.distribution-download.properties deleted file mode 100644 index d62eec2eb23a7..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.distribution-download.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.DistributionDownloadPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.distro-test.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.distro-test.properties deleted file mode 100644 index 04ea82588f7ab..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.distro-test.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.test.DistroTestPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.docker-support.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.docker-support.properties deleted file mode 100644 index 85a84d7f59c0f..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.docker-support.properties +++ /dev/null @@ -1,12 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -implementation-class=org.opensearch.gradle.docker.DockerSupportPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.docs-test.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.docs-test.properties deleted file mode 100644 index cccd14290aa07..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.docs-test.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.doc.DocsTestPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.global-build-info.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.global-build-info.properties deleted file mode 100644 index 105bb6b7b4330..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.global-build-info.properties +++ /dev/null @@ -1,12 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -implementation-class=org.opensearch.gradle.info.GlobalBuildInfoPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.internal-cluster-test.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.internal-cluster-test.properties deleted file mode 100644 index 530534769180d..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.internal-cluster-test.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.test.InternalClusterTestPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.internal-distribution-archive-check.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.internal-distribution-archive-check.properties deleted file mode 100644 index 6ad5455e12b70..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.internal-distribution-archive-check.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.internal.InternalDistributionArchiveCheckPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.internal-distribution-archive-setup.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.internal-distribution-archive-setup.properties deleted file mode 100644 index 9d3f52eb56b6e..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.internal-distribution-archive-setup.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.internal.InternalDistributionArchiveSetupPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.internal-distribution-bwc-setup.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.internal-distribution-bwc-setup.properties deleted file mode 100644 index 731307a1b3545..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.internal-distribution-bwc-setup.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.internal.InternalDistributionBwcSetupPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.internal-distribution-download.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.internal-distribution-download.properties deleted file mode 100644 index 1ae2bc93cdb23..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.internal-distribution-download.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.internal.InternalDistributionDownloadPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.java-rest-test.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.java-rest-test.properties deleted file mode 100644 index d3c6952031a44..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.java-rest-test.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.test.rest.JavaRestTestPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.java.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.java.properties deleted file mode 100644 index 3ca8ae40beffb..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.java.properties +++ /dev/null @@ -1,12 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -implementation-class=org.opensearch.gradle.OpenSearchJavaPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.jdk-download.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.jdk-download.properties deleted file mode 100644 index 9bf7fb7895a94..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.jdk-download.properties +++ /dev/null @@ -1,12 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -implementation-class=org.opensearch.gradle.JdkDownloadPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.opensearchplugin.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.opensearchplugin.properties deleted file mode 100644 index 84d89b8bc28ce..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.opensearchplugin.properties +++ /dev/null @@ -1,12 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -implementation-class=org.opensearch.gradle.plugin.PluginBuildPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.publish.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.publish.properties deleted file mode 100644 index 01aa629679594..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.publish.properties +++ /dev/null @@ -1,12 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -implementation-class=org.opensearch.gradle.PublishPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.reaper.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.reaper.properties deleted file mode 100644 index 1117c0c4f815c..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.reaper.properties +++ /dev/null @@ -1,12 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -implementation-class=org.opensearch.gradle.ReaperPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.repositories.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.repositories.properties deleted file mode 100644 index f0570c389f3c1..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.repositories.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.RepositoriesSetupPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.rest-resources.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.rest-resources.properties deleted file mode 100644 index c643a1a5217ba..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.rest-resources.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.test.rest.RestResourcesPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.rest-test.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.rest-test.properties deleted file mode 100644 index 1a6188dcb74c2..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.rest-test.properties +++ /dev/null @@ -1,12 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -implementation-class=org.opensearch.gradle.test.RestTestPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.standalone-rest-test.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.standalone-rest-test.properties deleted file mode 100644 index 60de7d014e041..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.standalone-rest-test.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.test.StandaloneRestTestPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.standalone-test.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.standalone-test.properties deleted file mode 100644 index d579f151df4ec..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.standalone-test.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.test.StandaloneTestPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.symbolic-link-preserving-tar.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.symbolic-link-preserving-tar.properties deleted file mode 100644 index 6753020f167fb..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.symbolic-link-preserving-tar.properties +++ /dev/null @@ -1,12 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -implementation-class=org.opensearch.gradle.tar.SymoblicLinkPreservingTarPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.test-base.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.test-base.properties deleted file mode 100644 index ff3be7b30dbcb..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.test-base.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.OpenSearchTestBasePlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.test-with-dependencies.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.test-with-dependencies.properties deleted file mode 100644 index 6cb409a617224..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.test-with-dependencies.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.test.TestWithDependenciesPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.test-with-ssl.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.test-with-ssl.properties deleted file mode 100644 index 1dc88f71d40aa..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.test-with-ssl.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.test.TestWithSslPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.test.fixtures.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.test.fixtures.properties deleted file mode 100644 index 00b9748f1f0cc..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.test.fixtures.properties +++ /dev/null @@ -1,12 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -implementation-class=org.opensearch.gradle.testfixtures.TestFixturesPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.testclusters.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.testclusters.properties deleted file mode 100644 index 902e928c0e664..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.testclusters.properties +++ /dev/null @@ -1,12 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -implementation-class=org.opensearch.gradle.testclusters.TestClustersPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.validate-rest-spec.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.validate-rest-spec.properties deleted file mode 100644 index 3c88abf9dc82f..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.validate-rest-spec.properties +++ /dev/null @@ -1,12 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -implementation-class=org.opensearch.gradle.precommit.ValidateRestSpecPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.yaml-rest-test.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.yaml-rest-test.properties deleted file mode 100644 index f4945114e3a57..0000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/opensearch.yaml-rest-test.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -implementation-class=org.opensearch.gradle.test.rest.YamlRestTestPlugin diff --git a/buildSrc/src/main/resources/buildSrc.marker b/buildSrc/src/main/resources/buildSrc.marker deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/buildSrc/src/main/resources/cacerts.bcfks b/buildSrc/src/main/resources/cacerts.bcfks deleted file mode 100644 index 9c3863eda60c5..0000000000000 Binary files a/buildSrc/src/main/resources/cacerts.bcfks and /dev/null differ diff --git a/buildSrc/src/main/resources/deb/README b/buildSrc/src/main/resources/deb/README deleted file mode 100644 index cdecf00756d31..0000000000000 --- a/buildSrc/src/main/resources/deb/README +++ /dev/null @@ -1,4 +0,0 @@ -This directory contains templates that work around gradle-ospackage-plugin -trying to be helpful and adding templates for your os packaging scripts. We -have relatively nice scripts already so we just override the templates to be -mostly noops. diff --git a/buildSrc/src/main/resources/deb/conffiles.ftl b/buildSrc/src/main/resources/deb/conffiles.ftl deleted file mode 100644 index db7788a4e441b..0000000000000 --- a/buildSrc/src/main/resources/deb/conffiles.ftl +++ /dev/null @@ -1,3 +0,0 @@ -<% files.each {file -> %><%= file -%> -<% } %> diff --git a/buildSrc/src/main/resources/deb/postinst.ftl b/buildSrc/src/main/resources/deb/postinst.ftl deleted file mode 100644 index 9acfc0f084e06..0000000000000 --- a/buildSrc/src/main/resources/deb/postinst.ftl +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -e -<% commands.each {command -> %><%= command %><% } %> diff --git a/buildSrc/src/main/resources/deb/preinst.ftl b/buildSrc/src/main/resources/deb/preinst.ftl deleted file mode 100644 index 9acfc0f084e06..0000000000000 --- a/buildSrc/src/main/resources/deb/preinst.ftl +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -e -<% commands.each {command -> %><%= command %><% } %> diff --git a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.core.resources.prefs b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 6fd0a9aab1327..0000000000000 --- a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,6 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/main/resources=UTF-8 -encoding//src/test/java=UTF-8 -encoding//src/test/resources=UTF-8 -encoding/=UTF-8 \ No newline at end of file diff --git a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.core.prefs b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b310bac04c66b..0000000000000 --- a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,24 +0,0 @@ -eclipse.preferences.version=1 - -# this is merged with gradle's generated properties during 'gradle eclipse' - -# NOTE: null pointer analysis etc is not enabled currently, it seems very unstable -# (e.g. crashing eclipse etc) -# org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=enabled -# org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -# org.eclipse.jdt.core.compiler.annotation.nullable=org.opensearch.common.Nullable -# org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled -# org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning -# org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning -# org.eclipse.jdt.core.compiler.problem.nullReference=warning -# org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning -# org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -# org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning - -# We check this in Gradle. Eclipse fails this check because it doesn't have separate class-paths for -org.eclipse.jdt.core.circularClasspath=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.formatter.comment.line_length=140 -org.eclipse.jdt.core.formatter.lineSplit=140 -org.eclipse.jdt.core.formatter.tabulation.char=space -org.eclipse.jdt.core.formatter.tabulation.size=4 diff --git a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 827a41bf634c9..0000000000000 --- a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,6 +0,0 @@ -eclipse.preferences.version=1 -formatter_settings_version=12 -# Intellij IDEA import order -org.eclipse.jdt.ui.importorder=;com;org;java;javax;\#; -# License header -org.eclipse.jdt.ui.text.custom_code_templates= diff --git a/buildSrc/src/main/resources/fips_java_bcjsse_11.policy b/buildSrc/src/main/resources/fips_java_bcjsse_11.policy deleted file mode 100644 index 10193f4eb385d..0000000000000 --- a/buildSrc/src/main/resources/fips_java_bcjsse_11.policy +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -// Security Policy for JDK 11 and higher, with BouncyCastle FIPS provider and BouncyCastleJsseProvider in FIPS mode - -grant { - permission java.security.SecurityPermission "putProviderProperty.BCFIPS"; - permission java.security.SecurityPermission "putProviderProperty.BCJSSE"; - permission java.lang.RuntimePermission "getProtectionDomain"; - permission java.util.PropertyPermission "java.runtime.name", "read"; - permission org.bouncycastle.crypto.CryptoServicesPermission "tlsAlgorithmsEnabled"; - //io.netty.handler.codec.DecoderException - permission java.lang.RuntimePermission "accessClassInPackage.sun.security.internal.spec"; - //java.security.InvalidAlgorithmParameterException: Cannot process GCMParameterSpec - permission java.lang.RuntimePermission "accessDeclaredMembers"; - permission java.util.PropertyPermission "intellij.debug.agent", "read"; - permission java.util.PropertyPermission "intellij.debug.agent", "write"; - permission org.bouncycastle.crypto.CryptoServicesPermission "exportSecretKey"; - permission org.bouncycastle.crypto.CryptoServicesPermission "exportPrivateKey"; - permission java.io.FilePermission "${javax.net.ssl.trustStore}", "read"; -}; diff --git a/buildSrc/src/main/resources/fips_java_bcjsse_11.security b/buildSrc/src/main/resources/fips_java_bcjsse_11.security deleted file mode 100644 index e6a025e7eb10d..0000000000000 --- a/buildSrc/src/main/resources/fips_java_bcjsse_11.security +++ /dev/null @@ -1,53 +0,0 @@ -# Security Properties for JDK 11 and higher, with BouncyCastle FIPS provider and BouncyCastleJsseProvider in FIPS mode - -security.provider.1=org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider C:HYBRID;ENABLE{All}; -security.provider.2=org.bouncycastle.jsse.provider.BouncyCastleJsseProvider fips:BCFIPS -security.provider.3=SUN -security.provider.4=SunJGSS -securerandom.source=file:/dev/urandom -securerandom.strongAlgorithms=NativePRNGBlocking:SUN,DRBG:SUN -securerandom.drbg.config= -login.configuration.provider=sun.security.provider.ConfigFile -policy.provider=sun.security.provider.PolicyFile -policy.expandProperties=true -policy.allowSystemProperty=true -policy.ignoreIdentityScope=false -keystore.type=BCFKS -keystore.type.compat=true -package.access=sun.misc.,\ - sun.reflect. -package.definition=sun.misc.,\ - sun.reflect. -security.overridePropertiesFile=true -ssl.KeyManagerFactory.algorithm=PKIX -ssl.TrustManagerFactory.algorithm=PKIX -networkaddress.cache.negative.ttl=10 -krb5.kdc.bad.policy = tryLast -jdk.certpath.disabledAlgorithms=MD2, MD5, SHA1 jdkCA & usage TLSServer, \ - RSA keySize < 1024, DSA keySize < 1024, EC keySize < 224 -jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, \ - DSA keySize < 1024 -jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA, DH keySize < 1024, \ - EC keySize < 224, DES40_CBC, RC4_40, 3DES_EDE_CBC -jdk.tls.legacyAlgorithms= \ - K_NULL, C_NULL, M_NULL, \ - DH_anon, ECDH_anon, \ - RC4_128, RC4_40, DES_CBC, DES40_CBC, \ - 3DES_EDE_CBC -jdk.tls.keyLimits=AES/GCM/NoPadding KeyUpdate 2^37 -crypto.policy=unlimited -jdk.xml.dsig.secureValidationPolicy=\ - disallowAlg http://www.w3.org/TR/1999/REC-xslt-19991116,\ - disallowAlg http://www.w3.org/2001/04/xmldsig-more#rsa-md5,\ - disallowAlg http://www.w3.org/2001/04/xmldsig-more#hmac-md5,\ - disallowAlg http://www.w3.org/2001/04/xmldsig-more#md5,\ - maxTransforms 5,\ - maxReferences 30,\ - disallowReferenceUriSchemes file http https,\ - minKeySize RSA 1024,\ - minKeySize DSA 1024,\ - minKeySize EC 224,\ - noDuplicateIds,\ - noRetrievalMethodLoops -jceks.key.serialFilter = java.base/java.lang.Enum;java.base/java.security.KeyRep;\ - java.base/java.security.KeyRep$Type;java.base/javax.crypto.spec.SecretKeySpec;!* diff --git a/buildSrc/src/main/resources/fips_java_bcjsse_8.policy b/buildSrc/src/main/resources/fips_java_bcjsse_8.policy deleted file mode 100644 index 87dbe85c22ab5..0000000000000 --- a/buildSrc/src/main/resources/fips_java_bcjsse_8.policy +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -// Security Policy for JDK 8, with BouncyCastle FIPS provider and BouncyCastleJsseProvider in FIPS mode - -grant codeBase "file:${java.home}/lib/ext/localedata.jar" { - // Allow resource bundles to be loaded for non root locales. See - // https://github.com/elastic/elasticsearch/issues/39981 - permission java.lang.RuntimePermission "accessClassInPackage.sun.util.*"; -}; -grant { - permission java.security.SecurityPermission "putProviderProperty.BCFIPS"; - permission java.security.SecurityPermission "putProviderProperty.BCJSSE"; - permission java.lang.RuntimePermission "getProtectionDomain"; - permission java.util.PropertyPermission "java.runtime.name", "read"; - permission org.bouncycastle.crypto.CryptoServicesPermission "tlsAlgorithmsEnabled"; - //io.netty.handler.codec.DecoderException - permission java.lang.RuntimePermission "accessClassInPackage.sun.security.internal.spec"; - //java.security.InvalidAlgorithmParameterException: Cannot process GCMParameterSpec - permission java.lang.RuntimePermission "accessDeclaredMembers"; - permission java.util.PropertyPermission "intellij.debug.agent", "read"; - permission java.util.PropertyPermission "intellij.debug.agent", "write"; - permission org.bouncycastle.crypto.CryptoServicesPermission "exportSecretKey"; - permission org.bouncycastle.crypto.CryptoServicesPermission "exportPrivateKey"; - permission java.io.FilePermission "${javax.net.ssl.trustStore}", "read"; -}; diff --git a/buildSrc/src/main/resources/fips_java_bcjsse_8.security b/buildSrc/src/main/resources/fips_java_bcjsse_8.security deleted file mode 100644 index df21041f5191b..0000000000000 --- a/buildSrc/src/main/resources/fips_java_bcjsse_8.security +++ /dev/null @@ -1,134 +0,0 @@ -# Security Properties for JDK 8, with BouncyCastle FIPS provider and BouncyCastleJsseProvider in FIPS mode - -security.provider.1=org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider C:HYBRID;ENABLE{All}; -security.provider.2=org.bouncycastle.jsse.provider.BouncyCastleJsseProvider fips:BCFIPS -security.provider.3=sun.security.provider.Sun -security.provider.4=sun.security.jgss.SunProvider -securerandom.source=file:/dev/urandom -securerandom.strongAlgorithms=NativePRNGBlocking:SUN -login.configuration.provider=sun.security.provider.ConfigFile -policy.provider=sun.security.provider.PolicyFile -policy.url.1=file:${java.home}/lib/security/java.policy -policy.url.2=file:${user.home}/.java.policy -policy.expandProperties=true -policy.allowSystemProperty=true -policy.ignoreIdentityScope=false -keystore.type=bcfks -keystore.type.compat=true -package.access=sun.,\ - org.GNOME.Accessibility.,\ - com.sun.xml.internal.,\ - com.sun.imageio.,\ - com.sun.istack.internal.,\ - com.sun.jmx.,\ - com.sun.media.sound.,\ - com.sun.naming.internal.,\ - com.sun.proxy.,\ - com.sun.corba.se.,\ - com.sun.org.apache.bcel.internal.,\ - com.sun.org.apache.regexp.internal.,\ - com.sun.org.apache.xerces.internal.,\ - com.sun.org.apache.xpath.internal.,\ - com.sun.org.apache.xalan.internal.extensions.,\ - com.sun.org.apache.xalan.internal.lib.,\ - com.sun.org.apache.xalan.internal.res.,\ - com.sun.org.apache.xalan.internal.templates.,\ - com.sun.org.apache.xalan.internal.utils.,\ - com.sun.org.apache.xalan.internal.xslt.,\ - com.sun.org.apache.xalan.internal.xsltc.cmdline.,\ - com.sun.org.apache.xalan.internal.xsltc.compiler.,\ - com.sun.org.apache.xalan.internal.xsltc.trax.,\ - com.sun.org.apache.xalan.internal.xsltc.util.,\ - com.sun.org.apache.xml.internal.res.,\ - com.sun.org.apache.xml.internal.resolver.helpers.,\ - com.sun.org.apache.xml.internal.resolver.readers.,\ - com.sun.org.apache.xml.internal.security.,\ - com.sun.org.apache.xml.internal.serializer.utils.,\ - com.sun.org.apache.xml.internal.utils.,\ - com.sun.org.glassfish.,\ - com.oracle.xmlns.internal.,\ - com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ - org.jcp.xml.dsig.internal.,\ - jdk.internal.,\ - jdk.nashorn.internal.,\ - jdk.nashorn.tools.,\ - jdk.xml.internal.,\ - com.sun.activation.registries. - -package.definition=sun.,\ - com.sun.xml.internal.,\ - com.sun.imageio.,\ - com.sun.istack.internal.,\ - com.sun.jmx.,\ - com.sun.media.sound.,\ - com.sun.naming.internal.,\ - com.sun.proxy.,\ - com.sun.corba.se.,\ - com.sun.org.apache.bcel.internal.,\ - com.sun.org.apache.regexp.internal.,\ - com.sun.org.apache.xerces.internal.,\ - com.sun.org.apache.xpath.internal.,\ - com.sun.org.apache.xalan.internal.extensions.,\ - com.sun.org.apache.xalan.internal.lib.,\ - com.sun.org.apache.xalan.internal.res.,\ - com.sun.org.apache.xalan.internal.templates.,\ - com.sun.org.apache.xalan.internal.utils.,\ - com.sun.org.apache.xalan.internal.xslt.,\ - com.sun.org.apache.xalan.internal.xsltc.cmdline.,\ - com.sun.org.apache.xalan.internal.xsltc.compiler.,\ - com.sun.org.apache.xalan.internal.xsltc.trax.,\ - com.sun.org.apache.xalan.internal.xsltc.util.,\ - com.sun.org.apache.xml.internal.res.,\ - com.sun.org.apache.xml.internal.resolver.helpers.,\ - com.sun.org.apache.xml.internal.resolver.readers.,\ - com.sun.org.apache.xml.internal.security.,\ - com.sun.org.apache.xml.internal.serializer.utils.,\ - com.sun.org.apache.xml.internal.utils.,\ - com.sun.org.glassfish.,\ - com.oracle.xmlns.internal.,\ - com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ - org.jcp.xml.dsig.internal.,\ - jdk.internal.,\ - jdk.nashorn.internal.,\ - jdk.nashorn.tools.,\ - jdk.xml.internal.,\ - com.sun.activation.registries. - -ssl.KeyManagerFactory.algorithm=PKIX -ssl.TrustManagerFactory.algorithm=PKIX -networkaddress.cache.negative.ttl=10 -krb5.kdc.bad.policy = tryLast -jdk.certpath.disabledAlgorithms=MD2, MD5, SHA1 jdkCA & usage TLSServer, \ - RSA keySize < 1024, DSA keySize < 1024, EC keySize < 224 - -jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, DSA keySize < 1024 - - -jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA, DH keySize < 1024, \ - EC keySize < 224, DES40_CBC, RC4_40, 3DES_EDE_CBC - -jdk.tls.legacyAlgorithms= \ - K_NULL, C_NULL, M_NULL, \ - DH_anon, ECDH_anon, \ - RC4_128, RC4_40, DES_CBC, DES40_CBC, \ - 3DES_EDE_CBC -crypto.policy=unlimited - -jdk.xml.dsig.secureValidationPolicy=\ - disallowAlg http://www.w3.org/TR/1999/REC-xslt-19991116,\ - disallowAlg http://www.w3.org/2001/04/xmldsig-more#rsa-md5,\ - disallowAlg http://www.w3.org/2001/04/xmldsig-more#hmac-md5,\ - disallowAlg http://www.w3.org/2001/04/xmldsig-more#md5,\ - maxTransforms 5,\ - maxReferences 30,\ - disallowReferenceUriSchemes file http https,\ - minKeySize RSA 1024,\ - minKeySize DSA 1024,\ - minKeySize EC 224,\ - noDuplicateIds,\ - noRetrievalMethodLoops - -jceks.key.serialFilter = java.lang.Enum;java.security.KeyRep;\ - java.security.KeyRep$Type;javax.crypto.spec.SecretKeySpec;!* diff --git a/buildSrc/src/main/resources/fips_java_sunjsse.policy b/buildSrc/src/main/resources/fips_java_sunjsse.policy deleted file mode 100644 index 1d2f06e3a1314..0000000000000 --- a/buildSrc/src/main/resources/fips_java_sunjsse.policy +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -// Security Policy for JDK 8, with BouncyCastle FIPS provider and SunJSSE in FIPS mode - -grant codeBase "file:${java.home}/lib/ext/localedata.jar" { - // Allow resource bundles to be loaded for non root locales. See - // https://github.com/elastic/elasticsearch/issues/39981 - permission java.lang.RuntimePermission "accessClassInPackage.sun.util.*"; -}; -grant { - permission org.bouncycastle.crypto.CryptoServicesPermission "exportPrivateKey"; - permission org.bouncycastle.crypto.CryptoServicesPermission "exportSecretKey"; - permission java.lang.RuntimePermission "getProtectionDomain"; - permission java.util.PropertyPermission "java.runtime.name", "read"; - permission org.bouncycastle.crypto.CryptoServicesPermission "tlsAlgorithmsEnabled"; - //io.netty.handler.codec.DecoderException - permission java.lang.RuntimePermission "accessClassInPackage.sun.security.internal.spec"; - //java.security.InvalidAlgorithmParameterException: Cannot process GCMParameterSpec - permission java.lang.RuntimePermission "accessDeclaredMembers"; -}; diff --git a/buildSrc/src/main/resources/fips_java_sunjsse.security b/buildSrc/src/main/resources/fips_java_sunjsse.security deleted file mode 100644 index 2959bea3b8596..0000000000000 --- a/buildSrc/src/main/resources/fips_java_sunjsse.security +++ /dev/null @@ -1,134 +0,0 @@ -# Security Properties for JDK 8, with BouncyCastle FIPS provider and SunJSSE in FIPS mode - -security.provider.1=org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider C:HYBRID;ENABLE{All}; -security.provider.2=com.sun.net.ssl.internal.ssl.Provider BCFIPS -security.provider.3=sun.security.provider.Sun -security.provider.4=sun.security.jgss.SunProvider -securerandom.source=file:/dev/urandom -securerandom.strongAlgorithms=NativePRNGBlocking:SUN -login.configuration.provider=sun.security.provider.ConfigFile -policy.provider=sun.security.provider.PolicyFile -policy.url.1=file:${java.home}/lib/security/java.policy -policy.url.2=file:${user.home}/.java.policy -policy.expandProperties=true -policy.allowSystemProperty=true -policy.ignoreIdentityScope=false -keystore.type=bcfks -keystore.type.compat=true -package.access=sun.,\ - org.GNOME.Accessibility.,\ - com.sun.xml.internal.,\ - com.sun.imageio.,\ - com.sun.istack.internal.,\ - com.sun.jmx.,\ - com.sun.media.sound.,\ - com.sun.naming.internal.,\ - com.sun.proxy.,\ - com.sun.corba.se.,\ - com.sun.org.apache.bcel.internal.,\ - com.sun.org.apache.regexp.internal.,\ - com.sun.org.apache.xerces.internal.,\ - com.sun.org.apache.xpath.internal.,\ - com.sun.org.apache.xalan.internal.extensions.,\ - com.sun.org.apache.xalan.internal.lib.,\ - com.sun.org.apache.xalan.internal.res.,\ - com.sun.org.apache.xalan.internal.templates.,\ - com.sun.org.apache.xalan.internal.utils.,\ - com.sun.org.apache.xalan.internal.xslt.,\ - com.sun.org.apache.xalan.internal.xsltc.cmdline.,\ - com.sun.org.apache.xalan.internal.xsltc.compiler.,\ - com.sun.org.apache.xalan.internal.xsltc.trax.,\ - com.sun.org.apache.xalan.internal.xsltc.util.,\ - com.sun.org.apache.xml.internal.res.,\ - com.sun.org.apache.xml.internal.resolver.helpers.,\ - com.sun.org.apache.xml.internal.resolver.readers.,\ - com.sun.org.apache.xml.internal.security.,\ - com.sun.org.apache.xml.internal.serializer.utils.,\ - com.sun.org.apache.xml.internal.utils.,\ - com.sun.org.glassfish.,\ - com.oracle.xmlns.internal.,\ - com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ - org.jcp.xml.dsig.internal.,\ - jdk.internal.,\ - jdk.nashorn.internal.,\ - jdk.nashorn.tools.,\ - jdk.xml.internal.,\ - com.sun.activation.registries. - -package.definition=sun.,\ - com.sun.xml.internal.,\ - com.sun.imageio.,\ - com.sun.istack.internal.,\ - com.sun.jmx.,\ - com.sun.media.sound.,\ - com.sun.naming.internal.,\ - com.sun.proxy.,\ - com.sun.corba.se.,\ - com.sun.org.apache.bcel.internal.,\ - com.sun.org.apache.regexp.internal.,\ - com.sun.org.apache.xerces.internal.,\ - com.sun.org.apache.xpath.internal.,\ - com.sun.org.apache.xalan.internal.extensions.,\ - com.sun.org.apache.xalan.internal.lib.,\ - com.sun.org.apache.xalan.internal.res.,\ - com.sun.org.apache.xalan.internal.templates.,\ - com.sun.org.apache.xalan.internal.utils.,\ - com.sun.org.apache.xalan.internal.xslt.,\ - com.sun.org.apache.xalan.internal.xsltc.cmdline.,\ - com.sun.org.apache.xalan.internal.xsltc.compiler.,\ - com.sun.org.apache.xalan.internal.xsltc.trax.,\ - com.sun.org.apache.xalan.internal.xsltc.util.,\ - com.sun.org.apache.xml.internal.res.,\ - com.sun.org.apache.xml.internal.resolver.helpers.,\ - com.sun.org.apache.xml.internal.resolver.readers.,\ - com.sun.org.apache.xml.internal.security.,\ - com.sun.org.apache.xml.internal.serializer.utils.,\ - com.sun.org.apache.xml.internal.utils.,\ - com.sun.org.glassfish.,\ - com.oracle.xmlns.internal.,\ - com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ - org.jcp.xml.dsig.internal.,\ - jdk.internal.,\ - jdk.nashorn.internal.,\ - jdk.nashorn.tools.,\ - jdk.xml.internal.,\ - com.sun.activation.registries. - -ssl.KeyManagerFactory.algorithm=SunX509 -ssl.TrustManagerFactory.algorithm=PKIX -networkaddress.cache.negative.ttl=10 -krb5.kdc.bad.policy = tryLast -jdk.certpath.disabledAlgorithms=MD2, MD5, SHA1 jdkCA & usage TLSServer, \ - RSA keySize < 1024, DSA keySize < 1024, EC keySize < 224 - -jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, DSA keySize < 1024 - - -jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA, DH keySize < 1024, \ - EC keySize < 224, DES40_CBC, RC4_40, 3DES_EDE_CBC - -jdk.tls.legacyAlgorithms= \ - K_NULL, C_NULL, M_NULL, \ - DH_anon, ECDH_anon, \ - RC4_128, RC4_40, DES_CBC, DES40_CBC, \ - 3DES_EDE_CBC -crypto.policy=unlimited - -jdk.xml.dsig.secureValidationPolicy=\ - disallowAlg http://www.w3.org/TR/1999/REC-xslt-19991116,\ - disallowAlg http://www.w3.org/2001/04/xmldsig-more#rsa-md5,\ - disallowAlg http://www.w3.org/2001/04/xmldsig-more#hmac-md5,\ - disallowAlg http://www.w3.org/2001/04/xmldsig-more#md5,\ - maxTransforms 5,\ - maxReferences 30,\ - disallowReferenceUriSchemes file http https,\ - minKeySize RSA 1024,\ - minKeySize DSA 1024,\ - minKeySize EC 224,\ - noDuplicateIds,\ - noRetrievalMethodLoops - -jceks.key.serialFilter = java.lang.Enum;java.security.KeyRep;\ - java.security.KeyRep$Type;javax.crypto.spec.SecretKeySpec;!* diff --git a/buildSrc/src/main/resources/forbidden/http-signatures.txt b/buildSrc/src/main/resources/forbidden/http-signatures.txt deleted file mode 100644 index dcf20bbb09387..0000000000000 --- a/buildSrc/src/main/resources/forbidden/http-signatures.txt +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on -# an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the License. - -@defaultMessage Explicitly specify the ContentType of HTTP entities when creating -org.apache.http.entity.StringEntity#(java.lang.String) -org.apache.http.entity.StringEntity#(java.lang.String,java.lang.String) -org.apache.http.entity.StringEntity#(java.lang.String,java.nio.charset.Charset) -org.apache.http.entity.ByteArrayEntity#(byte[]) -org.apache.http.entity.ByteArrayEntity#(byte[],int,int) -org.apache.http.entity.FileEntity#(java.io.File) -org.apache.http.entity.InputStreamEntity#(java.io.InputStream) -org.apache.http.entity.InputStreamEntity#(java.io.InputStream,long) -org.apache.http.nio.entity.NByteArrayEntity#(byte[]) -org.apache.http.nio.entity.NByteArrayEntity#(byte[],int,int) -org.apache.http.nio.entity.NFileEntity#(java.io.File) -org.apache.http.nio.entity.NStringEntity#(java.lang.String) -org.apache.http.nio.entity.NStringEntity#(java.lang.String,java.lang.String) - -@defaultMessage Use non-deprecated constructors -org.apache.http.nio.entity.NFileEntity#(java.io.File,java.lang.String) -org.apache.http.nio.entity.NFileEntity#(java.io.File,java.lang.String,boolean) -org.apache.http.entity.FileEntity#(java.io.File,java.lang.String) -org.apache.http.entity.StringEntity#(java.lang.String,java.lang.String,java.lang.String) - -@defaultMessage BasicEntity is easy to mess up and forget to set content type -org.apache.http.entity.BasicHttpEntity#() - -@defaultMessage EntityTemplate is easy to mess up and forget to set content type -org.apache.http.entity.EntityTemplate#(org.apache.http.entity.ContentProducer) - -@defaultMessage SerializableEntity uses java serialization and makes it easy to forget to set content type -org.apache.http.entity.SerializableEntity#(java.io.Serializable) diff --git a/buildSrc/src/main/resources/forbidden/jdk-signatures.txt b/buildSrc/src/main/resources/forbidden/jdk-signatures.txt deleted file mode 100644 index b2fd479dce5ff..0000000000000 --- a/buildSrc/src/main/resources/forbidden/jdk-signatures.txt +++ /dev/null @@ -1,113 +0,0 @@ -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on -# an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the License. - -@defaultMessage Convert to URI -java.net.URL#getPath() -java.net.URL#getFile() - -@defaultMessage Usage of getLocalHost is discouraged -java.net.InetAddress#getLocalHost() - -@defaultMessage Use java.nio.file instead of java.io.File API -java.util.jar.JarFile -java.util.zip.ZipFile -java.io.File -java.io.FileInputStream -java.io.FileOutputStream -java.io.PrintStream#(java.lang.String,java.lang.String) -java.io.PrintWriter#(java.lang.String,java.lang.String) -java.util.Formatter#(java.lang.String,java.lang.String,java.util.Locale) -java.io.RandomAccessFile -java.nio.file.Path#toFile() - -@defaultMessage Specify a location for the temp file/directory instead. -java.nio.file.Files#createTempDirectory(java.lang.String,java.nio.file.attribute.FileAttribute[]) -java.nio.file.Files#createTempFile(java.lang.String,java.lang.String,java.nio.file.attribute.FileAttribute[]) - -@defaultMessage Don't use java serialization - this can break BWC without noticing it -java.io.ObjectOutputStream -java.io.ObjectOutput -java.io.ObjectInputStream -java.io.ObjectInput - -java.nio.file.Files#isHidden(java.nio.file.Path) @ Dependent on the operating system, use FileSystemUtils.isHidden instead - -@defaultMessage Resolve hosts explicitly to the address(es) you want with InetAddress. -java.net.InetSocketAddress#(java.lang.String,int) -java.net.Socket#(java.lang.String,int) -java.net.Socket#(java.lang.String,int,java.net.InetAddress,int) - -@defaultMessage Don't bind to wildcard addresses. Be specific. -java.net.DatagramSocket#() -java.net.DatagramSocket#(int) -java.net.InetSocketAddress#(int) -java.net.MulticastSocket#() -java.net.MulticastSocket#(int) -java.net.ServerSocket#(int) -java.net.ServerSocket#(int,int) - -@defaultMessage use NetworkAddress format() to print IP or IP+ports -java.net.InetAddress#toString() -java.net.InetAddress#getHostAddress() -java.net.Inet4Address#getHostAddress() -java.net.Inet6Address#getHostAddress() -java.net.InetSocketAddress#toString() - -@defaultMessage avoid DNS lookups by accident: if you have a valid reason, then @SuppressWarnings with that reason so its completely clear -java.net.InetAddress#getHostName() -java.net.InetAddress#getCanonicalHostName() - -java.net.InetSocketAddress#getHostName() @ Use getHostString() instead, which avoids a DNS lookup - -@defaultMessage Do not violate java's access system -java.lang.Class#getDeclaredClasses() @ Do not violate java's access system: Use getClasses() instead -java.lang.Class#getDeclaredConstructor(java.lang.Class[]) @ Do not violate java's access system: Use getConstructor() instead -java.lang.Class#getDeclaredConstructors() @ Do not violate java's access system: Use getConstructors() instead -java.lang.Class#getDeclaredField(java.lang.String) @ Do not violate java's access system: Use getField() instead -java.lang.Class#getDeclaredFields() @ Do not violate java's access system: Use getFields() instead -java.lang.Class#getDeclaredMethod(java.lang.String, java.lang.Class[]) @ Do not violate java's access system: Use getMethod() instead -java.lang.Class#getDeclaredMethods() @ Do not violate java's access system: Use getMethods() instead -java.lang.reflect.AccessibleObject#setAccessible(boolean) -java.lang.reflect.AccessibleObject#setAccessible(java.lang.reflect.AccessibleObject[], boolean) - -@defaultMessage this method needs special permission -java.lang.Thread#getAllStackTraces() - -@defaultMessage Stopping threads explicitly leads to inconsistent states. Use interrupt() instead. -java.lang.Thread#stop() -# uncomment when https://github.com/elastic/elasticsearch/issues/31715 is fixed -# java.lang.Thread#stop(java.lang.Throwable) - -@defaultMessage Please do not terminate the application -java.lang.System#exit(int) -java.lang.Runtime#exit(int) -java.lang.Runtime#halt(int) - -@defaultMessage Treat system properties as immutable -java.lang.System#setProperties(java.util.Properties) -java.lang.System#setProperty(java.lang.String,java.lang.String) -java.lang.System#clearProperty(java.lang.String) -java.lang.System#getProperties() @ Use BootstrapInfo.getSystemProperties for a read-only view - -@defaultMessage Avoid unchecked warnings by using Collections#empty(List|Map|Set) methods -java.util.Collections#EMPTY_LIST -java.util.Collections#EMPTY_MAP -java.util.Collections#EMPTY_SET - -java.util.Collections#shuffle(java.util.List) @ Use java.util.Collections#shuffle(java.util.List, java.util.Random) with a reproducible source of randomness - -@defaultMessage Avoid creating FilePermission objects directly, but use FilePermissionUtils instead -java.io.FilePermission#(java.lang.String,java.lang.String) diff --git a/buildSrc/src/main/resources/forbidden/opensearch-all-signatures.txt b/buildSrc/src/main/resources/forbidden/opensearch-all-signatures.txt deleted file mode 100644 index 1e4e669e4722f..0000000000000 --- a/buildSrc/src/main/resources/forbidden/opensearch-all-signatures.txt +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on -# an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the License. - -java.nio.file.Paths @ Use org.opensearch.common.io.PathUtils.get() instead. -java.nio.file.FileSystems#getDefault() @ use org.opensearch.common.io.PathUtils.getDefaultFileSystem() instead. - -java.nio.file.Files#getFileStore(java.nio.file.Path) @ Use org.opensearch.env.Environment.getFileStore() instead, impacted by JDK-8034057 -java.nio.file.Files#isWritable(java.nio.file.Path) @ Use org.opensearch.env.Environment.isWritable() instead, impacted by JDK-8034057 - -@defaultMessage Use org.opensearch.common.Randomness#get for reproducible sources of randomness -java.util.Random#() -java.util.concurrent.ThreadLocalRandom - -java.security.MessageDigest#clone() @ use org.opensearch.common.hash.MessageDigests - -@defaultMessage Don't use MethodHandles in slow ways, don't be lenient in tests. -java.lang.invoke.MethodHandle#invoke(java.lang.Object[]) -java.lang.invoke.MethodHandle#invokeWithArguments(java.lang.Object[]) -java.lang.invoke.MethodHandle#invokeWithArguments(java.util.List) - -@defaultMessage Don't open socket connections -java.net.URL#openStream() -java.net.URLConnection#connect() -java.net.URLConnection#getInputStream() -java.net.Socket#connect(java.net.SocketAddress) -java.net.Socket#connect(java.net.SocketAddress, int) -java.nio.channels.SocketChannel#open(java.net.SocketAddress) -java.nio.channels.SocketChannel#connect(java.net.SocketAddress) - -# This method is misleading, and uses lenient boolean parsing under the hood. If you intend to parse -# a system property as a boolean, use -# org.opensearch.common.Booleans#parseBoolean(java.lang.String) on the result of -# java.lang.SystemProperty#getProperty(java.lang.String) instead. If you were not intending to parse -# a system property as a boolean, but instead parse a string to a boolean, use -# org.opensearch.common.Booleans#parseBoolean(java.lang.String) directly on the string. -@defaultMessage use org.opensearch.common.Booleans#parseBoolean(java.lang.String) -java.lang.Boolean#getBoolean(java.lang.String) - -org.apache.lucene.util.IOUtils @ use @org.opensearch.core.internal.io instead - -@defaultMessage use executors from org.opensearch.common.util.concurrent.OpenSearchExecutors instead which will properly bubble up Errors -java.util.concurrent.AbstractExecutorService#() -java.util.concurrent.ThreadPoolExecutor#(int, int, long, java.util.concurrent.TimeUnit, java.util.concurrent.BlockingQueue) -java.util.concurrent.ThreadPoolExecutor#(int, int, long, java.util.concurrent.TimeUnit, java.util.concurrent.BlockingQueue, java.util.concurrent.ThreadFactory) -java.util.concurrent.ThreadPoolExecutor#(int, int, long, java.util.concurrent.TimeUnit, java.util.concurrent.BlockingQueue, java.util.concurrent.RejectedExecutionHandler) -java.util.concurrent.ThreadPoolExecutor#(int, int, long, java.util.concurrent.TimeUnit, java.util.concurrent.BlockingQueue, java.util.concurrent.ThreadFactory, java.util.concurrent.RejectedExecutionHandler) - -@defaultMessage extend org.opensearch.threadpool.Scheduler.SafeScheduledThreadPoolExecutor instead which will properly bubble up Errors -java.util.concurrent.ScheduledThreadPoolExecutor#(int) -java.util.concurrent.ScheduledThreadPoolExecutor#(int, java.util.concurrent.ThreadFactory) -java.util.concurrent.ScheduledThreadPoolExecutor#(int, java.util.concurrent.RejectedExecutionHandler) -java.util.concurrent.ScheduledThreadPoolExecutor#(int, java.util.concurrent.ThreadFactory, java.util.concurrent.RejectedExecutionHandler) diff --git a/buildSrc/src/main/resources/forbidden/opensearch-server-signatures.txt b/buildSrc/src/main/resources/forbidden/opensearch-server-signatures.txt deleted file mode 100644 index 27fba8069125d..0000000000000 --- a/buildSrc/src/main/resources/forbidden/opensearch-server-signatures.txt +++ /dev/null @@ -1,149 +0,0 @@ -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on -# an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the License. - -# For third-party dependencies, please put signatures in third-party.txt instead of here. - -@defaultMessage spawns threads with vague names; use a custom thread factory and name threads so that you can tell (by its name) which executor it is associated with - -java.util.concurrent.Executors#newFixedThreadPool(int) -java.util.concurrent.Executors#newSingleThreadExecutor() -java.util.concurrent.Executors#newCachedThreadPool() -java.util.concurrent.Executors#newSingleThreadScheduledExecutor() -java.util.concurrent.Executors#newScheduledThreadPool(int) -java.util.concurrent.Executors#defaultThreadFactory() -java.util.concurrent.Executors#privilegedThreadFactory() - -java.lang.Character#codePointBefore(char[],int) @ Implicit start offset is error-prone when the char[] is a buffer and the first chars are random chars -java.lang.Character#codePointAt(char[],int) @ Implicit end offset is error-prone when the char[] is a buffer and the last chars are random chars - -@defaultMessage Reference management is tricky, leave it to SearcherManager -org.apache.lucene.index.IndexReader#decRef() -org.apache.lucene.index.IndexReader#incRef() -org.apache.lucene.index.IndexReader#tryIncRef() - -@defaultMessage Only use wait / notify when really needed try to use concurrency primitives, latches or callbacks instead. -java.lang.Object#wait() -java.lang.Object#wait(long) -java.lang.Object#wait(long,int) -java.lang.Object#notify() -java.lang.Object#notifyAll() - -@defaultMessage Beware of the behavior of this method on MIN_VALUE -java.lang.Math#abs(int) -java.lang.Math#abs(long) - -@defaultMessage Please do not try to stop the world -java.lang.System#gc() - -@defaultMessage Use Channels.* methods to write to channels. Do not write directly. -java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer) -java.nio.channels.FileChannel#write(java.nio.ByteBuffer, long) -java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[], int, int) -java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[]) -java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer) -java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[]) -java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[], int, int) -java.nio.channels.FileChannel#read(java.nio.ByteBuffer, long) - -@defaultMessage Use Lucene.parseLenient instead it strips off minor version -org.apache.lucene.util.Version#parseLeniently(java.lang.String) - -@defaultMessage Spawns a new thread which is solely under lucenes control use ThreadPool#relativeTimeInMillis instead -org.apache.lucene.search.TimeLimitingCollector#getGlobalTimerThread() -org.apache.lucene.search.TimeLimitingCollector#getGlobalCounter() - -@defaultMessage Don't interrupt threads use FutureUtils#cancel(Future) instead -java.util.concurrent.Future#cancel(boolean) - -@defaultMessage Don't try reading from paths that are not configured in Environment, resolve from Environment instead -org.opensearch.common.io.PathUtils#get(java.lang.String, java.lang.String[]) -org.opensearch.common.io.PathUtils#get(java.net.URI) - -@defaultMessage Constructing a DateTime without a time zone is dangerous -org.joda.time.DateTime#() -org.joda.time.DateTime#(long) -org.joda.time.DateTime#(int, int, int, int, int) -org.joda.time.DateTime#(int, int, int, int, int, int) -org.joda.time.DateTime#(int, int, int, int, int, int, int) -org.joda.time.DateTime#now() -org.joda.time.DateTimeZone#getDefault() - -@defaultMessage Local times may be ambiguous or nonexistent in a specific time zones. Use ZoneRules#getValidOffsets() instead. -java.time.LocalDateTime#atZone(java.time.ZoneId) -java.time.ZonedDateTime#of(int, int, int, int, int, int, int, java.time.ZoneId) -java.time.ZonedDateTime#of(java.time.LocalDate, java.time.LocalTime, java.time.ZoneId) -java.time.ZonedDateTime#of(java.time.LocalDateTime, java.time.ZoneId) -java.time.ZonedDateTime#truncatedTo(java.time.temporal.TemporalUnit) -java.time.ZonedDateTime#of(int, int, int, int, int, int, int, java.time.ZoneId) -java.time.ZonedDateTime#of(java.time.LocalDate, java.time.LocalTime, java.time.ZoneId) -java.time.ZonedDateTime#of(java.time.LocalDateTime, java.time.ZoneId) -java.time.ZonedDateTime#ofLocal(java.time.LocalDateTime, java.time.ZoneId, java.time.ZoneOffset) -java.time.OffsetDateTime#atZoneSimilarLocal(java.time.ZoneId) -java.time.zone.ZoneRules#getOffset(java.time.LocalDateTime) - -@defaultMessage Manipulation of an OffsetDateTime may yield a time that is not valid in the desired time zone. Use ZonedDateTime instead. -java.time.OffsetDateTime#minus(long, java.time.temporal.TemporalUnit) -java.time.OffsetDateTime#minus(long, java.time.temporal.TemporalUnit) -java.time.OffsetDateTime#minus(java.time.temporal.TemporalAmount) -java.time.OffsetDateTime#minusDays(long) -java.time.OffsetDateTime#minusHours(long) -java.time.OffsetDateTime#minusMinutes(long) -java.time.OffsetDateTime#minusMonths(long) -java.time.OffsetDateTime#minusNanos(long) -java.time.OffsetDateTime#minusSeconds(long) -java.time.OffsetDateTime#minusWeeks(long) -java.time.OffsetDateTime#minusYears(long) -java.time.OffsetDateTime#plus(long, java.time.temporal.TemporalUnit) -java.time.OffsetDateTime#plus(java.time.temporal.TemporalAmount) -java.time.OffsetDateTime#plusDays(long) -java.time.OffsetDateTime#plusHours(long) -java.time.OffsetDateTime#plusMinutes(long) -java.time.OffsetDateTime#plusMonths(long) -java.time.OffsetDateTime#plusNanos(long) -java.time.OffsetDateTime#plusSeconds(long) -java.time.OffsetDateTime#plusWeeks(long) -java.time.OffsetDateTime#plusYears(long) -java.time.OffsetDateTime#with(java.time.temporal.TemporalAdjuster) -java.time.OffsetDateTime#with(java.time.temporal.TemporalField, long) -java.time.OffsetDateTime#withDayOfMonth(int) -java.time.OffsetDateTime#withDayOfYear(int) -java.time.OffsetDateTime#withHour(int) -java.time.OffsetDateTime#withMinute(int) -java.time.OffsetDateTime#withMonth(int) -java.time.OffsetDateTime#withNano(int) -java.time.OffsetDateTime#withOffsetSameInstant(java.time.ZoneOffset) -java.time.OffsetDateTime#withOffsetSameLocal(java.time.ZoneOffset) -java.time.OffsetDateTime#withSecond(int) -java.time.OffsetDateTime#withYear(int) - -@defaultMessage Daylight saving is not the only reason for a change in timezone offset. -java.time.zone.ZoneRules#getStandardOffset(java.time.Instant) -java.time.zone.ZoneRules#getDaylightSavings(java.time.Instant) -java.time.zone.ZoneRules#isDaylightSavings(java.time.Instant) - -@defaultMessage Use logger methods with non-Object parameter -org.apache.logging.log4j.Logger#trace(java.lang.Object) -org.apache.logging.log4j.Logger#trace(java.lang.Object, java.lang.Throwable) -org.apache.logging.log4j.Logger#debug(java.lang.Object) -org.apache.logging.log4j.Logger#debug(java.lang.Object, java.lang.Throwable) -org.apache.logging.log4j.Logger#info(java.lang.Object) -org.apache.logging.log4j.Logger#info(java.lang.Object, java.lang.Throwable) -org.apache.logging.log4j.Logger#warn(java.lang.Object) -org.apache.logging.log4j.Logger#warn(java.lang.Object, java.lang.Throwable) -org.apache.logging.log4j.Logger#error(java.lang.Object) -org.apache.logging.log4j.Logger#error(java.lang.Object, java.lang.Throwable) -org.apache.logging.log4j.Logger#fatal(java.lang.Object) -org.apache.logging.log4j.Logger#fatal(java.lang.Object, java.lang.Throwable) diff --git a/buildSrc/src/main/resources/forbidden/opensearch-test-signatures.txt b/buildSrc/src/main/resources/forbidden/opensearch-test-signatures.txt deleted file mode 100644 index 766e13878cc25..0000000000000 --- a/buildSrc/src/main/resources/forbidden/opensearch-test-signatures.txt +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on -# an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the License. - -com.carrotsearch.randomizedtesting.RandomizedTest#globalTempDir() @ Use newTempDirPath() instead -com.carrotsearch.randomizedtesting.annotations.Seed @ Don't commit hardcoded seeds -com.carrotsearch.randomizedtesting.annotations.Repeat @ Don't commit hardcoded repeats - -org.apache.lucene.codecs.Codec#setDefault(org.apache.lucene.codecs.Codec) @ Use the SuppressCodecs("*") annotation instead -org.apache.lucene.util.LuceneTestCase$Slow @ Don't write slow tests -org.junit.Ignore @ Use AwaitsFix instead -org.apache.lucene.util.LuceneTestCase$Nightly @ We don't run nightly tests at this point! -com.carrotsearch.randomizedtesting.annotations.Nightly @ We don't run nightly tests at this point! - -org.junit.Test @defaultMessage Just name your test method testFooBar - -java.lang.Math#random() @ Use one of the various randomization methods from LuceneTestCase or ESTestCase for reproducibility diff --git a/buildSrc/src/main/resources/forbidden/third-party-audit.txt b/buildSrc/src/main/resources/forbidden/third-party-audit.txt deleted file mode 100644 index 0346d6d8a583f..0000000000000 --- a/buildSrc/src/main/resources/forbidden/third-party-audit.txt +++ /dev/null @@ -1,98 +0,0 @@ -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on -# an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the License. - -# Checks that we run against bytecode of third-party dependencies -# -# Be judicious about what is denied here: MANY classes will be subject -# to these rules, so please try to keep the false positive rate low! -# -# Each third party .class failing checks will need to be explicitly -# listed in the module's build.gradle file: -# -# thirdPartyAudit.excludes = [ -# // uses internal java api: sun.misc.Unsafe -# 'org.foo.Bar', -# // missing class! -# 'com.missing.dependency.WTF', -# // ... -# ] -# -# Wildcards are not allowed, excludes must be exact. The build also fails with -# the message "Invalid exclusions, nothing is wrong with these classes" if -# extraneous classes are in the excludes list, this ensures the list is -# up-to-date, and that each module accurately documents the evil things -# that its dependencies do. -# -# For more information, look at ThirdPartyAuditTask.groovy in buildSrc/ - -# -# Ruleset to fail on java internal apis, using this logic: -# http://docs.oracle.com/javase/8/docs/api/java/lang/SecurityManager.html#checkPackageAccess-java.lang.String- -# -# // The list may change at any time, regenerated with: -# for (String pkg : new TreeSet<>(Arrays.asList( -# Security.getProperty("package.access").split(",")))) { -# System.out.println(pkg + "**"); -# } -# -@defaultMessage non-public internal runtime class -com.oracle.webservices.internal.** -com.oracle.xmlns.internal.** -com.sun.activation.registries.** -com.sun.browser.** -com.sun.corba.se.** -com.sun.glass.** -com.sun.imageio.** -com.sun.istack.internal.** -com.sun.javafx.** -com.sun.jmx.** -com.sun.media.** -com.sun.media.sound.** -com.sun.naming.internal.** -com.sun.openpisces.** -com.sun.org.apache.bcel.internal.** -com.sun.org.apache.regexp.internal.** -com.sun.org.apache.xalan.internal.extensions.** -com.sun.org.apache.xalan.internal.lib.** -com.sun.org.apache.xalan.internal.res.** -com.sun.org.apache.xalan.internal.templates.** -com.sun.org.apache.xalan.internal.utils.** -com.sun.org.apache.xalan.internal.xslt.** -com.sun.org.apache.xalan.internal.xsltc.cmdline.** -com.sun.org.apache.xalan.internal.xsltc.compiler.** -com.sun.org.apache.xalan.internal.xsltc.trax.** -com.sun.org.apache.xalan.internal.xsltc.util.** -com.sun.org.apache.xerces.internal.** -com.sun.org.apache.xml.internal.res.** -com.sun.org.apache.xml.internal.security.** -com.sun.org.apache.xml.internal.serializer.utils.** -com.sun.org.apache.xml.internal.utils.** -com.sun.org.apache.xpath.internal.** -com.sun.org.glassfish.** -com.sun.pisces.** -com.sun.prism.** -com.sun.proxy.** -com.sun.scenario.** -com.sun.t2k.** -com.sun.webkit.** -com.sun.xml.internal.** -jdk.internal.** -jdk.management.resource.internal.** -jdk.nashorn.internal.** -jdk.nashorn.tools.** -oracle.jrockit.jfr.** -org.jcp.xml.dsig.internal.** -sun.** diff --git a/buildSrc/src/main/resources/license-headers/license-header.txt b/buildSrc/src/main/resources/license-headers/license-header.txt deleted file mode 100644 index b5b39ea4ed3cd..0000000000000 --- a/buildSrc/src/main/resources/license-headers/license-header.txt +++ /dev/null @@ -1,7 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ diff --git a/buildSrc/src/main/resources/minimumCompilerVersion b/buildSrc/src/main/resources/minimumCompilerVersion deleted file mode 100644 index b4de394767536..0000000000000 --- a/buildSrc/src/main/resources/minimumCompilerVersion +++ /dev/null @@ -1 +0,0 @@ -11 diff --git a/buildSrc/src/main/resources/minimumGradleVersion b/buildSrc/src/main/resources/minimumGradleVersion deleted file mode 100644 index ba92e72f5775b..0000000000000 --- a/buildSrc/src/main/resources/minimumGradleVersion +++ /dev/null @@ -1 +0,0 @@ -6.6.1 \ No newline at end of file diff --git a/buildSrc/src/main/resources/minimumRuntimeVersion b/buildSrc/src/main/resources/minimumRuntimeVersion deleted file mode 100644 index 468437494697b..0000000000000 --- a/buildSrc/src/main/resources/minimumRuntimeVersion +++ /dev/null @@ -1 +0,0 @@ -1.8 \ No newline at end of file diff --git a/buildSrc/src/main/resources/opensearch.properties b/buildSrc/src/main/resources/opensearch.properties deleted file mode 100644 index a2c3f37f8f027..0000000000000 --- a/buildSrc/src/main/resources/opensearch.properties +++ /dev/null @@ -1,13 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -version=@version@ -luceneVersion=@luceneVersion@ diff --git a/buildSrc/src/main/resources/plugin-descriptor.properties b/buildSrc/src/main/resources/plugin-descriptor.properties deleted file mode 100644 index ce1803bdb676b..0000000000000 --- a/buildSrc/src/main/resources/plugin-descriptor.properties +++ /dev/null @@ -1,59 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# - -# OpenSearch plugin descriptor file -# This file must exist as 'plugin-descriptor.properties' inside a plugin. -# -### example plugin for "foo" -# -# foo.zip <-- zip file for the plugin, with this structure: -# |____ .jar <-- classes, resources, dependencies -# |____ .jar <-- any number of jars -# |____ plugin-descriptor.properties <-- example contents below: -# -# classname=foo.bar.BazPlugin -# description=My cool plugin -# version=6.0 -# opensearch.version=6.0 -# java.version=1.8 -# -### mandatory elements for all plugins: -# -# 'description': simple summary of the plugin -description=${description} -# -# 'version': plugin's version -version=${version} -# -# 'name': the plugin name -name=${name} -# -# 'classname': the name of the class to load, fully-qualified. -classname=${classname} -# -# 'java.version': version of java the code is built against -# use the system property java.specification.version -# version string must be a sequence of nonnegative decimal integers -# separated by "."'s and may have leading zeros -java.version=${javaVersion} -# -# 'opensearch.version': version of opensearch compiled against -opensearch.version=${opensearchVersion} -### optional elements for plugins: -# -# 'custom.foldername': the custom name of the folder in which the plugin is installed. -custom.foldername=${customFolderName} -# -# 'extended.plugins': other plugins this plugin extends through SPI -extended.plugins=${extendedPlugins} -# -# 'has.native.controller': whether or not the plugin has a native controller -has.native.controller=${hasNativeController} diff --git a/buildSrc/src/main/resources/test/ssl/README.md b/buildSrc/src/main/resources/test/ssl/README.md deleted file mode 100644 index 9d7d1427160bc..0000000000000 --- a/buildSrc/src/main/resources/test/ssl/README.md +++ /dev/null @@ -1,20 +0,0 @@ -This directory contains test certificates used for testing ssl handling. - -These keystores and certificates can be used via applying the `opensearch.test-with-ssl` plugin. - -The generated certificates are valid till 05. Jun 2030. - -The certificates are generated using catch-all SAN in the following procedure: - -1. Generate the node's keystore: - `keytool -genkey -alias test-node -keystore test-node.jks -keyalg RSA -keysize 2048 -validity 3654 -dname CN="OpenSearch Build Test Infrastructure" -keypass keypass -storepass keypass -ext san=dns:localhost,dns:localhost.localdomain,dns:localhost4,dns:localhost4.localdomain4,dns:localhost6,dns:localhost6.localdomain6,ip:127.0.0.1,ip:0:0:0:0:0:0:0:1` -2. Generate the client's keystore: - `keytool -genkey -alias test-client -keystore test-client.jks -keyalg RSA -keysize 2048 -validity 3654 -dname CN="OpenSearch Build Test Infrastructure" -keypass keypass -storepass keypass -ext san=dns:localhost,dns:localhost.localdomain,dns:localhost4,dns:localhost4.localdomain4,dns:localhost6,dns:localhost6.localdomain6,ip:127.0.0.1,ip:0:0:0:0:0:0:0:1` -3. Export the node's certificate: - `keytool -export -alias test-node -keystore test-node.jks -storepass keypass -file test-node.crt` -4. Import the node certificate in the client's keystore: - `keytool -import -alias test-node -keystore test-client.jks -storepass keypass -file test-node.crt -noprompt` -5. Export the client's certificate: - `keytool -export -alias test-client -keystore test-client.jks -storepass keypass -file test-client.crt` -6. Import the client certificate in the node's keystore: - `keytool -import -alias test-client -keystore test-node.jks -storepass keypass -file test-client.crt -noprompt` diff --git a/buildSrc/src/main/resources/test/ssl/test-client.crt b/buildSrc/src/main/resources/test/ssl/test-client.crt deleted file mode 100644 index 5459c2a0b0707..0000000000000 Binary files a/buildSrc/src/main/resources/test/ssl/test-client.crt and /dev/null differ diff --git a/buildSrc/src/main/resources/test/ssl/test-client.jks b/buildSrc/src/main/resources/test/ssl/test-client.jks deleted file mode 100644 index e2ed37ec7cf03..0000000000000 Binary files a/buildSrc/src/main/resources/test/ssl/test-client.jks and /dev/null differ diff --git a/buildSrc/src/main/resources/test/ssl/test-node.crt b/buildSrc/src/main/resources/test/ssl/test-node.crt deleted file mode 100644 index c2a27e3544875..0000000000000 Binary files a/buildSrc/src/main/resources/test/ssl/test-node.crt and /dev/null differ diff --git a/buildSrc/src/main/resources/test/ssl/test-node.jks b/buildSrc/src/main/resources/test/ssl/test-node.jks deleted file mode 100644 index 59e995321a943..0000000000000 Binary files a/buildSrc/src/main/resources/test/ssl/test-node.jks and /dev/null differ diff --git a/buildSrc/src/test/java/org/opensearch/gradle/ArchitectureTests.java b/buildSrc/src/test/java/org/opensearch/gradle/ArchitectureTests.java deleted file mode 100644 index f13214420b434..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/ArchitectureTests.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.gradle; - -import org.opensearch.gradle.test.GradleUnitTestCase; - -public class ArchitectureTests extends GradleUnitTestCase { - - final String architecture = System.getProperty("os.arch", ""); - - public void testCurrentArchitecture() { - assertEquals(Architecture.X64, currentArchitecture("amd64")); - assertEquals(Architecture.X64, currentArchitecture("x86_64")); - assertEquals(Architecture.ARM64, currentArchitecture("aarch64")); - assertEquals(Architecture.PPC64LE, currentArchitecture("ppc64le")); - } - - public void testInvalidCurrentArchitecture() { - assertThrows("can not determine architecture from [", IllegalArgumentException.class, () -> currentArchitecture("fooBar64")); - } - - /** - * Determines the return value of {@link Architecture#current()} based on a string representing a potential OS Architecture. - * - * @param osArchToTest An expected value of the {@code os.arch} system property on another architecture. - * @return the value of the {@link Architecture} enum which would have resulted with the given value. - * @throws IllegalArgumentException if the string is not mapped to a value of the {@link Architecture} enum. - */ - private Architecture currentArchitecture(String osArchToTest) throws IllegalArgumentException { - // Test new architecture - System.setProperty("os.arch", osArchToTest); - try { - return Architecture.current(); - } finally { - // Restore actual architecture property value - System.setProperty("os.arch", this.architecture); - } - } -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/BwcOpenSearchVersionsTests.java b/buildSrc/src/test/java/org/opensearch/gradle/BwcOpenSearchVersionsTests.java deleted file mode 100644 index 28f116710e408..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/BwcOpenSearchVersionsTests.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.gradle; - -import org.opensearch.gradle.test.GradleUnitTestCase; -import org.junit.Rule; -import org.junit.rules.ExpectedException; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static java.util.Arrays.asList; - -/** - * Tests to specifically verify the OpenSearch version 1.x with Legacy ES versions. - * This supplements the tests in BwcVersionsTests. - * - * Currently the versioning logic doesn't work for OpenSearch 2.x as the masking - * is only applied specifically for 1.x. - */ -public class BwcOpenSearchVersionsTests extends GradleUnitTestCase { - - private static final Map> sampleVersions = new HashMap<>(); - - @Rule - public ExpectedException expectedEx = ExpectedException.none(); - - static { - sampleVersions.put("1.0.0", asList("5_6_13", "6_6_1", "6_8_15", "7_0_0", "7_9_1", "7_10_0", "7_10_1", "7_10_2", "1_0_0")); - sampleVersions.put("1.1.0", asList("5_6_13", "6_6_1", "6_8_15", "7_0_0", "7_9_1", "7_10_0", "7_10_1", "7_10_2", "1_0_0", "1_1_0")); - } - - public void testWireCompatible() { - assertVersionsEquals( - asList("6.8.15", "7.0.0", "7.9.1", "7.10.0", "7.10.1", "7.10.2"), - getVersionCollection("1.0.0").getWireCompatible() - ); - assertVersionsEquals( - asList("6.8.15", "7.0.0", "7.9.1", "7.10.0", "7.10.1", "7.10.2", "1.0.0"), - getVersionCollection("1.1.0").getWireCompatible() - ); - } - - public void testWireCompatibleUnreleased() { - assertVersionsEquals(Collections.emptyList(), getVersionCollection("1.0.0").getUnreleasedWireCompatible()); - } - - public void testIndexCompatible() { - assertVersionsEquals( - asList("6.6.1", "6.8.15", "7.0.0", "7.9.1", "7.10.0", "7.10.1", "7.10.2"), - getVersionCollection("1.0.0").getIndexCompatible() - ); - assertVersionsEquals( - asList("6.6.1", "6.8.15", "7.0.0", "7.9.1", "7.10.0", "7.10.1", "7.10.2", "1.0.0"), - getVersionCollection("1.1.0").getIndexCompatible() - ); - } - - public void testIndexCompatibleUnreleased() { - assertVersionsEquals(Collections.emptyList(), getVersionCollection("1.0.0").getUnreleasedIndexCompatible()); - } - - public void testGetUnreleased() { - assertVersionsEquals(Collections.singletonList("1.0.0"), getVersionCollection("1.0.0").getUnreleased()); - } - - private String formatVersionToLine(final String version) { - return " public static final Version V_" + version.replaceAll("\\.", "_") + " "; - } - - private void assertVersionsEquals(List expected, List actual) { - assertEquals(expected.stream().map(Version::fromString).collect(Collectors.toList()), actual); - } - - private BwcVersions getVersionCollection(String versionString) { - List versionMap = sampleVersions.get(versionString); - assertNotNull(versionMap); - Version version = Version.fromString(versionString); - assertNotNull(version); - return new BwcVersions(versionMap.stream().map(this::formatVersionToLine).collect(Collectors.toList()), version); - } -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/BwcVersionsTests.java b/buildSrc/src/test/java/org/opensearch/gradle/BwcVersionsTests.java deleted file mode 100644 index 94c4e66726acd..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/BwcVersionsTests.java +++ /dev/null @@ -1,784 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.opensearch.gradle.test.GradleUnitTestCase; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; - -public class BwcVersionsTests extends GradleUnitTestCase { - - private static final Map> sampleVersions = new HashMap<>(); - - @Rule - public ExpectedException expectedEx = ExpectedException.none(); - - static { - // unreleased major and two unreleased minors ( minor in feature freeze ) - sampleVersions.put("8.0.0", asList("7_0_0", "7_0_1", "7_1_0", "7_1_1", "7_2_0", "7_3_0", "8.0.0")); - sampleVersions.put( - "7.0.0-alpha1", - asList( - "6_0_0_alpha1", - "6_0_0_alpha2", - "6_0_0_beta1", - "6_0_0_beta2", - "6_0_0_rc1", - "6_0_0_rc2", - "6_0_0", - "6_0_1", - "6_1_0", - "6_1_1", - "6_1_2", - "6_1_3", - "6_1_4", - "6_2_0", - "6_2_1", - "6_2_2", - "6_2_3", - "6_2_4", - "6_3_0", - "6_3_1", - "6_3_2", - "6_4_0", - "6_4_1", - "6_4_2", - "6_5_0", - "7_0_0_alpha1" - ) - ); - sampleVersions.put( - "6.5.0", - asList( - "5_0_0_alpha1", - "5_0_0_alpha2", - "5_0_0_alpha3", - "5_0_0_alpha4", - "5_0_0_alpha5", - "5_0_0_beta1", - "5_0_0_rc1", - "5_0_0", - "5_0_1", - "5_0_2", - "5_1_1", - "5_1_2", - "5_2_0", - "5_2_1", - "5_2_2", - "5_3_0", - "5_3_1", - "5_3_2", - "5_3_3", - "5_4_0", - "5_4_1", - "5_4_2", - "5_4_3", - "5_5_0", - "5_5_1", - "5_5_2", - "5_5_3", - "5_6_0", - "5_6_1", - "5_6_2", - "5_6_3", - "5_6_4", - "5_6_5", - "5_6_6", - "5_6_7", - "5_6_8", - "5_6_9", - "5_6_10", - "5_6_11", - "5_6_12", - "5_6_13", - "6_0_0_alpha1", - "6_0_0_alpha2", - "6_0_0_beta1", - "6_0_0_beta2", - "6_0_0_rc1", - "6_0_0_rc2", - "6_0_0", - "6_0_1", - "6_1_0", - "6_1_1", - "6_1_2", - "6_1_3", - "6_1_4", - "6_2_0", - "6_2_1", - "6_2_2", - "6_2_3", - "6_2_4", - "6_3_0", - "6_3_1", - "6_3_2", - "6_4_0", - "6_4_1", - "6_4_2", - "6_5_0" - ) - ); - sampleVersions.put( - "6.6.0", - asList( - "5_0_0_alpha1", - "5_0_0_alpha2", - "5_0_0_alpha3", - "5_0_0_alpha4", - "5_0_0_alpha5", - "5_0_0_beta1", - "5_0_0_rc1", - "5_0_0", - "5_0_1", - "5_0_2", - "5_1_1", - "5_1_2", - "5_2_0", - "5_2_1", - "5_2_2", - "5_3_0", - "5_3_1", - "5_3_2", - "5_3_3", - "5_4_0", - "5_4_1", - "5_4_2", - "5_4_3", - "5_5_0", - "5_5_1", - "5_5_2", - "5_5_3", - "5_6_0", - "5_6_1", - "5_6_2", - "5_6_3", - "5_6_4", - "5_6_5", - "5_6_6", - "5_6_7", - "5_6_8", - "5_6_9", - "5_6_10", - "5_6_11", - "5_6_12", - "5_6_13", - "6_0_0_alpha1", - "6_0_0_alpha2", - "6_0_0_beta1", - "6_0_0_beta2", - "6_0_0_rc1", - "6_0_0_rc2", - "6_0_0", - "6_0_1", - "6_1_0", - "6_1_1", - "6_1_2", - "6_1_3", - "6_1_4", - "6_2_0", - "6_2_1", - "6_2_2", - "6_2_3", - "6_2_4", - "6_3_0", - "6_3_1", - "6_3_2", - "6_4_0", - "6_4_1", - "6_4_2", - "6_5_0", - "6_6_0" - ) - ); - sampleVersions.put( - "6.4.2", - asList( - "5_0_0_alpha1", - "5_0_0_alpha2", - "5_0_0_alpha3", - "5_0_0_alpha4", - "5_0_0_alpha5", - "5_0_0_beta1", - "5_0_0_rc1", - "5_0_0", - "5_0_1", - "5_0_2", - "5_1_1", - "5_1_2", - "5_2_0", - "5_2_1", - "5_2_2", - "5_3_0", - "5_3_1", - "5_3_2", - "5_3_3", - "5_4_0", - "5_4_1", - "5_4_2", - "5_4_3", - "5_5_0", - "5_5_1", - "5_5_2", - "5_5_3", - "5_6_0", - "5_6_1", - "5_6_2", - "5_6_3", - "5_6_4", - "5_6_5", - "5_6_6", - "5_6_7", - "5_6_8", - "5_6_9", - "5_6_10", - "5_6_11", - "5_6_12", - "5_6_13", - "6_0_0_alpha1", - "6_0_0_alpha2", - "6_0_0_beta1", - "6_0_0_beta2", - "6_0_0_rc1", - "6_0_0_rc2", - "6_0_0", - "6_0_1", - "6_1_0", - "6_1_1", - "6_1_2", - "6_1_3", - "6_1_4", - "6_2_0", - "6_2_1", - "6_2_2", - "6_2_3", - "6_2_4", - "6_3_0", - "6_3_1", - "6_3_2", - "6_4_0", - "6_4_1", - "6_4_2" - ) - ); - sampleVersions.put("7.1.0", asList("7_1_0", "7_0_0", "6_7_0", "6_6_1", "6_6_0")); - } - - @Test(expected = IllegalArgumentException.class) - public void testExceptionOnEmpty() { - new BwcVersions(asList("foo", "bar"), Version.fromString("7.0.0")); - } - - @Test(expected = IllegalStateException.class) - public void testExceptionOnNonCurrent() { - new BwcVersions(singletonList(formatVersionToLine("6.5.0")), Version.fromString("7.0.0")); - } - - @Test(expected = IllegalStateException.class) - public void testExceptionOnTooManyMajors() { - new BwcVersions( - asList(formatVersionToLine("5.6.12"), formatVersionToLine("6.5.0"), formatVersionToLine("7.0.0")), - Version.fromString("6.5.0") - ); - } - - public void testWireCompatible() { - assertVersionsEquals(asList("6.5.0"), getVersionCollection("7.0.0-alpha1").getWireCompatible()); - assertVersionsEquals( - asList( - "5.6.0", - "5.6.1", - "5.6.2", - "5.6.3", - "5.6.4", - "5.6.5", - "5.6.6", - "5.6.7", - "5.6.8", - "5.6.9", - "5.6.10", - "5.6.11", - "5.6.12", - "5.6.13", - "6.0.0", - "6.0.1", - "6.1.0", - "6.1.1", - "6.1.2", - "6.1.3", - "6.1.4", - "6.2.0", - "6.2.1", - "6.2.2", - "6.2.3", - "6.2.4", - "6.3.0", - "6.3.1", - "6.3.2", - "6.4.0", - "6.4.1", - "6.4.2" - ), - getVersionCollection("6.5.0").getWireCompatible() - ); - - assertVersionsEquals( - asList( - "5.6.0", - "5.6.1", - "5.6.2", - "5.6.3", - "5.6.4", - "5.6.5", - "5.6.6", - "5.6.7", - "5.6.8", - "5.6.9", - "5.6.10", - "5.6.11", - "5.6.12", - "5.6.13", - "6.0.0", - "6.0.1", - "6.1.0", - "6.1.1", - "6.1.2", - "6.1.3", - "6.1.4", - "6.2.0", - "6.2.1", - "6.2.2", - "6.2.3", - "6.2.4", - "6.3.0", - "6.3.1", - "6.3.2", - "6.4.0", - "6.4.1" - ), - getVersionCollection("6.4.2").getWireCompatible() - ); - - assertVersionsEquals( - asList( - "5.6.0", - "5.6.1", - "5.6.2", - "5.6.3", - "5.6.4", - "5.6.5", - "5.6.6", - "5.6.7", - "5.6.8", - "5.6.9", - "5.6.10", - "5.6.11", - "5.6.12", - "5.6.13", - "6.0.0", - "6.0.1", - "6.1.0", - "6.1.1", - "6.1.2", - "6.1.3", - "6.1.4", - "6.2.0", - "6.2.1", - "6.2.2", - "6.2.3", - "6.2.4", - "6.3.0", - "6.3.1", - "6.3.2", - "6.4.0", - "6.4.1", - "6.4.2", - "6.5.0" - ), - getVersionCollection("6.6.0").getWireCompatible() - ); - - assertVersionsEquals(asList("7.3.0"), getVersionCollection("8.0.0").getWireCompatible()); - assertVersionsEquals(asList("6.7.0", "7.0.0"), getVersionCollection("7.1.0").getWireCompatible()); - - } - - public void testWireCompatibleUnreleased() { - assertVersionsEquals(asList("6.5.0"), getVersionCollection("7.0.0-alpha1").getUnreleasedWireCompatible()); - assertVersionsEquals(asList("5.6.13", "6.4.2"), getVersionCollection("6.5.0").getUnreleasedWireCompatible()); - - assertVersionsEquals(asList("5.6.13"), getVersionCollection("6.4.2").getUnreleasedWireCompatible()); - - assertVersionsEquals(asList("5.6.13", "6.4.2", "6.5.0"), getVersionCollection("6.6.0").getUnreleasedWireCompatible()); - - assertVersionsEquals(asList("7.3.0"), getVersionCollection("8.0.0").getUnreleasedWireCompatible()); - assertVersionsEquals(asList("6.7.0", "7.0.0"), getVersionCollection("7.1.0").getWireCompatible()); - } - - public void testIndexCompatible() { - assertVersionsEquals( - asList( - "6.0.0", - "6.0.1", - "6.1.0", - "6.1.1", - "6.1.2", - "6.1.3", - "6.1.4", - "6.2.0", - "6.2.1", - "6.2.2", - "6.2.3", - "6.2.4", - "6.3.0", - "6.3.1", - "6.3.2", - "6.4.0", - "6.4.1", - "6.4.2", - "6.5.0" - ), - getVersionCollection("7.0.0-alpha1").getIndexCompatible() - ); - - assertVersionsEquals( - asList( - "5.0.0", - "5.0.1", - "5.0.2", - "5.1.1", - "5.1.2", - "5.2.0", - "5.2.1", - "5.2.2", - "5.3.0", - "5.3.1", - "5.3.2", - "5.3.3", - "5.4.0", - "5.4.1", - "5.4.2", - "5.4.3", - "5.5.0", - "5.5.1", - "5.5.2", - "5.5.3", - "5.6.0", - "5.6.1", - "5.6.2", - "5.6.3", - "5.6.4", - "5.6.5", - "5.6.6", - "5.6.7", - "5.6.8", - "5.6.9", - "5.6.10", - "5.6.11", - "5.6.12", - "5.6.13", - "6.0.0", - "6.0.1", - "6.1.0", - "6.1.1", - "6.1.2", - "6.1.3", - "6.1.4", - "6.2.0", - "6.2.1", - "6.2.2", - "6.2.3", - "6.2.4", - "6.3.0", - "6.3.1", - "6.3.2", - "6.4.0", - "6.4.1", - "6.4.2" - ), - getVersionCollection("6.5.0").getIndexCompatible() - ); - - assertVersionsEquals( - asList( - "5.0.0", - "5.0.1", - "5.0.2", - "5.1.1", - "5.1.2", - "5.2.0", - "5.2.1", - "5.2.2", - "5.3.0", - "5.3.1", - "5.3.2", - "5.3.3", - "5.4.0", - "5.4.1", - "5.4.2", - "5.4.3", - "5.5.0", - "5.5.1", - "5.5.2", - "5.5.3", - "5.6.0", - "5.6.1", - "5.6.2", - "5.6.3", - "5.6.4", - "5.6.5", - "5.6.6", - "5.6.7", - "5.6.8", - "5.6.9", - "5.6.10", - "5.6.11", - "5.6.12", - "5.6.13", - "6.0.0", - "6.0.1", - "6.1.0", - "6.1.1", - "6.1.2", - "6.1.3", - "6.1.4", - "6.2.0", - "6.2.1", - "6.2.2", - "6.2.3", - "6.2.4", - "6.3.0", - "6.3.1", - "6.3.2", - "6.4.0", - "6.4.1" - ), - getVersionCollection("6.4.2").getIndexCompatible() - ); - - assertVersionsEquals( - asList( - "5.0.0", - "5.0.1", - "5.0.2", - "5.1.1", - "5.1.2", - "5.2.0", - "5.2.1", - "5.2.2", - "5.3.0", - "5.3.1", - "5.3.2", - "5.3.3", - "5.4.0", - "5.4.1", - "5.4.2", - "5.4.3", - "5.5.0", - "5.5.1", - "5.5.2", - "5.5.3", - "5.6.0", - "5.6.1", - "5.6.2", - "5.6.3", - "5.6.4", - "5.6.5", - "5.6.6", - "5.6.7", - "5.6.8", - "5.6.9", - "5.6.10", - "5.6.11", - "5.6.12", - "5.6.13", - "6.0.0", - "6.0.1", - "6.1.0", - "6.1.1", - "6.1.2", - "6.1.3", - "6.1.4", - "6.2.0", - "6.2.1", - "6.2.2", - "6.2.3", - "6.2.4", - "6.3.0", - "6.3.1", - "6.3.2", - "6.4.0", - "6.4.1", - "6.4.2", - "6.5.0" - ), - getVersionCollection("6.6.0").getIndexCompatible() - ); - - assertVersionsEquals( - asList("7.0.0", "7.0.1", "7.1.0", "7.1.1", "7.2.0", "7.3.0"), - getVersionCollection("8.0.0").getIndexCompatible() - ); - } - - public void testIndexCompatibleUnreleased() { - assertVersionsEquals(asList("6.4.2", "6.5.0"), getVersionCollection("7.0.0-alpha1").getUnreleasedIndexCompatible()); - - assertVersionsEquals(asList("5.6.13", "6.4.2"), getVersionCollection("6.5.0").getUnreleasedIndexCompatible()); - - assertVersionsEquals(asList("5.6.13"), getVersionCollection("6.4.2").getUnreleasedIndexCompatible()); - - assertVersionsEquals(asList("5.6.13", "6.4.2", "6.5.0"), getVersionCollection("6.6.0").getUnreleasedIndexCompatible()); - - assertVersionsEquals(asList("7.1.1", "7.2.0", "7.3.0"), getVersionCollection("8.0.0").getUnreleasedIndexCompatible()); - } - - public void testGetUnreleased() { - assertVersionsEquals(asList("6.4.2", "6.5.0", "7.0.0-alpha1"), getVersionCollection("7.0.0-alpha1").getUnreleased()); - assertVersionsEquals(asList("5.6.13", "6.4.2", "6.5.0"), getVersionCollection("6.5.0").getUnreleased()); - assertVersionsEquals(asList("5.6.13", "6.4.2"), getVersionCollection("6.4.2").getUnreleased()); - assertVersionsEquals(asList("5.6.13", "6.4.2", "6.5.0", "6.6.0"), getVersionCollection("6.6.0").getUnreleased()); - assertVersionsEquals(asList("7.1.1", "7.2.0", "7.3.0", "8.0.0"), getVersionCollection("8.0.0").getUnreleased()); - assertVersionsEquals(asList("6.6.1", "6.7.0", "7.0.0", "7.1.0"), getVersionCollection("7.1.0").getUnreleased()); - } - - public void testGetBranch() { - assertUnreleasedBranchNames(asList("6.4", "6.x"), getVersionCollection("7.0.0-alpha1")); - assertUnreleasedBranchNames(asList("5.6", "6.4"), getVersionCollection("6.5.0")); - assertUnreleasedBranchNames(singletonList("5.6"), getVersionCollection("6.4.2")); - assertUnreleasedBranchNames(asList("5.6", "6.4", "6.5"), getVersionCollection("6.6.0")); - assertUnreleasedBranchNames(asList("7.1", "7.2", "7.x"), getVersionCollection("8.0.0")); - assertUnreleasedBranchNames(asList("6.6", "6.7", "7.0"), getVersionCollection("7.1.0")); - } - - public void testGetGradleProjectPath() { - assertUnreleasedGradleProjectPaths( - asList(":distribution:bwc:bugfix", ":distribution:bwc:minor"), - getVersionCollection("7.0.0-alpha1") - ); - assertUnreleasedGradleProjectPaths( - asList(":distribution:bwc:maintenance", ":distribution:bwc:bugfix"), - getVersionCollection("6.5.0") - ); - assertUnreleasedGradleProjectPaths(singletonList(":distribution:bwc:maintenance"), getVersionCollection("6.4.2")); - assertUnreleasedGradleProjectPaths( - asList(":distribution:bwc:maintenance", ":distribution:bwc:bugfix", ":distribution:bwc:minor"), - getVersionCollection("6.6.0") - ); - assertUnreleasedGradleProjectPaths( - asList(":distribution:bwc:bugfix", ":distribution:bwc:staged", ":distribution:bwc:minor"), - getVersionCollection("8.0.0") - ); - assertUnreleasedGradleProjectPaths( - asList(":distribution:bwc:maintenance", ":distribution:bwc:staged", ":distribution:bwc:minor"), - getVersionCollection("7.1.0") - ); - } - - public void testCompareToAuthoritative() { - List listOfVersions = asList("7.0.0", "7.0.1", "7.1.0", "7.1.1", "7.2.0", "7.3.0", "8.0.0"); - List authoritativeReleasedVersions = Stream.of("7.0.0", "7.0.1", "7.1.0") - .map(Version::fromString) - .collect(Collectors.toList()); - - BwcVersions vc = new BwcVersions( - listOfVersions.stream().map(this::formatVersionToLine).collect(Collectors.toList()), - Version.fromString("8.0.0") - ); - vc.compareToAuthoritative(authoritativeReleasedVersions); - } - - public void testCompareToAuthoritativeUnreleasedActuallyReleased() { - List listOfVersions = asList("7.0.0", "7.0.1", "7.1.0", "7.1.1", "7.2.0", "7.3.0", "8.0.0"); - List authoritativeReleasedVersions = Stream.of("7.0.0", "7.0.1", "7.1.0", "7.1.1", "8.0.0") - .map(Version::fromString) - .collect(Collectors.toList()); - - BwcVersions vc = new BwcVersions( - listOfVersions.stream().map(this::formatVersionToLine).collect(Collectors.toList()), - Version.fromString("8.0.0") - ); - expectedEx.expect(IllegalStateException.class); - expectedEx.expectMessage("but they are released"); - vc.compareToAuthoritative(authoritativeReleasedVersions); - } - - public void testCompareToAuthoritativeNotReallyRelesed() { - List listOfVersions = asList("7.0.0", "7.0.1", "7.1.0", "7.1.1", "7.2.0", "7.3.0", "8.0.0"); - List authoritativeReleasedVersions = Stream.of("7.0.0", "7.0.1").map(Version::fromString).collect(Collectors.toList()); - BwcVersions vc = new BwcVersions( - listOfVersions.stream().map(this::formatVersionToLine).collect(Collectors.toList()), - Version.fromString("8.0.0") - ); - expectedEx.expect(IllegalStateException.class); - expectedEx.expectMessage("not really released"); - vc.compareToAuthoritative(authoritativeReleasedVersions); - } - - private void assertUnreleasedGradleProjectPaths(List expectedNAmes, BwcVersions bwcVersions) { - List actualNames = new ArrayList<>(); - bwcVersions.forPreviousUnreleased(unreleasedVersion -> actualNames.add(unreleasedVersion.gradleProjectPath)); - assertEquals(expectedNAmes, actualNames); - } - - private void assertUnreleasedBranchNames(List expectedBranches, BwcVersions bwcVersions) { - List actualBranches = new ArrayList<>(); - bwcVersions.forPreviousUnreleased(unreleasedVersionInfo -> actualBranches.add(unreleasedVersionInfo.branch)); - assertEquals(expectedBranches, actualBranches); - } - - private String formatVersionToLine(final String version) { - return " public static final Version V_" + version.replaceAll("\\.", "_") + " "; - } - - private void assertVersionsEquals(List expected, List actual) { - assertEquals(expected.stream().map(Version::fromString).collect(Collectors.toList()), actual); - } - - private BwcVersions getVersionCollection(String currentVersion) { - return new BwcVersions( - sampleVersions.get(currentVersion).stream().map(this::formatVersionToLine).collect(Collectors.toList()), - Version.fromString(currentVersion) - ); - } -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/ConcatFilesTaskTests.java b/buildSrc/src/test/java/org/opensearch/gradle/ConcatFilesTaskTests.java deleted file mode 100644 index 3b9c1c81e0345..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/ConcatFilesTaskTests.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.Arrays; - -import org.opensearch.gradle.test.GradleUnitTestCase; -import org.gradle.api.Project; -import org.gradle.testfixtures.ProjectBuilder; - -public class ConcatFilesTaskTests extends GradleUnitTestCase { - - public void testHeaderAdded() throws IOException { - - Project project = createProject(); - ConcatFilesTask concatFilesTask = createTask(project); - - concatFilesTask.setHeaderLine("Header"); - - File file = new File(project.getProjectDir(), "src/main/java/Code.java"); - file.getParentFile().mkdirs(); - file.createNewFile(); - concatFilesTask.setTarget(file); - concatFilesTask.setFiles(project.fileTree("tmp/")); - - concatFilesTask.concatFiles(); - - assertEquals(Arrays.asList("Header"), Files.readAllLines(concatFilesTask.getTarget().toPath(), StandardCharsets.UTF_8)); - - file.delete(); - } - - public void testConcatenationWithUnique() throws IOException { - - Project project = createProject(); - ConcatFilesTask concatFilesTask = createTask(project); - - File file = new File(project.getProjectDir(), "src/main/java/Code.java"); - file.getParentFile().mkdirs(); - file.createNewFile(); - concatFilesTask.setTarget(file); - - File file1 = new File(project.getProjectDir(), "src/main/input/java/file1.java"); - File file2 = new File(project.getProjectDir(), "src/main/input/text/file2.txt"); - file1.getParentFile().mkdirs(); - file2.getParentFile().mkdirs(); - file1.createNewFile(); - file2.createNewFile(); - Files.write(file1.toPath(), ("Hello" + System.lineSeparator() + "Hello").getBytes(StandardCharsets.UTF_8)); - Files.write(file2.toPath(), ("Hello" + System.lineSeparator() + "नमस्ते").getBytes(StandardCharsets.UTF_8)); - - concatFilesTask.setFiles(project.fileTree(file1.getParentFile().getParentFile())); - - concatFilesTask.concatFiles(); - - assertEquals(Arrays.asList("Hello", "नमस्ते"), Files.readAllLines(concatFilesTask.getTarget().toPath(), StandardCharsets.UTF_8)); - - } - - private Project createProject() { - Project project = ProjectBuilder.builder().build(); - return project; - } - - private ConcatFilesTask createTask(Project project) { - return project.getTasks().create("concatFilesTask", ConcatFilesTask.class); - } - -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/DistributionDownloadPluginTests.java b/buildSrc/src/test/java/org/opensearch/gradle/DistributionDownloadPluginTests.java deleted file mode 100644 index 54660c4c69e68..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/DistributionDownloadPluginTests.java +++ /dev/null @@ -1,303 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.opensearch.gradle.OpenSearchDistribution.Platform; -import org.opensearch.gradle.OpenSearchDistribution.Type; -import org.opensearch.gradle.info.BuildParams; -import org.opensearch.gradle.test.GradleUnitTestCase; -import org.gradle.api.NamedDomainObjectContainer; -import org.gradle.api.Project; -import org.gradle.testfixtures.ProjectBuilder; - -import java.io.File; -import java.util.Arrays; -import java.util.TreeSet; - -import static org.hamcrest.core.StringContains.containsString; - -public class DistributionDownloadPluginTests extends GradleUnitTestCase { - private static Project rootProject; - private static Project archivesProject; - private static Project packagesProject; - private static Project bwcProject; - - private static final Version BWC_MAJOR_VERSION = Version.fromString("4.0.0"); - private static final Version BWC_MINOR_VERSION = Version.fromString("3.1.0"); - private static final Version BWC_STAGED_VERSION = Version.fromString("3.0.0"); - private static final Version BWC_BUGFIX_VERSION = Version.fromString("3.0.1"); - private static final Version BWC_MAINTENANCE_VERSION = Version.fromString("2.90.1"); - private static final BwcVersions BWC_MINOR = new BwcVersions( - new TreeSet<>(Arrays.asList(BWC_BUGFIX_VERSION, BWC_MINOR_VERSION, BWC_MAJOR_VERSION)), - BWC_MAJOR_VERSION - ); - private static final BwcVersions BWC_STAGED = new BwcVersions( - new TreeSet<>(Arrays.asList(BWC_STAGED_VERSION, BWC_MINOR_VERSION, BWC_MAJOR_VERSION)), - BWC_MAJOR_VERSION - ); - private static final BwcVersions BWC_BUGFIX = new BwcVersions( - new TreeSet<>(Arrays.asList(BWC_BUGFIX_VERSION, BWC_MINOR_VERSION, BWC_MAJOR_VERSION)), - BWC_MAJOR_VERSION - ); - private static final BwcVersions BWC_MAINTENANCE = new BwcVersions( - new TreeSet<>(Arrays.asList(BWC_MAINTENANCE_VERSION, BWC_STAGED_VERSION, BWC_MINOR_VERSION)), - BWC_MINOR_VERSION - ); - - public void testVersionDefault() { - OpenSearchDistribution distro = checkDistro(createProject(null, false), "testdistro", null, Type.ARCHIVE, Platform.LINUX, true); - assertEquals(distro.getVersion(), VersionProperties.getOpenSearch()); - } - - public void testBadVersionFormat() { - assertDistroError( - createProject(null, false), - "testdistro", - "badversion", - Type.ARCHIVE, - Platform.LINUX, - true, - "Invalid version format: 'badversion'" - ); - } - - public void testTypeDefault() { - OpenSearchDistribution distro = checkDistro(createProject(null, false), "testdistro", "5.0.0", null, Platform.LINUX, true); - assertEquals(distro.getType(), Type.ARCHIVE); - } - - public void testPlatformDefault() { - OpenSearchDistribution distro = checkDistro(createProject(null, false), "testdistro", "5.0.0", Type.ARCHIVE, null, true); - assertEquals(distro.getPlatform(), OpenSearchDistribution.CURRENT_PLATFORM); - } - - public void testPlatformForIntegTest() { - assertDistroError( - createProject(null, false), - "testdistro", - "5.0.0", - Type.INTEG_TEST_ZIP, - Platform.LINUX, - null, - "platform cannot be set on opensearch distribution [testdistro]" - ); - } - - public void testBundledJdkDefault() { - OpenSearchDistribution distro = checkDistro(createProject(null, false), "testdistro", "5.0.0", Type.ARCHIVE, Platform.LINUX, true); - assertTrue(distro.getBundledJdk()); - } - - public void testBundledJdkForIntegTest() { - assertDistroError( - createProject(null, false), - "testdistro", - "5.0.0", - Type.INTEG_TEST_ZIP, - null, - true, - "bundledJdk cannot be set on opensearch distribution [testdistro]" - ); - } - - public void testLocalCurrentVersionIntegTestZip() { - Project project = createProject(BWC_MINOR, true); - Project archiveProject = ProjectBuilder.builder().withParent(archivesProject).withName("integ-test-zip").build(); - archiveProject.getConfigurations().create("default"); - archiveProject.getArtifacts().add("default", new File("doesnotmatter")); - createDistro(project, "distro", VersionProperties.getOpenSearch(), Type.INTEG_TEST_ZIP, null, null); - checkPlugin(project); - } - - public void testLocalCurrentVersionArchives() { - for (Platform platform : Platform.values()) { - for (boolean bundledJdk : new boolean[] { true, false }) { - for (Architecture architecture : Architecture.values()) { - // create a new project in each iteration, so that we know we are resolving the only additional project being created - Project project = createProject(BWC_MINOR, true); - String projectName = projectName(platform.toString(), bundledJdk); - projectName += (platform == Platform.WINDOWS ? "-zip" : "-tar"); - Project archiveProject = ProjectBuilder.builder().withParent(archivesProject).withName(projectName).build(); - archiveProject.getConfigurations().create("default"); - archiveProject.getArtifacts().add("default", new File("doesnotmatter")); - final OpenSearchDistribution distro = createDistro( - project, - "distro", - VersionProperties.getOpenSearch(), - Type.ARCHIVE, - platform, - bundledJdk - ); - distro.setArchitecture(architecture); - checkPlugin(project); - } - } - } - } - - public void testLocalCurrentVersionPackages() { - for (Type packageType : new Type[] { Type.RPM, Type.DEB }) { - for (boolean bundledJdk : new boolean[] { true, false }) { - Project project = createProject(BWC_MINOR, true); - String projectName = projectName(packageType.toString(), bundledJdk); - Project packageProject = ProjectBuilder.builder().withParent(packagesProject).withName(projectName).build(); - packageProject.getConfigurations().create("default"); - packageProject.getArtifacts().add("default", new File("doesnotmatter")); - createDistro(project, "distro", VersionProperties.getOpenSearch(), packageType, null, bundledJdk); - checkPlugin(project); - } - } - } - - public void testLocalBwcArchives() { - for (Platform platform : Platform.values()) { - // note: no non bundled jdk for bwc - String configName = projectName(platform.toString(), true); - configName += (platform == Platform.WINDOWS ? "-zip" : "-tar"); - - checkBwc("minor", configName, BWC_MINOR_VERSION, Type.ARCHIVE, platform, BWC_MINOR, true); - checkBwc("staged", configName, BWC_STAGED_VERSION, Type.ARCHIVE, platform, BWC_STAGED, true); - checkBwc("bugfix", configName, BWC_BUGFIX_VERSION, Type.ARCHIVE, platform, BWC_BUGFIX, true); - checkBwc("maintenance", configName, BWC_MAINTENANCE_VERSION, Type.ARCHIVE, platform, BWC_MAINTENANCE, true); - } - } - - public void testLocalBwcPackages() { - for (Type packageType : new Type[] { Type.RPM, Type.DEB }) { - // note: no non bundled jdk for bwc - String configName = projectName(packageType.toString(), true); - - checkBwc("minor", configName, BWC_MINOR_VERSION, packageType, null, BWC_MINOR, true); - checkBwc("staged", configName, BWC_STAGED_VERSION, packageType, null, BWC_STAGED, true); - checkBwc("bugfix", configName, BWC_BUGFIX_VERSION, packageType, null, BWC_BUGFIX, true); - checkBwc("maintenance", configName, BWC_MAINTENANCE_VERSION, packageType, null, BWC_MAINTENANCE, true); - } - } - - private void assertDistroError( - Project project, - String name, - String version, - Type type, - Platform platform, - Boolean bundledJdk, - String message - ) { - IllegalArgumentException e = expectThrows( - IllegalArgumentException.class, - () -> checkDistro(project, name, version, type, platform, bundledJdk) - ); - assertThat(e.getMessage(), containsString(message)); - } - - private OpenSearchDistribution createDistro( - Project project, - String name, - String version, - Type type, - Platform platform, - Boolean bundledJdk - ) { - NamedDomainObjectContainer distros = DistributionDownloadPlugin.getContainer(project); - return distros.create(name, distro -> { - if (version != null) { - distro.setVersion(version); - } - if (type != null) { - distro.setType(type); - } - if (platform != null) { - distro.setPlatform(platform); - } - if (bundledJdk != null) { - distro.setBundledJdk(bundledJdk); - } - }); - } - - // create a distro and finalize its configuration - private OpenSearchDistribution checkDistro( - Project project, - String name, - String version, - Type type, - Platform platform, - Boolean bundledJdk - ) { - OpenSearchDistribution distribution = createDistro(project, name, version, type, platform, bundledJdk); - distribution.finalizeValues(); - return distribution; - } - - // check the download plugin can be fully configured - private void checkPlugin(Project project) { - DistributionDownloadPlugin plugin = project.getPlugins().getPlugin(DistributionDownloadPlugin.class); - plugin.setupDistributions(project); - } - - private void checkBwc( - String projectName, - String config, - Version version, - Type type, - Platform platform, - BwcVersions bwcVersions, - boolean isInternal - ) { - Project project = createProject(bwcVersions, isInternal); - Project archiveProject = ProjectBuilder.builder().withParent(bwcProject).withName(projectName).build(); - archiveProject.getConfigurations().create(config); - archiveProject.getArtifacts().add(config, new File("doesnotmatter")); - createDistro(project, "distro", version.toString(), type, platform, true); - checkPlugin(project); - } - - private Project createProject(BwcVersions bwcVersions, boolean isInternal) { - rootProject = ProjectBuilder.builder().build(); - BuildParams.init(params -> params.setIsInternal(isInternal)); - Project distributionProject = ProjectBuilder.builder().withParent(rootProject).withName("distribution").build(); - archivesProject = ProjectBuilder.builder().withParent(distributionProject).withName("archives").build(); - packagesProject = ProjectBuilder.builder().withParent(distributionProject).withName("packages").build(); - bwcProject = ProjectBuilder.builder().withParent(distributionProject).withName("bwc").build(); - Project project = ProjectBuilder.builder().withParent(rootProject).build(); - if (bwcVersions != null) { - project.getExtensions().getExtraProperties().set("bwcVersions", bwcVersions); - } - project.getPlugins().apply("opensearch.distribution-download"); - return project; - } - - private static String projectName(String base, boolean bundledJdk) { - return bundledJdk ? base : ("no-jdk-" + base); - } -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/EmptyDirTaskTests.java b/buildSrc/src/test/java/org/opensearch/gradle/EmptyDirTaskTests.java deleted file mode 100644 index b4eae42c625ac..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/EmptyDirTaskTests.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import java.io.File; -import java.io.IOException; - -import com.carrotsearch.randomizedtesting.RandomizedTest; -import org.apache.tools.ant.taskdefs.condition.Os; -import org.opensearch.gradle.test.GradleUnitTestCase; -import org.gradle.api.Project; -import org.gradle.testfixtures.ProjectBuilder; - -public class EmptyDirTaskTests extends GradleUnitTestCase { - - public void testCreateEmptyDir() throws Exception { - Project project = ProjectBuilder.builder().build(); - EmptyDirTask emptyDirTask = project.getTasks().create("emptyDirTask", EmptyDirTask.class); - assertEquals(0755, emptyDirTask.getDirMode()); - - // generate a new temporary folder and make sure it does not exists - File newEmptyFolder = getNewNonExistingTempFolderFile(project); - - emptyDirTask.setDir(newEmptyFolder); - emptyDirTask.create(); - - assertTrue(newEmptyFolder.exists()); - assertTrue(newEmptyFolder.isDirectory()); - assertTrue(newEmptyFolder.canExecute()); - assertTrue(newEmptyFolder.canRead()); - assertTrue(newEmptyFolder.canWrite()); - - // cleanup - newEmptyFolder.delete(); - } - - public void testCreateEmptyDirNoPermissions() throws Exception { - RandomizedTest.assumeFalse("Functionality is Unix specific", Os.isFamily(Os.FAMILY_WINDOWS)); - - Project project = ProjectBuilder.builder().build(); - EmptyDirTask emptyDirTask = project.getTasks().create("emptyDirTask", EmptyDirTask.class); - emptyDirTask.setDirMode(0000); - - // generate a new temporary folder and make sure it does not exists - File newEmptyFolder = getNewNonExistingTempFolderFile(project); - - emptyDirTask.setDir(newEmptyFolder); - emptyDirTask.create(); - - assertTrue(newEmptyFolder.exists()); - assertTrue(newEmptyFolder.isDirectory()); - assertFalse(newEmptyFolder.canExecute()); - assertFalse(newEmptyFolder.canRead()); - assertFalse(newEmptyFolder.canWrite()); - - // cleanup - newEmptyFolder.delete(); - } - - private File getNewNonExistingTempFolderFile(Project project) throws IOException { - File newEmptyFolder = new File(project.getBuildDir(), "empty-dir"); - assertFalse(newEmptyFolder.exists()); - return newEmptyFolder; - } - -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/JdkDownloadPluginTests.java b/buildSrc/src/test/java/org/opensearch/gradle/JdkDownloadPluginTests.java deleted file mode 100644 index 00af8b1fdff45..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/JdkDownloadPluginTests.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.opensearch.gradle.test.GradleUnitTestCase; -import org.gradle.api.NamedDomainObjectContainer; -import org.gradle.api.Project; -import org.gradle.testfixtures.ProjectBuilder; -import org.junit.BeforeClass; - -import static org.hamcrest.CoreMatchers.equalTo; - -public class JdkDownloadPluginTests extends GradleUnitTestCase { - private static Project rootProject; - - @BeforeClass - public static void setupRoot() { - rootProject = ProjectBuilder.builder().build(); - } - - public void testMissingVendor() { - assertJdkError(createProject(), "testjdk", null, "11.0.2+33", "linux", "x64", "vendor not specified for jdk [testjdk]"); - } - - public void testUnknownVendor() { - assertJdkError( - createProject(), - "testjdk", - "unknown", - "11.0.2+33", - "linux", - "x64", - "unknown vendor [unknown] for jdk [testjdk], must be one of [adoptium, adoptopenjdk, openjdk]" - ); - } - - public void testMissingVersion() { - assertJdkError(createProject(), "testjdk", "openjdk", null, "linux", "x64", "version not specified for jdk [testjdk]"); - } - - public void testBadVersionFormat() { - assertJdkError( - createProject(), - "testjdk", - "openjdk", - "badversion", - "linux", - "x64", - "malformed version [badversion] for jdk [testjdk]" - ); - } - - public void testMissingPlatform() { - assertJdkError(createProject(), "testjdk", "openjdk", "11.0.2+33", null, "x64", "platform not specified for jdk [testjdk]"); - } - - public void testUnknownPlatform() { - assertJdkError( - createProject(), - "testjdk", - "openjdk", - "11.0.2+33", - "unknown", - "x64", - "unknown platform [unknown] for jdk [testjdk], must be one of [darwin, freebsd, linux, mac, windows]" - ); - } - - public void testMissingArchitecture() { - assertJdkError(createProject(), "testjdk", "openjdk", "11.0.2+33", "linux", null, "architecture not specified for jdk [testjdk]"); - } - - public void testUnknownArchitecture() { - assertJdkError( - createProject(), - "testjdk", - "openjdk", - "11.0.2+33", - "linux", - "unknown", - "unknown architecture [unknown] for jdk [testjdk], must be one of [aarch64, x64, ppc64le]" - ); - } - - private void assertJdkError( - final Project project, - final String name, - final String vendor, - final String version, - final String platform, - final String architecture, - final String message - ) { - IllegalArgumentException e = expectThrows( - IllegalArgumentException.class, - () -> createJdk(project, name, vendor, version, platform, architecture) - ); - assertThat(e.getMessage(), equalTo(message)); - } - - private void createJdk(Project project, String name, String vendor, String version, String platform, String architecture) { - @SuppressWarnings("unchecked") - NamedDomainObjectContainer jdks = (NamedDomainObjectContainer) project.getExtensions().getByName("jdks"); - jdks.create(name, jdk -> { - if (vendor != null) { - jdk.setVendor(vendor); - } - if (version != null) { - jdk.setVersion(version); - } - if (platform != null) { - jdk.setPlatform(platform); - } - if (architecture != null) { - jdk.setArchitecture(architecture); - } - }).finalizeValues(); - } - - private Project createProject() { - Project project = ProjectBuilder.builder().withParent(rootProject).build(); - project.getPlugins().apply("opensearch.jdk-download"); - return project; - } -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/VersionTests.java b/buildSrc/src/test/java/org/opensearch/gradle/VersionTests.java deleted file mode 100644 index 40f9ffe7dfa8d..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/VersionTests.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle; - -import org.opensearch.gradle.test.GradleUnitTestCase; -import org.junit.Rule; -import org.junit.rules.ExpectedException; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -public class VersionTests extends GradleUnitTestCase { - - @Rule - public ExpectedException expectedEx = ExpectedException.none(); - - public void testVersionParsing() { - assertVersionEquals("7.0.1", 7, 0, 1); - assertVersionEquals("7.0.1-alpha2", 7, 0, 1); - assertVersionEquals("5.1.2-rc3", 5, 1, 2); - assertVersionEquals("6.1.2-SNAPSHOT", 6, 1, 2); - assertVersionEquals("6.1.2-beta1-SNAPSHOT", 6, 1, 2); - assertVersionEquals("17.03.11", 17, 3, 11); - } - - public void testRelaxedVersionParsing() { - assertVersionEquals("6.1.2", 6, 1, 2, Version.Mode.RELAXED); - assertVersionEquals("6.1.2-SNAPSHOT", 6, 1, 2, Version.Mode.RELAXED); - assertVersionEquals("6.1.2-beta1-SNAPSHOT", 6, 1, 2, Version.Mode.RELAXED); - assertVersionEquals("6.1.2-foo", 6, 1, 2, Version.Mode.RELAXED); - assertVersionEquals("6.1.2-foo-bar", 6, 1, 2, Version.Mode.RELAXED); - assertVersionEquals("16.01.22", 16, 1, 22, Version.Mode.RELAXED); - } - - public void testCompareWithStringVersions() { - // 1.10.2 is now rebased to OpenSearch version; so this needs to report - assertTrue("OpenSearch 1.10.20 is not interpreted as after Legacy 2.0.0", Version.fromString("1.10.20").after("2.0.0")); - assertTrue( - "7.0.0-alpha1 should be equal to 7.0.0-alpha1", - Version.fromString("7.0.0-alpha1").equals(Version.fromString("7.0.0-alpha1")) - ); - assertTrue( - "7.0.0-SNAPSHOT should be equal to 7.0.0-SNAPSHOT", - Version.fromString("7.0.0-SNAPSHOT").equals(Version.fromString("7.0.0-SNAPSHOT")) - ); - } - - public void testCollections() { - assertTrue( - Arrays.asList( - Version.fromString("5.2.0"), - Version.fromString("5.2.1-SNAPSHOT"), - Version.fromString("6.0.0"), - Version.fromString("6.0.1"), - Version.fromString("6.1.0") - ).containsAll(Arrays.asList(Version.fromString("6.0.1"), Version.fromString("5.2.1-SNAPSHOT"))) - ); - Set versions = new HashSet<>(); - versions.addAll( - Arrays.asList( - Version.fromString("5.2.0"), - Version.fromString("5.2.1-SNAPSHOT"), - Version.fromString("6.0.0"), - Version.fromString("6.0.1"), - Version.fromString("6.1.0") - ) - ); - Set subset = new HashSet<>(); - subset.addAll(Arrays.asList(Version.fromString("6.0.1"), Version.fromString("5.2.1-SNAPSHOT"))); - assertTrue(versions.containsAll(subset)); - } - - public void testToString() { - assertEquals("7.0.1", new Version(7, 0, 1).toString()); - } - - public void testCompareVersions() { - assertEquals(0, new Version(7, 0, 0).compareTo(new Version(7, 0, 0))); - assertOrder(Version.fromString("19.0.1"), Version.fromString("20.0.3")); - } - - public void testExceptionEmpty() { - expectedEx.expect(IllegalArgumentException.class); - expectedEx.expectMessage("Invalid version format"); - Version.fromString(""); - } - - public void testExceptionSyntax() { - expectedEx.expect(IllegalArgumentException.class); - expectedEx.expectMessage("Invalid version format"); - Version.fromString("foo.bar.baz"); - } - - private void assertOrder(Version smaller, Version bigger) { - assertEquals(smaller + " should be smaller than " + bigger, -1, smaller.compareTo(bigger)); - } - - private void assertVersionEquals(String stringVersion, int major, int minor, int revision) { - assertVersionEquals(stringVersion, major, minor, revision, Version.Mode.STRICT); - } - - private void assertVersionEquals(String stringVersion, int major, int minor, int revision, Version.Mode mode) { - Version version = Version.fromString(stringVersion, mode); - assertEquals(major, version.getMajor()); - assertEquals(minor, version.getMinor()); - assertEquals(revision, version.getRevision()); - } - -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/doc/RestTestFromSnippetsTaskTests.java b/buildSrc/src/test/java/org/opensearch/gradle/doc/RestTestFromSnippetsTaskTests.java deleted file mode 100644 index 79b79f91c9363..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/doc/RestTestFromSnippetsTaskTests.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.doc; - -import org.opensearch.gradle.test.GradleUnitTestCase; -import org.gradle.api.InvalidUserDataException; -import org.junit.Rule; -import org.junit.rules.ExpectedException; - -import static org.opensearch.gradle.doc.RestTestsFromSnippetsTask.replaceBlockQuote; - -public class RestTestFromSnippetsTaskTests extends GradleUnitTestCase { - @Rule - public ExpectedException expectedEx = ExpectedException.none(); - - public void testInvalidBlockQuote() { - String input = "\"foo\": \"\"\"bar\""; - expectedEx.expect(InvalidUserDataException.class); - expectedEx.expectMessage("Invalid block quote starting at 7 in:\n" + input); - replaceBlockQuote(input); - } - - public void testSimpleBlockQuote() { - assertEquals("\"foo\": \"bort baz\"", replaceBlockQuote("\"foo\": \"\"\"bort baz\"\"\"")); - } - - public void testMultipleBlockQuotes() { - assertEquals( - "\"foo\": \"bort baz\", \"bar\": \"other\"", - replaceBlockQuote("\"foo\": \"\"\"bort baz\"\"\", \"bar\": \"\"\"other\"\"\"") - ); - } - - public void testEscapingInBlockQuote() { - assertEquals("\"foo\": \"bort\\\" baz\"", replaceBlockQuote("\"foo\": \"\"\"bort\" baz\"\"\"")); - assertEquals("\"foo\": \"bort\\n baz\"", replaceBlockQuote("\"foo\": \"\"\"bort\n baz\"\"\"")); - } - - public void testIsDocWriteRequest() { - assertTrue((boolean) RestTestsFromSnippetsTask.shouldAddShardFailureCheck("doc-index/_search")); - assertFalse((boolean) RestTestsFromSnippetsTask.shouldAddShardFailureCheck("_cat")); - } -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/docker/DockerSupportServiceTests.java b/buildSrc/src/test/java/org/opensearch/gradle/docker/DockerSupportServiceTests.java deleted file mode 100644 index e2acf3c087ecc..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/docker/DockerSupportServiceTests.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.docker; - -import org.opensearch.gradle.test.GradleIntegrationTestCase; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.opensearch.gradle.docker.DockerSupportService.deriveId; -import static org.opensearch.gradle.docker.DockerSupportService.parseOsRelease; -import static org.hamcrest.CoreMatchers.equalTo; - -public class DockerSupportServiceTests extends GradleIntegrationTestCase { - - public void testParseOsReleaseOnOracle() { - final List lines = Arrays.asList( - "NAME=\"Oracle Linux Server\"", - "VERSION=\"6.10\"", - "ID=\"ol\"", - "VERSION_ID=\"6.10\"", - "PRETTY_NAME=\"Oracle Linux Server 6.10\"", - "ANSI_COLOR=\"0;31\"", - "CPE_NAME=\"cpe:/o:oracle:linux:6:10:server\"", - "HOME_URL" + "=\"https://linux.oracle.com/\"", - "BUG_REPORT_URL=\"https://bugzilla.oracle.com/\"", - "", - "ORACLE_BUGZILLA_PRODUCT" + "=\"Oracle Linux 6\"", - "ORACLE_BUGZILLA_PRODUCT_VERSION=6.10", - "ORACLE_SUPPORT_PRODUCT=\"Oracle Linux\"", - "ORACLE_SUPPORT_PRODUCT_VERSION=6.10" - ); - - final Map results = parseOsRelease(lines); - - final Map expected = new HashMap<>(); - expected.put("ANSI_COLOR", "0;31"); - expected.put("BUG_REPORT_URL", "https://bugzilla.oracle.com/"); - expected.put("CPE_NAME", "cpe:/o:oracle:linux:6:10:server"); - expected.put("HOME_URL" + "", "https://linux.oracle.com/"); - expected.put("ID", "ol"); - expected.put("NAME", "oracle linux server"); - expected.put("ORACLE_BUGZILLA_PRODUCT" + "", "oracle linux 6"); - expected.put("ORACLE_BUGZILLA_PRODUCT_VERSION", "6.10"); - expected.put("ORACLE_SUPPORT_PRODUCT", "oracle linux"); - expected.put("ORACLE_SUPPORT_PRODUCT_VERSION", "6.10"); - expected.put("PRETTY_NAME", "oracle linux server 6.10"); - expected.put("VERSION", "6.10"); - expected.put("VERSION_ID", "6.10"); - - assertThat(expected, equalTo(results)); - } - - /** - * Trailing whitespace should be removed - */ - public void testRemoveTrailingWhitespace() { - final List lines = Arrays.asList("NAME=\"Oracle Linux Server\" "); - - final Map results = parseOsRelease(lines); - - final Map expected = new HashMap() { - { - put("NAME", "oracle linux server"); - } - }; - - assertThat(expected, equalTo(results)); - } - - /** - * Comments should be removed - */ - public void testRemoveComments() { - final List lines = Arrays.asList("# A comment", "NAME=\"Oracle Linux Server\""); - - final Map results = parseOsRelease(lines); - - final Map expected = new HashMap() { - { - put("NAME", "oracle linux server"); - } - }; - - assertThat(expected, equalTo(results)); - } - - public void testDeriveIdOnOracle() { - final Map osRelease = new HashMap<>(); - osRelease.put("ID", "ol"); - osRelease.put("VERSION_ID", "6.10"); - - assertThat("ol-6.10", equalTo(deriveId(osRelease))); - } -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/http/WaitForHttpResourceTests.java b/buildSrc/src/test/java/org/opensearch/gradle/http/WaitForHttpResourceTests.java deleted file mode 100644 index 347d7f31f6382..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/http/WaitForHttpResourceTests.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.http; - -import org.opensearch.gradle.test.GradleUnitTestCase; - -import java.io.File; -import java.net.URL; -import java.security.KeyStore; -import java.security.cert.Certificate; -import java.security.cert.X509Certificate; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.notNullValue; - -public class WaitForHttpResourceTests extends GradleUnitTestCase { - - public void testBuildTrustStoreFromFile() throws Exception { - final WaitForHttpResource http = new WaitForHttpResource(new URL("https://localhost/")); - final URL ca = getClass().getResource("/ca.p12"); - assertThat(ca, notNullValue()); - http.setTrustStoreFile(new File(ca.getPath())); - http.setTrustStorePassword("password"); - final KeyStore store = http.buildTrustStore(); - final Certificate certificate = store.getCertificate("ca"); - assertThat(certificate, notNullValue()); - assertThat(certificate, instanceOf(X509Certificate.class)); - assertThat(((X509Certificate) certificate).getSubjectDN().toString(), equalTo("CN=Elastic Certificate Tool Autogenerated CA")); - } - - public void testBuildTrustStoreFromCA() throws Exception { - final WaitForHttpResource http = new WaitForHttpResource(new URL("https://localhost/")); - final URL ca = getClass().getResource("/ca.pem"); - assertThat(ca, notNullValue()); - http.setCertificateAuthorities(new File(ca.getPath())); - final KeyStore store = http.buildTrustStore(); - final Certificate certificate = store.getCertificate("cert-0"); - assertThat(certificate, notNullValue()); - assertThat(certificate, instanceOf(X509Certificate.class)); - assertThat(((X509Certificate) certificate).getSubjectDN().toString(), equalTo("CN=Elastic Certificate Tool Autogenerated CA")); - } -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/plugin/PluginBuildPluginTests.java b/buildSrc/src/test/java/org/opensearch/gradle/plugin/PluginBuildPluginTests.java deleted file mode 100644 index 9ed0e3e494992..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/plugin/PluginBuildPluginTests.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.plugin; - -import org.opensearch.gradle.BwcVersions; -import org.opensearch.gradle.test.GradleUnitTestCase; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.internal.project.ProjectInternal; -import org.gradle.testfixtures.ProjectBuilder; -import org.junit.Before; -import org.junit.Ignore; -import org.mockito.Mockito; - -import java.util.stream.Collectors; - -public class PluginBuildPluginTests extends GradleUnitTestCase { - - private Project project; - - @Before - public void setUp() throws Exception { - project = ProjectBuilder.builder().withName(getClass().getName()).build(); - } - - public void testApply() { - // FIXME: distribution download plugin doesn't support running externally - project.getExtensions().getExtraProperties().set("bwcVersions", Mockito.mock(BwcVersions.class)); - project.getPlugins().apply(PluginBuildPlugin.class); - - assertNotNull( - "plugin extension created with the right name", - project.getExtensions().findByName(PluginBuildPlugin.PLUGIN_EXTENSION_NAME) - ); - assertNotNull("plugin extensions has the right type", project.getExtensions().findByType(PluginPropertiesExtension.class)); - - assertNull("plugin should not create the integTest task", project.getTasks().findByName("integTest")); - } - - @Ignore("https://github.com/elastic/elasticsearch/issues/47123") - public void testApplyWithAfterEvaluate() { - project.getExtensions().getExtraProperties().set("bwcVersions", Mockito.mock(BwcVersions.class)); - project.getPlugins().apply(PluginBuildPlugin.class); - PluginPropertiesExtension extension = project.getExtensions().getByType(PluginPropertiesExtension.class); - extension.setNoticeFile(project.file("test.notice")); - extension.setLicenseFile(project.file("test.license")); - extension.setDescription("just a test"); - extension.setClassname(getClass().getName()); - - ((ProjectInternal) project).evaluate(); - - assertNotNull( - "Task to generate notice not created: " + project.getTasks().stream().map(Task::getPath).collect(Collectors.joining(", ")), - project.getTasks().findByName("generateNotice") - ); - } -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/plugin/PluginPropertiesExtensionTests.java b/buildSrc/src/test/java/org/opensearch/gradle/plugin/PluginPropertiesExtensionTests.java deleted file mode 100644 index 35d181b0e2154..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/plugin/PluginPropertiesExtensionTests.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.plugin; - -import org.opensearch.gradle.test.GradleUnitTestCase; -import org.gradle.api.Project; -import org.gradle.api.plugins.JavaPlugin; -import org.gradle.testfixtures.ProjectBuilder; - -public class PluginPropertiesExtensionTests extends GradleUnitTestCase { - - public void testCreatingPluginPropertiesExtensionWithNameAndVersion() { - String projectName = "Test"; - String projectVersion = "5.0"; - - PluginPropertiesExtension pluginPropertiesExtension = new PluginPropertiesExtension( - this.createProject(projectName, projectVersion) - ); - - assertEquals(projectName, pluginPropertiesExtension.getName()); - assertEquals(projectVersion, pluginPropertiesExtension.getVersion()); - } - - public void testCreatingPluginPropertiesExtensionWithNameWithoutVersion() { - String projectName = "Test"; - - PluginPropertiesExtension pluginPropertiesExtension = new PluginPropertiesExtension(this.createProject(projectName, null)); - - assertEquals(projectName, pluginPropertiesExtension.getName()); - assertEquals("unspecified", pluginPropertiesExtension.getVersion()); - } - - private Project createProject(String projectName, String version) { - Project project = ProjectBuilder.builder().withName(projectName).build(); - project.setVersion(version); - - project.getPlugins().apply(JavaPlugin.class); - - return project; - } -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/precommit/DependencyLicensesTaskTests.java b/buildSrc/src/test/java/org/opensearch/gradle/precommit/DependencyLicensesTaskTests.java deleted file mode 100644 index 59f7a807476a0..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/precommit/DependencyLicensesTaskTests.java +++ /dev/null @@ -1,328 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.opensearch.gradle.test.GradleUnitTestCase; -import org.gradle.api.Action; -import org.gradle.api.GradleException; -import org.gradle.api.Project; -import org.gradle.api.artifacts.Dependency; -import org.gradle.api.file.FileCollection; -import org.gradle.api.plugins.JavaPlugin; -import org.gradle.api.tasks.TaskProvider; -import org.gradle.testfixtures.ProjectBuilder; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; -import java.security.NoSuchAlgorithmException; -import java.util.HashMap; -import java.util.Map; - -import static org.hamcrest.CoreMatchers.containsString; - -public class DependencyLicensesTaskTests extends GradleUnitTestCase { - - private static final String PERMISSIVE_LICENSE_TEXT = "Eclipse Public License - v 2.0"; - private static final String STRICT_LICENSE_TEXT = "GNU LESSER GENERAL PUBLIC LICENSE Version 3"; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private UpdateShasTask updateShas; - - private TaskProvider task; - - private Project project; - - private Dependency dependency; - - @Before - public void prepare() { - project = createProject(); - task = createDependencyLicensesTask(project); - updateShas = createUpdateShasTask(project, task); - dependency = project.getDependencies().localGroovy(); - } - - @Test - public void givenProjectWithLicensesDirButNoDependenciesThenShouldThrowException() throws Exception { - expectedException.expect(GradleException.class); - expectedException.expectMessage(containsString("exists, but there are no dependencies")); - - getLicensesDir(project).mkdir(); - task.get().checkDependencies(); - } - - @Test - public void givenProjectWithoutLicensesDirButWithDependenciesThenShouldThrowException() throws Exception { - expectedException.expect(GradleException.class); - expectedException.expectMessage(containsString("does not exist, but there are dependencies")); - - project.getDependencies().add("compile", dependency); - task.get().checkDependencies(); - } - - @Test - public void givenProjectWithoutLicensesDirNorDependenciesThenShouldReturnSilently() throws Exception { - task.get().checkDependencies(); - } - - @Test - public void givenProjectWithDependencyButNoShaFileThenShouldReturnException() throws Exception { - expectedException.expect(GradleException.class); - expectedException.expectMessage(containsString("Missing SHA for ")); - - File licensesDir = getLicensesDir(project); - createFileIn(licensesDir, "groovy-all-LICENSE.txt", PERMISSIVE_LICENSE_TEXT); - createFileIn(licensesDir, "groovy-all-NOTICE.txt", ""); - - project.getDependencies().add("compile", project.getDependencies().localGroovy()); - task.get().checkDependencies(); - } - - @Test - public void givenProjectWithDependencyButNoLicenseFileThenShouldReturnException() throws Exception { - expectedException.expect(GradleException.class); - expectedException.expectMessage(containsString("Missing LICENSE for ")); - - project.getDependencies().add("compile", project.getDependencies().localGroovy()); - - getLicensesDir(project).mkdir(); - updateShas.updateShas(); - task.get().checkDependencies(); - } - - @Test - public void givenProjectWithDependencyButNoNoticeFileThenShouldReturnException() throws Exception { - expectedException.expect(GradleException.class); - expectedException.expectMessage(containsString("Missing NOTICE for ")); - - project.getDependencies().add("compile", dependency); - - createFileIn(getLicensesDir(project), "groovy-all-LICENSE.txt", PERMISSIVE_LICENSE_TEXT); - - updateShas.updateShas(); - task.get().checkDependencies(); - } - - @Test - public void givenProjectWithStrictDependencyButNoSourcesFileThenShouldReturnException() throws Exception { - expectedException.expect(GradleException.class); - expectedException.expectMessage(containsString("Missing SOURCES for ")); - - project.getDependencies().add("compile", dependency); - - createFileIn(getLicensesDir(project), "groovy-all-LICENSE.txt", STRICT_LICENSE_TEXT); - createFileIn(getLicensesDir(project), "groovy-all-NOTICE.txt", ""); - - updateShas.updateShas(); - task.get().checkDependencies(); - } - - @Test - public void givenProjectWithStrictDependencyAndEverythingInOrderThenShouldReturnSilently() throws Exception { - project.getDependencies().add("compile", dependency); - - createFileIn(getLicensesDir(project), "groovy-all-LICENSE.txt", STRICT_LICENSE_TEXT); - createFileIn(getLicensesDir(project), "groovy-all-NOTICE.txt", ""); - createFileIn(getLicensesDir(project), "groovy-all-SOURCES.txt", ""); - - updateShas.updateShas(); - task.get().checkDependencies(); - } - - @Test - public void givenProjectWithDependencyAndEverythingInOrderThenShouldReturnSilently() throws Exception { - project.getDependencies().add("compile", dependency); - - File licensesDir = getLicensesDir(project); - - createAllDefaultDependencyFiles(licensesDir, "groovy-all"); - task.get().checkDependencies(); - } - - @Test - public void givenProjectWithALicenseButWithoutTheDependencyThenShouldThrowException() throws Exception { - expectedException.expect(GradleException.class); - expectedException.expectMessage(containsString("Unused license ")); - - project.getDependencies().add("compile", dependency); - - File licensesDir = getLicensesDir(project); - createAllDefaultDependencyFiles(licensesDir, "groovy-all"); - createFileIn(licensesDir, "non-declared-LICENSE.txt", ""); - - task.get().checkDependencies(); - } - - @Test - public void givenProjectWithANoticeButWithoutTheDependencyThenShouldThrowException() throws Exception { - expectedException.expect(GradleException.class); - expectedException.expectMessage(containsString("Unused notice ")); - - project.getDependencies().add("compile", dependency); - - File licensesDir = getLicensesDir(project); - createAllDefaultDependencyFiles(licensesDir, "groovy-all"); - createFileIn(licensesDir, "non-declared-NOTICE.txt", ""); - - task.get().checkDependencies(); - } - - @Test - public void givenProjectWithAShaButWithoutTheDependencyThenShouldThrowException() throws Exception { - expectedException.expect(GradleException.class); - expectedException.expectMessage(containsString("Unused sha files found: \n")); - - project.getDependencies().add("compile", dependency); - - File licensesDir = getLicensesDir(project); - createAllDefaultDependencyFiles(licensesDir, "groovy-all"); - createFileIn(licensesDir, "non-declared.sha1", ""); - - task.get().checkDependencies(); - } - - @Test - public void givenProjectWithADependencyWithWrongShaThenShouldThrowException() throws Exception { - expectedException.expect(GradleException.class); - expectedException.expectMessage(containsString("SHA has changed! Expected ")); - - project.getDependencies().add("compile", dependency); - - File licensesDir = getLicensesDir(project); - createAllDefaultDependencyFiles(licensesDir, "groovy-all"); - - Path groovySha = Files.list(licensesDir.toPath()).filter(file -> file.toFile().getName().contains("sha")).findFirst().get(); - - Files.write(groovySha, new byte[] { 1 }, StandardOpenOption.CREATE); - - task.get().checkDependencies(); - } - - @Test - public void givenProjectWithADependencyMappingThenShouldReturnSilently() throws Exception { - project.getDependencies().add("compile", dependency); - - File licensesDir = getLicensesDir(project); - createAllDefaultDependencyFiles(licensesDir, "groovy"); - - Map mappings = new HashMap<>(); - mappings.put("from", "groovy-all"); - mappings.put("to", "groovy"); - - task.get().mapping(mappings); - task.get().checkDependencies(); - } - - @Test - public void givenProjectWithAIgnoreShaConfigurationAndNoShaFileThenShouldReturnSilently() throws Exception { - project.getDependencies().add("compile", dependency); - - File licensesDir = getLicensesDir(project); - createFileIn(licensesDir, "groovy-all-LICENSE.txt", PERMISSIVE_LICENSE_TEXT); - createFileIn(licensesDir, "groovy-all-NOTICE.txt", ""); - - task.get().ignoreSha("groovy-all"); - task.get().checkDependencies(); - } - - @Test - public void givenProjectWithoutLicensesDirWhenAskingForShaFilesThenShouldThrowException() { - expectedException.expect(GradleException.class); - expectedException.expectMessage(containsString("isn't a valid directory")); - - task.get().getShaFiles(); - } - - private Project createProject() { - Project project = ProjectBuilder.builder().build(); - project.getPlugins().apply(JavaPlugin.class); - - return project; - } - - private void createAllDefaultDependencyFiles(File licensesDir, String dependencyName) throws IOException, NoSuchAlgorithmException { - createFileIn(licensesDir, dependencyName + "-LICENSE.txt", PERMISSIVE_LICENSE_TEXT); - createFileIn(licensesDir, dependencyName + "-NOTICE.txt", ""); - - updateShas.updateShas(); - } - - private File getLicensesDir(Project project) { - return getFile(project, "licenses"); - } - - private File getFile(Project project, String fileName) { - return project.getProjectDir().toPath().resolve(fileName).toFile(); - } - - private void createFileIn(File parent, String name, String content) throws IOException { - parent.mkdir(); - - Path file = parent.toPath().resolve(name); - file.toFile().createNewFile(); - - Files.write(file, content.getBytes(StandardCharsets.UTF_8)); - } - - private UpdateShasTask createUpdateShasTask(Project project, TaskProvider dependencyLicensesTask) { - UpdateShasTask task = project.getTasks().register("updateShas", UpdateShasTask.class).get(); - - task.setParentTask(dependencyLicensesTask); - return task; - } - - private TaskProvider createDependencyLicensesTask(Project project) { - TaskProvider task = project.getTasks() - .register("dependencyLicenses", DependencyLicensesTask.class, new Action() { - @Override - public void execute(DependencyLicensesTask dependencyLicensesTask) { - dependencyLicensesTask.setDependencies(getDependencies(project)); - } - }); - - return task; - } - - private FileCollection getDependencies(Project project) { - return project.getConfigurations().getByName("compile"); - } -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/precommit/FilePermissionsTaskTests.java b/buildSrc/src/test/java/org/opensearch/gradle/precommit/FilePermissionsTaskTests.java deleted file mode 100644 index f47964dd17a7a..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/precommit/FilePermissionsTaskTests.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import java.io.File; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.util.List; - -import com.carrotsearch.randomizedtesting.RandomizedTest; -import org.apache.tools.ant.taskdefs.condition.Os; -import org.opensearch.gradle.test.GradleUnitTestCase; -import org.gradle.api.GradleException; -import org.gradle.api.Project; -import org.gradle.api.plugins.JavaPlugin; -import org.gradle.testfixtures.ProjectBuilder; -import org.junit.Assert; - -public class FilePermissionsTaskTests extends GradleUnitTestCase { - - public void testCheckPermissionsWhenAnExecutableFileExists() throws Exception { - RandomizedTest.assumeFalse("Functionality is Unix specific", Os.isFamily(Os.FAMILY_WINDOWS)); - - Project project = createProject(); - - FilePermissionsTask filePermissionsTask = createTask(project); - - File file = new File(project.getProjectDir(), "src/main/java/Code.java"); - file.getParentFile().mkdirs(); - file.createNewFile(); - file.setExecutable(true); - - try { - filePermissionsTask.checkInvalidPermissions(); - Assert.fail("the check should have failed because of the executable file permission"); - } catch (GradleException e) { - assertTrue(e.getMessage().startsWith("Found invalid file permissions")); - } - file.delete(); - } - - public void testCheckPermissionsWhenNoFileExists() throws Exception { - RandomizedTest.assumeFalse("Functionality is Unix specific", Os.isFamily(Os.FAMILY_WINDOWS)); - - Project project = createProject(); - - FilePermissionsTask filePermissionsTask = createTask(project); - - filePermissionsTask.checkInvalidPermissions(); - - File outputMarker = new File(project.getBuildDir(), "markers/filePermissions"); - List result = Files.readAllLines(outputMarker.toPath(), Charset.forName("UTF-8")); - assertEquals("done", result.get(0)); - } - - public void testCheckPermissionsWhenNoExecutableFileExists() throws Exception { - RandomizedTest.assumeFalse("Functionality is Unix specific", Os.isFamily(Os.FAMILY_WINDOWS)); - - Project project = createProject(); - - FilePermissionsTask filePermissionsTask = createTask(project); - - File file = new File(project.getProjectDir(), "src/main/java/Code.java"); - file.getParentFile().mkdirs(); - file.createNewFile(); - - filePermissionsTask.checkInvalidPermissions(); - - File outputMarker = new File(project.getBuildDir(), "markers/filePermissions"); - List result = Files.readAllLines(outputMarker.toPath(), Charset.forName("UTF-8")); - assertEquals("done", result.get(0)); - - file.delete(); - } - - private Project createProject() { - Project project = ProjectBuilder.builder().build(); - project.getPlugins().apply(JavaPlugin.class); - return project; - } - - private FilePermissionsTask createTask(Project project) { - return project.getTasks().create("filePermissionsTask", FilePermissionsTask.class); - } - -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/precommit/ForbiddenPatternsTaskTests.java b/buildSrc/src/test/java/org/opensearch/gradle/precommit/ForbiddenPatternsTaskTests.java deleted file mode 100644 index ea4db8954bca4..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/precommit/ForbiddenPatternsTaskTests.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.opensearch.gradle.test.GradleUnitTestCase; -import org.gradle.api.GradleException; -import org.gradle.api.Project; -import org.gradle.api.plugins.JavaPlugin; -import org.gradle.testfixtures.ProjectBuilder; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -public class ForbiddenPatternsTaskTests extends GradleUnitTestCase { - - public void testCheckInvalidPatternsWhenNoSourceFilesExist() throws Exception { - Project project = createProject(); - ForbiddenPatternsTask task = createTask(project); - - checkAndAssertTaskSuccessful(task); - } - - public void testCheckInvalidPatternsWhenSourceFilesExistNoViolation() throws Exception { - Project project = createProject(); - ForbiddenPatternsTask task = createTask(project); - - writeSourceFile(project, "src/main/java/Foo.java", "public void bar() {}"); - checkAndAssertTaskSuccessful(task); - } - - public void testCheckInvalidPatternsWhenSourceFilesExistHavingTab() throws Exception { - Project project = createProject(); - ForbiddenPatternsTask task = createTask(project); - - writeSourceFile(project, "src/main/java/Bar.java", "\tpublic void bar() {}"); - checkAndAssertTaskThrowsException(task); - } - - public void testCheckInvalidPatternsWithCustomRule() throws Exception { - Map rule = new HashMap<>(); - rule.put("name", "TODO comments are not allowed"); - rule.put("pattern", "\\/\\/.*(?i)TODO"); - - Project project = createProject(); - ForbiddenPatternsTask task = createTask(project); - task.rule(rule); - - writeSourceFile(project, "src/main/java/Moot.java", "GOOD LINE", "//todo", "// some stuff, toDo"); - checkAndAssertTaskThrowsException(task); - } - - public void testCheckInvalidPatternsWhenExcludingFiles() throws Exception { - Project project = createProject(); - ForbiddenPatternsTask task = createTask(project); - task.exclude("**/*.java"); - - writeSourceFile(project, "src/main/java/FooBarMoot.java", "\t"); - checkAndAssertTaskSuccessful(task); - } - - private Project createProject() { - Project project = ProjectBuilder.builder().build(); - project.getPlugins().apply(JavaPlugin.class); - - return project; - } - - private ForbiddenPatternsTask createTask(Project project) { - return project.getTasks().create("forbiddenPatterns", ForbiddenPatternsTask.class); - } - - private ForbiddenPatternsTask createTask(Project project, String taskName) { - return project.getTasks().create(taskName, ForbiddenPatternsTask.class); - } - - private void writeSourceFile(Project project, String name, String... lines) throws IOException { - File file = new File(project.getProjectDir(), name); - file.getParentFile().mkdirs(); - file.createNewFile(); - - if (lines.length != 0) Files.write(file.toPath(), Arrays.asList(lines), StandardCharsets.UTF_8); - } - - private void checkAndAssertTaskSuccessful(ForbiddenPatternsTask task) throws IOException { - task.checkInvalidPatterns(); - assertTaskSuccessful(task.getProject(), task.getName()); - } - - private void checkAndAssertTaskThrowsException(ForbiddenPatternsTask task) throws IOException { - try { - task.checkInvalidPatterns(); - fail("GradleException was expected to be thrown in this case!"); - } catch (GradleException e) { - assertTrue(e.getMessage().startsWith("Found invalid patterns")); - } - } - - private void assertTaskSuccessful(Project project, String fileName) throws IOException { - File outputMarker = new File(project.getBuildDir(), "markers/" + fileName); - assertTrue(outputMarker.exists()); - - Optional result = Files.readAllLines(outputMarker.toPath(), StandardCharsets.UTF_8).stream().findFirst(); - assertTrue(result.isPresent()); - assertEquals("done", result.get()); - } -} diff --git a/buildSrc/src/test/java/org/opensearch/gradle/precommit/UpdateShasTaskTests.java b/buildSrc/src/test/java/org/opensearch/gradle/precommit/UpdateShasTaskTests.java deleted file mode 100644 index d1056f15ba8f5..0000000000000 --- a/buildSrc/src/test/java/org/opensearch/gradle/precommit/UpdateShasTaskTests.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.precommit; - -import org.apache.commons.io.FileUtils; -import org.opensearch.gradle.test.GradleUnitTestCase; -import org.gradle.api.Action; -import org.gradle.api.GradleException; -import org.gradle.api.Project; -import org.gradle.api.artifacts.Dependency; -import org.gradle.api.file.FileCollection; -import org.gradle.api.plugins.JavaPlugin; -import org.gradle.api.tasks.TaskProvider; -import org.gradle.testfixtures.ProjectBuilder; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; -import java.security.NoSuchAlgorithmException; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.equalTo; - -public class UpdateShasTaskTests extends GradleUnitTestCase { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private UpdateShasTask task; - - private Project project; - - private Dependency dependency; - - @Before - public void prepare() throws IOException { - project = createProject(); - task = createUpdateShasTask(project); - dependency = project.getDependencies().localGroovy(); - - } - - @Test - public void whenDependencyDoesntExistThenShouldDeleteDependencySha() throws IOException, NoSuchAlgorithmException { - - File unusedSha = createFileIn(getLicensesDir(project), "test.sha1", ""); - task.updateShas(); - - assertFalse(unusedSha.exists()); - } - - @Test - public void whenDependencyExistsButShaNotThenShouldCreateNewShaFile() throws IOException, NoSuchAlgorithmException { - project.getDependencies().add("compile", dependency); - - getLicensesDir(project).mkdir(); - task.updateShas(); - - assertTrue( - "Expected a sha file to exist with a name prefix of 'groovy-", - Files.list(getLicensesDir(project).toPath()).anyMatch(sha -> sha.toFile().getName().startsWith("groovy-")) - ); - } - - @Test - public void whenDependencyAndWrongShaExistsThenShouldNotOverwriteShaFile() throws IOException, NoSuchAlgorithmException { - project.getDependencies().add("compile", dependency); - - File groovyJar = task.getParentTask().getDependencies().getFiles().iterator().next(); - String groovyShaName = groovyJar.getName() + ".sha1"; - - File groovySha = createFileIn(getLicensesDir(project), groovyShaName, "content"); - task.updateShas(); - - assertThat(FileUtils.readFileToString(groovySha), equalTo("content")); - } - - @Test - public void whenLicensesDirDoesntExistThenShouldThrowException() throws IOException, NoSuchAlgorithmException { - expectedException.expect(GradleException.class); - expectedException.expectMessage(containsString("isn't a valid directory")); - - task.updateShas(); - } - - private Project createProject() { - Project project = ProjectBuilder.builder().build(); - project.getPlugins().apply(JavaPlugin.class); - - return project; - } - - private File getLicensesDir(Project project) { - return getFile(project, "licenses"); - } - - private File getFile(Project project, String fileName) { - return project.getProjectDir().toPath().resolve(fileName).toFile(); - } - - private File createFileIn(File parent, String name, String content) throws IOException { - parent.mkdir(); - - Path path = parent.toPath().resolve(name); - File file = path.toFile(); - - Files.write(path, content.getBytes(), StandardOpenOption.CREATE); - - return file; - } - - private UpdateShasTask createUpdateShasTask(Project project) { - UpdateShasTask task = project.getTasks().register("updateShas", UpdateShasTask.class).get(); - - task.setParentTask(createDependencyLicensesTask(project)); - return task; - } - - private TaskProvider createDependencyLicensesTask(Project project) { - TaskProvider task = project.getTasks() - .register("dependencyLicenses", DependencyLicensesTask.class, new Action() { - @Override - public void execute(DependencyLicensesTask dependencyLicensesTask) { - dependencyLicensesTask.setDependencies(getDependencies(project)); - } - }); - - return task; - } - - private FileCollection getDependencies(Project project) { - return project.getConfigurations().getByName("compile"); - } -} diff --git a/buildSrc/src/test/resources/ca.p12 b/buildSrc/src/test/resources/ca.p12 deleted file mode 100644 index cc44494515b9f..0000000000000 Binary files a/buildSrc/src/test/resources/ca.p12 and /dev/null differ diff --git a/buildSrc/src/test/resources/ca.pem b/buildSrc/src/test/resources/ca.pem deleted file mode 100644 index 8dda1767e4838..0000000000000 --- a/buildSrc/src/test/resources/ca.pem +++ /dev/null @@ -1,25 +0,0 @@ -Bag Attributes - friendlyName: ca - localKeyID: 54 69 6D 65 20 31 35 35 33 37 34 33 38 39 30 38 33 35 -subject=/CN=Elastic Certificate Tool Autogenerated CA -issuer=/CN=Elastic Certificate Tool Autogenerated CA ------BEGIN CERTIFICATE----- -MIIDSjCCAjKgAwIBAgIVAMQMmDRcXfXLaTp6ep1H8rC3tOrwMA0GCSqGSIb3DQEB -CwUAMDQxMjAwBgNVBAMTKUVsYXN0aWMgQ2VydGlmaWNhdGUgVG9vbCBBdXRvZ2Vu -ZXJhdGVkIENBMB4XDTE5MDMyODAzMzEyNloXDTIyMDMyNzAzMzEyNlowNDEyMDAG -A1UEAxMpRWxhc3RpYyBDZXJ0aWZpY2F0ZSBUb29sIEF1dG9nZW5lcmF0ZWQgQ0Ew -ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDT73N6JZeBPyzahc0aNcra -BpUROVGB9wXQqf8JeU4GtH+1qfqUKYKUJTe/DZWc+5Qz1WAKGZEvBySAlgbuncuq -VpLzWxpEui1vRW8JB3gjZgeY3vfErrEWWr95YM0e8rWu4AoAchzqsrG0/+po2eui -cN+8hI6jRKiBv/ZeQqja6KZ8y4Wt4VaNVL53+I7+eWA/aposu6/piUg2wZ/FNhVK -hypcJwDdp3fQaugtPj3y76303jTRgutgd3rtWFuy3MCDLfs3mSQUjO10s93zwLdC -XokyIywijS5CpO8mEuDRu9rb5J1DzwUpUfk+GMObb6rHjFKzSqnM3s+nasypQQ9L -AgMBAAGjUzBRMB0GA1UdDgQWBBQZEW88R95zSzO2tLseEWgI7ugvLzAfBgNVHSME -GDAWgBQZEW88R95zSzO2tLseEWgI7ugvLzAPBgNVHRMBAf8EBTADAQH/MA0GCSqG -SIb3DQEBCwUAA4IBAQBEJN0UbL77usVnzIvxKa3GpLBgJQAZtD1ifZppC4w46Bul -1G7Fdc+XMbzZlI4K6cWEdd5dfEssKA8btEtRzdNOqgggBpqrUU0mNlQ+vC22XORU -ykHAu2TsRwoHmuxkd9Et/QyuTFXR4fTiU8rsJuLFOgn+RdEblA0J0gJeIqdWI5Z1 -z13OyZEl6BCQFyrntu2eERxaHEfsJOSBZE4RcecnLNGhIJBXE0Pk4iTiViJF/h7d -+kUUegKx0qewZif2eEZgrz12Vuen9a6bh2i2pNS95vABVVMr8uB+J1BGkNA5YT7J -qtZA2tN//Evng7YDiR+KkB1kvXVZVIi2WPDLD/zu ------END CERTIFICATE----- diff --git a/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/BaseTestCase.java b/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/BaseTestCase.java deleted file mode 100644 index 8e06a1cad0241..0000000000000 --- a/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/BaseTestCase.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test; - -import com.carrotsearch.randomizedtesting.JUnit4MethodProvider; -import com.carrotsearch.randomizedtesting.RandomizedRunner; -import com.carrotsearch.randomizedtesting.annotations.TestMethodProviders; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering; -import junit.framework.AssertionFailedError; -import org.junit.Assert; -import org.junit.runner.RunWith; - -@RunWith(RandomizedRunner.class) -@TestMethodProviders({ JUnit4MethodProvider.class, JUnit3MethodProvider.class }) -@ThreadLeakLingering(linger = 5000) // wait for "Connection worker" to die -public abstract class BaseTestCase extends Assert { - - // add expectThrows from junit 5 - @FunctionalInterface - public interface ThrowingRunnable { - void run() throws Throwable; - } - - public static T expectThrows(Class expectedType, ThrowingRunnable runnable) { - try { - runnable.run(); - } catch (Throwable e) { - if (expectedType.isInstance(e)) { - return expectedType.cast(e); - } - AssertionFailedError assertion = new AssertionFailedError( - "Unexpected exception type, expected " + expectedType.getSimpleName() + " but got " + e - ); - assertion.initCause(e); - throw assertion; - } - throw new AssertionFailedError("Expected exception " + expectedType.getSimpleName() + " but no exception was thrown"); - } -} diff --git a/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/GradleIntegrationTestCase.java b/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/GradleIntegrationTestCase.java deleted file mode 100644 index dfdee35e783fd..0000000000000 --- a/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/GradleIntegrationTestCase.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test; - -import org.gradle.testkit.runner.BuildResult; -import org.gradle.testkit.runner.BuildTask; -import org.gradle.testkit.runner.GradleRunner; -import org.gradle.testkit.runner.TaskOutcome; -import org.junit.Rule; -import org.junit.rules.TemporaryFolder; - -import java.io.File; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.lang.management.ManagementFactory; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static org.hamcrest.CoreMatchers.containsString; - -public abstract class GradleIntegrationTestCase extends GradleUnitTestCase { - - @Rule - public TemporaryFolder testkitTmpDir = new TemporaryFolder(); - - protected File getProjectDir(String name) { - File root = new File("src/testKit/"); - if (root.exists() == false) { - throw new RuntimeException( - "Could not find resources dir for integration tests. " - + "Note that these tests can only be ran by Gradle and are not currently supported by the IDE" - ); - } - return new File(root, name).getAbsoluteFile(); - } - - protected GradleRunner getGradleRunner(String sampleProject) { - File testkit; - try { - testkit = testkitTmpDir.newFolder(); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - return GradleRunner.create() - .withProjectDir(getProjectDir(sampleProject)) - .withPluginClasspath() - .withTestKitDir(testkit) - .withDebug(ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("-agentlib:jdwp") > 0); - } - - protected File getBuildDir(String name) { - return new File(getProjectDir(name), "build"); - } - - protected void assertOutputContains(String output, String... lines) { - for (String line : lines) { - assertOutputContains(output, line); - } - List index = Stream.of(lines).map(line -> output.indexOf(line)).collect(Collectors.toList()); - if (index.equals(index.stream().sorted().collect(Collectors.toList())) == false) { - fail( - "Expected the following lines to appear in this order:\n" - + Stream.of(lines).map(line -> " - `" + line + "`").collect(Collectors.joining("\n")) - + "\nTBut the order was different. Output is:\n\n```" - + output - + "\n```\n" - ); - } - } - - protected void assertOutputContains(String output, Set lines) { - for (String line : lines) { - assertOutputContains(output, line); - } - } - - protected void assertOutputContains(String output, String line) { - assertThat("Expected the following line in output:\n\n" + line + "\n\nOutput is:\n" + output, output, containsString(line)); - } - - protected void assertOutputDoesNotContain(String output, String line) { - assertFalse("Expected the following line not to be in output:\n\n" + line + "\n\nOutput is:\n" + output, output.contains(line)); - } - - protected void assertOutputDoesNotContain(String output, String... lines) { - for (String line : lines) { - assertOutputDoesNotContain(line); - } - } - - protected void assertTaskFailed(BuildResult result, String taskName) { - assertTaskOutcome(result, taskName, TaskOutcome.FAILED); - } - - protected void assertTaskSuccessful(BuildResult result, String... taskNames) { - for (String taskName : taskNames) { - assertTaskOutcome(result, taskName, TaskOutcome.SUCCESS); - } - } - - protected void assertTaskSkipped(BuildResult result, String... taskNames) { - for (String taskName : taskNames) { - assertTaskOutcome(result, taskName, TaskOutcome.SKIPPED); - } - } - - protected void assertTaskNoSource(BuildResult result, String... taskNames) { - for (String taskName : taskNames) { - assertTaskOutcome(result, taskName, TaskOutcome.NO_SOURCE); - } - } - - private void assertTaskOutcome(BuildResult result, String taskName, TaskOutcome taskOutcome) { - BuildTask task = result.task(taskName); - if (task == null) { - fail( - "Expected task `" + taskName + "` to be " + taskOutcome + ", but it did not run" + "\n\nOutput is:\n" + result.getOutput() - ); - } - assertEquals( - "Expected task `" - + taskName - + "` to be " - + taskOutcome - + " but it was: " - + task.getOutcome() - + "\n\nOutput is:\n" - + result.getOutput(), - taskOutcome, - task.getOutcome() - ); - } - - protected void assertTaskUpToDate(BuildResult result, String... taskNames) { - for (String taskName : taskNames) { - BuildTask task = result.task(taskName); - if (task == null) { - fail("Expected task `" + taskName + "` to be up-to-date, but it did not run"); - } - assertEquals( - "Expected task to be up to date but it was: " + task.getOutcome() + "\n\nOutput is:\n" + result.getOutput(), - TaskOutcome.UP_TO_DATE, - task.getOutcome() - ); - } - } - - protected void assertNoDeprecationWarning(BuildResult result) { - assertOutputDoesNotContain(result.getOutput(), "Deprecated Gradle features were used in this build"); - } - - protected void assertBuildFileExists(BuildResult result, String projectName, String path) { - Path absPath = getBuildDir(projectName).toPath().resolve(path); - assertTrue( - result.getOutput() + "\n\nExpected `" + absPath + "` to exists but it did not" + "\n\nOutput is:\n" + result.getOutput(), - Files.exists(absPath) - ); - } - - protected void assertBuildFileDoesNotExists(BuildResult result, String projectName, String path) { - Path absPath = getBuildDir(projectName).toPath().resolve(path); - assertFalse( - result.getOutput() + "\n\nExpected `" + absPath + "` bo to exists but it did" + "\n\nOutput is:\n" + result.getOutput(), - Files.exists(absPath) - ); - } - - protected String getLocalTestDownloadsPath() { - return getLocalTestPath("test.local-test-downloads-path"); - } - - private String getLocalTestPath(String propertyName) { - String property = System.getProperty(propertyName); - Objects.requireNonNull(property, propertyName + " not passed to tests"); - File file = new File(property); - assertTrue("Expected " + property + " to exist, but it did not!", file.exists()); - if (File.separator.equals("\\")) { - // Use / on Windows too, the build script is not happy with \ - return file.getAbsolutePath().replace(File.separator, "/"); - } else { - return file.getAbsolutePath(); - } - } - - public void assertOutputOnlyOnce(String output, String... text) { - for (String each : text) { - int i = output.indexOf(each); - if (i == -1) { - fail("Expected \n```" + each + "```\nto appear at most once, but it didn't at all.\n\nOutout is:\n" + output); - } - if (output.indexOf(each) != output.lastIndexOf(each)) { - fail("Expected `" + each + "` to appear at most once, but it did multiple times.\n\nOutout is:\n" + output); - } - } - } -} diff --git a/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/GradleThreadsFilter.java b/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/GradleThreadsFilter.java deleted file mode 100644 index 8f930bacdfa08..0000000000000 --- a/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/GradleThreadsFilter.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test; - -import com.carrotsearch.randomizedtesting.ThreadFilter; - -/** - * Filter out threads controlled by gradle that may be created during unit tests. - * - * Currently this includes pooled threads for Exec as well as file system event watcher threads. - */ -public class GradleThreadsFilter implements ThreadFilter { - - @Override - public boolean reject(Thread t) { - return t.getName().startsWith("Exec process") || t.getName().startsWith("File watcher consumer"); - } -} diff --git a/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/GradleUnitTestCase.java b/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/GradleUnitTestCase.java deleted file mode 100644 index a50a14a0ea932..0000000000000 --- a/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/GradleUnitTestCase.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test; - -import com.carrotsearch.randomizedtesting.JUnit4MethodProvider; -import com.carrotsearch.randomizedtesting.RandomizedRunner; -import com.carrotsearch.randomizedtesting.annotations.TestMethodProviders; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; -import org.junit.runner.RunWith; - -@RunWith(RandomizedRunner.class) -@TestMethodProviders({ JUnit4MethodProvider.class, JUnit3MethodProvider.class }) -@ThreadLeakFilters(defaultFilters = true, filters = { GradleThreadsFilter.class }) -public abstract class GradleUnitTestCase extends BaseTestCase {} diff --git a/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/JUnit3MethodProvider.java b/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/JUnit3MethodProvider.java deleted file mode 100644 index 0c01b6d519d62..0000000000000 --- a/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/JUnit3MethodProvider.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test; - -import com.carrotsearch.randomizedtesting.ClassModel; -import com.carrotsearch.randomizedtesting.ClassModel.MethodModel; -import com.carrotsearch.randomizedtesting.TestMethodProvider; - -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; - -/** - * Backwards compatible test* method provider (public, non-static). - * - * copy of org.apache.lucene.util.LuceneJUnit3MethodProvider to avoid a dependency between build and test fw. - */ -public final class JUnit3MethodProvider implements TestMethodProvider { - @Override - public Collection getTestMethods(Class suiteClass, ClassModel classModel) { - Map methods = classModel.getMethods(); - ArrayList result = new ArrayList<>(); - for (MethodModel mm : methods.values()) { - // Skip any methods that have overrieds/ shadows. - if (mm.getDown() != null) continue; - - Method m = mm.element; - if (m.getName().startsWith("test") - && Modifier.isPublic(m.getModifiers()) - && !Modifier.isStatic(m.getModifiers()) - && m.getParameterTypes().length == 0) { - result.add(m); - } - } - return result; - } -} diff --git a/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/TestClasspathUtils.java b/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/TestClasspathUtils.java deleted file mode 100644 index ec9a5fb157ccc..0000000000000 --- a/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/TestClasspathUtils.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.test; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; - -import static org.junit.Assert.fail; - -public class TestClasspathUtils { - - public static void setupJarJdkClasspath(File projectRoot) { - try { - URL originLocation = TestClasspathUtils.class.getClassLoader() - .loadClass("org.opensearch.bootstrap.JdkJarHellCheck") - .getProtectionDomain() - .getCodeSource() - .getLocation(); - File targetFile = new File( - projectRoot, - "sample_jars/build/testrepo/org/opensearch/opensearch-core/current/opensearch-core-current.jar" - ); - targetFile.getParentFile().mkdirs(); - Path originalPath = Paths.get(originLocation.toURI()); - Files.copy(originalPath, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING); - } catch (ClassNotFoundException | URISyntaxException | IOException e) { - e.printStackTrace(); - fail("Cannot setup jdk jar hell classpath"); - } - } - -} diff --git a/buildSrc/src/testKit/opensearch-build-resources/build.gradle b/buildSrc/src/testKit/opensearch-build-resources/build.gradle deleted file mode 100644 index 3d939ccffc6e3..0000000000000 --- a/buildSrc/src/testKit/opensearch-build-resources/build.gradle +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -import org.opensearch.gradle.ExportOpenSearchBuildResourcesTask - -plugins { - id 'base' - id 'opensearch.global-build-info' -} - -File buildResourcesDir = new File(project.getBuildDir(), 'build-tools-exported') -TaskProvider buildResourcesTask = tasks.register('buildResources', ExportOpenSearchBuildResourcesTask) { - outputDir = buildResourcesDir -} - -tasks.register("sampleCopy", Sync) { - /** Note: no explicit dependency. This works with tasks that use the Provider API a.k.a "Lazy Configuration" **/ - from buildResourcesTask - into "$buildDir/sampleCopy" -} - -tasks.register("noConfigAfterExecution") { - dependsOn buildResourcesTask - doLast { - buildResourcesTask.get().copy('foo') - } -} diff --git a/buildSrc/src/testKit/opensearch-build-resources/settings.gradle b/buildSrc/src/testKit/opensearch-build-resources/settings.gradle deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/buildSrc/src/testKit/opensearch.build/LICENSE b/buildSrc/src/testKit/opensearch.build/LICENSE deleted file mode 100644 index cf6ea07b18851..0000000000000 --- a/buildSrc/src/testKit/opensearch.build/LICENSE +++ /dev/null @@ -1 +0,0 @@ -this is a test license file \ No newline at end of file diff --git a/buildSrc/src/testKit/opensearch.build/NOTICE b/buildSrc/src/testKit/opensearch.build/NOTICE deleted file mode 100644 index 0c070fe74242a..0000000000000 --- a/buildSrc/src/testKit/opensearch.build/NOTICE +++ /dev/null @@ -1 +0,0 @@ -this is a test notice file \ No newline at end of file diff --git a/buildSrc/src/testKit/opensearch.build/build.gradle b/buildSrc/src/testKit/opensearch.build/build.gradle deleted file mode 100644 index a0093eb1d2cd1..0000000000000 --- a/buildSrc/src/testKit/opensearch.build/build.gradle +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -plugins { - id 'java' - id 'opensearch.build' -} - -ext.licenseFile = file("LICENSE") -ext.noticeFile = file("NOTICE") - -dependencies { - api "junit:junit:${versions.junit}" - // missing classes in thirdparty audit - api 'org.hamcrest:hamcrest-core:1.3' - jdkJarHell 'org.opensearch:opensearch-core:current' -} - -repositories { - /** - * Local test repo contains dummy jars with different group names and versions. - * - broken-log4j creates a log4j logger but has no pom, so the class will be missing - * - dummy-io has a class that creates a new java.io.File ( something which third-party-audit-absurd.txt forbids ) - * - version 0.0.2 has the same class and one extra file just to make the jar different - * - used for propagating jar containing jdkjarhell jar from integ test runtime classpath - */ - maven { - name = "local-test" - url = file("sample_jars/build/testrepo") - metadataSources { - artifact() - } - } - mavenCentral() -} - -repositories { - /** - * Local test repo contains jdkjarhell jar from integ test runtime classpath propagated at runtime - */ - maven { - name = "local-test" - url = file("sample_jars/build/testrepo") - metadataSources { - artifact() - } - } - mavenCentral() -} - -// todo remove offending rules -tasks.named('forbiddenApisMain').configure { onlyIf { false } } -tasks.named('forbiddenApisTest').configure { onlyIf { false } } -// requires dependency on testing fw -jarHell.enabled = false -// we don't have tests for now -test.enabled = false -thirdPartyAudit.enabled = false -// This requires an additional Jar not part of build-tools -loggerUsageCheck.enabled = false - -// TODO: shouldn't be part of BuildPlugin, should be tested separately -validateNebulaPom.enabled = false - -tasks.register("hello") { - doFirst { - println "build plugin can be applied" - } -} diff --git a/buildSrc/src/testKit/opensearch.build/licenses/hamcrest-core-1.3.jar.sha1 b/buildSrc/src/testKit/opensearch.build/licenses/hamcrest-core-1.3.jar.sha1 deleted file mode 100644 index 1085ece454c99..0000000000000 --- a/buildSrc/src/testKit/opensearch.build/licenses/hamcrest-core-1.3.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -42a25dc3219429f0e5d060061f71acb49bf010a0 \ No newline at end of file diff --git a/buildSrc/src/testKit/opensearch.build/licenses/hamcrest-core-LICENSE.txt b/buildSrc/src/testKit/opensearch.build/licenses/hamcrest-core-LICENSE.txt deleted file mode 100644 index 803baec32939c..0000000000000 --- a/buildSrc/src/testKit/opensearch.build/licenses/hamcrest-core-LICENSE.txt +++ /dev/null @@ -1,22 +0,0 @@ -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/buildSrc/src/testKit/opensearch.build/licenses/hamcrest-core-NOTICE.txt b/buildSrc/src/testKit/opensearch.build/licenses/hamcrest-core-NOTICE.txt deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/buildSrc/src/testKit/opensearch.build/licenses/junit-4.13.2.jar.sha1 b/buildSrc/src/testKit/opensearch.build/licenses/junit-4.13.2.jar.sha1 deleted file mode 100644 index 7d065692bff1a..0000000000000 --- a/buildSrc/src/testKit/opensearch.build/licenses/junit-4.13.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -8ac9e16d933b6fb43bc7f576336b8f4d7eb5ba12 \ No newline at end of file diff --git a/buildSrc/src/testKit/opensearch.build/licenses/junit-LICENSE.txt b/buildSrc/src/testKit/opensearch.build/licenses/junit-LICENSE.txt deleted file mode 100644 index 803baec32939c..0000000000000 --- a/buildSrc/src/testKit/opensearch.build/licenses/junit-LICENSE.txt +++ /dev/null @@ -1,22 +0,0 @@ -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/buildSrc/src/testKit/opensearch.build/licenses/junit-NOTICE.txt b/buildSrc/src/testKit/opensearch.build/licenses/junit-NOTICE.txt deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/buildSrc/src/testKit/opensearch.build/settings.gradle b/buildSrc/src/testKit/opensearch.build/settings.gradle deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/buildSrc/src/testKit/opensearch.build/src/main/java/org/opensearch/SampleClass.java b/buildSrc/src/testKit/opensearch.build/src/main/java/org/opensearch/SampleClass.java deleted file mode 100644 index de51b76925f1d..0000000000000 --- a/buildSrc/src/testKit/opensearch.build/src/main/java/org/opensearch/SampleClass.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch; - -/** - * This is just a test class - */ -public class SampleClass { - -} diff --git a/buildSrc/src/testKit/reaper/build.gradle b/buildSrc/src/testKit/reaper/build.gradle deleted file mode 100644 index fdcf4dc2f2468..0000000000000 --- a/buildSrc/src/testKit/reaper/build.gradle +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -plugins { - id 'opensearch.reaper' -} - -tasks.register("launchReaper") { - doLast { - def reaper = project.extensions.getByName('reaper') - reaper.registerCommand('test', 'true') - reaper.unregister('test') - } -} diff --git a/buildSrc/src/testKit/reaper/settings.gradle b/buildSrc/src/testKit/reaper/settings.gradle deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/buildSrc/src/testKit/symbolic-link-preserving-tar/build.gradle b/buildSrc/src/testKit/symbolic-link-preserving-tar/build.gradle deleted file mode 100644 index 57f906d38582a..0000000000000 --- a/buildSrc/src/testKit/symbolic-link-preserving-tar/build.gradle +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -import org.opensearch.gradle.tar.SymbolicLinkPreservingTar - -plugins { - id 'base' - id 'distribution' - id 'opensearch.symbolic-link-preserving-tar' -} - -final String source = Objects.requireNonNull(System.getProperty('tests.symbolic_link_preserving_tar_source')) -boolean preserveFileTimestamps; -final String testPreserveFileTimestamps = - Objects.requireNonNull(System.getProperty('tests.symbolic_link_preserving_tar_preserve_file_timestamps')) -switch (testPreserveFileTimestamps) { - case "true": - preserveFileTimestamps = true - break - case "false": - preserveFileTimestamps = false - break - default: - throw new IllegalArgumentException( - "tests.symbolic_link_preserving_tar_preserve_file_timestamps must be [true] or [false] but was [" - + testPreserveFileTimestamps + "]") -} - -tasks.register("buildBZip2Tar", SymbolicLinkPreservingTar) { SymbolicLinkPreservingTar tar -> - tar.archiveExtension = 'tar.bz2' - tar.compression = Compression.BZIP2 - tar.preserveFileTimestamps = preserveFileTimestamps - from fileTree(source) - doLast { - println archiveFile.get().asFile.path - } -} - -tasks.register("buildGZipTar", SymbolicLinkPreservingTar) { SymbolicLinkPreservingTar tar -> - tar.archiveExtension = 'tar.gz' - tar.compression = Compression.GZIP - tar.preserveFileTimestamps = preserveFileTimestamps - from fileTree(source) - doLast { - println archiveFile.get().asFile.path - } -} - -tasks.register("buildTar", SymbolicLinkPreservingTar) { SymbolicLinkPreservingTar tar -> - tar.archiveExtension = 'tar' - tar.preserveFileTimestamps = preserveFileTimestamps - from fileTree(source) - doLast { - println archiveFile.get().asFile.path - } -} diff --git a/buildSrc/src/testKit/symbolic-link-preserving-tar/settings.gradle b/buildSrc/src/testKit/symbolic-link-preserving-tar/settings.gradle deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/buildSrc/src/testKit/testingConventions/all_classes_in_tasks/src/test/java/org/opensearch/gradle/testkit/NamingConventionIT.java b/buildSrc/src/testKit/testingConventions/all_classes_in_tasks/src/test/java/org/opensearch/gradle/testkit/NamingConventionIT.java deleted file mode 100644 index 0415db2568e75..0000000000000 --- a/buildSrc/src/testKit/testingConventions/all_classes_in_tasks/src/test/java/org/opensearch/gradle/testkit/NamingConventionIT.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class NamingConventionIT { - -} diff --git a/buildSrc/src/testKit/testingConventions/all_classes_in_tasks/src/test/java/org/opensearch/gradle/testkit/NamingConventionTests.java b/buildSrc/src/testKit/testingConventions/all_classes_in_tasks/src/test/java/org/opensearch/gradle/testkit/NamingConventionTests.java deleted file mode 100644 index ca3d36692e62b..0000000000000 --- a/buildSrc/src/testKit/testingConventions/all_classes_in_tasks/src/test/java/org/opensearch/gradle/testkit/NamingConventionTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class NamingConventionTests { - -} diff --git a/buildSrc/src/testKit/testingConventions/build.gradle b/buildSrc/src/testKit/testingConventions/build.gradle deleted file mode 100644 index 418e833e8cb14..0000000000000 --- a/buildSrc/src/testKit/testingConventions/build.gradle +++ /dev/null @@ -1,93 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -plugins { - id 'opensearch.build' apply false -} - -allprojects { - apply plugin: 'java' - apply plugin: 'opensearch.build' - - repositories { - mavenCentral() - } - dependencies { - testImplementation "junit:junit:4.13.2" - } - - ext.licenseFile = file("$buildDir/dummy/license") - ext.noticeFile = file("$buildDir/dummy/notice") - - testingConventions.naming { - // Reset default to no baseClass checks - Tests { - baseClasses = [] - } - IT { - baseClasses = [] - } - } -} - -project(':empty_test_task') { - tasks.register("emptyTest", Test) -} - -project(':all_classes_in_tasks') { - test { - include "**/Convention*" - } -} - -project(':not_implementing_base') { - testingConventions.naming { - Tests { - baseClass 'org.opensearch.gradle.testkit.Unit' - } - IT { - baseClass 'org.opensearch.gradle.testkit.Integration' - } - } - test { - include "**/*IT.class" - include "**/*Tests.class" - } -} - -project(':valid_setup_no_base') { - test { - include "**/*IT.class" - include "**/*Tests.class" - } -} - -project(':tests_in_main') { - -} - -project(':valid_setup_with_base') { - test { - include "**/*IT.class" - include "**/*Tests.class" - } - testingConventions.naming { - Tests { - baseClass 'org.opensearch.gradle.testkit.Unit' - } - IT { - baseClass 'org.opensearch.gradle.testkit.Integration' - } - } -} - - - diff --git a/buildSrc/src/testKit/testingConventions/empty_test_task/.gitignore b/buildSrc/src/testKit/testingConventions/empty_test_task/.gitignore deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/LooksLikeATestWithoutNamingConvention1.java b/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/LooksLikeATestWithoutNamingConvention1.java deleted file mode 100644 index a0aae44518194..0000000000000 --- a/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/LooksLikeATestWithoutNamingConvention1.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -import org.junit.Test; - -public class LooksLikeATestWithoutNamingConvention1 { - - @Test - public void annotatedTestMethod() { - - } - -} diff --git a/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/LooksLikeATestWithoutNamingConvention2.java b/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/LooksLikeATestWithoutNamingConvention2.java deleted file mode 100644 index ea8da5c345ab5..0000000000000 --- a/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/LooksLikeATestWithoutNamingConvention2.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -import org.junit.Assert; - -public class LooksLikeATestWithoutNamingConvention2 extends Assert { - -} diff --git a/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/LooksLikeATestWithoutNamingConvention3.java b/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/LooksLikeATestWithoutNamingConvention3.java deleted file mode 100644 index 033a2b1828c59..0000000000000 --- a/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/LooksLikeATestWithoutNamingConvention3.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class LooksLikeATestWithoutNamingConvention3 { - - public void testMethod() { - - } - -} diff --git a/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/LooksLikeTestsButAbstract.java b/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/LooksLikeTestsButAbstract.java deleted file mode 100644 index 84a19ad5394f8..0000000000000 --- a/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/LooksLikeTestsButAbstract.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public abstract class LooksLikeTestsButAbstract { - - public void testMethod() { - - } - -} diff --git a/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/NamingConventionIT.java b/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/NamingConventionIT.java deleted file mode 100644 index 0415db2568e75..0000000000000 --- a/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/NamingConventionIT.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class NamingConventionIT { - -} diff --git a/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/NamingConventionTests.java b/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/NamingConventionTests.java deleted file mode 100644 index ca3d36692e62b..0000000000000 --- a/buildSrc/src/testKit/testingConventions/incorrect_naming_conventions/src/test/java/org/opensearch/gradle/testkit/NamingConventionTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class NamingConventionTests { - -} diff --git a/buildSrc/src/testKit/testingConventions/no_tests_in_inner_classes/src/test/java/org/opensearch/gradle/testkit/NastyInnerClasses.java b/buildSrc/src/testKit/testingConventions/no_tests_in_inner_classes/src/test/java/org/opensearch/gradle/testkit/NastyInnerClasses.java deleted file mode 100644 index 07759ecbc6134..0000000000000 --- a/buildSrc/src/testKit/testingConventions/no_tests_in_inner_classes/src/test/java/org/opensearch/gradle/testkit/NastyInnerClasses.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -import org.junit.Assert; -import org.junit.Test; - -public class NastyInnerClasses { - - public static class NamingConventionTests { - - } - - public static class NamingConventionIT { - - } - - public static class LooksLikeATestWithoutNamingConvention1 { - @Test - public void annotatedTestMethod() { - - } - } - - public static class LooksLikeATestWithoutNamingConvention2 extends Assert { - - } - - public static class LooksLikeATestWithoutNamingConvention3 { - - public void testMethod() { - - } - - } - - static abstract public class NonOffendingAbstractTests { - - } - - private static class NonOffendingPrivateTests { - - } - - static class NonOffendingPackageTests { - - } -} diff --git a/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/AbstractIT.java b/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/AbstractIT.java deleted file mode 100644 index 391da8891543c..0000000000000 --- a/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/AbstractIT.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public abstract class AbstractIT { - -} diff --git a/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/Integration.java b/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/Integration.java deleted file mode 100644 index 5df6cdaed0235..0000000000000 --- a/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/Integration.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class Integration { - -} diff --git a/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionIT.java b/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionIT.java deleted file mode 100644 index 0415db2568e75..0000000000000 --- a/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionIT.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class NamingConventionIT { - -} diff --git a/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionMissmatchIT.java b/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionMissmatchIT.java deleted file mode 100644 index 4bda4c81c70aa..0000000000000 --- a/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionMissmatchIT.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class NamingConventionMissmatchIT extends Unit { - -} diff --git a/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionMissmatchTests.java b/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionMissmatchTests.java deleted file mode 100644 index a810d4f83f946..0000000000000 --- a/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionMissmatchTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class NamingConventionMissmatchTests extends Integration { - -} diff --git a/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionTests.java b/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionTests.java deleted file mode 100644 index ca3d36692e62b..0000000000000 --- a/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class NamingConventionTests { - -} diff --git a/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/Unit.java b/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/Unit.java deleted file mode 100644 index c22b542def7b8..0000000000000 --- a/buildSrc/src/testKit/testingConventions/not_implementing_base/src/test/java/org/opensearch/gradle/testkit/Unit.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class Unit { - -} diff --git a/buildSrc/src/testKit/testingConventions/settings.gradle b/buildSrc/src/testKit/testingConventions/settings.gradle deleted file mode 100644 index c4206edd63ff7..0000000000000 --- a/buildSrc/src/testKit/testingConventions/settings.gradle +++ /dev/null @@ -1,19 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -include 'no_tests_in_inner_classes' -include 'incorrect_naming_conventions' -include 'empty_test_task' -include 'all_classes_in_tasks' -include 'not_implementing_base' -include 'valid_setup_no_base' -include 'valid_setup_with_base' -include 'tests_in_main' \ No newline at end of file diff --git a/buildSrc/src/testKit/testingConventions/tests_in_main/src/main/java/org/opensearch/gradle/testkit/NamingConventionIT.java b/buildSrc/src/testKit/testingConventions/tests_in_main/src/main/java/org/opensearch/gradle/testkit/NamingConventionIT.java deleted file mode 100644 index 0415db2568e75..0000000000000 --- a/buildSrc/src/testKit/testingConventions/tests_in_main/src/main/java/org/opensearch/gradle/testkit/NamingConventionIT.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class NamingConventionIT { - -} diff --git a/buildSrc/src/testKit/testingConventions/tests_in_main/src/main/java/org/opensearch/gradle/testkit/NamingConventionTests.java b/buildSrc/src/testKit/testingConventions/tests_in_main/src/main/java/org/opensearch/gradle/testkit/NamingConventionTests.java deleted file mode 100644 index ca3d36692e62b..0000000000000 --- a/buildSrc/src/testKit/testingConventions/tests_in_main/src/main/java/org/opensearch/gradle/testkit/NamingConventionTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class NamingConventionTests { - -} diff --git a/buildSrc/src/testKit/testingConventions/valid_setup_no_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionIT.java b/buildSrc/src/testKit/testingConventions/valid_setup_no_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionIT.java deleted file mode 100644 index 0415db2568e75..0000000000000 --- a/buildSrc/src/testKit/testingConventions/valid_setup_no_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionIT.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class NamingConventionIT { - -} diff --git a/buildSrc/src/testKit/testingConventions/valid_setup_no_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionTests.java b/buildSrc/src/testKit/testingConventions/valid_setup_no_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionTests.java deleted file mode 100644 index ca3d36692e62b..0000000000000 --- a/buildSrc/src/testKit/testingConventions/valid_setup_no_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class NamingConventionTests { - -} diff --git a/buildSrc/src/testKit/testingConventions/valid_setup_with_base/src/test/java/org/opensearch/gradle/testkit/Integration.java b/buildSrc/src/testKit/testingConventions/valid_setup_with_base/src/test/java/org/opensearch/gradle/testkit/Integration.java deleted file mode 100644 index 5df6cdaed0235..0000000000000 --- a/buildSrc/src/testKit/testingConventions/valid_setup_with_base/src/test/java/org/opensearch/gradle/testkit/Integration.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class Integration { - -} diff --git a/buildSrc/src/testKit/testingConventions/valid_setup_with_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionIT.java b/buildSrc/src/testKit/testingConventions/valid_setup_with_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionIT.java deleted file mode 100644 index 5d08141fa94d2..0000000000000 --- a/buildSrc/src/testKit/testingConventions/valid_setup_with_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionIT.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class NamingConventionIT extends Integration { - -} diff --git a/buildSrc/src/testKit/testingConventions/valid_setup_with_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionTests.java b/buildSrc/src/testKit/testingConventions/valid_setup_with_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionTests.java deleted file mode 100644 index e0f94b33fb44b..0000000000000 --- a/buildSrc/src/testKit/testingConventions/valid_setup_with_base/src/test/java/org/opensearch/gradle/testkit/NamingConventionTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class NamingConventionTests extends Unit { - -} diff --git a/buildSrc/src/testKit/testingConventions/valid_setup_with_base/src/test/java/org/opensearch/gradle/testkit/Unit.java b/buildSrc/src/testKit/testingConventions/valid_setup_with_base/src/test/java/org/opensearch/gradle/testkit/Unit.java deleted file mode 100644 index c22b542def7b8..0000000000000 --- a/buildSrc/src/testKit/testingConventions/valid_setup_with_base/src/test/java/org/opensearch/gradle/testkit/Unit.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.gradle.testkit; - -public class Unit { - -} diff --git a/buildSrc/src/testKit/thirdPartyAudit/build.gradle b/buildSrc/src/testKit/thirdPartyAudit/build.gradle deleted file mode 100644 index 41e699db94dcf..0000000000000 --- a/buildSrc/src/testKit/thirdPartyAudit/build.gradle +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -import org.opensearch.gradle.precommit.ThirdPartyAuditPrecommitPlugin -import org.opensearch.gradle.precommit.ThirdPartyAuditTask - - -plugins { - id 'java' - // bring in build-tools onto the classpath - id 'opensearch.global-build-info' -} - -plugins.apply(ThirdPartyAuditPrecommitPlugin) - -repositories { - /** - * Local test repo contains dummy jars with different group names and versions. - * - broken-log4j creates a log4j logger but has no pom, so the class will be missing - * - dummy-io has a class that creates a new java.io.File ( something which third-party-audit-absurd.txt forbids ) - * - version 0.0.2 has the same class and one extra file just to make the jar different - * - used for propagating jar containing jdkjarhell jar from integ test runtime classpath - */ - maven { - name = "local-test" - url = file("sample_jars/build/testrepo") - metadataSources { - artifact() - } - } - mavenCentral() -} - -dependencies { - forbiddenApisCliJar 'de.thetaphi:forbiddenapis:3.2' - jdkJarHell 'org.opensearch:opensearch-core:current' - compileOnly "org.${project.properties.compileOnlyGroup}:${project.properties.compileOnlyVersion}" - implementation "org.${project.properties.compileGroup}:${project.properties.compileVersion}" -} - -tasks.register("empty", ThirdPartyAuditTask) { - targetCompatibility = JavaVersion.VERSION_11 - signatureFile = file('third-party-audit-empty.txt') -} - -tasks.register("absurd", ThirdPartyAuditTask) { - targetCompatibility = JavaVersion.VERSION_11 - signatureFile = file('third-party-audit-absurd.txt') -} diff --git a/buildSrc/src/testKit/thirdPartyAudit/sample_jars/build.gradle b/buildSrc/src/testKit/thirdPartyAudit/sample_jars/build.gradle deleted file mode 100644 index c8c89fb5e4273..0000000000000 --- a/buildSrc/src/testKit/thirdPartyAudit/sample_jars/build.gradle +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -plugins { - id 'java' -} -repositories { - mavenCentral() -} -dependencies { - implementation 'org.apache.logging.log4j:log4j-core:2.17.2' -} - -["0.0.1", "0.0.2"].forEach { v -> - ["opensearch", "other"].forEach { p -> - tasks.register("dummy-${p}-${v}", Jar) { - destinationDirectory = file("${buildDir}/testrepo/org/${p}/gradle/dummy-io/${v}/") - archiveFileName = "dummy-io-${v}.jar" - from sourceSets.main.output - include "**/TestingIO.class" - if (v == "0.0.2") { - manifest { - attributes( - "X-Different": "Different manifest, different jar" - ) - } - } - } - build.dependsOn("dummy-${p}-${v}") - } -} - -["0.0.1"].forEach { v -> - ["opensearch", "other"].forEach { p -> - tasks.register("broken-log4j-${p}-${v}", Jar) { - destinationDir = file("${buildDir}/testrepo/org/${p}/gradle/broken-log4j/${v}/") - archiveFileName = "broken-log4j-${v}.jar" - from sourceSets.main.output - include "**/TestingLog4j.class" - } - build.dependsOn("broken-log4j-${p}-${v}") - } -} - -tasks.register("jarhellJdk", Jar) { - destinationDir = file("${buildDir}/testrepo/org/other/gradle/jarhellJdk/0.0.1/") - archiveFileName = "jarhellJdk-0.0.1.jar" - from sourceSets.main.output - include "**/String.class" - into "java/lang" -} -build.dependsOn("jarhellJdk") diff --git a/buildSrc/src/testKit/thirdPartyAudit/sample_jars/src/main/java/String.java b/buildSrc/src/testKit/thirdPartyAudit/sample_jars/src/main/java/String.java deleted file mode 100644 index 118e7dbc18312..0000000000000 --- a/buildSrc/src/testKit/thirdPartyAudit/sample_jars/src/main/java/String.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -class String { - -} diff --git a/buildSrc/src/testKit/thirdPartyAudit/sample_jars/src/main/java/TestingIO.java b/buildSrc/src/testKit/thirdPartyAudit/sample_jars/src/main/java/TestingIO.java deleted file mode 100644 index 0d6d1762d2521..0000000000000 --- a/buildSrc/src/testKit/thirdPartyAudit/sample_jars/src/main/java/TestingIO.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -import java.io.File; - -public class TestingIO { - public TestingIO() { - new File("foo"); - } -} diff --git a/buildSrc/src/testKit/thirdPartyAudit/sample_jars/src/main/java/TestingLog4j.java b/buildSrc/src/testKit/thirdPartyAudit/sample_jars/src/main/java/TestingLog4j.java deleted file mode 100644 index efb873d1772c6..0000000000000 --- a/buildSrc/src/testKit/thirdPartyAudit/sample_jars/src/main/java/TestingLog4j.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -import org.apache.logging.log4j.LogManager; - -public class TestingLog4j { - public TestingLog4j() { - LogManager.getLogger(); - } -} diff --git a/buildSrc/src/testKit/thirdPartyAudit/settings.gradle b/buildSrc/src/testKit/thirdPartyAudit/settings.gradle deleted file mode 100644 index 582faadddaef1..0000000000000 --- a/buildSrc/src/testKit/thirdPartyAudit/settings.gradle +++ /dev/null @@ -1,12 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -include 'sample_jars' \ No newline at end of file diff --git a/buildSrc/src/testKit/thirdPartyAudit/third-party-audit-absurd.txt b/buildSrc/src/testKit/thirdPartyAudit/third-party-audit-absurd.txt deleted file mode 100644 index bac396aa809d3..0000000000000 --- a/buildSrc/src/testKit/thirdPartyAudit/third-party-audit-absurd.txt +++ /dev/null @@ -1,2 +0,0 @@ -@defaultMessage non-public internal runtime class -java.io.** \ No newline at end of file diff --git a/buildSrc/src/testKit/thirdPartyAudit/third-party-audit-empty.txt b/buildSrc/src/testKit/thirdPartyAudit/third-party-audit-empty.txt deleted file mode 100644 index c97de2d6468f6..0000000000000 --- a/buildSrc/src/testKit/thirdPartyAudit/third-party-audit-empty.txt +++ /dev/null @@ -1 +0,0 @@ -@defaultMessage non-public internal runtime class \ No newline at end of file diff --git a/buildSrc/version.properties b/buildSrc/version.properties deleted file mode 100644 index bd02287298fb4..0000000000000 --- a/buildSrc/version.properties +++ /dev/null @@ -1,54 +0,0 @@ -opensearch = 1.3.20 -lucene = 8.10.1 - -bundled_jdk_vendor = adoptium -bundled_jdk = 11.0.25+9 - -# optional dependencies -spatial4j = 0.7 -jts = 1.15.0 -jackson = 2.14.2 -jackson_databind = 2.14.2 -snakeyaml = 2.0 -icu4j = 62.2 -supercsv = 2.4.0 -log4j = 2.17.1 -slf4j = 1.6.2 -jdom2 = 2.0.6.1 -asm = 9.6 -jettison = 1.5.4 -asm = 9.5 -woodstox = 6.4.0 -kotlin = 1.7.10 -guava = 32.0.1-jre -protobuf = 3.25.5 - -# when updating the JNA version, also update the version in buildSrc/build.gradle -jna = 5.5.0 - -netty = 4.1.115.Final -reactor_netty = 1.0.39 -reactor = 3.4.34 -joda = 2.12.2 -jetty = 9.4.53.v20231009 - -# when updating this version, you need to ensure compatibility with: -# - plugins/ingest-attachment (transitive dependency, check the upstream POM) -# - distribution/tools/plugin-cli -bouncycastle=1.78.1 -# test dependencies -randomizedrunner = 2.7.1 -junit = 4.13.2 -httpclient = 4.5.13 -httpcore = 4.4.12 -httpasyncclient = 4.1.4 -commonslogging = 1.1.3 -commonscodec = 1.13 -hamcrest = 2.1 -mocksocket = 1.2 -mockito = 3.12.4 -objenesis = 3.2 -bytebuddy = 1.14.3 - -# benchmark dependencies -jmh = 1.19 diff --git a/plugins/repository-hdfs/build.gradle b/plugins/repository-hdfs/build.gradle index 67ca9671f4fb8..246fb0c3507e9 100644 --- a/plugins/repository-hdfs/build.gradle +++ b/plugins/repository-hdfs/build.gradle @@ -375,7 +375,6 @@ thirdPartyAudit { 'org.apache.hadoop.thirdparty.com.google.common.hash.LittleEndianByteArray$UnsafeByteArray', 'org.apache.hadoop.thirdparty.com.google.common.hash.LittleEndianByteArray$UnsafeByteArray$1', 'org.apache.hadoop.thirdparty.com.google.common.hash.LittleEndianByteArray$UnsafeByteArray$2', - 'org.apache.hadoop.thirdparty.com.google.common.hash.LittleEndianByteArray$UnsafeByteArray$3', 'org.apache.hadoop.thirdparty.com.google.common.hash.Striped64', 'org.apache.hadoop.thirdparty.com.google.common.hash.Striped64$1', 'org.apache.hadoop.thirdparty.com.google.common.hash.Striped64$Cell', @@ -383,8 +382,11 @@ thirdPartyAudit { 'org.apache.hadoop.thirdparty.com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator$1', 'org.apache.hadoop.thirdparty.com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper', 'org.apache.hadoop.thirdparty.com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper$1', + 'org.apache.hadoop.thirdparty.protobuf.MessageSchema', 'org.apache.hadoop.thirdparty.protobuf.UnsafeUtil', 'org.apache.hadoop.thirdparty.protobuf.UnsafeUtil$1', + 'org.apache.hadoop.thirdparty.protobuf.UnsafeUtil$Android32MemoryAccessor', + 'org.apache.hadoop.thirdparty.protobuf.UnsafeUtil$Android64MemoryAccessor', 'org.apache.hadoop.thirdparty.protobuf.UnsafeUtil$JvmMemoryAccessor', 'org.apache.hadoop.thirdparty.protobuf.UnsafeUtil$MemoryAccessor', @@ -429,10 +431,6 @@ thirdPartyAudit { 'org.apache.hadoop.shaded.org.apache.curator.shaded.com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper', 'org.apache.hadoop.shaded.org.apache.curator.shaded.com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper$1', 'org.apache.hadoop.shaded.org.xbill.DNS.spi.DNSJavaNameServiceDescriptor', - 'org.apache.hadoop.shaded.org.xerial.snappy.pure.PureJavaSnappy', - 'org.apache.hadoop.shaded.org.xerial.snappy.pure.SnappyRawCompressor', - 'org.apache.hadoop.shaded.org.xerial.snappy.pure.SnappyRawDecompressor', - 'org.apache.hadoop.shaded.org.xerial.snappy.pure.UnsafeUtil', 'org.apache.avro.reflect.FieldAccessUnsafe', 'org.apache.avro.reflect.FieldAccessUnsafe$UnsafeBooleanField',