From cf1dadf2e7381f3fa831692a5dab6baab5fbd202 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 22 Nov 2024 11:58:50 +0000 Subject: [PATCH] Stop publishing CLI's Homebrew formula in commercial builds Closes gh-43247 --- .../spring-boot-cli/build.gradle | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-cli/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-cli/build.gradle index 312efac1434..15adb4f29b1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-cli/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-cli/build.gradle @@ -1,3 +1,6 @@ +import org.springframework.boot.build.properties.BuildProperties +import org.springframework.boot.build.properties.BuildType + plugins { id "java" id "eclipse" @@ -104,17 +107,27 @@ task tar(type: Tar) { configureArchive it } -task homebrewFormula(type: org.springframework.boot.build.cli.HomebrewFormula) { - dependsOn tar - outputDir = layout.buildDirectory.dir("homebrew") - template = file("src/main/homebrew/spring-boot.rb") - archive = tar.archiveFile -} +if (BuildProperties.get(project).buildType() == BuildType.OPEN_SOURCE) { + task homebrewFormula(type: org.springframework.boot.build.cli.HomebrewFormula) { + dependsOn tar + outputDir = layout.buildDirectory.dir("homebrew") + template = file("src/main/homebrew/spring-boot.rb") + archive = tar.archiveFile + } -def homebrewFormulaArtifact = artifacts.add("archives", file(layout.buildDirectory.file("homebrew/spring-boot.rb"))) { - type "rb" - classifier "homebrew" - builtBy "homebrewFormula" + def homebrewFormulaArtifact = artifacts.add("archives", file(layout.buildDirectory.file("homebrew/spring-boot.rb"))) { + type "rb" + classifier "homebrew" + builtBy "homebrewFormula" + } + + publishing { + publications { + getByName("maven") { + artifact homebrewFormulaArtifact + } + } + } } publishing { @@ -123,7 +136,6 @@ publishing { artifact fullJar artifact tar artifact zip - artifact homebrewFormulaArtifact } } }