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

org.wildfly.channelplugin.AbstractChannelMojo Maven / Gradle / Ivy

Go to download

This maven plugin overrides dependencies versions in a Maven project according to Wildfly channel definition.

There is a newer version: 1.0.19
Show newest version
package org.wildfly.channelplugin;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.commonjava.maven.ext.common.ManipulationException;
import org.commonjava.maven.ext.common.model.Project;
import org.commonjava.maven.ext.io.PomIO;

import javax.inject.Inject;
import java.util.List;
import java.util.Optional;

public abstract class AbstractChannelMojo extends AbstractMojo {

    @Inject
    MavenProject mavenProject;

    @Inject
    PomIO pomIO;

    /**
     * Returns PME representation of current project module and its submodules.
     */
    protected List parsePmeProjects() throws ManipulationException {
        return pomIO.parseProject(mavenProject.getModel().getPomFile());
    }

    protected Project findRootProject(List projects) throws MojoExecutionException {
        Optional rootProjectOptional = projects.stream().filter(Project::isExecutionRoot).findFirst();
        if (rootProjectOptional.isEmpty()) {
            throw new MojoExecutionException("Can't identify root project.");
        }
        return rootProjectOptional.get();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy