From 9d57cbc1d579f01020e194ed3fa8b81c7868b2b8 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 12 Jan 2023 12:00:39 +0000 Subject: [PATCH] Drop scoop manifest creation Closes gh-33703 --- .../AbstractPackageManagerDefinitionTask.java | 121 ------------------ .../boot/build/cli/HomebrewFormula.java | 95 +++++++++++++- .../boot/build/cli/ScoopManifest.java | 37 ------ .../spring-boot-cli/build.gradle | 14 -- .../src/main/scoop/springboot.json | 26 ---- 5 files changed, 93 insertions(+), 200 deletions(-) delete mode 100644 buildSrc/src/main/java/org/springframework/boot/build/cli/AbstractPackageManagerDefinitionTask.java delete mode 100644 buildSrc/src/main/java/org/springframework/boot/build/cli/ScoopManifest.java delete mode 100644 spring-boot-project/spring-boot-cli/src/main/scoop/springboot.json diff --git a/buildSrc/src/main/java/org/springframework/boot/build/cli/AbstractPackageManagerDefinitionTask.java b/buildSrc/src/main/java/org/springframework/boot/build/cli/AbstractPackageManagerDefinitionTask.java deleted file mode 100644 index a0d090c2cd..0000000000 --- a/buildSrc/src/main/java/org/springframework/boot/build/cli/AbstractPackageManagerDefinitionTask.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2012-2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.build.cli; - -import java.io.File; -import java.security.MessageDigest; -import java.util.HashMap; -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; -import org.gradle.api.tasks.OutputDirectory; -import org.gradle.api.tasks.PathSensitive; -import org.gradle.api.tasks.PathSensitivity; -import org.gradle.api.tasks.TaskExecutionException; - -import org.springframework.boot.build.artifactory.ArtifactoryRepository; - -/** - * Base class for generating a package manager definition file such as a Scoop manifest or - * 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 archive; - - private File template; - - private File outputDir; - - public AbstractPackageManagerDefinitionTask() { - getInputs().property("version", getProject().provider(getProject()::getVersion)); - } - - @InputFile - @PathSensitive(PathSensitivity.RELATIVE) - public RegularFile getArchive() { - return this.archive.get(); - } - - public void setArchive(Provider archive) { - this.archive = archive; - } - - @InputFile - @PathSensitive(PathSensitivity.RELATIVE) - public File getTemplate() { - return this.template; - } - - public void setTemplate(File template) { - this.template = template; - } - - @OutputDirectory - public File getOutputDir() { - return this.outputDir; - } - - public void setOutputDir(File outputDir) { - this.outputDir = outputDir; - } - - protected void createDescriptor(Map additionalProperties) { - getProject().copy((copy) -> { - copy.from(this.template); - copy.into(this.outputDir); - copy.expand(getProperties(additionalProperties)); - }); - } - - private Map getProperties(Map additionalProperties) { - Map 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"); - return new DigestUtils(digest).digestAsHex(file); - } - catch (Exception ex) { - throw new TaskExecutionException(this, ex); - } - } - - private String getRepo(Project project) { - ArtifactoryRepository artifactoryRepo = ArtifactoryRepository.forProject(project); - return (!artifactoryRepo.isRelease()) ? String.format(SPRING_REPO, artifactoryRepo.getName()) : MAVEN_REPO; - } - -} 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 9b75f4ad29..15f922ee52 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,17 +16,108 @@ package org.springframework.boot.build.cli; +import java.io.File; +import java.security.MessageDigest; import java.util.Collections; +import java.util.HashMap; +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.Task; +import org.gradle.api.file.RegularFile; +import org.gradle.api.provider.Provider; +import org.gradle.api.tasks.InputFile; +import org.gradle.api.tasks.OutputDirectory; +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.springframework.boot.build.artifactory.ArtifactoryRepository; /** * A {@link Task} for creating a Homebrew formula manifest. * * @author Andy Wilkinson */ -public class HomebrewFormula extends AbstractPackageManagerDefinitionTask { +public class HomebrewFormula 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 archive; + + private File template; + + private File outputDir; + + public HomebrewFormula() { + getInputs().property("version", getProject().provider(getProject()::getVersion)); + } + + @InputFile + @PathSensitive(PathSensitivity.RELATIVE) + public RegularFile getArchive() { + return this.archive.get(); + } + + public void setArchive(Provider archive) { + this.archive = archive; + } + + @InputFile + @PathSensitive(PathSensitivity.RELATIVE) + public File getTemplate() { + return this.template; + } + + public void setTemplate(File template) { + this.template = template; + } + + @OutputDirectory + public File getOutputDir() { + return this.outputDir; + } + + public void setOutputDir(File outputDir) { + this.outputDir = outputDir; + } + + protected void createDescriptor(Map additionalProperties) { + getProject().copy((copy) -> { + copy.from(this.template); + copy.into(this.outputDir); + copy.expand(getProperties(additionalProperties)); + }); + } + + private Map getProperties(Map additionalProperties) { + Map 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"); + return new DigestUtils(digest).digestAsHex(file); + } + catch (Exception ex) { + throw new TaskExecutionException(this, ex); + } + } + + private String getRepo(Project project) { + ArtifactoryRepository artifactoryRepo = ArtifactoryRepository.forProject(project); + return (!artifactoryRepo.isRelease()) ? String.format(SPRING_REPO, artifactoryRepo.getName()) : MAVEN_REPO; + } @TaskAction void createFormula() { diff --git a/buildSrc/src/main/java/org/springframework/boot/build/cli/ScoopManifest.java b/buildSrc/src/main/java/org/springframework/boot/build/cli/ScoopManifest.java deleted file mode 100644 index 0fba7f3313..0000000000 --- a/buildSrc/src/main/java/org/springframework/boot/build/cli/ScoopManifest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2012-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.build.cli; - -import java.util.Collections; - -import org.gradle.api.Task; -import org.gradle.api.tasks.TaskAction; - -/** - * A {@link Task} for creating a Scoop manifest. - * - * @author Andy Wilkinson - */ -public class ScoopManifest extends AbstractPackageManagerDefinitionTask { - - @TaskAction - void createManifest() { - String version = getProject().getVersion().toString(); - createDescriptor(Collections.singletonMap("scoopVersion", version.substring(0, version.lastIndexOf('.')))); - } - -} diff --git a/spring-boot-project/spring-boot-cli/build.gradle b/spring-boot-project/spring-boot-cli/build.gradle index 57bfc18262..0be9b6a93c 100644 --- a/spring-boot-project/spring-boot-cli/build.gradle +++ b/spring-boot-project/spring-boot-cli/build.gradle @@ -161,19 +161,6 @@ task tar(type: Tar) { configureArchive it } -task scoopManifest(type: org.springframework.boot.build.cli.ScoopManifest) { - dependsOn zip - outputDir = file("${buildDir}/scoop") - template = file("src/main/scoop/springboot.json") - archive = zip.archiveFile -} - -def scoopManifestArtifact = artifacts.add("archives", file("${buildDir}/scoop/springboot.json")) { - type "json" - classifier "scoop" - builtBy "scoopManifest" -} - task homebrewFormula(type: org.springframework.boot.build.cli.HomebrewFormula) { dependsOn tar outputDir = file("${buildDir}/homebrew") @@ -193,7 +180,6 @@ publishing { artifact fullJar artifact tar artifact zip - artifact scoopManifestArtifact artifact homebrewFormulaArtifact } } diff --git a/spring-boot-project/spring-boot-cli/src/main/scoop/springboot.json b/spring-boot-project/spring-boot-cli/src/main/scoop/springboot.json deleted file mode 100644 index d49cacca6d..0000000000 --- a/spring-boot-project/spring-boot-cli/src/main/scoop/springboot.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "homepage": "https://projects.spring.io/spring-boot/", - "version": "${scoopVersion}", - "license": "Apache 2.0", - "hash": "${hash}", - "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": { - "JDK": [ - "java/oraclejdk", - "java/openjdk" - ] - }, - "checkver": { - "github": "https://github.com/spring-projects/spring-boot", - "re": "/releases/tag/(?:v)?(2[\\d.]+)\\\\.RELEASE" - }, - "autoupdate": { - "url": "https://repo.spring.io/release/org/springframework/boot/spring-boot-cli/\$version.RELEASE/spring-boot-cli-\$version.RELEASE-bin.zip", - "extract_dir": "spring-\$version.RELEASE", - "hash": { - "url": "\$url.sha256" - } - } -}