|
|
|
|
@ -36,8 +36,12 @@ import org.gradle.api.tasks.PathSensitive;
@@ -36,8 +36,12 @@ import org.gradle.api.tasks.PathSensitive;
|
|
|
|
|
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 @@ import org.springframework.boot.build.artifacts.ArtifactRelease;
@@ -46,16 +50,18 @@ import org.springframework.boot.build.artifacts.ArtifactRelease;
|
|
|
|
|
*/ |
|
|
|
|
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<String, Object> 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 @@ public abstract class HomebrewFormula extends DefaultTask {
@@ -84,6 +90,11 @@ public abstract class HomebrewFormula extends DefaultTask {
|
|
|
|
|
|
|
|
|
|
@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()); |
|
|
|
|
|