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

jreleaser / jreleaser / #558

08 Dec 2025 02:56PM UTC coverage: 48.239% (+0.02%) from 48.215%
#558

push

github

aalmiray
feat(core): warn when a name template cannot be resolved

Closes #1960

Closes #1961

299 of 573 new or added lines in 133 files covered. (52.18%)

4 existing lines in 4 files now uncovered.

26047 of 53996 relevant lines covered (48.24%)

0.48 hits per line

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

5.88
/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) {
54
        super(context);
1✔
55
    }
1✔
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

NEW
69
        String repoUrl = releaser.getResolvedRepoUrl(context, 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);
×
NEW
73
        props.set(KEY_ASDF_PLUGIN_TOOL_CHECK, resolveTemplate(context.getLogger(), 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