Search in sources :

Example 1 with JReleaserException

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);
    }
}
Also used : AssemblerProcessingException(org.jreleaser.model.assembler.spi.AssemblerProcessingException) JReleaserException(org.jreleaser.util.JReleaserException)

Example 2 with JReleaserException

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;
}
Also used : Codeberg(org.jreleaser.model.Codeberg) Repository(org.jreleaser.model.releaser.spi.Repository) Github(org.jreleaser.model.Github) JReleaserModel(org.jreleaser.model.JReleaserModel) GitService(org.jreleaser.model.GitService) IOException(java.io.IOException) Gitlab(org.jreleaser.model.Gitlab) JReleaserException(org.jreleaser.util.JReleaserException)

Example 3 with JReleaserException

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();
}
Also used : PackagerProcessingException(org.jreleaser.model.packager.spi.PackagerProcessingException) JReleaserException(org.jreleaser.util.JReleaserException)

Example 4 with JReleaserException

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)));
    }
}
Also used : Path(java.nio.file.Path) Reader(java.io.Reader) IOException(java.io.IOException) JReleaserException(org.jreleaser.util.JReleaserException)

Example 5 with JReleaserException

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;
}
Also used : Path(java.nio.file.Path) JReleaserException(org.jreleaser.util.JReleaserException)

Aggregations

JReleaserException (org.jreleaser.util.JReleaserException)31 IOException (java.io.IOException)23 Path (java.nio.file.Path)22 Reader (java.io.Reader)15 ArrayList (java.util.ArrayList)3 LinkedHashMap (java.util.LinkedHashMap)3 Artifact (org.jreleaser.model.Artifact)3 PrintWriter (java.io.PrintWriter)2 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)2 FileSystem (java.nio.file.FileSystem)2 PathMatcher (java.nio.file.PathMatcher)2 Map (java.util.Map)2 Scanner (java.util.Scanner)2 JReleaserModel (org.jreleaser.model.JReleaserModel)2 ResolvedType (com.fasterxml.classmate.ResolvedType)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 SerializationFeature (com.fasterxml.jackson.databind.SerializationFeature)1 Option (com.github.victools.jsonschema.generator.Option)1 OptionPreset (com.github.victools.jsonschema.generator.OptionPreset)1 SchemaGenerationContext (com.github.victools.jsonschema.generator.SchemaGenerationContext)1