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

jreleaser / jreleaser / #517

28 Jul 2025 01:13PM UTC coverage: 45.494% (+0.7%) from 44.827%
#517

push

github

aalmiray
feat(core): Log path to settings file

Relates to #1945

36 of 47 new or added lines in 6 files covered. (76.6%)

3 existing lines in 2 files now uncovered.

24034 of 52829 relevant lines covered (45.49%)

0.45 hits per line

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

67.86
/core/jreleaser-model-impl/src/main/java/org/jreleaser/config/JReleaserConfigLoader.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.config;
19

20
import org.jreleaser.bundle.RB;
21
import org.jreleaser.model.JReleaserException;
22
import org.jreleaser.model.internal.JReleaserModel;
23

24
import java.io.IOException;
25
import java.io.InputStream;
26
import java.nio.file.Path;
27
import java.util.Map;
28
import java.util.ServiceLoader;
29

30
/**
31
 * @author Andres Almiray
32
 * @since 0.1.0
33
 */
34
public final class JReleaserConfigLoader {
35
    private JReleaserConfigLoader() {
36
        // noop
37
    }
38

39
    public static JReleaserModel loadConfig(Path configFile) {
40
        ServiceLoader<JReleaserConfigParser> parsers = ServiceLoader.load(JReleaserConfigParser.class, JReleaserConfigParser.class.getClassLoader());
1✔
41

42
        for (JReleaserConfigParser parser : parsers) {
1✔
43
            if (parser.supports(configFile)) {
1✔
44
                try {
45
                    parser.validate(configFile);
1✔
46
                } catch (IOException e) {
×
47
                    throw new JReleaserException(RB.$("ERROR_invalid_config_file", configFile), e);
×
48
                }
1✔
49
                try (InputStream inputStream = configFile.toUri().toURL().openStream()) {
1✔
50
                    return parser.parse(inputStream);
1✔
51
                } catch (IOException e) {
×
52
                    throw new JReleaserException(RB.$("ERROR_parsing_config_file", configFile), e);
×
53
                }
54
            }
55
        }
1✔
56
        throw new JReleaserException(RB.$("ERROR_unsupported_config_format", configFile));
×
57
    }
58

59
    public static Map<String, String> loadProperties(Path file) throws IOException {
60
        ServiceLoader<JReleaserConfigParser> parsers = ServiceLoader.load(JReleaserConfigParser.class, JReleaserConfigParser.class.getClassLoader());
1✔
61

62
        for (JReleaserConfigParser parser : parsers) {
1✔
63
            if (parser.supports(file)) {
1✔
64
                try (InputStream inputStream = file.toUri().toURL().openStream()) {
1✔
65
                    return parser.properties(inputStream);
1✔
66
                }
67
            }
68
        }
1✔
UNCOV
69
        throw new JReleaserException(RB.$("ERROR_unsupported_config_format", file));
×
70
    }
71

72
    public static <T> T load(Class<T> type, String resource, InputStream inputStream) throws IOException {
73
        ServiceLoader<JReleaserConfigParser> parsers = ServiceLoader.load(JReleaserConfigParser.class, JReleaserConfigParser.class.getClassLoader());
1✔
74

75
        for (JReleaserConfigParser parser : parsers) {
1✔
76
            if (parser.supports(resource)) {
1✔
77
                try {
78
                    return parser.load(type, inputStream);
1✔
79
                } catch (IOException e) {
×
80
                    throw new JReleaserException(RB.$("ERROR_load_resource", resource), e);
×
81
                }
82
            }
83
        }
1✔
84
        throw new JReleaserException(RB.$("ERROR_unsupported_config_format", resource));
×
85
    }
86
}
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