Search in sources :

Example 1 with RuleSelection

use of com.buschmais.jqassistant.core.rule.api.model.RuleSelection in project jqa-maven-plugin by jQAssistant.

the class EffectiveRulesMojo method aggregate.

@Override
public void aggregate(MavenProject rootModule, List<MavenProject> projects, Store store) throws MojoExecutionException, MojoFailureException {
    getLog().info("Effective rules for '" + rootModule.getName() + "'.");
    RuleSet ruleSet = readRules(rootModule);
    RuleSelection ruleSelection = RuleSelection.select(ruleSet, groups, constraints, concepts);
    RuleHelper ruleHelper = new RuleHelper(LOGGER);
    try {
        ruleHelper.printRuleSet(ruleSet, ruleSelection);
    } catch (RuleException e) {
        throw new MojoExecutionException("Cannot print effective rules.", e);
    }
}
Also used : RuleSet(com.buschmais.jqassistant.core.rule.api.model.RuleSet) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) RuleSelection(com.buschmais.jqassistant.core.rule.api.model.RuleSelection) RuleHelper(com.buschmais.jqassistant.core.rule.api.RuleHelper) RuleException(com.buschmais.jqassistant.core.rule.api.model.RuleException)

Example 2 with RuleSelection

use of com.buschmais.jqassistant.core.rule.api.model.RuleSelection in project jqa-maven-plugin by jQAssistant.

the class AnalyzeMojo method aggregate.

@Override
public void aggregate(MojoExecutionContext mojoExecutionContext) throws MojoExecutionException, MojoFailureException {
    MavenConfiguration configuration = mojoExecutionContext.getConfiguration();
    MavenProject rootModule = mojoExecutionContext.getRootModule();
    RuleSet ruleSet = readRules(mojoExecutionContext);
    Analyze analyze = configuration.analyze();
    RuleSelection ruleSelection = RuleSelection.select(ruleSet, analyze.groups(), analyze.constraints(), analyze.concepts());
    File outputDirectory = mojoExecutionContext.getOutputDirectory();
    withStore(store -> analyze(configuration, rootModule, ruleSet, ruleSelection, store, outputDirectory), mojoExecutionContext);
}
Also used : MavenConfiguration(com.buschmais.jqassistant.scm.maven.configuration.MavenConfiguration) RuleSet(com.buschmais.jqassistant.core.rule.api.model.RuleSet) MavenProject(org.apache.maven.project.MavenProject) RuleSelection(com.buschmais.jqassistant.core.rule.api.model.RuleSelection) File(java.io.File) Analyze(com.buschmais.jqassistant.core.analysis.api.configuration.Analyze)

Example 3 with RuleSelection

use of com.buschmais.jqassistant.core.rule.api.model.RuleSelection in project jqa-maven-plugin by jQAssistant.

the class EffectiveRulesMojo method aggregate.

@Override
public void aggregate(MojoExecutionContext mojoExecutionContext) throws MojoExecutionException, MojoFailureException {
    getLog().info("Effective rules for '" + mojoExecutionContext.getRootModule().getName() + "'.");
    Analyze analyze = mojoExecutionContext.getConfiguration().analyze();
    RuleSet ruleSet = readRules(mojoExecutionContext);
    RuleSelection ruleSelection = RuleSelection.select(ruleSet, analyze.groups(), analyze.constraints(), analyze.concepts());
    RuleHelper ruleHelper = new RuleHelper(LOGGER);
    try {
        ruleHelper.printRuleSet(ruleSet, ruleSelection, analyze.rule());
    } catch (RuleException e) {
        throw new MojoExecutionException("Cannot print effective rules.", e);
    }
}
Also used : RuleSet(com.buschmais.jqassistant.core.rule.api.model.RuleSet) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) RuleSelection(com.buschmais.jqassistant.core.rule.api.model.RuleSelection) RuleHelper(com.buschmais.jqassistant.core.rule.api.RuleHelper) RuleException(com.buschmais.jqassistant.core.rule.api.model.RuleException) Analyze(com.buschmais.jqassistant.core.analysis.api.configuration.Analyze)

Example 4 with RuleSelection

use of com.buschmais.jqassistant.core.rule.api.model.RuleSelection in project jqa-maven-plugin by jQAssistant.

the class AnalyzeMojo method aggregate.

@Override
public void aggregate(MavenProject rootModule, List<MavenProject> projects, Store store) throws MojoExecutionException, MojoFailureException {
    getLog().info("Executing analysis for '" + rootModule.getName() + "'.");
    getLog().info("Will warn on violations starting from severity '" + warnOnSeverity + "'");
    getLog().info("Will fail on violations starting from severity '" + failOnSeverity + "'.");
    RuleSet ruleSet = readRules(rootModule);
    RuleSelection ruleSelection = RuleSelection.select(ruleSet, groups, constraints, concepts);
    ReportContext reportContext = new ReportContextImpl(store, ProjectResolver.getOutputDirectory(rootModule));
    Severity effectiveFailOnSeverity = failOnSeverity;
    Map<String, Object> properties = getReportProperties();
    Map<String, ReportPlugin> reportPlugins = getPluginRepository().getAnalyzerPluginRepository().getReportPlugins(reportContext, properties);
    InMemoryReportPlugin inMemoryReportPlugin = new InMemoryReportPlugin(new CompositeReportPlugin(reportPlugins, reportTypes.isEmpty() ? null : reportTypes));
    AnalyzerConfiguration configuration = new AnalyzerConfiguration();
    configuration.setExecuteAppliedConcepts(executeAppliedConcepts);
    try {
        Analyzer analyzer = new AnalyzerImpl(configuration, store, getPluginRepository().getAnalyzerPluginRepository().getRuleInterpreterPlugins(emptyMap()), inMemoryReportPlugin, logger);
        analyzer.execute(ruleSet, ruleSelection, ruleParameters);
    } catch (RuleException e) {
        throw new MojoExecutionException("Analysis failed.", e);
    }
    if (attachReportArchive) {
        attachReportArchive(rootModule, reportContext);
    }
    ReportHelper reportHelper = new ReportHelper(logger);
    store.beginTransaction();
    try {
        verifyAnalysisResults(inMemoryReportPlugin, reportHelper, effectiveFailOnSeverity);
    } finally {
        store.commitTransaction();
    }
}
Also used : RuleSet(com.buschmais.jqassistant.core.rule.api.model.RuleSet) ReportContextImpl(com.buschmais.jqassistant.core.report.impl.ReportContextImpl) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ReportHelper(com.buschmais.jqassistant.core.report.api.ReportHelper) Severity(com.buschmais.jqassistant.core.rule.api.model.Severity) CompositeReportPlugin(com.buschmais.jqassistant.core.report.impl.CompositeReportPlugin) InMemoryReportPlugin(com.buschmais.jqassistant.core.report.impl.InMemoryReportPlugin) Analyzer(com.buschmais.jqassistant.core.analysis.api.Analyzer) RuleException(com.buschmais.jqassistant.core.rule.api.model.RuleException) InMemoryReportPlugin(com.buschmais.jqassistant.core.report.impl.InMemoryReportPlugin) ReportPlugin(com.buschmais.jqassistant.core.report.api.ReportPlugin) CompositeReportPlugin(com.buschmais.jqassistant.core.report.impl.CompositeReportPlugin) XmlReportPlugin(com.buschmais.jqassistant.core.report.impl.XmlReportPlugin) RuleSelection(com.buschmais.jqassistant.core.rule.api.model.RuleSelection) ReportContext(com.buschmais.jqassistant.core.report.api.ReportContext) AnalyzerImpl(com.buschmais.jqassistant.core.analysis.impl.AnalyzerImpl) AnalyzerConfiguration(com.buschmais.jqassistant.core.analysis.api.AnalyzerConfiguration)

Aggregations

RuleSelection (com.buschmais.jqassistant.core.rule.api.model.RuleSelection)4 RuleSet (com.buschmais.jqassistant.core.rule.api.model.RuleSet)4 RuleException (com.buschmais.jqassistant.core.rule.api.model.RuleException)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 Analyze (com.buschmais.jqassistant.core.analysis.api.configuration.Analyze)2 RuleHelper (com.buschmais.jqassistant.core.rule.api.RuleHelper)2 Analyzer (com.buschmais.jqassistant.core.analysis.api.Analyzer)1 AnalyzerConfiguration (com.buschmais.jqassistant.core.analysis.api.AnalyzerConfiguration)1 AnalyzerImpl (com.buschmais.jqassistant.core.analysis.impl.AnalyzerImpl)1 ReportContext (com.buschmais.jqassistant.core.report.api.ReportContext)1 ReportHelper (com.buschmais.jqassistant.core.report.api.ReportHelper)1 ReportPlugin (com.buschmais.jqassistant.core.report.api.ReportPlugin)1 CompositeReportPlugin (com.buschmais.jqassistant.core.report.impl.CompositeReportPlugin)1 InMemoryReportPlugin (com.buschmais.jqassistant.core.report.impl.InMemoryReportPlugin)1 ReportContextImpl (com.buschmais.jqassistant.core.report.impl.ReportContextImpl)1 XmlReportPlugin (com.buschmais.jqassistant.core.report.impl.XmlReportPlugin)1 Severity (com.buschmais.jqassistant.core.rule.api.model.Severity)1 MavenConfiguration (com.buschmais.jqassistant.scm.maven.configuration.MavenConfiguration)1 File (java.io.File)1 MavenProject (org.apache.maven.project.MavenProject)1