Search in sources :

Example 1 with Gitlab

use of org.jreleaser.model.Gitlab 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 2 with Gitlab

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

the class ModelConfigurer method autoConfigureGitlab.

private static void autoConfigureGitlab(JReleaserContext context, Repository repository) {
    GitService service = context.getModel().getRelease().getGitService();
    if (service != null) {
        if (!(service instanceof Gitlab)) {
            context.getModel().getRelease().getGitService().setMatch(false);
            context.getModel().getRelease().getGitService().setSkipTag(true);
            context.getLogger().warn(RB.$("ERROR_context_configurer_detected_git"), "gitlab", service.getServiceName());
        }
    } else {
        context.getModel().getRelease().setGitlab(new Gitlab());
    }
    fillGitProperties(context.getModel().getRelease().getGitService(), repository, context.getModel().getCommit());
}
Also used : GitService(org.jreleaser.model.GitService) Gitlab(org.jreleaser.model.Gitlab)

Aggregations

GitService (org.jreleaser.model.GitService)2 Gitlab (org.jreleaser.model.Gitlab)2 IOException (java.io.IOException)1 Codeberg (org.jreleaser.model.Codeberg)1 Github (org.jreleaser.model.Github)1 JReleaserModel (org.jreleaser.model.JReleaserModel)1 Repository (org.jreleaser.model.releaser.spi.Repository)1 JReleaserException (org.jreleaser.util.JReleaserException)1