Don't use repo.spring.io in released Homebrew or Scoop recipes

Update our Homebrew and Scoop recipes to use `repo1.maven.org` rather
than `repo.spring.io` for releases.

Fixes gh-33702
pull/33774/head
Phillip Webb 2 years ago
parent 0d9967c70c
commit 68af379714

@ -25,6 +25,12 @@ import org.gradle.api.Project;
*/
public final class ArtifactoryRepository {
private static final String SNAPSHOT = "snapshot";
private static final String MILESTONE = "milestone";
private static final String RELEASE = "release";
private final String name;
private ArtifactoryRepository(String name) {
@ -35,6 +41,10 @@ public final class ArtifactoryRepository {
return this.name;
}
public boolean isRelease() {
return RELEASE.equals(this.name);
}
@Override
public String toString() {
return this.name;
@ -48,13 +58,13 @@ public final class ArtifactoryRepository {
String version = project.getVersion().toString();
int modifierIndex = version.lastIndexOf('-');
if (modifierIndex == -1) {
return "release";
return RELEASE;
}
String type = version.substring(modifierIndex + 1);
if (type.startsWith("M") || type.startsWith("RC")) {
return "milestone";
return MILESTONE;
}
return "snapshot";
return SNAPSHOT;
}
}

@ -23,6 +23,7 @@ import java.util.Map;
import org.apache.commons.codec.digest.DigestUtils;
import org.gradle.api.DefaultTask;
import org.gradle.api.Project;
import org.gradle.api.file.RegularFile;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.InputFile;
@ -38,9 +39,14 @@ import org.springframework.boot.build.artifactory.ArtifactoryRepository;
* a Homebrew formula.
*
* @author Andy Wilkinson
* @author Phillip Webb
*/
public abstract class AbstractPackageManagerDefinitionTask extends DefaultTask {
private static final String SPRING_REPO = "https://repo.spring.io/%s";
private static final String MAVEN_REPO = "https://repo1.maven.org/maven2";
private Provider<RegularFile> archive;
private File template;
@ -84,14 +90,19 @@ public abstract class AbstractPackageManagerDefinitionTask extends DefaultTask {
getProject().copy((copy) -> {
copy.from(this.template);
copy.into(this.outputDir);
Map<String, Object> properties = new HashMap<>(additionalProperties);
properties.put("hash", sha256(this.archive.get().getAsFile()));
properties.put("repo", ArtifactoryRepository.forProject(getProject()));
properties.put("project", getProject());
copy.expand(properties);
copy.expand(getProperties(additionalProperties));
});
}
private Map<String, Object> getProperties(Map<String, Object> additionalProperties) {
Map<String, Object> properties = new HashMap<>(additionalProperties);
Project project = getProject();
properties.put("hash", sha256(this.archive.get().getAsFile()));
properties.put("repo", getRepo(project));
properties.put("project", project);
return properties;
}
private String sha256(File file) {
try {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
@ -102,4 +113,9 @@ public abstract class AbstractPackageManagerDefinitionTask extends DefaultTask {
}
}
private String getRepo(Project project) {
ArtifactoryRepository artifactoryRepo = ArtifactoryRepository.forProject(project);
return (!artifactoryRepo.isRelease()) ? String.format(SPRING_REPO, artifactoryRepo.getName()) : MAVEN_REPO;
}
}

@ -2,7 +2,7 @@ require 'formula'
class SpringBoot < Formula
homepage 'https://spring.io/projects/spring-boot'
url 'https://repo.spring.io/${repo}/org/springframework/boot/spring-boot-cli/${project.version}/spring-boot-cli-${project.version}-bin.tar.gz'
url '${repo}/org/springframework/boot/spring-boot-cli/${project.version}/spring-boot-cli-${project.version}-bin.tar.gz'
version '${project.version}'
sha256 '${hash}'
head 'https://github.com/spring-projects/spring-boot.git'

@ -3,7 +3,7 @@
"version": "${scoopVersion}",
"license": "Apache 2.0",
"hash": "${hash}",
"url": "https://repo.spring.io/${repo}/org/springframework/boot/spring-boot-cli/${project.version}/spring-boot-cli-${project.version}-bin.zip",
"url": "${repo}/org/springframework/boot/spring-boot-cli/${project.version}/spring-boot-cli-${project.version}-bin.zip",
"extract_dir": "spring-${project.version}",
"bin": "bin\\\\spring.bat",
"suggest": {

Loading…
Cancel
Save