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

jreleaser / jreleaser / #513

27 Jul 2025 10:36PM UTC coverage: 44.82% (-0.3%) from 45.153%
#513

push

github

aalmiray
feat(hooks): Add named groups to command and script hooks

Closes #1947

55 of 478 new or added lines in 14 files covered. (11.51%)

18 existing lines in 6 files now uncovered.

23664 of 52798 relevant lines covered (44.82%)

0.45 hits per line

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

66.67
/core/jreleaser-model-impl/src/main/java/org/jreleaser/model/internal/hooks/AbstractHook.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.hooks;
19

20
import org.jreleaser.model.internal.common.AbstractActivatable;
21
import org.jreleaser.model.internal.common.Matrix;
22

23
import java.util.LinkedHashMap;
24
import java.util.LinkedHashSet;
25
import java.util.Map;
26
import java.util.Set;
27

28
/**
29
 * @author Andres Almiray
30
 * @since 1.2.0
31
 */
32
public abstract class AbstractHook<S extends AbstractHook<S>> extends AbstractActivatable<S> implements Hook {
1✔
33
    private static final long serialVersionUID = -6030166783085333908L;
34

35
    private final Map<String, String> environment = new LinkedHashMap<>();
1✔
36
    private final Set<String> platforms = new LinkedHashSet<>();
1✔
37
    private final Filter filter = new Filter();
1✔
38
    protected final Matrix matrix = new Matrix();
1✔
39

40
    protected Boolean continueOnError;
41
    protected Boolean verbose;
42
    protected String name;
43
    protected String condition;
44
    protected Boolean applyDefaultMatrix;
45

46
    @Override
47
    public void merge(S source) {
48
        super.merge(source);
×
49
        this.continueOnError = merge(this.continueOnError, source.continueOnError);
×
50
        this.verbose = merge(this.verbose, source.verbose);
×
NEW
51
        this.name = merge(this.name, source.name);
×
52
        this.condition = merge(this.condition, source.condition);
×
53
        this.applyDefaultMatrix = merge(this.applyDefaultMatrix, source.applyDefaultMatrix);
×
54
        setFilter(source.getFilter());
×
55
        setPlatforms(merge(this.platforms, source.getPlatforms()));
×
56
        setEnvironment(merge(this.environment, source.getEnvironment()));
×
57
        setMatrix(source.matrix);
×
58
    }
×
59

60
    @Override
61
    public boolean isContinueOnError() {
62
        return null != continueOnError && continueOnError;
1✔
63
    }
64

65
    @Override
66
    public void setContinueOnError(Boolean continueOnError) {
67
        this.continueOnError = continueOnError;
×
68
    }
×
69

70
    @Override
71
    public boolean isContinueOnErrorSet() {
72
        return null != continueOnError;
×
73
    }
74

75
    @Override
76
    public boolean isVerbose() {
77
        return null != verbose && verbose;
1✔
78
    }
79

80
    @Override
81
    public void setVerbose(Boolean verbose) {
82
        this.verbose = verbose;
1✔
83
    }
1✔
84

85
    @Override
86
    public boolean isVerboseSet() {
87
        return null != verbose;
×
88
    }
89

90
    @Override
91
    public String getName() {
92
        return name;
1✔
93
    }
94

95
    @Override
96
    public void setName(String name) {
NEW
97
        this.name = name;
×
NEW
98
    }
×
99

100
    @Override
101
    public String getCondition() {
102
        return condition;
1✔
103
    }
104

105
    @Override
106
    public void setCondition(String condition) {
107
        this.condition = condition;
×
108
    }
×
109

110
    @Override
111
    public Filter getFilter() {
112
        return filter;
1✔
113
    }
114

115
    @Override
116
    public void setFilter(Filter filter) {
117
        this.filter.merge(filter);
1✔
118
    }
1✔
119

120
    @Override
121
    public Set<String> getPlatforms() {
122
        return platforms;
1✔
123
    }
124

125
    @Override
126
    public void setPlatforms(Set<String> platforms) {
127
        this.platforms.clear();
1✔
128
        this.platforms.addAll(platforms);
1✔
129
    }
1✔
130

131
    @Override
132
    public Map<String, String> getEnvironment() {
133
        return environment;
1✔
134
    }
135

136
    @Override
137
    public void setEnvironment(Map<String, String> environment) {
138
        this.environment.clear();
1✔
139
        this.environment.putAll(environment);
1✔
140
    }
1✔
141

142
    @Override
143
    public void addEnvironment(Map<String, String> environment) {
144
        this.environment.putAll(environment);
×
145
    }
×
146

147
    @Override
148
    public boolean isApplyDefaultMatrixSet() {
149
        return null != applyDefaultMatrix;
×
150
    }
151

152
    @Override
153
    public boolean isApplyDefaultMatrix() {
154
        return null != applyDefaultMatrix && applyDefaultMatrix;
1✔
155
    }
156

157
    @Override
158
    public void setApplyDefaultMatrix(Boolean applyDefaultMatrix) {
159
        this.applyDefaultMatrix = applyDefaultMatrix;
1✔
160
    }
1✔
161

162
    @Override
163
    public Matrix getMatrix() {
164
        return matrix;
1✔
165
    }
166

167
    @Override
168
    public void setMatrix(Matrix matrix) {
169
        this.matrix.merge(matrix);
1✔
170
    }
1✔
171

172
    @Override
173
    public Map<String, Object> asMap(boolean full) {
174
        Map<String, Object> map = new LinkedHashMap<>();
1✔
175
        map.put("enabled", isEnabled());
1✔
176
        map.put("active", getActive());
1✔
177
        map.put("continueOnError", isContinueOnError());
1✔
178
        map.put("verbose", isVerbose());
1✔
179
        map.put("platforms", platforms);
1✔
180
        map.put("name", name);
1✔
181
        map.put("condition", condition);
1✔
182
        Map<String, Object> filterAsMap = filter.asMap(full);
1✔
183
        if (full || !filterAsMap.isEmpty()) {
1✔
184
            map.put("filter", filterAsMap);
1✔
185
        }
186
        map.put("environment", environment);
1✔
187
        map.put("applyDefaultMatrix", isApplyDefaultMatrix());
1✔
188
        matrix.asMap(map);
1✔
189
        asMap(full, map);
1✔
190

191
        return map;
1✔
192
    }
193

194
    protected abstract void asMap(boolean full, Map<String, Object> map);
195
}
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