use of org.jreleaser.sdk.tool.ToolException in project jreleaser by jreleaser.
the class NativeImageAssemblerProcessor method upx.
private void upx(Path image) throws AssemblerProcessingException {
Upx upx = new Upx(context, assembler.getUpx().getVersion());
try {
if (!upx.setup()) {
context.getLogger().warn(RB.$("tool_unavailable", "upx"));
return;
}
} catch (ToolException e) {
throw new AssemblerProcessingException(e.getMessage(), e);
}
List<String> args = new ArrayList<>(assembler.getUpx().getArgs());
args.add(image.getFileName().toString());
context.getLogger().info("upx {}", image.getFileName().toString());
try {
upx.compress(image.getParent(), args);
} catch (CommandException e) {
throw new AssemblerProcessingException(RB.$("ERROR_unexpected_error"), e);
}
}
use of org.jreleaser.sdk.tool.ToolException in project jreleaser by jreleaser.
the class Signer method cosignSign.
private static void cosignSign(JReleaserContext context) throws SigningException {
Signing signing = context.getModel().getSigning();
Cosign cosign = new Cosign(context, signing.getCosign().getVersion());
try {
if (!cosign.setup()) {
context.getLogger().warn(RB.$("tool_unavailable", "cosign"));
return;
}
} catch (ToolException e) {
throw new SigningException(e.getMessage(), e);
}
String privateKey = signing.getCosign().getResolvedPrivateKeyFile();
String publicKey = signing.getCosign().getResolvedPublicKeyFile();
Path privateKeyFile = isNotBlank(privateKey) ? context.getBasedir().resolve(privateKey) : null;
Path publicKeyFile = isNotBlank(publicKey) ? context.getBasedir().resolve(publicKey) : null;
byte[] password = (signing.getResolvedCosignPassword() + System.lineSeparator()).getBytes();
boolean forceSign = false;
if (null == privateKeyFile) {
privateKeyFile = signing.getCosign().getResolvedPrivateKeyFilePath(context);
publicKeyFile = privateKeyFile.resolveSibling("cosign.pub");
if (!Files.exists(privateKeyFile)) {
privateKeyFile = cosign.generateKeyPair(password);
forceSign = true;
}
}
Path thePublicKeyFile = publicKeyFile;
List<FilePair> files = collectArtifacts(context, forceSign, pair -> isValid(context, cosign, thePublicKeyFile, pair));
if (files.isEmpty()) {
context.getLogger().info(RB.$("signing.no.match"));
return;
}
files = files.stream().filter(FilePair::isInvalid).collect(Collectors.toList());
if (files.isEmpty()) {
context.getLogger().info(RB.$("signing.up.to.date"));
return;
}
if (!cosign.checkPassword(privateKeyFile, password)) {
context.getLogger().warn(RB.$("WARN_cosign_password_does_not_match", "cosign"));
return;
}
sign(context, files, cosign, privateKeyFile, password);
verify(context, files, cosign, publicKeyFile);
}
Aggregations