Skip to content

Commit

Permalink
Extract dependency definitions from plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
breskeby committed Jun 9, 2021
1 parent a420da8 commit 43dff24
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import org.elasticsearch.gradle.internal.precommit.JarHellPrecommitPlugin
import org.elasticsearch.gradle.internal.precommit.ThirdPartyAuditPrecommitPlugin

String elasticsearchLibraryCorePath = ":libs:elasticsearch-core"

configure(allprojects - project(elasticsearchLibraryCorePath)) {
project.getPlugins().withType(JarHellPrecommitPlugin) {
project.getDependencies().add("jarHell", project(elasticsearchLibraryCorePath));
}

project.getPlugins().withType(ThirdPartyAuditPrecommitPlugin) {
project.getDependencies().add("jdkJarHell", project.project(elasticsearchLibraryCorePath));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ public class JarHellPrecommitPlugin extends PrecommitPlugin {
@Override
public TaskProvider<? extends Task> createTask(Project project) {
project.getPluginManager().apply(JarHellPlugin.class);

if (BuildParams.isInternal() && project.getPath().equals(":libs:elasticsearch-core") == false) {
// ideally we would configure this as a default dependency. But Default dependencies do not work correctly
// with gradle project dependencies as they're resolved to late in the build and don't setup according task
// dependencies properly
project.getDependencies().add("jarHell", project.project(":libs:elasticsearch-core"));
}

return project.getTasks().withType(JarHellTask.class).named("jarHell");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ public TaskProvider<? extends Task> createTask(Project project) {
project.getConfigurations().create("forbiddenApisCliJar");
project.getDependencies().add("forbiddenApisCliJar", "de.thetaphi:forbiddenapis:3.1");
Configuration jdkJarHellConfig = project.getConfigurations().create(JDK_JAR_HELL_CONFIG_NAME);
if (BuildParams.isInternal() && project.getPath().equals(LIBS_ELASTICSEARCH_CORE_PROJECT_PATH) == 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_ELASTICSEARCH_CORE_PROJECT_PATH));
}

TaskProvider<ExportElasticsearchBuildResourcesTask> resourcesTask = project.getTasks()
.register("thirdPartyAuditResources", ExportElasticsearchBuildResourcesTask.class);
Path resourcesDir = project.getBuildDir().toPath().resolve("third-party-audit-config");
Expand Down

0 comments on commit 43dff24

Please sign in to comment.