use of org.jreleaser.util.MustacheUtils in project jreleaser by jreleaser.
the class BrewPackagerProcessor method fillPackagerProperties.
@Override
protected void fillPackagerProperties(Map<String, Object> props, Distribution distribution) throws PackagerProcessingException {
GitService gitService = context.getModel().getRelease().getGitService();
props.put(KEY_BREW_FORMULA_NAME, packager.getResolvedFormulaName(props));
props.put(KEY_HOMEBREW_TAP_REPO_URL, gitService.getResolvedRepoUrl(context.getModel(), packager.getTap().getOwner(), packager.getTap().getResolvedName()));
props.put(KEY_HOMEBREW_TAP_REPO_CLONE_URL, gitService.getResolvedRepoCloneUrl(context.getModel(), packager.getTap().getOwner(), packager.getTap().getResolvedName()));
props.put(KEY_BREW_HAS_LIVECHECK, packager.hasLivecheck());
if (packager.hasLivecheck()) {
props.put(KEY_BREW_LIVECHECK, packager.getLivecheck().stream().map(line -> resolveTemplate(line, props)).map(MustacheUtils::passThrough).collect(Collectors.toList()));
}
Brew.Cask cask = packager.getCask();
if (cask.isEnabled()) {
boolean hasPkg = isNotBlank(cask.getPkgName());
boolean hasApp = isNotBlank(cask.getAppName());
props.put(KEY_BREW_CASK_NAME, cask.getResolvedCaskName(props));
props.put(KEY_BREW_CASK_DISPLAY_NAME, cask.getResolvedDisplayName(props));
props.put(KEY_BREW_CASK_HAS_UNINSTALL, !cask.getUninstallItems().isEmpty());
props.put(KEY_BREW_CASK_HAS_PKG, hasPkg);
if (hasPkg) {
props.put(KEY_BREW_CASK_PKG, cask.getResolvedPkgName(props));
}
props.put(KEY_BREW_CASK_HAS_APP, hasApp);
if (hasApp) {
props.put(KEY_BREW_CASK_APP, cask.getResolvedAppName(props));
}
props.put(KEY_BREW_CASK_UNINSTALL, cask.getUninstallItems());
props.put(KEY_BREW_CASK_HAS_ZAP, !cask.getZapItems().isEmpty());
props.put(KEY_BREW_CASK_ZAP, cask.getZapItems());
String appcast = cask.getResolvedAppcast(props);
props.put(KEY_BREW_CASK_HAS_APPCAST, isNotBlank(appcast));
props.put(KEY_BREW_CASK_APPCAST, appcast);
if (!hasApp && !hasPkg) {
for (Artifact artifact : collectArtifacts(distribution)) {
if (artifact.getPath().endsWith(ZIP.extension())) {
props.put(KEY_DISTRIBUTION_URL, resolveArtifactUrl(props, distribution, artifact));
props.put(KEY_BREW_CASK_HAS_BINARY, true);
break;
}
}
}
} else if (packager.isMultiPlatform()) {
List<String> multiPlatforms = new ArrayList<>();
for (Artifact artifact : collectArtifacts(distribution)) {
if (!artifact.getPath().endsWith(ZIP.extension()) || isBlank(artifact.getPlatform()))
continue;
String template = null;
String artifactUrl = resolveArtifactUrl(props, distribution, artifact);
if (PlatformUtils.isMac(artifact.getPlatform())) {
if (PlatformUtils.isArm(artifact.getPlatform())) {
template = TPL_MAC_ARM;
} else {
template = TPL_MAC_INTEL;
}
} else if (PlatformUtils.isLinux(artifact.getPlatform())) {
if (PlatformUtils.isArm(artifact.getPlatform())) {
template = TPL_LINUX_ARM;
} else {
template = TPL_LINUX_INTEL;
}
}
if (isNotBlank(template)) {
Map<String, Object> newProps = new LinkedHashMap<>(props);
newProps.put(KEY_DISTRIBUTION_URL, artifactUrl);
newProps.put(KEY_DISTRIBUTION_CHECKSUM_SHA_256, artifact.getHash(Algorithm.SHA_256));
multiPlatforms.add(resolveTemplate(template, newProps));
}
}
if (multiPlatforms.isEmpty()) {
throw new PackagerProcessingException(org.jreleaser.bundle.RB.$("ERROR_brew_multiplatform_artifacts"));
}
props.put(KEY_BREW_MULTIPLATFORM, passThrough(String.join(System.lineSeparator() + " ", multiPlatforms)));
} else if ((distribution.getType() == Distribution.DistributionType.JAVA_BINARY || distribution.getType() == Distribution.DistributionType.SINGLE_JAR) && !isTrue(packager.getExtraProperties().get(SKIP_JAVA))) {
packager.addDependency("openjdk@" + props.get(KEY_DISTRIBUTION_JAVA_VERSION));
}
props.put(KEY_BREW_DEPENDENCIES, packager.getDependenciesAsList().stream().map(dependency -> passThrough(dependency.toString())).collect(Collectors.toList()));
}
Aggregations