use of org.jreleaser.util.JReleaserException in project jreleaser by jreleaser.
the class Assemblers method assemble.
private static void assemble(JReleaserContext context, Assembler assembler) {
try {
context.getLogger().increaseIndent();
context.getLogger().setPrefix(assembler.getType());
DistributionAssembler processor = createDistributionAssembler(context, assembler);
processor.assemble();
context.getLogger().restorePrefix();
context.getLogger().decreaseIndent();
} catch (AssemblerProcessingException e) {
throw new JReleaserException(e.getMessage(), e);
}
}
use of org.jreleaser.util.JReleaserException in project jreleaser by jreleaser.
the class ModelAutoConfigurer method autoConfiguredModel.
private JReleaserModel autoConfiguredModel(Path basedir) {
JReleaserModel model = new JReleaserModel();
model.getProject().setName(projectName);
model.getProject().setVersion(projectVersion);
model.getProject().setVersionPattern(projectVersionPattern);
model.getProject().getSnapshot().setPattern(projectSnapshotPattern);
model.getProject().getSnapshot().setLabel(projectSnapshotLabel);
model.getProject().getSnapshot().setFullChangelog(projectSnapshotFullChangelog);
try {
Repository repository = GitSdk.of(basedir, gitRootSearch).getRemote();
GitService service = null;
switch(repository.getKind()) {
case GITHUB:
service = new Github();
model.getRelease().setGithub((Github) service);
if (prerelease)
((Github) service).getPrerelease().setEnabled(true);
((Github) service).getPrerelease().setPattern(prereleasePattern);
((Github) service).setDraft(draft);
break;
case GITLAB:
service = new Gitlab();
model.getRelease().setGitlab((Gitlab) service);
break;
case CODEBERG:
service = new Codeberg();
model.getRelease().setCodeberg((Codeberg) service);
if (prerelease)
((Codeberg) service).getPrerelease().setEnabled(true);
((Codeberg) service).getPrerelease().setPattern(prereleasePattern);
((Codeberg) service).setDraft(draft);
break;
default:
throw new JReleaserException(RB.$("ERROR_context_configurer_unsupported_url", repository.getHttpUrl()));
}
service.setUsername(username);
service.setTagName(tagName);
service.setPreviousTagName(previousTagName);
service.setReleaseName(releaseName);
service.getMilestone().setName(milestoneName);
service.setOverwrite(overwrite);
service.getUpdate().setEnabled(update);
if (!updateSections.isEmpty()) {
if (!update) {
throw new JReleaserException(RB.$("ERROR_context_configurer_update_not_set"));
}
service.getUpdate().setSections(updateSections);
}
service.setSkipTag(skipTag);
service.setSkipRelease(skipRelease);
if (isNotBlank(branch))
service.setBranch(branch);
if (isNotBlank(changelog))
service.getChangelog().setExternal(changelog);
if (isNotBlank(commitAuthorName))
service.getCommitAuthor().setName(commitAuthorName);
if (isNotBlank(commitAuthorEmail))
service.getCommitAuthor().setEmail(commitAuthorEmail);
if (changelogFormatted)
service.getChangelog().setFormatted(Active.ALWAYS);
} catch (IOException e) {
throw new JReleaserException(e.getMessage());
}
if (signing) {
model.getSigning().setActive(Active.ALWAYS);
model.getSigning().setArmored(armored);
}
if (!files.isEmpty()) {
for (String file : files) {
model.getFiles().addArtifact(Artifact.of(basedir.resolve(file)));
}
}
if (!globs.isEmpty()) {
model.getFiles().addArtifacts(Artifacts.resolveFiles(logger, basedir, globs));
}
return model;
}
use of org.jreleaser.util.JReleaserException in project jreleaser by jreleaser.
the class Distributions method processPackager.
private static void processPackager(JReleaserContext context, Distribution distribution, String packagerName, PackagerProcessingFunction function) {
context.getLogger().increaseIndent();
context.getLogger().setPrefix(packagerName);
try {
DistributionProcessor processor = createDistributionProcessor(context, distribution, packagerName);
function.consume(processor);
} catch (PackagerProcessingException e) {
throw new JReleaserException(RB.$("ERROR_unexpected_error"), e);
}
context.getLogger().restorePrefix();
context.getLogger().decreaseIndent();
}
use of org.jreleaser.util.JReleaserException in project jreleaser by jreleaser.
the class GoogleChat method getResolvedMessageTemplate.
public String getResolvedMessageTemplate(JReleaserContext context, Map<String, Object> extraProps) {
Map<String, Object> props = context.fullProps();
applyTemplates(props, getResolvedExtraProperties());
props.put(KEY_TAG_NAME, context.getModel().getRelease().getGitService().getEffectiveTagName(context.getModel()));
props.putAll(extraProps);
Path templatePath = context.getBasedir().resolve(messageTemplate);
try {
Reader reader = java.nio.file.Files.newBufferedReader(templatePath);
return applyTemplate(reader, props);
} catch (IOException e) {
throw new JReleaserException(RB.$("ERROR_unexpected_error_reading_template", context.relativizeToBasedir(templatePath)));
}
}
use of org.jreleaser.util.JReleaserException in project jreleaser by jreleaser.
the class Glob method resolveDirectory.
private Path resolveDirectory(JReleaserContext context) {
// resolve directory
Path path = context.getBasedir();
if (isNotBlank(directory)) {
directory = Artifacts.resolveForGlob(directory, context, this);
path = context.getBasedir().resolve(Paths.get(directory)).normalize();
if (context.getMode().validatePaths() && !exists(path)) {
throw new JReleaserException(RB.$("ERROR_path_does_not_exist", context.relativizeToBasedir(path)));
}
}
return path;
}
Aggregations