Skip to content

Commit

Permalink
build: Do not hard-code dependencies on plugin projects
Browse files Browse the repository at this point in the history
Previously, the CLI module bundled all core plugins by simply depending
on them. However, that is a problem if programmatic users want to depend
on the core CLI module only, without any commands. To solve that, create
a custom "pluginClasspath" configuration that bundles all plugins, and
add that to the distribution manually.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Oct 19, 2023
1 parent 08bdef5 commit 1708ac3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
22 changes: 20 additions & 2 deletions cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,22 @@ plugins {
id("ort-application-conventions")
}

configurations {
create("pluginClasspath")
}

application {
applicationName = "ort"
mainClass = "org.ossreviewtoolkit.cli.OrtMainKt"

applicationDistribution.from(configurations["pluginClasspath"]) {
// Copy to "lib" instead of "plugin" to avoid duplicate dependency artifacts for core plugins.
into("lib")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}

dependencies {
implementation(platform(project(":plugins:commands")))

implementation(project(":model"))
implementation(project(":plugins:commands:command-api"))
implementation(project(":utils:common-utils"))
Expand All @@ -39,6 +47,16 @@ dependencies {
implementation(libs.mordant)
implementation(libs.slf4j)

"pluginClasspath"(platform(project(":plugins:commands")))
"pluginClasspath"(platform(project(":plugins:package-configuration-providers")))
"pluginClasspath"(platform(project(":plugins:package-curation-providers")))
"pluginClasspath"(platform(project(":plugins:package-managers")))
"pluginClasspath"(platform(project(":plugins:reporters")))
"pluginClasspath"(platform(project(":plugins:scanners")))

funTestImplementation(platform(project(":plugins:commands")))
funTestImplementation(platform(project(":plugins:package-managers")))
funTestImplementation(platform(project(":plugins:reporters")))
funTestImplementation(project(":downloader"))
funTestImplementation(project(":evaluator"))
funTestImplementation(project(":notifier"))
Expand Down
3 changes: 1 addition & 2 deletions plugins/commands/analyzer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ plugins {
dependencies {
api(project(":plugins:commands:command-api"))

implementation(platform(project(":plugins:package-curation-providers")))
implementation(platform(project(":plugins:package-managers")))
implementation(project(":plugins:package-curation-providers:package-curation-provider-api"))

implementation(project(":analyzer"))
implementation(project(":model"))
Expand Down
8 changes: 6 additions & 2 deletions plugins/commands/evaluator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ plugins {
dependencies {
api(project(":plugins:commands:command-api"))

implementation(platform(project(":plugins:package-configuration-providers")))
implementation(platform(project(":plugins:package-curation-providers")))
implementation(project(":plugins:package-configuration-providers:package-configuration-provider-api"))
implementation(project(":plugins:package-curation-providers:package-curation-provider-api"))

// TODO: Get rid of these hard-coded dependencies on plugins.
implementation(project(":plugins:package-configuration-providers:dir-package-configuration-provider"))
implementation(project(":plugins:package-curation-providers:file-package-curation-provider"))

implementation(project(":evaluator"))
implementation(project(":model"))
Expand Down
6 changes: 4 additions & 2 deletions plugins/commands/reporter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ plugins {
dependencies {
api(project(":plugins:commands:command-api"))

implementation(platform(project(":plugins:package-configuration-providers")))
implementation(platform(project(":plugins:reporters")))
implementation(project(":plugins:package-configuration-providers:package-configuration-provider-api"))

// TODO: Get rid of these hard-coded dependencies on plugins.
implementation(project(":plugins:package-configuration-providers:dir-package-configuration-provider"))

implementation(project(":reporter"))
implementation(project(":model"))
Expand Down

0 comments on commit 1708ac3

Please sign in to comment.