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

com.paypal.butterfly.utilities.operations.pom.PomCopyManagedDependencies Maven / Gradle / Ivy

There is a newer version: 3.2.7
Show newest version
package com.paypal.butterfly.utilities.operations.pom;

import java.util.Collections;
import java.util.List;

import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Model;

/**
 * Copies managed dependencies from a POM file to another.
 * It also allows replacements plus filtering which managed dependencies to copy.
 *
 * @author facarvalho
 */
public class PomCopyManagedDependencies extends AbstractPomCopyDependencies {

    private static final String DESCRIPTION = "Copy Maven managed dependencies from POM file %s to %s";

    public PomCopyManagedDependencies() {
        super(DESCRIPTION);
    }

    @Override
    List getMavenDependencies(Model mavenModel) {
        DependencyManagement dependencyManagement = mavenModel.getDependencyManagement();
        if (dependencyManagement == null) {
            return Collections.emptyList();
        }
        return dependencyManagement.getDependencies();
    }

    @Override
    void addMavenDependencies(Model mavenModelTo, List dependencies) {
        if (mavenModelTo.getDependencyManagement() == null) {
            mavenModelTo.setDependencyManagement(new DependencyManagement());
        }
        dependencies.forEach(d -> mavenModelTo.getDependencyManagement().addDependency(d));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy