• 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

0.0
/sdks/jreleaser-forgejo-java-sdk/src/main/java/org/jreleaser/sdk/forgejo/ForgejoMavenDeployer.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.sdk.forgejo;
19

20
import org.jreleaser.bundle.RB;
21
import org.jreleaser.model.internal.JReleaserContext;
22
import org.jreleaser.model.spi.deploy.DeployException;
23
import org.jreleaser.model.spi.deploy.maven.Deployable;
24
import org.jreleaser.sdk.commons.AbstractMavenDeployer;
25

26
import java.net.MalformedURLException;
27
import java.net.URI;
28
import java.net.URISyntaxException;
29
import java.net.URL;
30
import java.util.Set;
31

32
/**
33
 * @author Andres Almiray
34
 * @since 1.18.0
35
 */
36
public class ForgejoMavenDeployer extends AbstractMavenDeployer<org.jreleaser.model.api.deploy.maven.ForgejoMavenDeployer,
37
    org.jreleaser.model.internal.deploy.maven.ForgejoMavenDeployer> {
38
    private org.jreleaser.model.internal.deploy.maven.ForgejoMavenDeployer deployer;
39

40
    public ForgejoMavenDeployer(JReleaserContext context) {
41
        super(context);
×
42
    }
×
43

44
    @Override
45
    public org.jreleaser.model.internal.deploy.maven.ForgejoMavenDeployer getDeployer() {
46
        return deployer;
×
47
    }
48

49
    @Override
50
    public void setDeployer(org.jreleaser.model.internal.deploy.maven.ForgejoMavenDeployer deployer) {
51
        this.deployer = deployer;
×
52
    }
×
53

54
    @Override
55
    public String getType() {
56
        return org.jreleaser.model.api.deploy.maven.ForgejoMavenDeployer.TYPE;
×
57
    }
58

59
    @Override
60
    public void deploy(String name) throws DeployException {
61
        deployPackages();
×
62
    }
×
63

64
    @Override
65
    protected void deleteExistingPackages(String baseUrl, String token, Set<Deployable> deployables) throws DeployException {
66
        for (Deployable deployable : deployables) {
×
67
            if (deployable.getFilename().endsWith(".pom")) {
×
68
                deletePackage(baseUrl, token, deployable);
×
69
            }
70
        }
×
71
    }
×
72

73
    private void deletePackage(String baseUrl, String token, Deployable deployable) throws DeployException {
74
        URL url = null;
×
75

76
        try {
77
            url = new URI(baseUrl).toURL();
×
78
        } catch (URISyntaxException | MalformedURLException e) {
×
79
            context.getLogger().trace(e);
×
80
            throw new DeployException(RB.$("ERROR_unexpected_deploy", deployable.getGav(), e.getMessage()), e);
×
81
        }
×
82

83
        StringBuilder theUrl = new StringBuilder(url.getProtocol())
×
84
            .append("://")
×
85
            .append(url.getHost());
×
86
        if (url.getPort() != -1) {
×
87
            theUrl.append(url.getPort());
×
88
        }
89

90
        try {
91
            Forgejo api = new Forgejo(context.asImmutable(),
×
92
                theUrl.toString(),
×
93
                token,
94
                deployer.getConnectTimeout(),
×
95
                deployer.getReadTimeout());
×
96

97
            api.deletePackage(deployer.getUsername(),
×
98
                "maven",
99
                deployable.getGroupId() + "-" + deployable.getArtifactId(),
×
100
                deployable.getVersion());
×
101
        } catch (Exception e) {
×
102
            context.getLogger().debug(RB.$("ERROR_forgejo_delete_package", deployer.getUsername(),
×
103
                "maven",
104
                deployable.getGroupId() + "-" + deployable.getArtifactId(),
×
105
                deployable.getVersion()));
×
106
        }
×
107
    }
×
108
}
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