All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jreleaser.maven.plugin.AbstractPackager Maven / Gradle / Ivy

There is a newer version: 1.16.0
Show newest version
/*
 * SPDX-License-Identifier: Apache-2.0
 *
 * Copyright 2020-2022 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.maven.plugin;

import java.util.LinkedHashMap;
import java.util.Map;

import static org.jreleaser.util.StringUtils.isNotBlank;

/**
 * @author Andres Almiray
 * @since 0.1.0
 */
abstract class AbstractPackager implements Packager {
    protected final Map extraProperties = new LinkedHashMap<>();
    protected Active active;
    protected Boolean continueOnError;
    protected String downloadUrl;

    void setAll(AbstractPackager packager) {
        this.active = packager.active;
        this.continueOnError = packager.continueOnError;
        this.downloadUrl = packager.downloadUrl;
        setExtraProperties(packager.extraProperties);
    }

    @Override
    public Active getActive() {
        return active;
    }

    @Override
    public void setActive(Active active) {
        this.active = active;
    }

    @Override
    public String resolveActive() {
        return active != null ? active.name() : null;
    }

    @Override
    public boolean isContinueOnError() {
        return continueOnError != null && continueOnError;
    }

    @Override
    public void setContinueOnError(Boolean continueOnError) {
        this.continueOnError = continueOnError;
    }

    @Override
    public boolean isContinueOnErrorSet() {
        return continueOnError != null;
    }

    @Override
    public String getDownloadUrl() {
        return downloadUrl;
    }

    @Override
    public void setDownloadUrl(String downloadUrl) {
        this.downloadUrl = downloadUrl;
    }

    @Override
    public Map getExtraProperties() {
        return extraProperties;
    }

    @Override
    public void setExtraProperties(Map extraProperties) {
        this.extraProperties.clear();
        this.extraProperties.putAll(extraProperties);
    }

    public boolean isSet() {
        return null != active ||
            isNotBlank(downloadUrl) ||
            !extraProperties.isEmpty();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy