Skip to content

Commit 9d57cbc

Browse files
committed
Drop scoop manifest creation
Closes gh-33703
1 parent 1606f5b commit 9d57cbc

File tree

5 files changed

+93
-200
lines changed

5 files changed

+93
-200
lines changed

buildSrc/src/main/java/org/springframework/boot/build/cli/AbstractPackageManagerDefinitionTask.java

Lines changed: 0 additions & 121 deletions
This file was deleted.

buildSrc/src/main/java/org/springframework/boot/build/cli/HomebrewFormula.java

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,17 +16,108 @@
1616

1717
package org.springframework.boot.build.cli;
1818

19+
import java.io.File;
20+
import java.security.MessageDigest;
1921
import java.util.Collections;
22+
import java.util.HashMap;
23+
import java.util.Map;
2024

25+
import org.apache.commons.codec.digest.DigestUtils;
26+
import org.gradle.api.DefaultTask;
27+
import org.gradle.api.Project;
2128
import org.gradle.api.Task;
29+
import org.gradle.api.file.RegularFile;
30+
import org.gradle.api.provider.Provider;
31+
import org.gradle.api.tasks.InputFile;
32+
import org.gradle.api.tasks.OutputDirectory;
33+
import org.gradle.api.tasks.PathSensitive;
34+
import org.gradle.api.tasks.PathSensitivity;
2235
import org.gradle.api.tasks.TaskAction;
36+
import org.gradle.api.tasks.TaskExecutionException;
37+
38+
import org.springframework.boot.build.artifactory.ArtifactoryRepository;
2339

2440
/**
2541
* A {@link Task} for creating a Homebrew formula manifest.
2642
*
2743
* @author Andy Wilkinson
2844
*/
29-
public class HomebrewFormula extends AbstractPackageManagerDefinitionTask {
45+
public class HomebrewFormula extends DefaultTask {
46+
47+
private static final String SPRING_REPO = "https://repo.spring.io/%s";
48+
49+
private static final String MAVEN_REPO = "https://repo1.maven.org/maven2";
50+
51+
private Provider<RegularFile> archive;
52+
53+
private File template;
54+
55+
private File outputDir;
56+
57+
public HomebrewFormula() {
58+
getInputs().property("version", getProject().provider(getProject()::getVersion));
59+
}
60+
61+
@InputFile
62+
@PathSensitive(PathSensitivity.RELATIVE)
63+
public RegularFile getArchive() {
64+
return this.archive.get();
65+
}
66+
67+
public void setArchive(Provider<RegularFile> archive) {
68+
this.archive = archive;
69+
}
70+
71+
@InputFile
72+
@PathSensitive(PathSensitivity.RELATIVE)
73+
public File getTemplate() {
74+
return this.template;
75+
}
76+
77+
public void setTemplate(File template) {
78+
this.template = template;
79+
}
80+
81+
@OutputDirectory
82+
public File getOutputDir() {
83+
return this.outputDir;
84+
}
85+
86+
public void setOutputDir(File outputDir) {
87+
this.outputDir = outputDir;
88+
}
89+
90+
protected void createDescriptor(Map<String, Object> additionalProperties) {
91+
getProject().copy((copy) -> {
92+
copy.from(this.template);
93+
copy.into(this.outputDir);
94+
copy.expand(getProperties(additionalProperties));
95+
});
96+
}
97+
98+
private Map<String, Object> getProperties(Map<String, Object> additionalProperties) {
99+
Map<String, Object> properties = new HashMap<>(additionalProperties);
100+
Project project = getProject();
101+
properties.put("hash", sha256(this.archive.get().getAsFile()));
102+
properties.put("repo", getRepo(project));
103+
properties.put("project", project);
104+
return properties;
105+
}
106+
107+
private String sha256(File file) {
108+
try {
109+
MessageDigest digest = MessageDigest.getInstance("SHA-256");
110+
return new DigestUtils(digest).digestAsHex(file);
111+
}
112+
catch (Exception ex) {
113+
throw new TaskExecutionException(this, ex);
114+
}
115+
}
116+
117+
private String getRepo(Project project) {
118+
ArtifactoryRepository artifactoryRepo = ArtifactoryRepository.forProject(project);
119+
return (!artifactoryRepo.isRelease()) ? String.format(SPRING_REPO, artifactoryRepo.getName()) : MAVEN_REPO;
120+
}
30121

31122
@TaskAction
32123
void createFormula() {

buildSrc/src/main/java/org/springframework/boot/build/cli/ScoopManifest.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

spring-boot-project/spring-boot-cli/build.gradle

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,6 @@ task tar(type: Tar) {
161161
configureArchive it
162162
}
163163

164-
task scoopManifest(type: org.springframework.boot.build.cli.ScoopManifest) {
165-
dependsOn zip
166-
outputDir = file("${buildDir}/scoop")
167-
template = file("src/main/scoop/springboot.json")
168-
archive = zip.archiveFile
169-
}
170-
171-
def scoopManifestArtifact = artifacts.add("archives", file("${buildDir}/scoop/springboot.json")) {
172-
type "json"
173-
classifier "scoop"
174-
builtBy "scoopManifest"
175-
}
176-
177164
task homebrewFormula(type: org.springframework.boot.build.cli.HomebrewFormula) {
178165
dependsOn tar
179166
outputDir = file("${buildDir}/homebrew")
@@ -193,7 +180,6 @@ publishing {
193180
artifact fullJar
194181
artifact tar
195182
artifact zip
196-
artifact scoopManifestArtifact
197183
artifact homebrewFormulaArtifact
198184
}
199185
}

spring-boot-project/spring-boot-cli/src/main/scoop/springboot.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)