Search in sources :

Example 6 with JReleaserException

use of org.jreleaser.util.JReleaserException in project jreleaser by jreleaser.

the class Discussions method getResolvedMessageTemplate.

public String getResolvedMessageTemplate(JReleaserContext context, Map<String, Object> extraProps) {
    Map<String, Object> props = context.fullProps();
    applyTemplates(props, getResolvedExtraProperties());
    props.put(Constants.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 7 with JReleaserException

use of org.jreleaser.util.JReleaserException in project jreleaser by jreleaser.

the class AbstractJReleaserMojo method createContext.

protected JReleaserContext createContext() throws MojoExecutionException {
    try {
        if (isQuiet()) {
            System.setProperty(JRELEASER_QUIET, "true");
        }
        JReleaserLogger logger = getLogger();
        PlatformUtils.resolveCurrentPlatform(logger);
        Path basedir = resolveBasedir();
        logger.info("JReleaser {}", JReleaserVersion.getPlainVersion());
        JReleaserVersion.banner(logger.getTracer());
        if (null != configFile) {
            logger.info("Configuring with {}", configFile.getAbsolutePath());
        }
        logger.increaseIndent();
        logger.info("- basedir set to {}", basedir.toAbsolutePath());
        logger.decreaseIndent();
        return ContextCreator.create(logger, resolveConfigurer(configFile), getMode(), null == configFile ? convertModel() : readModel(logger), basedir, outputDirectory.toPath(), dryrun, gitRootSearch, collectSelectedPlatforms());
    } catch (JReleaserException e) {
        throw new MojoExecutionException("JReleaser for project " + project.getArtifactId() + " has not been properly configured.", e);
    }
}
Also used : Path(java.nio.file.Path) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) JReleaserLogger(org.jreleaser.util.JReleaserLogger) JReleaserException(org.jreleaser.util.JReleaserException)

Example 8 with JReleaserException

use of org.jreleaser.util.JReleaserException in project jreleaser by jreleaser.

the class JpackageResolver method resolveJpackageOutputs.

private static void resolveJpackageOutputs(JReleaserContext context, Jpackage jpackage, Errors errors) {
    Path baseOutputDirectory = context.getAssembleDirectory().resolve(jpackage.getName()).resolve(jpackage.getType());
    Artifact jdk = jpackage.getResolvedPlatformPackager().getJdk();
    if (!context.isPlatformSelected(jdk))
        return;
    Jpackage.PlatformPackager packager = jpackage.getResolvedPlatformPackager();
    String platform = jdk.getPlatform();
    for (String type : packager.getTypes()) {
        try {
            Optional<Path> file = listFilesAndProcess(baseOutputDirectory, files -> files.filter(path -> path.getFileName().toString().endsWith(type)).findFirst());
            if (!file.isPresent()) {
                errors.assembly(RB.$("validation_missing_assembly", jpackage.getType(), jpackage.getName(), jpackage.getName()));
            } else {
                Artifact artifact = Artifact.of(file.get(), platform);
                artifact.setExtraProperties(jpackage.getExtraProperties());
                artifact.activate();
                jpackage.addOutput(artifact);
            }
        } catch (IOException e) {
            throw new JReleaserException(RB.$("ERROR_unexpected_error"), e);
        }
    }
}
Also used : Path(java.nio.file.Path) Jpackage(org.jreleaser.model.Jpackage) IOException(java.io.IOException) Artifact(org.jreleaser.model.Artifact) JReleaserException(org.jreleaser.util.JReleaserException)

Example 9 with JReleaserException

use of org.jreleaser.util.JReleaserException in project jreleaser by jreleaser.

the class Webhook 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 10 with JReleaserException

use of org.jreleaser.util.JReleaserException in project jreleaser by jreleaser.

the class Zulip 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)

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