• 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-github-java-sdk/src/main/java/org/jreleaser/sdk/github/GithubMavenDeployer.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.github;
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
import org.jreleaser.sdk.github.api.GhPackageVersion;
26

27
import java.util.List;
28
import java.util.Optional;
29
import java.util.Set;
30

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

39
    public GithubMavenDeployer(JReleaserContext context) {
40
        super(context);
×
41
    }
×
42

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

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

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

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

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

72
    private void deletePackage(String token, Deployable deployable) {
73
        String packageType = "maven";
×
74
        String packageName = deployable.getGroupId() + "." + deployable.getArtifactId();
×
75
        String packageVersion = deployable.getVersion();
×
76

77
        try {
78
            Github api = new Github(context.asImmutable(),
×
79
                context.getModel().getRelease().getGithub().getApiEndpoint(),
×
80
                token,
81
                deployer.getConnectTimeout(),
×
82
                deployer.getReadTimeout());
×
83

84
            List<GhPackageVersion> ghPackageVersions = api.listPackageVersions(packageType, packageName);
×
85
            if (ghPackageVersions.isEmpty()) return;
×
86

87
            if (ghPackageVersions.size() == 1) {
×
88
                api.deletePackage(packageType, packageName);
×
89
            } else {
90
                Optional<GhPackageVersion> ghPackageVersion = ghPackageVersions.stream()
×
91
                    .filter(pv -> pv.getName().equals(packageVersion))
×
92
                    .findFirst();
×
93

94
                if (ghPackageVersion.isPresent()) {
×
95
                    api.deletePackageVersion(packageType, packageType, packageVersion);
×
96
                }
97
            }
98
        } catch (Exception e) {
×
99
            context.getLogger().debug(RB.$("ERROR_github_delete_package", deployer.getUsername(),
×
100
                packageType,
101
                packageName,
102
                packageVersion));
103
        }
×
104
    }
×
105
}
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