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

com.maxifier.mxcache.gradle.MxCacheGradlePlugin Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2008-2014 Maxifier Ltd. All Rights Reserved.
 */
package com.maxifier.mxcache.gradle;

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;

import java.io.File;
import java.util.Set;

/**
 * @author Artyom Norin ([email protected])
 */
public class MxCacheGradlePlugin implements Plugin {

    @Override
    public void apply(Project project) {
        addInstrumentationFinalizer(project, "compileJava");
        addInstrumentationFinalizer(project, "compileTestJava");
    }

    private void addInstrumentationFinalizer(Project project, String compileTaskName) {
        Task compileTask = project.getTasks().getByPath(compileTaskName);
        if (compileTask != null) {
            Set files = compileTask.getOutputs().getFiles().getFiles();
            InstrumentationTask instrumentationTask = project.getTasks().create(compileTaskName + "Instrumentation", InstrumentationTask.class);
            instrumentationTask.setClassesRootFolders(files);
            compileTask.finalizedBy(instrumentationTask);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy