diff --git a/buildSrc/src/main/java/org/springframework/boot/build/cli/HomebrewFormula.java b/buildSrc/src/main/java/org/springframework/boot/build/cli/HomebrewFormula.java index e96487213da0..3edf6097d3c6 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/cli/HomebrewFormula.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/cli/HomebrewFormula.java @@ -36,8 +36,12 @@ import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.TaskAction; import org.gradle.api.tasks.TaskExecutionException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.build.artifacts.ArtifactRelease; +import org.springframework.boot.build.properties.BuildProperties; +import org.springframework.boot.build.properties.BuildType; /** * A {@link Task} for creating a Homebrew formula manifest. @@ -46,16 +50,18 @@ */ public abstract class HomebrewFormula extends DefaultTask { + private static final Logger logger = LoggerFactory.getLogger(HomebrewFormula.class); + private final FileSystemOperations fileSystemOperations; @Inject public HomebrewFormula(FileSystemOperations fileSystemOperations) { + this.fileSystemOperations = fileSystemOperations; Project project = getProject(); MapProperty properties = getProperties(); properties.put("hash", getArchive().map((archive) -> sha256(archive.getAsFile()))); getProperties().put("repo", ArtifactRelease.forProject(project).getDownloadRepo()); getProperties().put("version", project.getVersion().toString()); - this.fileSystemOperations = fileSystemOperations; } private String sha256(File file) { @@ -84,6 +90,11 @@ private String sha256(File file) { @TaskAction void createFormula() { + BuildType buildType = BuildProperties.get(getProject()).buildType(); + if (buildType != BuildType.OPEN_SOURCE) { + logger.debug("Skipping Homebrew formula for non open source build type"); + return; + } this.fileSystemOperations.copy((copy) -> { copy.from(getTemplate()); copy.into(getOutputDir());