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

io.qameta.allure.maven.AlureAggregateMojo Maven / Gradle / Ivy

There is a newer version: 2.15.2
Show newest version
package io.qameta.allure.maven;

import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author Dmitry Baev [email protected]
 *         Date: 04.08.15
 */
@Mojo(name = "aggregate", defaultPhase = LifecyclePhase.SITE,
        inheritByDefault = false, aggregator = true)
public class AlureAggregateMojo extends AllureGenerateMojo {

    /**
     * The projects in the reactor.
     */
    @Parameter(defaultValue = "${reactorProjects}", required = true, readonly = true)
    private List reactorProjects;

    /**
     * {@inheritDoc}
     */
    @Override
    protected List getInputDirectories() {
        Path relative = Paths.get(resultsDirectory);
        if (relative.isAbsolute()) {
            getLog().error("Input directory should be not absolute for aggregate goal.");
            return Collections.emptyList();
        }

        List result = new ArrayList<>();
        for (MavenProject child : reactorProjects) {
            Path target = Paths.get(child.getBuild().getDirectory());
            Path path = target.resolve(relative).toAbsolutePath();
            if (isDirectoryExists(path)) {
                result.add(path);
                getLog().info("Found results directory " + path);
            } else {
                getLog().warn("Results directory for module " + child.getName() + " not found.");
            }
        }

        return result;
    }

    @Override
    protected String getMojoName() {
        return "aggregate";
    }

    @Override
    protected boolean isAggregate() {
        return true;
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy