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

jreleaser / jreleaser / #510

27 Jul 2025 12:31PM UTC coverage: 45.783% (-3.6%) from 49.39%
#510

push

github

aalmiray
feat(packagers): Stage distribution publication in a fixed directory

Closes #1943

12 of 25 new or added lines in 4 files covered. (48.0%)

2208 existing lines in 190 files now uncovered.

23924 of 52255 relevant lines covered (45.78%)

0.46 hits per line

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

0.0
/core/jreleaser-model-impl/src/main/java/org/jreleaser/model/internal/util/SdkmanHelper.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.model.internal.util;
19

20
import org.jreleaser.bundle.RB;
21
import org.jreleaser.model.internal.JReleaserContext;
22
import org.jreleaser.model.internal.common.Artifact;
23
import org.jreleaser.model.internal.distributions.Distribution;
24
import org.jreleaser.util.PlatformUtils;
25

26
import java.util.Map;
27

28
import static org.jreleaser.model.api.packagers.SdkmanPackager.SKIP_SDKMAN;
29
import static org.jreleaser.util.FileType.ZIP;
30
import static org.jreleaser.util.StringUtils.isBlank;
31
import static org.jreleaser.util.StringUtils.isTrue;
32

33
/**
34
 * @author Andres Almiray
35
 * @since 1.0.0
36
 */
37
public final class SdkmanHelper {
38
    private static final String UNIVERSAL = "UNIVERSAL";
39
    private static final String MAC_ARM_64 = "MAC_ARM64";
40
    private static final String MAC_OSX = "MAC_OSX";
41
    private static final String LINUX_32 = "LINUX_32";
42
    private static final String LINUX_64 = "LINUX_64";
43
    private static final String LINUX_ARM_32 = "LINUX_ARM32";
44
    private static final String LINUX_ARM_64 = "LINUX_ARM64";
45
    private static final String WINDOWS_64 = "WINDOWS_64";
46

47
    private SdkmanHelper() {
48
        // noop
49
    }
50

51
    public static void collectArtifacts(JReleaserContext context, Distribution distribution, Map<String, String> platforms) {
UNCOV
52
        for (Artifact artifact : distribution.getArtifacts()) {
×
UNCOV
53
            if (!artifact.isActiveAndSelected()) continue;
×
54
            // only zips are supported
UNCOV
55
            if (!artifact.getPath().endsWith(ZIP.extension())) {
×
UNCOV
56
                context.getLogger().debug(RB.$("sdkman.no.artifacts.match"),
×
UNCOV
57
                    artifact.getEffectivePath(context, distribution).getFileName());
×
UNCOV
58
                continue;
×
59
            }
60

UNCOV
61
            if (isTrue(artifact.getExtraProperties().get(SKIP_SDKMAN))) {
×
62
                context.getLogger().debug(RB.$("sdkman.artifact.explicit.skip"),
×
63
                    artifact.getEffectivePath(context, distribution).getFileName());
×
64
                continue;
×
65
            }
66

UNCOV
67
            if (artifact.isOptional(context) && !artifact.resolvedPathExists()) {
×
68
                context.getLogger().debug(RB.$("sdkman.artifact.optional"),
×
69
                    artifact.getEffectivePath(context, distribution).getFileName());
×
70
                continue;
×
71
            }
72

UNCOV
73
            String platform = mapPlatform(artifact.getPlatform());
×
UNCOV
74
            if (isBlank(platform)) {
×
75
                context.getLogger().warn(RB.$("sdkman.platform.unsupported"), artifact.getPlatform());
×
76
                continue;
×
77
            }
78

UNCOV
79
            String url = artifactUrl(context, distribution, artifact);
×
UNCOV
80
            if (platforms.containsKey(platform)) {
×
81
                context.getLogger().warn(RB.$("sdkman.platform.replacement"), platform, url, platforms.get(platform));
×
82
            }
UNCOV
83
            platforms.put(platform, url);
×
UNCOV
84
        }
×
UNCOV
85
    }
×
86

87
    private static String mapPlatform(String platform) {
88
        /*
89
           SDKMAN! supports the following platform mappings
90
           - LINUX_64
91
           - LINUX_32
92
           - LINUX_ARM32
93
           - LINUX_ARM64
94
           - MAC_OSX
95
           - MAC_ARM64
96
           - WINDOWS_64
97
           - UNIVERSAL
98
         */
99

UNCOV
100
        if (isBlank(platform)) {
×
UNCOV
101
            return UNIVERSAL;
×
102
        }
103
        if (PlatformUtils.isMac(platform) || platform.contains("mac")) {
×
104
            return PlatformUtils.isArm(platform) ? MAC_ARM_64 : MAC_OSX;
×
105
        } else if (PlatformUtils.isWindows(platform)) {
×
106
            return WINDOWS_64;
×
107
        } else if (PlatformUtils.isLinux(platform)) {
×
108
            if (PlatformUtils.isIntel32(platform)) return LINUX_32;
×
109
            if (PlatformUtils.isIntel64(platform)) return LINUX_64;
×
110
            if (PlatformUtils.isArm32(platform)) return LINUX_ARM_32;
×
111
            if (PlatformUtils.isArm64(platform)) return LINUX_ARM_64;
×
112
            return LINUX_32;
×
113
        }
114

115
        return null;
×
116
    }
117

118
    private static String artifactUrl(JReleaserContext context, Distribution distribution, Artifact artifact) {
UNCOV
119
        return Artifacts.resolveDownloadUrl(context, context.getModel().getAnnounce().getSdkman(), distribution, artifact);
×
120
    }
121
}
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