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

jreleaser / jreleaser / #556

22 Nov 2025 04:17PM UTC coverage: 46.213% (-2.0%) from 48.203%
#556

push

github

aalmiray
feat(jdks): Allow filtering by platform

Closes #2000

Co-authored-by: Ixchel Ruiz <ixchelruiz@yahoo.com>

0 of 42 new or added lines in 5 files covered. (0.0%)

1116 existing lines in 107 files now uncovered.

24939 of 53965 relevant lines covered (46.21%)

0.46 hits per line

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

0.0
/plugins/jdks-maven-plugin/src/main/java/org/jreleaser/jdks/maven/plugin/AbstractSetupMojo.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.jdks.maven.plugin;
19

20
import org.apache.maven.plugin.AbstractMojo;
21
import org.apache.maven.plugins.annotations.Parameter;
22
import org.apache.maven.project.MavenProject;
23
import org.jreleaser.logging.SimpleJReleaserLoggerAdapter;
24
import org.jreleaser.util.Env;
25
import org.jreleaser.util.PlatformUtils;
26
import org.jreleaser.util.StringUtils;
27

28
import java.util.ArrayList;
29
import java.util.Arrays;
30
import java.util.Collections;
31
import java.util.List;
32

33
import static java.util.stream.Collectors.toList;
34
import static org.jreleaser.util.StringUtils.isBlank;
35
import static org.jreleaser.util.StringUtils.isNotBlank;
36

37
/**
38
 * @author Andres Almiray
39
 * @since 0.3.0
40
 */
NEW
41
abstract class AbstractSetupMojo extends AbstractMojo {
×
42
    @Parameter(defaultValue = "${project}", readonly = true, required = true)
43
    protected MavenProject project;
44

45
    /**
46
     * Activates paths matching the current platform.
47
     */
48
    @Parameter(property = "jreleaser.select.current.platform")
49
    private Boolean selectCurrentPlatform;
50

51
    /**
52
     * Activates paths matching the given platform.
53
     */
54
    @Parameter(property = "jreleaser.select.platforms")
55
    private String[] selectPlatforms;
56

57
    /**
58
     * Activates paths not matching the given platform.
59
     */
60
    @Parameter(property = "jreleaser.reject.platforms")
61
    private String[] rejectedPlatforms;
62

63
    protected boolean isPlatformSelected(String platform) {
NEW
64
        if (isBlank(platform)) return true;
×
65

NEW
66
        List<String> selectedPlatforms = collectSelectedPlatforms();
×
NEW
67
        if (!selectedPlatforms.isEmpty()) {
×
NEW
68
            return selectedPlatforms.stream()
×
NEW
69
                .anyMatch(selected -> matchPlatform(selected, platform));
×
70
        }
71

NEW
72
        List<String> rejectedPlatforms = collectRejectedPlatforms();
×
NEW
73
        if (!rejectedPlatforms.isEmpty()) {
×
NEW
74
            return rejectedPlatforms.stream()
×
NEW
75
                .noneMatch(selected -> matchPlatform(selected, platform));
×
76
        }
77

NEW
78
        return true;
×
79
    }
80

81
    private List<String> collectSelectedPlatforms() {
NEW
82
        boolean resolvedSelectCurrentPlatform = resolveBoolean("SELECT_CURRENT_PLATFORM", selectCurrentPlatform);
×
NEW
83
        if (resolvedSelectCurrentPlatform) {
×
NEW
84
            PlatformUtils.resolveCurrentPlatform(new SimpleJReleaserLoggerAdapter());
×
NEW
85
            return Collections.singletonList(PlatformUtils.getCurrentFull());
×
86
        }
87

NEW
88
        List<String> list = new ArrayList<>();
×
NEW
89
        if (null != selectPlatforms && selectPlatforms.length > 0) {
×
NEW
90
            Collections.addAll(list, selectPlatforms);
×
91
        }
NEW
92
        return resolveCollection("SELECT_PLATFORMS", list);
×
93
    }
94

95
    private List<String> collectRejectedPlatforms() {
NEW
96
        List<String> list = new ArrayList<>();
×
NEW
97
        if (null != rejectedPlatforms && rejectedPlatforms.length > 0) {
×
NEW
98
            Collections.addAll(list, rejectedPlatforms);
×
99
        }
NEW
100
        return resolveCollection("REJECT_PLATFORMS", list);
×
101
    }
102

103
    private boolean resolveBoolean(String key, Boolean value) {
NEW
104
        if (null != value) return value;
×
NEW
105
        String resolvedValue = Env.resolve(key, "");
×
NEW
106
        return isNotBlank(resolvedValue) && Boolean.parseBoolean(resolvedValue);
×
107
    }
108

109
    private List<String> resolveCollection(String key, List<String> values) {
NEW
110
        if (!values.isEmpty()) return values;
×
NEW
111
        String resolvedValue = Env.resolve(key, "");
×
NEW
112
        if (isBlank(resolvedValue)) return Collections.emptyList();
×
NEW
113
        return Arrays.stream(resolvedValue.trim().split(","))
×
NEW
114
            .map(String::trim)
×
NEW
115
            .filter(StringUtils::isNotBlank)
×
NEW
116
            .collect(toList());
×
117
    }
118

119
    private boolean matchPlatform(String input, String target) {
NEW
120
        input = input.replace("aarch_64", "aarch64");
×
NEW
121
        return PlatformUtils.isCompatible(input, target);
×
122
    }
123
}
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