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

jreleaser / jreleaser / #477

04 Apr 2025 05:53PM UTC coverage: 35.124% (-5.1%) from 40.183%
#477

push

github

aalmiray
fix(deploy): Add missing Forgejo messages

Related to #1842

18210 of 51845 relevant lines covered (35.12%)

0.35 hits per line

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

68.97
/core/jreleaser-model-impl/src/main/java/org/jreleaser/model/internal/hooks/Hooks.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 com.fasterxml.jackson.annotation.JsonIgnore;
21
import org.jreleaser.model.Active;
22
import org.jreleaser.model.internal.common.AbstractActivatable;
23
import org.jreleaser.model.internal.common.Domain;
24
import org.jreleaser.model.internal.common.Matrix;
25

26
import java.util.LinkedHashMap;
27
import java.util.Map;
28

29
import static java.util.Collections.unmodifiableMap;
30

31
/**
32
 * @author Andres Almiray
33
 * @since 1.2.0
34
 */
35
public final class Hooks extends AbstractActivatable<Hooks> implements Domain {
36
    private static final long serialVersionUID = 1623942143835992825L;
37

38
    private final Map<String, String> environment = new LinkedHashMap<>();
1✔
39
    private final CommandHooks command = new CommandHooks();
1✔
40
    private final ScriptHooks script = new ScriptHooks();
1✔
41
    private final Matrix matrix = new Matrix();
1✔
42

43
    private String condition;
44
    private Boolean applyDefaultMatrix;
45

46
    @JsonIgnore
1✔
47
    private final org.jreleaser.model.api.hooks.Hooks immutable = new org.jreleaser.model.api.hooks.Hooks() {
1✔
48
        private static final long serialVersionUID = -4757423955700050484L;
49

50
        @Override
51
        public org.jreleaser.model.api.hooks.CommandHooks getCommand() {
52
            return command.asImmutable();
×
53
        }
54

55
        @Override
56
        public org.jreleaser.model.api.hooks.ScriptHooks getScript() {
57
            return script.asImmutable();
×
58
        }
59

60
        @Override
61
        public String getCondition() {
62
            return Hooks.this.getCondition();
×
63
        }
64

65
        @Override
66
        public Map<String, String> getEnvironment() {
67
            return unmodifiableMap(Hooks.this.getEnvironment());
×
68
        }
69

70
        @Override
71
        public boolean isApplyDefaultMatrix() {
72
            return Hooks.this.isApplyDefaultMatrix();
×
73
        }
74

75
        @Override
76
        public org.jreleaser.model.api.common.Matrix getMatrix() {
77
            return matrix.asImmutable();
×
78
        }
79

80
        @Override
81
        public Active getActive() {
82
            return Hooks.this.getActive();
×
83
        }
84

85
        @Override
86
        public boolean isEnabled() {
87
            return Hooks.this.isEnabled();
×
88
        }
89

90
        @Override
91
        public Map<String, Object> asMap(boolean full) {
92
            return unmodifiableMap(Hooks.this.asMap(full));
×
93
        }
94
    };
95

96
    public Hooks() {
1✔
97
        enabledSet(true);
1✔
98
    }
1✔
99

100
    public org.jreleaser.model.api.hooks.Hooks asImmutable() {
101
        return immutable;
×
102
    }
103

104
    @Override
105
    public void merge(Hooks source) {
106
        super.merge(source);
1✔
107
        this.condition = merge(this.condition, source.condition);
1✔
108
        setCommand(source.command);
1✔
109
        setScript(source.script);
1✔
110
        setEnvironment(merge(this.environment, source.getEnvironment()));
1✔
111
        setMatrix(source.matrix);
1✔
112
    }
1✔
113

114
    @Override
115
    public boolean isSet() {
116
        return super.isSet() ||
×
117
            command.isSet() ||
×
118
            script.isSet();
×
119
    }
120

121
    public CommandHooks getCommand() {
122
        return command;
1✔
123
    }
124

125
    public void setCommand(CommandHooks command) {
126
        this.command.merge(command);
1✔
127
    }
1✔
128

129
    public ScriptHooks getScript() {
130
        return script;
1✔
131
    }
132

133
    public void setScript(ScriptHooks script) {
134
        this.script.merge(script);
1✔
135
    }
1✔
136

137
    public String getCondition() {
138
        return condition;
1✔
139
    }
140

141
    public void setCondition(String condition) {
142
        this.condition = condition;
×
143
    }
×
144

145
    public Map<String, String> getEnvironment() {
146
        return environment;
1✔
147
    }
148

149
    public void setEnvironment(Map<String, String> environment) {
150
        this.environment.clear();
1✔
151
        this.environment.putAll(environment);
1✔
152
    }
1✔
153

154
    public boolean isApplyDefaultMatrixSet() {
155
        return null != applyDefaultMatrix;
×
156
    }
157

158
    public boolean isApplyDefaultMatrix() {
159
        return null != applyDefaultMatrix && applyDefaultMatrix;
1✔
160
    }
161

162
    public void setApplyDefaultMatrix(Boolean applyDefaultMatrix) {
163
        this.applyDefaultMatrix = applyDefaultMatrix;
×
164
    }
×
165

166
    public Matrix getMatrix() {
167
        return matrix;
1✔
168
    }
169

170
    public void setMatrix(Matrix matrix) {
171
        this.matrix.merge(matrix);
1✔
172
    }
1✔
173

174
    @Override
175
    public Map<String, Object> asMap(boolean full) {
176
        Map<String, Object> map = new LinkedHashMap<>();
1✔
177
        map.put("enabled", isEnabled());
1✔
178
        map.put("active", getActive());
1✔
179
        map.put("condition", condition);
1✔
180
        map.put("environment", environment);
1✔
181
        matrix.asMap(map);
1✔
182
        map.put("command", command.asMap(full));
1✔
183
        map.put("script", script.asMap(full));
1✔
184
        return map;
1✔
185
    }
186
}
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