|
|
@ -23,6 +23,7 @@ import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
|
import org.gradle.api.DefaultTask;
|
|
|
|
import org.gradle.api.DefaultTask;
|
|
|
|
|
|
|
|
import org.gradle.api.Project;
|
|
|
|
import org.gradle.api.file.RegularFile;
|
|
|
|
import org.gradle.api.file.RegularFile;
|
|
|
|
import org.gradle.api.provider.Provider;
|
|
|
|
import org.gradle.api.provider.Provider;
|
|
|
|
import org.gradle.api.tasks.InputFile;
|
|
|
|
import org.gradle.api.tasks.InputFile;
|
|
|
@ -38,9 +39,14 @@ import org.springframework.boot.build.artifactory.ArtifactoryRepository;
|
|
|
|
* a Homebrew formula.
|
|
|
|
* a Homebrew formula.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
|
|
|
|
* @author Phillip Webb
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public abstract class AbstractPackageManagerDefinitionTask extends DefaultTask {
|
|
|
|
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 Provider<RegularFile> archive;
|
|
|
|
|
|
|
|
|
|
|
|
private File template;
|
|
|
|
private File template;
|
|
|
@ -84,12 +90,17 @@ public abstract class AbstractPackageManagerDefinitionTask extends DefaultTask {
|
|
|
|
getProject().copy((copy) -> {
|
|
|
|
getProject().copy((copy) -> {
|
|
|
|
copy.from(this.template);
|
|
|
|
copy.from(this.template);
|
|
|
|
copy.into(this.outputDir);
|
|
|
|
copy.into(this.outputDir);
|
|
|
|
|
|
|
|
copy.expand(getProperties(additionalProperties));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, Object> getProperties(Map<String, Object> additionalProperties) {
|
|
|
|
Map<String, Object> properties = new HashMap<>(additionalProperties);
|
|
|
|
Map<String, Object> properties = new HashMap<>(additionalProperties);
|
|
|
|
|
|
|
|
Project project = getProject();
|
|
|
|
properties.put("hash", sha256(this.archive.get().getAsFile()));
|
|
|
|
properties.put("hash", sha256(this.archive.get().getAsFile()));
|
|
|
|
properties.put("repo", ArtifactoryRepository.forProject(getProject()));
|
|
|
|
properties.put("repo", getRepo(project));
|
|
|
|
properties.put("project", getProject());
|
|
|
|
properties.put("project", project);
|
|
|
|
copy.expand(properties);
|
|
|
|
return properties;
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String sha256(File file) {
|
|
|
|
private String sha256(File file) {
|
|
|
@ -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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|