mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Drop scoop manifest creation
Closes gh-33703
This commit is contained in:
parent
1606f5b88c
commit
9d57cbc1d5
@ -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<RegularFile> 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<RegularFile> 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<String, Object> additionalProperties) {
|
|
||||||
getProject().copy((copy) -> {
|
|
||||||
copy.from(this.template);
|
|
||||||
copy.into(this.outputDir);
|
|
||||||
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");
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -16,17 +16,108 @@
|
|||||||
|
|
||||||
package org.springframework.boot.build.cli;
|
package org.springframework.boot.build.cli;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.security.MessageDigest;
|
||||||
import java.util.Collections;
|
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.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.TaskAction;
|
||||||
|
import org.gradle.api.tasks.TaskExecutionException;
|
||||||
|
|
||||||
|
import org.springframework.boot.build.artifactory.ArtifactoryRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Task} for creating a Homebrew formula manifest.
|
* A {@link Task} for creating a Homebrew formula manifest.
|
||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @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<RegularFile> 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<RegularFile> 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<String, Object> additionalProperties) {
|
||||||
|
getProject().copy((copy) -> {
|
||||||
|
copy.from(this.template);
|
||||||
|
copy.into(this.outputDir);
|
||||||
|
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");
|
||||||
|
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
|
@TaskAction
|
||||||
void createFormula() {
|
void createFormula() {
|
||||||
|
@ -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('.'))));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -161,19 +161,6 @@ task tar(type: Tar) {
|
|||||||
configureArchive it
|
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) {
|
task homebrewFormula(type: org.springframework.boot.build.cli.HomebrewFormula) {
|
||||||
dependsOn tar
|
dependsOn tar
|
||||||
outputDir = file("${buildDir}/homebrew")
|
outputDir = file("${buildDir}/homebrew")
|
||||||
@ -193,7 +180,6 @@ publishing {
|
|||||||
artifact fullJar
|
artifact fullJar
|
||||||
artifact tar
|
artifact tar
|
||||||
artifact zip
|
artifact zip
|
||||||
artifact scoopManifestArtifact
|
|
||||||
artifact homebrewFormulaArtifact
|
artifact homebrewFormulaArtifact
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user