Search in sources :

Example 1 with MavenConfiguration

use of com.buschmais.jqassistant.scm.maven.configuration.MavenConfiguration 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 2 with MavenConfiguration

use of com.buschmais.jqassistant.scm.maven.configuration.MavenConfiguration in project jqa-maven-plugin by jQAssistant.

the class AbstractMojo method execute.

@Override
public final void execute() throws MojoExecutionException, MojoFailureException {
    if (!runtimeInformation.isMavenVersion("[3.5,)")) {
        throw new MojoExecutionException("jQAssistant requires Maven 3.5.x or above.");
    }
    // parallel builds
    synchronized (AbstractMojo.class) {
        MavenConfiguration configuration = getConfiguration();
        MojoExecutionContext mojoExecutionContext = new MojoExecutionContext(session, currentProject, configuration);
        MavenProject rootModule = mojoExecutionContext.getRootModule();
        Set<MavenProject> executedModules = getExecutedModules(rootModule);
        if (configuration.skip()) {
            getLog().info("Skipping execution.");
        } else {
            if (isResetStoreBeforeExecution() && executedModules.isEmpty()) {
                withStore(store -> store.reset(), mojoExecutionContext);
            }
            execute(mojoExecutionContext, executedModules);
        }
        executedModules.add(currentProject);
    }
}
Also used : MavenConfiguration(com.buschmais.jqassistant.scm.maven.configuration.MavenConfiguration) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MavenProject(org.apache.maven.project.MavenProject)

Example 3 with MavenConfiguration

use of com.buschmais.jqassistant.scm.maven.configuration.MavenConfiguration in project jqa-maven-plugin by jQAssistant.

the class ScanMojo method execute.

@Override
public void execute(MojoExecutionContext mojoExecutionContext, MavenProject mavenProject) throws MojoExecutionException, MojoFailureException {
    MavenConfiguration configuration = mojoExecutionContext.getConfiguration();
    File outputDirectory = mojoExecutionContext.getOutputDirectory();
    withStore(store -> scan(mavenProject, configuration, store, outputDirectory), mojoExecutionContext);
}
Also used : MavenConfiguration(com.buschmais.jqassistant.scm.maven.configuration.MavenConfiguration) File(java.io.File)

Example 4 with MavenConfiguration

use of com.buschmais.jqassistant.scm.maven.configuration.MavenConfiguration in project jqa-maven-plugin by jQAssistant.

the class AbstractMojo method withStore.

/**
 * Execute an operation with the store.
 * <p>
 * This method enforces thread safety based on the store factory.
 *
 * @param storeOperation
 *     The store.
 * @throws MojoExecutionException
 *     On execution errors.
 * @throws MojoFailureException
 *     On execution failures.
 */
protected final void withStore(StoreOperation storeOperation, MojoExecutionContext mojoExecutionContext) throws MojoExecutionException, MojoFailureException {
    MavenProject rootModule = mojoExecutionContext.getRootModule();
    MavenConfiguration configuration = mojoExecutionContext.getConfiguration();
    Store store = getStore(configuration, () -> storeDirectory != null ? storeDirectory : new File(rootModule.getBuild().getDirectory(), STORE_DIRECTORY));
    try {
        storeOperation.run(store);
    } finally {
        releaseStore(store);
    }
}
Also used : MavenConfiguration(com.buschmais.jqassistant.scm.maven.configuration.MavenConfiguration) MavenProject(org.apache.maven.project.MavenProject) Store(com.buschmais.jqassistant.core.store.api.Store) File(java.io.File)

Aggregations

MavenConfiguration (com.buschmais.jqassistant.scm.maven.configuration.MavenConfiguration)4 File (java.io.File)3 MavenProject (org.apache.maven.project.MavenProject)3 Analyze (com.buschmais.jqassistant.core.analysis.api.configuration.Analyze)1 RuleSelection (com.buschmais.jqassistant.core.rule.api.model.RuleSelection)1 RuleSet (com.buschmais.jqassistant.core.rule.api.model.RuleSet)1 Store (com.buschmais.jqassistant.core.store.api.Store)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1