• 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

47.83
/core/jreleaser-model-impl/src/main/java/org/jreleaser/model/internal/files/Files.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.files;
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.Artifact;
24
import org.jreleaser.model.internal.common.Domain;
25
import org.jreleaser.model.internal.common.Glob;
26

27
import java.util.ArrayList;
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 java.util.Collections.unmodifiableMap;
36
import static java.util.stream.Collectors.toList;
37
import static java.util.stream.Collectors.toSet;
38

39
/**
40
 * @author Andres Almiray
41
 * @since 0.1.0
42
 */
43
public final class Files extends AbstractActivatable<Files> implements Domain {
1✔
44
    private static final long serialVersionUID = -7799032884331569570L;
45

46
    private final Set<Artifact> artifacts = new LinkedHashSet<>();
1✔
47
    private final List<Glob> globs = new ArrayList<>();
1✔
48
    @JsonIgnore
1✔
49
    private final Set<Artifact> paths = new LinkedHashSet<>();
50
    @JsonIgnore
51
    private boolean resolved;
52

53
    @JsonIgnore
1✔
54
    private final org.jreleaser.model.api.files.Files immutable = new org.jreleaser.model.api.files.Files() {
1✔
55
        private static final long serialVersionUID = -328612924170955820L;
56

57
        private Set<? extends org.jreleaser.model.api.common.Artifact> paths;
58
        private Set<? extends org.jreleaser.model.api.common.Artifact> artifacts;
59
        private List<? extends org.jreleaser.model.api.common.Glob> globs;
60

61
        @Override
62
        public Set<? extends org.jreleaser.model.api.common.Artifact> getPaths() {
63
            if (null == paths) {
×
64
                paths = Files.this.paths.stream()
×
65
                    .map(Artifact::asImmutable)
×
66
                    .collect(toSet());
×
67
            }
68
            return paths;
×
69
        }
70

71
        @Override
72
        public Set<? extends org.jreleaser.model.api.common.Artifact> getArtifacts() {
73
            if (null == artifacts) {
×
74
                artifacts = Files.this.artifacts.stream()
×
75
                    .map(Artifact::asImmutable)
×
76
                    .collect(toSet());
×
77
            }
78
            return artifacts;
×
79
        }
80

81
        @Override
82
        public List<? extends org.jreleaser.model.api.common.Glob> getGlobs() {
83
            if (null == globs) {
×
84
                globs = Files.this.globs.stream()
×
85
                    .map(Glob::asImmutable)
×
86
                    .collect(toList());
×
87
            }
88
            return globs;
×
89
        }
90

91
        @Override
92
        public Active getActive() {
93
            return Files.this.getActive();
×
94
        }
95

96
        @Override
97
        public boolean isEnabled() {
98
            return Files.this.isEnabled();
×
99
        }
100

101
        @Override
102
        public Map<String, Object> asMap(boolean full) {
103
            return unmodifiableMap(Files.this.asMap(full));
×
104
        }
105
    };
106

107
    public org.jreleaser.model.api.files.Files asImmutable() {
108
        return immutable;
×
109
    }
110

111
    @Override
112
    public void merge(Files source) {
113
        super.merge(source);
1✔
114
        setArtifacts(merge(this.artifacts, source.artifacts));
1✔
115
        setGlobs(merge(this.globs, source.globs));
1✔
116
    }
1✔
117

118
    public boolean isEmpty() {
119
        return artifacts.isEmpty() && globs.isEmpty();
1✔
120
    }
121

122
    public boolean arePathsResolved() {
123
        return resolved;
×
124
    }
125

126
    public Set<Artifact> getPaths() {
127
        return Artifact.sortArtifacts(paths);
×
128
    }
129

130
    public void setPaths(Set<Artifact> paths) {
131
        this.paths.clear();
×
132
        this.paths.addAll(paths);
×
133
        this.resolved = true;
×
134
    }
×
135

136
    public Set<Artifact> getArtifacts() {
137
        return Artifact.sortArtifacts(artifacts);
1✔
138
    }
139

140
    public void setArtifacts(Set<Artifact> artifacts) {
141
        this.artifacts.clear();
1✔
142
        this.artifacts.addAll(artifacts);
1✔
143
    }
1✔
144

145
    public void addArtifacts(Set<Artifact> artifacts) {
146
        this.artifacts.addAll(artifacts);
×
147
    }
×
148

149
    public void addArtifact(Artifact artifact) {
150
        if (null != artifact) {
×
151
            this.artifacts.add(artifact);
×
152
        }
153
    }
×
154

155
    public List<Glob> getGlobs() {
156
        return globs;
1✔
157
    }
158

159
    public void setGlobs(List<Glob> globs) {
160
        this.globs.clear();
1✔
161
        this.globs.addAll(globs);
1✔
162
    }
1✔
163

164
    public void addGlobs(List<Glob> globs) {
165
        this.globs.addAll(globs);
×
166
    }
×
167

168
    public void addGlob(Glob glob) {
169
        if (null != glob) {
×
170
            this.globs.add(glob);
×
171
        }
172
    }
×
173

174
    @Override
175
    public Map<String, Object> asMap(boolean full) {
176
        if (!full && !isEnabled()) return Collections.emptyMap();
1✔
177

178
        Map<String, Object> map = new LinkedHashMap<>();
1✔
179
        map.put("enabled", isEnabled());
1✔
180
        map.put("active", getActive());
1✔
181

182
        Map<String, Map<String, Object>> mappedArtifacts = new LinkedHashMap<>();
1✔
183
        int i = 0;
1✔
184
        for (Artifact artifact : getArtifacts()) {
1✔
185
            mappedArtifacts.put("artifact " + (i++), artifact.asMap(full));
1✔
186
        }
1✔
187
        map.put("artifacts", mappedArtifacts);
1✔
188

189
        Map<String, Map<String, Object>> mappedGlobs = new LinkedHashMap<>();
1✔
190
        for (i = 0; i < globs.size(); i++) {
1✔
191
            mappedGlobs.put("glob " + i, globs.get(i).asMap(full));
×
192
        }
193
        map.put("globs", mappedGlobs);
1✔
194

195
        return map;
1✔
196
    }
197
}
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