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

jreleaser / jreleaser / #479

05 Apr 2025 12:28PM UTC coverage: 48.516% (+13.4%) from 35.124%
#479

push

github

web-flow
feat(build): Ddd git to docker images

Fixes #1838

25153 of 51845 relevant lines covered (48.52%)

0.49 hits per line

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

43.14
/api/jreleaser-utils/src/main/java/org/jreleaser/util/Errors.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.util;
19

20
import org.jreleaser.logging.JReleaserLogger;
21

22
import java.io.PrintWriter;
23
import java.io.Serializable;
24
import java.io.StringWriter;
25
import java.util.LinkedHashSet;
26
import java.util.Objects;
27
import java.util.Set;
28

29
/**
30
 * @author Andres Almiray
31
 * @since 0.2.0
32
 */
33
public class Errors implements Serializable {
1✔
34
    private static final long serialVersionUID = -7835875752041439694L;
35

36
    private final Set<Error> assemblyErrors = new LinkedHashSet<>();
1✔
37
    private final Set<Error> configurationErrors = new LinkedHashSet<>();
1✔
38
    private final Set<Error> warnings = new LinkedHashSet<>();
1✔
39

40
    public boolean hasErrors() {
41
        return !assemblyErrors.isEmpty() || !configurationErrors.isEmpty();
1✔
42
    }
43

44
    public boolean hasAssemblyErrors() {
45
        return !assemblyErrors.isEmpty();
×
46
    }
47

48
    public boolean hasConfigurationErrors() {
49
        return !configurationErrors.isEmpty();
1✔
50
    }
51

52
    public boolean hasWarnings() {
53
        return !warnings.isEmpty();
1✔
54
    }
55

56
    public void assembly(String message) {
57
        assemblyErrors.add(new Error(Kind.ASSEMBLY, message));
×
58
    }
×
59

60
    public void configuration(String message) {
61
        configurationErrors.add(new Error(Kind.CONFIGURATION, message));
1✔
62
    }
1✔
63

64
    public void warning(String message) {
65
        warnings.add(new Error(Kind.CONFIGURATION, message));
1✔
66
    }
1✔
67

68
    public void logWarnings(JReleaserLogger logger) {
69
        warnings.forEach(e -> logger.warn(e.message));
1✔
70
    }
1✔
71

72
    public void logWarnings(PrintWriter writer) {
73
        warnings.forEach(e -> writer.println(e.message));
×
74
    }
×
75

76
    public void logErrors(JReleaserLogger logger) {
77
        assemblyErrors.forEach(e -> logger.error(e.message));
×
78
        configurationErrors.forEach(e -> logger.error(e.message));
×
79
    }
×
80

81
    public void logErrors(PrintWriter writer) {
82
        assemblyErrors.forEach(e -> writer.println(e.message));
×
83
        configurationErrors.forEach(e -> writer.println(e.message));
×
84
    }
×
85

86
    public String asString() {
87
        StringWriter writer = new StringWriter();
×
88
        logErrors(new PrintWriter(writer));
×
89
        return writer.toString();
×
90
    }
91

92
    public String warningsAsString() {
93
        StringWriter writer = new StringWriter();
×
94
        logWarnings(new PrintWriter(writer));
×
95
        return writer.toString();
×
96
    }
97

98
    public void addAll(Errors errors) {
99
        this.assemblyErrors.addAll(errors.assemblyErrors);
×
100
        this.configurationErrors.addAll(errors.configurationErrors);
×
101
        this.warnings.addAll(errors.warnings);
×
102
    }
×
103

104
    public enum Kind {
1✔
105
        ASSEMBLY,
1✔
106
        CONFIGURATION,
1✔
107
        WARNING
1✔
108
    }
109

110
    public static class Error implements Serializable {
111
        private static final long serialVersionUID = -9011553489507569322L;
112

113
        private final Kind kind;
114
        private final String message;
115

116
        public Error(Kind kind, String message) {
1✔
117
            this.kind = kind;
1✔
118
            this.message = message;
1✔
119
        }
1✔
120

121
        public Kind getKind() {
122
            return kind;
×
123
        }
124

125
        public String getMessage() {
126
            return message;
×
127
        }
128

129
        @Override
130
        public boolean equals(Object o) {
131
            if (this == o) return true;
×
132
            if (null == o || getClass() != o.getClass()) return false;
×
133
            Error error = (Error) o;
×
134
            return kind == error.kind &&
×
135
                message.equals(error.message);
×
136
        }
137

138
        @Override
139
        public int hashCode() {
140
            return Objects.hash(kind, message);
1✔
141
        }
142

143
        @Override
144
        public String toString() {
145
            return message;
×
146
        }
147
    }
148
}
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