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

jreleaser / jreleaser / #537

25 Sep 2025 02:50PM UTC coverage: 48.299% (-0.7%) from 48.959%
#537

push

github

web-flow
fix: check snapshot version for '-SNAPSHOT' tag

Fixe #1971

2 of 2 new or added lines in 1 file covered. (100.0%)

362 existing lines in 31 files now uncovered.

25821 of 53461 relevant lines covered (48.3%)

0.48 hits per line

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

27.78
/core/jreleaser-engine/src/main/java/org/jreleaser/packagers/AppdataUtils.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.jreleaser.bundle.RB;
21
import org.jreleaser.model.internal.JReleaserContext;
22
import org.jreleaser.model.internal.common.Icon;
23
import org.jreleaser.model.internal.distributions.Distribution;
24
import org.jreleaser.model.internal.packagers.TemplatePackager;
25
import org.jreleaser.model.spi.packagers.PackagerProcessingException;
26
import org.jreleaser.mustache.TemplateContext;
27

28
import java.io.IOException;
29
import java.net.URI;
30
import java.net.URISyntaxException;
31
import java.nio.file.Files;
32
import java.nio.file.Path;
33
import java.nio.file.Paths;
34
import java.text.SimpleDateFormat;
35
import java.util.Date;
36
import java.util.List;
37
import java.util.Set;
38
import java.util.regex.Pattern;
39

40
import static org.jreleaser.mustache.Templates.resolveTemplate;
41
import static org.jreleaser.util.StringUtils.getFilenameExtension;
42

43
/**
44
 * @author Andres Almiray
45
 * @since 1.5.0
46
 */
47
public final class AppdataUtils {
48
    private AppdataUtils() {
49
        // noop
50
    }
51

52
    public static void resolveIcons(JReleaserContext context, TemplatePackager<?> packager,
53
                                    Distribution distribution, TemplateContext props, List<Icon> icons) throws PackagerProcessingException {
54
        for (Icon icon : icons) {
1✔
55
            // check if exists
56
            String iconUrl = resolveTemplate(icon.getUrl(), props);
1✔
57
            String iconExt = getFilenameExtension(iconUrl);
1✔
58
            Path iconPath = Paths.get(packager.getTemplateDirectory(), "icons",
1✔
59
                icon.getWidth() + "x" + icon.getHeight(),
1✔
60
                distribution.getExecutable().getName() + "." + iconExt);
1✔
61
            iconPath = context.getBasedir().resolve(iconPath);
1✔
62

63
            if (!Files.exists(iconPath)) {
1✔
64
                // download
UNCOV
65
                context.getLogger().debug("{} -> {}", iconUrl, context.relativizeToBasedir(iconPath));
×
66
                try {
UNCOV
67
                    org.apache.commons.io.FileUtils.copyURLToFile(
×
UNCOV
68
                        new URI(iconUrl).toURL(),
×
UNCOV
69
                        iconPath.toFile(),
×
70
                        20000,
71
                        60000);
72
                } catch (URISyntaxException | IOException e) {
×
73
                    throw new PackagerProcessingException(RB.$("ERROR_unexpected_download", iconUrl), e);
×
UNCOV
74
                }
×
75
            }
76
        }
1✔
77
    }
1✔
78

79
    public static boolean isReleaseIncluded(Set<String> skipReleases, String version) {
80
        if (null == skipReleases || skipReleases.isEmpty()) {
×
81
            return true;
×
82
        }
83

84
        // 1. exact match
85
        if (skipReleases.contains(version)) {
×
86
            return false;
×
87
        }
88

89
        // 2. regex match
90
        for (String regex : skipReleases) {
×
91
            Pattern p = Pattern.compile(regex);
×
92
            if (p.matcher(version).matches()) return false;
×
93
        }
×
94

95
        return true;
×
96
    }
97

98
    public static class Release {
99
        private final String url;
100
        private final String version;
101
        private final String date;
102

103
        private Release(String url, String version, String date) {
×
104
            this.url = url;
×
105
            this.version = version;
×
106
            this.date = date;
×
107
        }
×
108

109
        public String getUrl() {
110
            return url;
×
111
        }
112

113
        public String getVersion() {
114
            return version;
×
115
        }
116

117
        public String getDate() {
118
            return date;
×
119
        }
120

121
        public static Release of(String url, String version, Date date) {
122
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
×
123
            return new Release(url, version, format.format(date));
×
124
        }
125
    }
126
}
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