Search in sources :

Example 1 with JReleaserContext

use of org.jreleaser.model.JReleaserContext in project jreleaser by jreleaser.

the class ContextCreator method create.

public static JReleaserContext create(JReleaserLogger logger, JReleaserContext.Configurer configurer, JReleaserContext.Mode mode, JReleaserModel model, Path basedir, Path outputDirectory, boolean dryrun, boolean gitRootSearch, List<String> selectedPlatforms) {
    JReleaserContext context = new JReleaserContext(logger, configurer, mode, model, basedir, outputDirectory, dryrun, gitRootSearch, selectedPlatforms);
    PlatformUtils.resolveCurrentPlatform(logger);
    ModelConfigurer.configure(context);
    return context;
}
Also used : JReleaserContext(org.jreleaser.model.JReleaserContext)

Example 2 with JReleaserContext

use of org.jreleaser.model.JReleaserContext in project jreleaser by jreleaser.

the class Uploaders method upload.

public static void upload(JReleaserContext context) {
    Upload upload = context.getModel().getUpload();
    if (!upload.isEnabled()) {
        context.getLogger().info(RB.$("uploaders.not.enabled"));
        return;
    }
    if (!context.getIncludedUploaderTypes().isEmpty()) {
        for (String uploaderType : context.getIncludedUploaderTypes()) {
            // check if the uploaderType is valid
            if (!Upload.supportedUploaders().contains(uploaderType)) {
                context.getLogger().warn(RB.$("ERROR_unsupported_uploader", uploaderType));
                continue;
            }
            Map<String, Uploader> uploaders = upload.findUploadersByType(uploaderType);
            if (uploaders.isEmpty()) {
                context.getLogger().debug(RB.$("uploaders.no.match"), uploaderType);
                return;
            }
            if (!context.getIncludedUploaderNames().isEmpty()) {
                for (String uploaderName : context.getIncludedUploaderNames()) {
                    if (!uploaders.containsKey(uploaderName)) {
                        context.getLogger().warn(RB.$("uploaders.uploader.not.configured"), uploaderType, uploaderName);
                        continue;
                    }
                    Uploader uploader = uploaders.get(uploaderName);
                    if (!uploader.isEnabled()) {
                        context.getLogger().info(RB.$("uploaders.uploader.disabled"), uploaderType, uploaderName);
                        continue;
                    }
                    context.getLogger().info(RB.$("uploaders.upload.with"), uploaderType, uploaderName);
                    upload(context, uploader);
                }
            } else {
                context.getLogger().info(RB.$("uploaders.upload.all.artifacts.with"), uploaderType);
                uploaders.values().forEach(uploader -> upload(context, uploader));
            }
        }
    } else if (!context.getIncludedUploaderNames().isEmpty()) {
        for (String uploaderName : context.getIncludedUploaderNames()) {
            List<Uploader> filteredUploaders = upload.findAllActiveUploaders().stream().filter(a -> uploaderName.equals(a.getName())).collect(toList());
            if (!filteredUploaders.isEmpty()) {
                context.getLogger().info(RB.$("uploaders.upload.all.artifacts.to"), uploaderName);
                filteredUploaders.forEach(uploader -> upload(context, uploader));
            } else {
                context.getLogger().warn(RB.$("uploaders.uploader.not.configured2"), uploaderName);
            }
        }
    } else {
        context.getLogger().info(RB.$("uploaders.upload.all.artifacts"));
        for (Uploader uploader : upload.findAllActiveUploaders()) {
            String uploaderType = uploader.getType();
            String uploaderName = uploader.getName();
            if (context.getExcludedUploaderTypes().contains(uploaderType) || context.getExcludedUploaderNames().contains(uploaderName)) {
                context.getLogger().info(RB.$("uploaders.uploader.excluded"), uploaderType, uploaderName);
                continue;
            }
            upload(context, uploader);
        }
    }
}
Also used : List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) UploadException(org.jreleaser.model.uploader.spi.UploadException) Map(java.util.Map) JReleaserContext(org.jreleaser.model.JReleaserContext) JReleaserException(org.jreleaser.util.JReleaserException) Uploader(org.jreleaser.model.Uploader) RB(org.jreleaser.bundle.RB) Upload(org.jreleaser.model.Upload) Upload(org.jreleaser.model.Upload) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Uploader(org.jreleaser.model.Uploader)

Example 3 with JReleaserContext

use of org.jreleaser.model.JReleaserContext in project jreleaser by jreleaser.

the class JReleaserAnnounceMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    Banner.display(project, getLog());
    if (skip) {
        getLog().info("Execution has been explicitly skipped.");
        return;
    }
    JReleaserContext context = createContext();
    context.setIncludedAnnouncers(collectEntries(includedAnnouncers, true));
    context.setExcludedAnnouncers(collectEntries(excludedAnnouncers, true));
    Workflows.announce(context).execute();
}
Also used : JReleaserContext(org.jreleaser.model.JReleaserContext)

Example 4 with JReleaserContext

use of org.jreleaser.model.JReleaserContext in project jreleaser by jreleaser.

the class JReleaserFullReleaseMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    Banner.display(project, getLog());
    if (skip) {
        getLog().info("Execution has been explicitly skipped.");
        return;
    }
    JReleaserContext context = createContext();
    context.setIncludedUploaderTypes(collectEntries(includedUploaders, true));
    context.setIncludedUploaderNames(collectEntries(includedUploaderNames));
    context.setIncludedDistributions(collectEntries(includedDistributions));
    context.setIncludedPackagers(collectEntries(includedPackagers, true));
    context.setIncludedAnnouncers(collectEntries(includedAnnouncers, true));
    context.setExcludedUploaderTypes(collectEntries(excludedUploaders, true));
    context.setExcludedUploaderNames(collectEntries(excludedUploaderNames));
    context.setExcludedDistributions(collectEntries(excludedDistributions));
    context.setExcludedPackagers(collectEntries(excludedPackagers, true));
    context.setExcludedAnnouncers(collectEntries(excludedAnnouncers, true));
    Workflows.fullRelease(context).execute();
}
Also used : JReleaserContext(org.jreleaser.model.JReleaserContext)

Example 5 with JReleaserContext

use of org.jreleaser.model.JReleaserContext in project jreleaser by jreleaser.

the class JReleaserPackageMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    Banner.display(project, getLog());
    if (skip) {
        getLog().info("Execution has been explicitly skipped.");
        return;
    }
    JReleaserContext context = createContext();
    context.setIncludedPackagers(collectEntries(includedPackagers, true));
    context.setIncludedDistributions(collectEntries(includedDistributions));
    context.setExcludedPackagers(collectEntries(excludedPackagers, true));
    context.setExcludedDistributions(collectEntries(excludedDistributions));
    Workflows.packageRelease(context).execute();
}
Also used : JReleaserContext(org.jreleaser.model.JReleaserContext)

Aggregations

JReleaserContext (org.jreleaser.model.JReleaserContext)29 RB (org.jreleaser.bundle.RB)13 Map (java.util.Map)11 List (java.util.List)10 Project (org.jreleaser.model.Project)8 StringUtils.isBlank (org.jreleaser.util.StringUtils.isBlank)8 StringUtils.isNotBlank (org.jreleaser.util.StringUtils.isNotBlank)8 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)7 Active (org.jreleaser.model.Active)7 Artifact (org.jreleaser.model.Artifact)7 Errors (org.jreleaser.util.Errors)7 ArrayList (java.util.ArrayList)5 LinkedHashSet (java.util.LinkedHashSet)5 Optional (java.util.Optional)5 Set (java.util.Set)5 Collectors (java.util.stream.Collectors)5 TemplateValidator.validateTemplate (org.jreleaser.model.validation.TemplateValidator.validateTemplate)5 PlatformUtils (org.jreleaser.util.PlatformUtils)5 IOException (java.io.IOException)4 Distribution (org.jreleaser.model.Distribution)4