• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jreleaser / jreleaser / #475

03 Apr 2025 10:50AM UTC coverage: 40.322% (-8.9%) from 49.193%
#475

push

github

aalmiray
feat(release): Support Forgejo as releaser

Closes #1842

Closes #1843

182 of 1099 new or added lines in 45 files covered. (16.56%)

4239 existing lines in 333 files now uncovered.

20797 of 51577 relevant lines covered (40.32%)

0.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/core/jreleaser-engine/src/main/java/org/jreleaser/packagers/AsdfPackagerProcessor.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 *
4
 * Copyright 2020-2025 The JReleaser authors.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     https://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
package org.jreleaser.packagers;
19

20
import org.apache.commons.lang3.StringUtils;
21
import org.jreleaser.model.internal.JReleaserContext;
22
import org.jreleaser.model.internal.distributions.Distribution;
23
import org.jreleaser.model.internal.packagers.AsdfPackager;
24
import org.jreleaser.model.internal.release.BaseReleaser;
25
import org.jreleaser.model.internal.release.GithubReleaser;
26
import org.jreleaser.model.internal.release.Releaser;
27
import org.jreleaser.model.spi.packagers.PackagerProcessingException;
28
import org.jreleaser.mustache.TemplateContext;
29

30
import java.nio.file.Path;
31

32
import static org.jreleaser.model.Constants.KEY_ASDF_DISTRIBUTION_ARTIFACT_FILE;
33
import static org.jreleaser.model.Constants.KEY_ASDF_DISTRIBUTION_ARTIFACT_FILE_NAME;
34
import static org.jreleaser.model.Constants.KEY_ASDF_DISTRIBUTION_ARTIFACT_ROOT_ENTRY_NAME;
35
import static org.jreleaser.model.Constants.KEY_ASDF_DISTRIBUTION_URL;
36
import static org.jreleaser.model.Constants.KEY_ASDF_PLUGIN_REPOSITORY_URL;
37
import static org.jreleaser.model.Constants.KEY_ASDF_PLUGIN_REPO_URL;
38
import static org.jreleaser.model.Constants.KEY_ASDF_PLUGIN_TOOL_CHECK;
39
import static org.jreleaser.model.Constants.KEY_DISTRIBUTION_ARTIFACT_FILE;
40
import static org.jreleaser.model.Constants.KEY_DISTRIBUTION_ARTIFACT_FILE_NAME;
41
import static org.jreleaser.model.Constants.KEY_DISTRIBUTION_ARTIFACT_ROOT_ENTRY_NAME;
42
import static org.jreleaser.model.Constants.KEY_DISTRIBUTION_JAVA_MAIN_CLASS;
43
import static org.jreleaser.model.Constants.KEY_DISTRIBUTION_JAVA_MAIN_MODULE;
44
import static org.jreleaser.model.Constants.KEY_DISTRIBUTION_URL;
45
import static org.jreleaser.mustache.Templates.resolveTemplate;
46
import static org.jreleaser.templates.TemplateUtils.trimTplExtension;
47

48
/**
49
 * @author Andres Almiray
50
 * @since 1.2.0
51
 */
52
public class AsdfPackagerProcessor extends AbstractRepositoryPackagerProcessor<AsdfPackager> {
53
    public AsdfPackagerProcessor(JReleaserContext context) {
UNCOV
54
        super(context);
×
UNCOV
55
    }
×
56

57
    @Override
58
    protected void doPackageDistribution(Distribution distribution, TemplateContext props, Path packageDirectory) throws PackagerProcessingException {
59
        super.doPackageDistribution(distribution, props, packageDirectory);
×
60
        copyPreparedFiles(props);
×
61
    }
×
62

63
    @Override
64
    protected void fillPackagerProperties(TemplateContext props, Distribution distribution) {
65
        props.set(KEY_DISTRIBUTION_JAVA_MAIN_CLASS, distribution.getJava().getMainClass());
×
66
        props.set(KEY_DISTRIBUTION_JAVA_MAIN_MODULE, distribution.getJava().getMainModule());
×
67
        BaseReleaser<?, ?> releaser = context.getModel().getRelease().getReleaser();
×
68

69
        String repoUrl = releaser.getResolvedRepoUrl(context.getModel(), packager.getRepository().getOwner(), packager.getRepository().getResolvedName());
×
70

71
        props.set(KEY_ASDF_PLUGIN_REPO_URL, repoUrl);
×
72
        props.set(KEY_ASDF_PLUGIN_REPOSITORY_URL, repoUrl);
×
73
        props.set(KEY_ASDF_PLUGIN_TOOL_CHECK, resolveTemplate(packager.getToolCheck(), props));
×
74

75
        String str = props.get(KEY_DISTRIBUTION_ARTIFACT_FILE);
×
76
        str = str.replace(context.getModel().getProject().getEffectiveVersion(), "$ASDF_INSTALL_VERSION");
×
77
        props.set(KEY_ASDF_DISTRIBUTION_ARTIFACT_FILE, str);
×
78
        str = props.get(KEY_DISTRIBUTION_ARTIFACT_FILE_NAME);
×
79
        str = str.replace(context.getModel().getProject().getEffectiveVersion(), "$version");
×
80
        props.set(KEY_ASDF_DISTRIBUTION_ARTIFACT_FILE_NAME, str);
×
81
        str = props.get(KEY_DISTRIBUTION_ARTIFACT_ROOT_ENTRY_NAME);
×
82
        str = str.replace(context.getModel().getProject().getEffectiveVersion(), "$version");
×
83
        props.set(KEY_ASDF_DISTRIBUTION_ARTIFACT_ROOT_ENTRY_NAME, str);
×
84
        str = props.get(KEY_DISTRIBUTION_URL);
×
85
        str = str.replace(context.getModel().getProject().getEffectiveVersion(), "$version");
×
86
        props.set(KEY_ASDF_DISTRIBUTION_URL, str);
×
87
    }
×
88

89
    @Override
90
    protected void writeFile(Distribution distribution,
91
                             String content,
92
                             TemplateContext props,
93
                             Path outputDirectory,
94
                             String fileName) throws PackagerProcessingException {
95
        Releaser<?> gitService = context.getModel().getRelease().getReleaser();
×
96
        if (fileName.contains("github") && !(gitService instanceof GithubReleaser)) {
×
97
            // skip
98
            return;
×
99
        } else if (fileName.contains("-github")) {
×
100
            fileName = StringUtils.remove(fileName, "-github");
×
101
        }
102

103
        fileName = trimTplExtension(fileName);
×
104

105
        Path outputFile = outputDirectory.resolve(fileName);
×
106

107
        writeFile(content, outputFile);
×
108
    }
×
109
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc