• 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

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

20
import com.fasterxml.jackson.annotation.JsonIgnore;
21
import com.github.mustachejava.TemplateFunction;
22
import org.jreleaser.bundle.RB;
23
import org.jreleaser.model.Constants;
24
import org.jreleaser.model.JReleaserException;
25
import org.jreleaser.model.JReleaserVersion;
26
import org.jreleaser.model.internal.announce.Announce;
27
import org.jreleaser.model.internal.assemble.Assemble;
28
import org.jreleaser.model.internal.catalog.Catalog;
29
import org.jreleaser.model.internal.checksum.Checksum;
30
import org.jreleaser.model.internal.common.Matrix;
31
import org.jreleaser.model.internal.deploy.Deploy;
32
import org.jreleaser.model.internal.distributions.Distribution;
33
import org.jreleaser.model.internal.download.Download;
34
import org.jreleaser.model.internal.environment.Environment;
35
import org.jreleaser.model.internal.extensions.Extension;
36
import org.jreleaser.model.internal.files.Files;
37
import org.jreleaser.model.internal.hooks.Hooks;
38
import org.jreleaser.model.internal.packagers.Packagers;
39
import org.jreleaser.model.internal.platform.Platform;
40
import org.jreleaser.model.internal.project.Project;
41
import org.jreleaser.model.internal.release.BaseReleaser;
42
import org.jreleaser.model.internal.release.Release;
43
import org.jreleaser.model.internal.signing.Signing;
44
import org.jreleaser.model.internal.upload.Upload;
45
import org.jreleaser.mustache.MustacheUtils;
46
import org.jreleaser.mustache.TemplateContext;
47
import org.jreleaser.util.PlatformUtils;
48

49
import java.time.ZonedDateTime;
50
import java.util.LinkedHashMap;
51
import java.util.List;
52
import java.util.Locale;
53
import java.util.Map;
54

55
import static java.util.Collections.unmodifiableMap;
56
import static java.util.function.Function.identity;
57
import static java.util.stream.Collectors.toList;
58
import static java.util.stream.Collectors.toMap;
59
import static org.jreleaser.mustache.MustacheUtils.applyTemplates;
60
import static org.jreleaser.util.StringUtils.getCapitalizedName;
61
import static org.jreleaser.util.StringUtils.isBlank;
62
import static org.jreleaser.util.StringUtils.isNotBlank;
63
import static org.jreleaser.util.TimeUtils.TIMESTAMP_FORMATTER;
64

65
/**
66
 * @author Andres Almiray
67
 * @since 0.1.0
68
 */
69
@org.jreleaser.infra.nativeimage.annotations.NativeImage
70
public class JReleaserModel {
71
    private final Environment environment = new Environment();
1✔
72
    private final Matrix matrix = new Matrix();
1✔
73
    private final Hooks hooks = new Hooks();
1✔
74
    private final Project project = new Project();
1✔
75
    private final Platform platform = new Platform();
1✔
76
    private final Release release = new Release();
1✔
77
    private final Packagers packagers = new Packagers();
1✔
78
    private final Announce announce = new Announce();
1✔
79
    private final Download download = new Download();
1✔
80
    private final Assemble assemble = new Assemble();
1✔
81
    private final Deploy deploy = new Deploy();
1✔
82
    private final Upload upload = new Upload();
1✔
83
    private final Checksum checksum = new Checksum();
1✔
84
    private final Signing signing = new Signing();
1✔
85
    private final Files files = new Files();
1✔
86
    private final Catalog catalog = new Catalog();
1✔
87
    private final Map<String, Distribution> distributions = new LinkedHashMap<>();
1✔
88
    private final Map<String, Extension> extensions = new LinkedHashMap<>();
1✔
89

90
    @JsonIgnore
91
    private final ZonedDateTime now;
92
    @JsonIgnore
93
    private final String timestamp;
94
    @JsonIgnore
95
    private org.jreleaser.model.api.JReleaserModel.Commit commit;
96

97
    @JsonIgnore
1✔
98
    private final org.jreleaser.model.api.JReleaserModel immutable = new org.jreleaser.model.api.JReleaserModel() {
1✔
99
        private static final long serialVersionUID = 7516005666920509247L;
100

101
        private Map<String, ? extends org.jreleaser.model.api.distributions.Distribution> distributions;
102
        private Map<String, ? extends org.jreleaser.model.api.extensions.Extension> extensions;
103

104
        @Override
105
        public ZonedDateTime getNow() {
106
            return now;
×
107
        }
108

109
        @Override
110
        public String getTimestamp() {
111
            return timestamp;
×
112
        }
113

114
        @Override
115
        public Commit getCommit() {
116
            return commit;
×
117
        }
118

119
        @Override
120
        public org.jreleaser.model.api.environment.Environment getEnvironment() {
121
            return environment.asImmutable();
1✔
122
        }
123

124
        @Override
125
        public org.jreleaser.model.api.common.Matrix getMatrix() {
126
            return matrix.asImmutable();
×
127
        }
128

129
        @Override
130
        public org.jreleaser.model.api.hooks.Hooks getHooks() {
131
            return hooks.asImmutable();
×
132
        }
133

134
        @Override
135
        public org.jreleaser.model.api.platform.Platform getPlatform() {
136
            return platform.asImmutable();
×
137
        }
138

139
        @Override
140
        public org.jreleaser.model.api.project.Project getProject() {
141
            return project.asImmutable();
×
142
        }
143

144
        @Override
145
        public org.jreleaser.model.api.release.Release getRelease() {
146
            return release.asImmutable();
×
147
        }
148

149
        @Override
150
        public org.jreleaser.model.api.packagers.Packagers getPackagers() {
151
            return packagers.asImmutable();
×
152
        }
153

154
        @Override
155
        public org.jreleaser.model.api.announce.Announce getAnnounce() {
156
            return announce.asImmutable();
×
157
        }
158

159
        @Override
160
        public org.jreleaser.model.api.assemble.Assemble getAssemble() {
161
            return assemble.asImmutable();
×
162
        }
163

164
        @Override
165
        public org.jreleaser.model.api.download.Download getDownload() {
166
            return download.asImmutable();
×
167
        }
168

169
        @Override
170
        public org.jreleaser.model.api.deploy.Deploy getDeploy() {
171
            return deploy.asImmutable();
×
172
        }
173

174
        @Override
175
        public org.jreleaser.model.api.upload.Upload getUpload() {
176
            return upload.asImmutable();
×
177
        }
178

179
        @Override
180
        public org.jreleaser.model.api.checksum.Checksum getChecksum() {
181
            return checksum.asImmutable();
×
182
        }
183

184
        @Override
185
        public org.jreleaser.model.api.signing.Signing getSigning() {
186
            return signing.asImmutable();
×
187
        }
188

189
        @Override
190
        public org.jreleaser.model.api.files.Files getFiles() {
191
            return files.asImmutable();
×
192
        }
193

194
        @Override
195
        public org.jreleaser.model.api.catalog.Catalog getCatalog() {
196
            return catalog.asImmutable();
×
197
        }
198

199
        @Override
200
        public Map<String, ? extends org.jreleaser.model.api.distributions.Distribution> getDistributions() {
201
            if (null == distributions) {
×
202
                distributions = JReleaserModel.this.distributions.values().stream()
×
203
                    .map(Distribution::asImmutable)
×
204
                    .collect(toMap(org.jreleaser.model.api.distributions.Distribution::getName, identity()));
×
205
            }
206
            return distributions;
×
207
        }
208

209
        @Override
210
        public Map<String, ? extends org.jreleaser.model.api.extensions.Extension> getExtensions() {
211
            if (null == extensions) {
×
212
                extensions = JReleaserModel.this.extensions.values().stream()
×
213
                    .map(Extension::asImmutable)
×
214
                    .collect(toMap(org.jreleaser.model.api.extensions.Extension::getName, identity()));
×
215
            }
216
            return extensions;
×
217
        }
218

219
        @Override
220
        public Map<String, Object> asMap(boolean full) {
221
            return unmodifiableMap(JReleaserModel.this.asMap(full));
×
222
        }
223
    };
224

225
    public JReleaserModel() {
1✔
226
        this.now = ZonedDateTime.now();
1✔
227
        this.timestamp = now.format(TIMESTAMP_FORMATTER);
1✔
228
    }
1✔
229

230
    public org.jreleaser.model.api.JReleaserModel asImmutable() {
231
        return immutable;
1✔
232
    }
233

234
    public ZonedDateTime getNow() {
235
        return now;
1✔
236
    }
237

238
    public String getTimestamp() {
239
        return timestamp;
1✔
240
    }
241

242
    public org.jreleaser.model.api.JReleaserModel.Commit getCommit() {
243
        return commit;
1✔
244
    }
245

246
    public void setCommit(org.jreleaser.model.api.JReleaserModel.Commit commit) {
247
        this.commit = commit;
1✔
248
    }
1✔
249

250
    public Environment getEnvironment() {
251
        return environment;
1✔
252
    }
253

254
    public void setEnvironment(Environment environment) {
255
        this.environment.merge(environment);
1✔
256
    }
1✔
257

258
    public Matrix getMatrix() {
259
        return matrix;
1✔
260
    }
261

262
    public void setMatrix(Matrix matrix) {
263
        this.matrix.merge(matrix);
1✔
264
    }
1✔
265

266
    public Hooks getHooks() {
267
        return hooks;
1✔
268
    }
269

270
    public void setHooks(Hooks hooks) {
271
        this.hooks.merge(hooks);
1✔
272
    }
1✔
273

274
    public Platform getPlatform() {
275
        return platform;
1✔
276
    }
277

278
    public void setPlatform(Platform platform) {
279
        this.platform.merge(platform);
1✔
280
    }
1✔
281

282
    public Project getProject() {
283
        return project;
1✔
284
    }
285

286
    public void setProject(Project project) {
287
        this.project.merge(project);
1✔
288
    }
1✔
289

290
    public Release getRelease() {
291
        return release;
1✔
292
    }
293

294
    public void setRelease(Release release) {
295
        this.release.merge(release);
1✔
296
    }
1✔
297

298
    public Packagers getPackagers() {
299
        return packagers;
1✔
300
    }
301

302
    public void setPackagers(Packagers packagers) {
303
        this.packagers.merge(packagers);
×
304
    }
×
305

306
    public Announce getAnnounce() {
307
        return announce;
1✔
308
    }
309

310
    public void setAnnounce(Announce announce) {
311
        this.announce.merge(announce);
1✔
312
    }
1✔
313

314
    public Assemble getAssemble() {
315
        return assemble;
1✔
316
    }
317

318
    public void setAssemble(Assemble assemble) {
319
        this.assemble.merge(assemble);
1✔
320
    }
1✔
321

322
    public Download getDownload() {
323
        return download;
1✔
324
    }
325

326
    public void setDownload(Download download) {
327
        this.download.merge(download);
1✔
328
    }
1✔
329

330
    public Deploy getDeploy() {
331
        return deploy;
1✔
332
    }
333

334
    public void setDeploy(Deploy deploy) {
335
        this.deploy.merge(deploy);
1✔
336
    }
1✔
337

338
    public Upload getUpload() {
339
        return upload;
1✔
340
    }
341

342
    public void setUpload(Upload upload) {
343
        this.upload.merge(upload);
1✔
344
    }
1✔
345

346
    public Checksum getChecksum() {
347
        return checksum;
1✔
348
    }
349

350
    public void setChecksum(Checksum checksum) {
351
        this.checksum.merge(checksum);
1✔
352
    }
1✔
353

354
    public Signing getSigning() {
355
        return signing;
1✔
356
    }
357

358
    public void setSigning(Signing signing) {
359
        this.signing.merge(signing);
1✔
360
    }
1✔
361

362
    public Files getFiles() {
363
        return files;
1✔
364
    }
365

366
    public void setFiles(Files files) {
367
        this.files.merge(files);
1✔
368
    }
1✔
369

370
    public Catalog getCatalog() {
371
        return catalog;
1✔
372
    }
373

374
    public void setCatalog(Catalog catalog) {
375
        this.catalog.merge(catalog);
1✔
376
    }
1✔
377

378
    public List<Distribution> getActiveDistributions() {
379
        return distributions.values().stream()
1✔
380
            .filter(Distribution::isEnabled)
1✔
381
            .collect(toList());
1✔
382
    }
383

384
    public Map<String, Distribution> getDistributions() {
385
        return distributions;
1✔
386
    }
387

388
    public void setDistributions(Map<String, Distribution> distributions) {
389
        this.distributions.clear();
1✔
390
        this.distributions.putAll(distributions);
1✔
391
    }
1✔
392

393
    public void addDistribution(Distribution distribution) {
394
        this.distributions.put(distribution.getName(), distribution);
×
395
    }
×
396

397
    public Distribution findDistribution(String name) {
398
        if (isBlank(name)) {
×
399
            throw new JReleaserException(RB.$("ERROR_distribution_name_is_blank"));
×
400
        }
401

402
        if (distributions.containsKey(name)) {
×
403
            return distributions.get(name);
×
404
        }
405

406
        throw new JReleaserException(RB.$("ERROR_distribution_not_found", name));
×
407
    }
408

409
    public List<Extension> getActiveExtensions() {
410
        return extensions.values().stream()
×
411
            .filter(Extension::isEnabled)
×
412
            .collect(toList());
×
413
    }
414

415
    public Map<String, Extension> getExtensions() {
416
        return extensions;
1✔
417
    }
418

419
    public void setExtensions(Map<String, Extension> extensions) {
420
        this.extensions.clear();
×
421
        this.extensions.putAll(extensions);
×
422
    }
×
423

424
    public void addExtension(Extension extension) {
425
        this.extensions.put(extension.getName(), extension);
×
426
    }
×
427

428
    public ZonedDateTime resolveArchiveTimestamp() {
429
        if (null != commit) return commit.getTimestamp();
1✔
430
        return now;
×
431
    }
432

433
    public Map<String, Object> asMap(boolean full) {
434
        Map<String, Object> map = new LinkedHashMap<>();
1✔
435

436
        List<Map<String, Object>> extensions = this.extensions.values()
1✔
437
            .stream()
1✔
438
            .filter(e -> full || e.isEnabled())
1✔
439
            .map(e -> e.asMap(full))
1✔
440
            .collect(toList());
1✔
441
        if (!extensions.isEmpty()) map.put("extensions", extensions);
1✔
442

443
        if (full || environment.isSet()) map.put("environment", environment.asMap(full));
1✔
444
        matrix.asMap(map);
1✔
445
        if (full || hooks.isSet()) map.put("hooks", hooks.asMap(full));
1✔
446
        map.put("project", project.asMap(full));
1✔
447
        if (full || platform.isSet()) map.put("platform", platform.asMap(full));
1✔
448
        map.put("release", release.asMap(full));
1✔
449
        map.put("checksum", checksum.asMap(full));
1✔
450
        if (full || signing.isEnabled()) map.put("signing", signing.asMap(full));
1✔
451
        if (full || announce.isEnabled()) map.put("announce", announce.asMap(full));
1✔
452
        if (!files.isEmpty()) map.put("files", files.asMap(full));
1✔
453
        if (full || packagers.hasEnabledPackagers()) map.put("packagers", packagers.asMap(full));
1✔
454
        if (full || download.isEnabled()) map.put("download", download.asMap(full));
1✔
455
        if (full || assemble.isEnabled()) map.put("assemble", assemble.asMap(full));
1✔
456
        if (full || deploy.isEnabled()) map.put("deploy", deploy.asMap(full));
1✔
457
        if (full || upload.isEnabled()) map.put("upload", upload.asMap(full));
1✔
458
        map.put("catalog", catalog.asMap(full));
1✔
459

460
        List<Map<String, Object>> distributions = this.distributions.values()
1✔
461
            .stream()
1✔
462
            .filter(d -> full || d.isEnabled())
1✔
463
            .map(d -> d.asMap(full))
1✔
464
            .collect(toList());
1✔
465
        if (!distributions.isEmpty()) map.put("distributions", distributions);
1✔
466

467
        return map;
1✔
468
    }
469

470
    public TemplateContext props() {
471
        TemplateContext props = new TemplateContext();
1✔
472
        props.set("Model", this.asImmutable());
1✔
473

474
        String jreleaserCreationStamp = String.format("Generated with JReleaser %s at %s",
1✔
475
            JReleaserVersion.getPlainVersion(), timestamp);
1✔
476
        props.set("jreleaserCreationStamp", jreleaserCreationStamp);
1✔
477

478
        fillProjectProperties(props, project);
1✔
479
        fillReleaserProperties(props, release);
1✔
480

481
        String osName = PlatformUtils.getDetectedOs();
1✔
482
        String osArch = PlatformUtils.getDetectedArch();
1✔
483
        props.set(Constants.KEY_OS_NAME, osName);
1✔
484
        props.set(Constants.KEY_OS_ARCH, osArch);
1✔
485
        props.set(Constants.KEY_OS_VERSION, PlatformUtils.getDetectedVersion());
1✔
486
        props.set(Constants.KEY_OS_PLATFORM, PlatformUtils.getCurrentFull());
1✔
487
        props.set(Constants.KEY_OS_PLATFORM_REPLACED, getPlatform().applyReplacements(PlatformUtils.getCurrentFull()));
1✔
488

489
        applyTemplates(props, project.resolvedExtraProperties());
1✔
490
        props.set(Constants.KEY_ZONED_DATE_TIME_NOW, now);
1✔
491
        props.set(ReleaserDownloadUrl.NAME, new ReleaserDownloadUrl());
1✔
492

493
        return props;
1✔
494
    }
495

496
    private void fillProjectProperties(TemplateContext props, Project project) {
497
        props.setAll(environment.getProperties());
1✔
498
        props.setAll(environment.getSourcedProperties());
1✔
499
        props.set(Constants.KEY_TIMESTAMP, timestamp);
1✔
500
        if (null != commit) {
1✔
501
            props.set(Constants.KEY_COMMIT_SHORT_HASH, commit.getShortHash());
1✔
502
            props.set(Constants.KEY_COMMIT_FULL_HASH, commit.getFullHash());
1✔
503
        }
504
        props.set(Constants.KEY_PROJECT_NAME, project.getName());
1✔
505
        props.set(Constants.KEY_PROJECT_NAME_CAPITALIZED, getCapitalizedName(project.getName()));
1✔
506
        props.set(Constants.KEY_PROJECT_VERSION, project.getVersion());
1✔
507
        props.set(Constants.KEY_PROJECT_STEREOTYPE, project.getStereotype());
1✔
508
        props.set(Constants.KEY_PROJECT_EFFECTIVE_VERSION, project.getEffectiveVersion());
1✔
509
        props.set(Constants.KEY_PROJECT_SNAPSHOT, String.valueOf(project.isSnapshot()));
1✔
510
        if (isNotBlank(project.getDescription())) {
1✔
511
            props.set(Constants.KEY_PROJECT_DESCRIPTION, MustacheUtils.passThrough(project.getDescription()));
1✔
512
        }
513
        if (isNotBlank(project.getLongDescription())) {
1✔
514
            props.set(Constants.KEY_PROJECT_LONG_DESCRIPTION, MustacheUtils.passThrough(project.getLongDescription()));
1✔
515
        }
516
        if (isNotBlank(project.getLicense())) {
1✔
517
            props.set(Constants.KEY_PROJECT_LICENSE, project.getLicense());
1✔
518
        }
519
        if (null != project.getInceptionYear()) {
1✔
520
            props.set(Constants.KEY_PROJECT_INCEPTION_YEAR, project.getInceptionYear());
1✔
521
        }
522
        if (isNotBlank(project.getCopyright())) {
1✔
523
            props.set(Constants.KEY_PROJECT_COPYRIGHT, project.getCopyright());
1✔
524
        }
525
        if (isNotBlank(project.getVendor())) {
1✔
526
            props.set(Constants.KEY_PROJECT_VENDOR, project.getVendor());
1✔
527
        }
528
        project.getLinks().fillProps(props);
1✔
529
        props.set(Constants.KEY_PROJECT_AUTHORS_BY_SPACE, String.join(" ", project.getAuthors()));
1✔
530
        props.set(Constants.KEY_PROJECT_AUTHORS_BY_COMMA, String.join(",", project.getAuthors()));
1✔
531
        props.set(Constants.KEY_PROJECT_TAGS_BY_SPACE, String.join(" ", project.getTags()));
1✔
532
        props.set(Constants.KEY_PROJECT_TAGS_BY_COMMA, String.join(",", project.getTags()));
1✔
533

534
        project.getLanguages().fillProperties(props);
1✔
535

536
        project.parseVersion();
1✔
537
        props.setAll(project.resolvedExtraProperties());
1✔
538
    }
1✔
539

540
    private void fillReleaserProperties(TemplateContext props, Release release) {
541
        BaseReleaser<?, ?> service = release.getReleaser();
1✔
542
        if (null == service) return;
1✔
543
        props.set(Constants.KEY_REPO_HOST, service.getHost());
1✔
544
        props.set(Constants.KEY_REPO_OWNER, service.getOwner());
1✔
545
        props.set(Constants.KEY_REPO_NAME, service.getName());
1✔
546
        props.set(Constants.KEY_REPO_BRANCH, service.getBranch());
1✔
547
        props.set(Constants.KEY_REPO_BRANCH_PUSH, service.getResolvedBranchPush(this));
1✔
548
        props.set(Constants.KEY_REVERSE_REPO_HOST, service.getReverseRepoHost());
1✔
549
        props.set(Constants.KEY_CANONICAL_REPO_NAME, service.getCanonicalRepoName());
1✔
550
        props.set(Constants.KEY_TAG_NAME, service.getEffectiveTagName(this));
1✔
551
        props.set(Constants.KEY_PREVIOUS_TAG_NAME, service.getResolvedPreviousTagName(this));
1✔
552
        props.set(Constants.KEY_RELEASE_NAME, service.getEffectiveReleaseName());
1✔
553
        props.set(Constants.KEY_MILESTONE_NAME, service.getMilestone().getEffectiveName());
1✔
554
        props.set(Constants.KEY_REPO_URL, service.getResolvedRepoUrl(this));
1✔
555
        props.set(Constants.KEY_REPO_CLONE_URL, service.getResolvedRepoCloneUrl(this));
1✔
556
        props.set(Constants.KEY_COMMIT_URL, service.getResolvedCommitUrl(this));
1✔
557
        props.set(Constants.KEY_SRC_URL, service.getResolvedSrcUrl(this));
1✔
558
        props.set(Constants.KEY_RELEASE_NOTES_URL, service.getResolvedReleaseNotesUrl(this));
1✔
559
        props.set(Constants.KEY_LATEST_RELEASE_URL, service.getResolvedLatestReleaseUrl(this));
1✔
560
        props.set(Constants.KEY_ISSUE_TRACKER_URL, service.getResolvedIssueTrackerUrl(this, false));
1✔
561
    }
1✔
562

563
    private final class ReleaserDownloadUrl implements TemplateFunction {
1✔
564
        private static final String NAME = "f_release_download_url";
565
        private static final String MARKDOWN = "md";
566
        private static final String ASCIIDOC = "adoc";
567
        private static final String HTML = "html";
568

569
        @Override
570
        public String apply(String input) {
571
            String format = MARKDOWN;
×
572
            String artifactFile = "";
×
573
            String linkName = "";
×
574
            String[] parts = input.split(":");
×
575
            if (parts.length == 1) {
×
576
                artifactFile = parts[0];
×
577
                linkName = artifactFile;
×
578
            } else if (parts.length == 2) {
×
579
                linkName = parts[0];
×
580
                artifactFile = parts[1];
×
581
            } else if (parts.length == 3) {
×
582
                format = parts[0];
×
583
                linkName = parts[1];
×
584
                artifactFile = parts[2];
×
585
            } else {
586
                throw new JReleaserException(RB.$("ERROR_invalid_function_input", input, NAME));
×
587
            }
588

589
            switch (linkName) {
×
590
                case MARKDOWN:
591
                case ASCIIDOC:
592
                case HTML:
593
                    format = linkName;
×
594
                    linkName = artifactFile;
×
595
            }
596

597
            switch (format.toLowerCase(Locale.ENGLISH)) {
×
598
                case MARKDOWN:
599
                    return ("[" + linkName + "](" + getRelease().getReleaser().getDownloadUrl() + ")")
×
600
                        .replace("{{artifactFile}}", artifactFile);
×
601
                case ASCIIDOC:
602
                    return ("link:" + getRelease().getReleaser().getDownloadUrl() + "[" + linkName + "]")
×
603
                        .replace("{{artifactFile}}", artifactFile);
×
604
                case HTML:
605
                    return ("<a href=\"" + getRelease().getReleaser().getDownloadUrl() + "\">" + linkName + "</a>")
×
606
                        .replace("{{artifactFile}}", artifactFile);
×
607
                default:
608
                    // noop
609
            }
610

611
            throw new JReleaserException(RB.$("ERROR_invalid_function_input", input, NAME));
×
612
        }
613
    }
614
}
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