org.jreleaser.model.internal.upload.AbstractGitPackageUploader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jreleaser-model-impl Show documentation
Show all versions of jreleaser-model-impl Show documentation
JReleaser Model implementation
The newest version!
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2024 The JReleaser authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jreleaser.model.internal.upload;
import org.jreleaser.model.internal.JReleaserContext;
import org.jreleaser.model.internal.common.Artifact;
import java.util.Map;
import static org.jreleaser.model.Constants.HIDE;
import static org.jreleaser.model.Constants.UNSET;
import static org.jreleaser.util.StringUtils.isNotBlank;
/**
* @author Andres Almiray
* @since 1.5.0
*/
public abstract class AbstractGitPackageUploader> extends AbstractUploader {
private static final long serialVersionUID = -9172635937307460363L;
private String host;
private String token;
private String packageName;
private String packageVersion;
protected AbstractGitPackageUploader(String type) {
super(type);
}
@Override
public void merge(S source) {
super.merge(source);
this.host = merge(this.host, source.getHost());
this.token = merge(this.token, source.getToken());
this.packageName = merge(this.packageName, source.getPackageName());
this.packageVersion = merge(this.packageVersion, source.getPackageVersion());
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getPackageName() {
return packageName;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public String getPackageVersion() {
return packageVersion;
}
public void setPackageVersion(String packageVersion) {
this.packageVersion = packageVersion;
}
@Override
protected void asMap(boolean full, Map props) {
props.put("host", host);
props.put("token", isNotBlank(token) ? HIDE : UNSET);
props.put("packageName", packageName);
props.put("packageVersion", packageVersion);
}
@Override
public String getResolvedDownloadUrl(JReleaserContext context, Artifact artifact) {
return getResolvedDownloadUrl(context.fullProps(), artifact);
}
public String getResolvedUploadUrl(JReleaserContext context, Artifact artifact) {
return getResolvedDownloadUrl(context, artifact);
}
}