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

jreleaser / jreleaser / #475

03 Apr 2025 10:50AM UTC coverage: 40.322% (-8.9%) from 49.193%
#475

push

github

aalmiray
feat(release): Support Forgejo as releaser

Closes #1842

Closes #1843

182 of 1099 new or added lines in 45 files covered. (16.56%)

4239 existing lines in 333 files now uncovered.

20797 of 51577 relevant lines covered (40.32%)

0.4 hits per line

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

44.44
/core/jreleaser-model-impl/src/main/java/org/jreleaser/model/internal/upload/AbstractUploader.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.upload;
19

20
import com.fasterxml.jackson.annotation.JsonIgnore;
21
import org.jreleaser.model.internal.JReleaserContext;
22
import org.jreleaser.model.internal.common.AbstractActivatable;
23
import org.jreleaser.model.internal.common.Artifact;
24
import org.jreleaser.model.internal.common.ExtraProperties;
25
import org.jreleaser.model.internal.util.Artifacts;
26
import org.jreleaser.mustache.TemplateContext;
27

28
import java.util.Collections;
29
import java.util.LinkedHashMap;
30
import java.util.LinkedHashSet;
31
import java.util.List;
32
import java.util.Map;
33
import java.util.Set;
34

35
import static org.jreleaser.model.Constants.KEY_UPLOADER_NAME;
36
import static org.jreleaser.util.CollectionUtils.listOf;
37
import static org.jreleaser.util.StringUtils.capitalize;
38
import static org.jreleaser.util.StringUtils.getClassNameForLowerCaseHyphenSeparatedName;
39

40
/**
41
 * @author Andres Almiray
42
 * @since 0.3.0
43
 */
44
public abstract class AbstractUploader<A extends org.jreleaser.model.api.upload.Uploader, S extends AbstractUploader<A, S>> extends AbstractActivatable<S> implements Uploader<A>, ExtraProperties {
45
    private static final long serialVersionUID = 2011958303607038304L;
46

47
    @JsonIgnore
48
    private final String type;
49
    private final Map<String, Object> extraProperties = new LinkedHashMap<>();
1✔
50
    @JsonIgnore
51
    private String name;
52
    private int connectTimeout;
53
    private int readTimeout;
54
    protected Boolean artifacts;
55
    protected Boolean files;
56
    protected Boolean signatures;
57
    protected Boolean checksums;
58
    protected Boolean catalogs;
59

60
    protected AbstractUploader(String type) {
1✔
61
        this.type = type;
1✔
62
    }
1✔
63

64
    @Override
65
    public void merge(S source) {
66
        super.merge(source);
×
67
        this.name = merge(this.name, source.getName());
×
68
        this.connectTimeout = merge(this.getConnectTimeout(), source.getConnectTimeout());
×
69
        this.readTimeout = merge(this.getReadTimeout(), source.getReadTimeout());
×
70
        this.artifacts = merge(this.artifacts, source.artifacts);
×
71
        this.files = merge(this.files, source.files);
×
72
        this.signatures = merge(this.signatures, source.signatures);
×
73
        this.checksums = merge(this.checksums, source.checksums);
×
74
        this.catalogs = merge(this.catalogs, source.catalogs);
×
75
        setExtraProperties(merge(this.extraProperties, source.getExtraProperties()));
×
76
    }
×
77

78
    @Override
79
    public String prefix() {
UNCOV
80
        return getType();
×
81
    }
82

83
    @Override
84
    public String getName() {
85
        return name;
1✔
86
    }
87

88
    @Override
89
    public void setName(String name) {
90
        this.name = name;
1✔
91
    }
1✔
92

93
    @Override
94
    public boolean isSnapshotSupported() {
95
        return true;
×
96
    }
97

98
    @Override
99
    public String getType() {
100
        return type;
1✔
101
    }
102

103
    @Override
104
    public Integer getConnectTimeout() {
105
        return connectTimeout;
1✔
106
    }
107

108
    @Override
109
    public void setConnectTimeout(Integer connectTimeout) {
110
        this.connectTimeout = connectTimeout;
1✔
111
    }
1✔
112

113
    @Override
114
    public Integer getReadTimeout() {
115
        return readTimeout;
1✔
116
    }
117

118
    @Override
119
    public void setReadTimeout(Integer readTimeout) {
120
        this.readTimeout = readTimeout;
1✔
121
    }
1✔
122

123
    @Override
124
    public Map<String, Object> getExtraProperties() {
125
        return extraProperties;
1✔
126
    }
127

128
    @Override
129
    public void setExtraProperties(Map<String, Object> extraProperties) {
130
        this.extraProperties.clear();
×
131
        this.extraProperties.putAll(extraProperties);
×
132
    }
×
133

134
    @Override
135
    public void addExtraProperties(Map<String, Object> extraProperties) {
136
        this.extraProperties.putAll(extraProperties);
×
137
    }
×
138

139
    @Override
140
    public boolean isArtifacts() {
141
        return null == artifacts || artifacts;
1✔
142
    }
143

144
    @Override
145
    public void setArtifacts(Boolean artifacts) {
146
        this.artifacts = artifacts;
×
147
    }
×
148

149
    @Override
150
    public boolean isArtifactsSet() {
151
        return null != artifacts;
×
152
    }
153

154
    @Override
155
    public boolean isFiles() {
156
        return null == files || files;
1✔
157
    }
158

159
    @Override
160
    public void setFiles(Boolean files) {
161
        this.files = files;
×
162
    }
×
163

164
    @Override
165
    public boolean isFilesSet() {
166
        return null != files;
×
167
    }
168

169
    @Override
170
    public boolean isSignatures() {
171
        return null == signatures || signatures;
1✔
172
    }
173

174
    @Override
175
    public void setSignatures(Boolean signatures) {
176
        this.signatures = signatures;
×
177
    }
×
178

179
    @Override
180
    public boolean isSignaturesSet() {
181
        return null != signatures;
×
182
    }
183

184
    @Override
185
    public boolean isChecksumsSet() {
186
        return null != checksums;
×
187
    }
188

189
    @Override
190
    public boolean isChecksums() {
191
        return null == checksums || checksums;
1✔
192
    }
193

194
    @Override
195
    public void setChecksums(Boolean checksums) {
196
        this.checksums = checksums;
×
197
    }
×
198

199
    @Override
200
    public boolean isCatalogsSet() {
201
        return null != catalogs;
×
202
    }
203

204
    @Override
205
    public boolean isCatalogs() {
206
        return null == catalogs || catalogs;
1✔
207
    }
208

209
    @Override
210
    public void setCatalogs(Boolean catalogs) {
211
        this.catalogs = catalogs;
×
212
    }
×
213

214
    @Override
215
    public Map<String, Object> asMap(boolean full) {
216
        if (!full && !isEnabled()) return Collections.emptyMap();
1✔
217

218
        Map<String, Object> props = new LinkedHashMap<>();
1✔
219
        props.put("enabled", isEnabled());
1✔
220
        props.put("active", getActive());
1✔
221
        props.put("connectTimeout", connectTimeout);
1✔
222
        props.put("readTimeout", readTimeout);
1✔
223
        props.put("artifacts", isArtifacts());
1✔
224
        props.put("files", isFiles());
1✔
225
        props.put("signatures", isSignatures());
1✔
226
        props.put("checksums", isChecksums());
1✔
227
        props.put("catalogs", isCatalogs());
1✔
228
        asMap(full, props);
1✔
229
        props.put("extraProperties", getExtraProperties());
1✔
230

231
        Map<String, Object> map = new LinkedHashMap<>();
1✔
232
        map.put(this.getName(), props);
1✔
233
        return map;
1✔
234
    }
235

236
    protected abstract void asMap(boolean full, Map<String, Object> props);
237

238
    @Override
239
    public List<String> resolveSkipKeys() {
UNCOV
240
        String skipUpload = "skipUpload";
×
UNCOV
241
        String skipUploadByType = skipUpload + capitalize(type);
×
UNCOV
242
        String skipUploadByName = skipUploadByType + getClassNameForLowerCaseHyphenSeparatedName(name);
×
UNCOV
243
        return listOf(skipUpload, skipUploadByType, skipUploadByName);
×
244
    }
245

246
    @Override
247
    public TemplateContext artifactProps(JReleaserContext context, Artifact artifact) {
UNCOV
248
        return artifactProps(context.fullProps(), artifact);
×
249
    }
250

251
    @Override
252
    public TemplateContext artifactProps(TemplateContext props, Artifact artifact) {
UNCOV
253
        props.set(KEY_UPLOADER_NAME, getName());
×
UNCOV
254
        Artifacts.artifactProps(artifact, props);
×
255

UNCOV
256
        Set<String> keys = new LinkedHashSet<>(props.keys());
×
UNCOV
257
        keys.stream()
×
UNCOV
258
            .filter(k -> k.contains("skip") || k.contains("Skip"))
×
UNCOV
259
            .forEach(props::remove);
×
260

UNCOV
261
        return props;
×
262
    }
263
}
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