Package com.buschmais.jqassistant.scm.maven

Source Code of com.buschmais.jqassistant.scm.maven.ExportRulesMojo

package com.buschmais.jqassistant.scm.maven;

import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Set;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.project.MavenProject;

import com.buschmais.jqassistant.core.analysis.api.RuleSetWriter;
import com.buschmais.jqassistant.core.analysis.api.rule.RuleSet;
import com.buschmais.jqassistant.core.analysis.impl.RuleSetWriterImpl;
import com.buschmais.jqassistant.core.store.api.Store;

/**
* Exports the effective rules to an XML file.
*/
@Mojo(name = "export-rules")
public class ExportRulesMojo extends AbstractAnalysisMojo {

    @Override
    protected void aggregate(MavenProject baseProject, Set<MavenProject> projects, Store store) throws MojoExecutionException, MojoFailureException {
        getLog().info("Exporting rules for '" + baseProject.getName() + "'.");
        final RuleSet ruleSet = resolveEffectiveRules(baseProject);
        RuleSetWriter ruleSetWriter = new RuleSetWriterImpl();
        String exportedRules = baseProject.getBuild().getDirectory() + "/jqassistant/jqassistant-rules.xml";
        Writer writer;
        try {
            writer = new FileWriter(exportedRules);
        } catch (IOException e) {
            throw new MojoExecutionException("Cannot create writer for rule export.", e);
        }
        ruleSetWriter.write(ruleSet, writer);
    }

    @Override
    protected boolean isResetStoreOnInitialization() {
        return false;
    }
}
TOP

Related Classes of com.buschmais.jqassistant.scm.maven.ExportRulesMojo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.