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

nebula.test.functional.GradleRunnerFactory.groovy Maven / Gradle / Ivy

There is a newer version: 10.6.1
Show newest version
package nebula.test.functional

import groovy.transform.CompileStatic
import nebula.test.functional.internal.DefaultGradleRunner
import nebula.test.functional.internal.GradleHandleFactory
import nebula.test.functional.internal.classpath.ClasspathInjectingGradleHandleFactory
import nebula.test.functional.internal.toolingapi.ToolingApiGradleHandleFactory

import java.util.function.Predicate

@CompileStatic
class GradleRunnerFactory {
    public static GradleRunner createTooling(boolean fork = false, String version = null, Integer daemonMaxIdleTimeInSeconds = null,
                                             Predicate classpathFilter = null) {
        GradleHandleFactory toolingApiHandleFactory = new ToolingApiGradleHandleFactory(fork, version, daemonMaxIdleTimeInSeconds);
        return create(toolingApiHandleFactory, classpathFilter ?: GradleRunner.CLASSPATH_DEFAULT);
    }

    public static GradleRunner create(GradleHandleFactory handleFactory, Predicate classpathFilter = null) {
        // TODO: Which class would be attached to the right classloader? Is using something from the test kit right?
        ClassLoader sourceClassLoader = GradleRunnerFactory.class.getClassLoader();
        create(handleFactory, sourceClassLoader, classpathFilter ?: GradleRunner.CLASSPATH_DEFAULT)
    }

    public static GradleRunner create(GradleHandleFactory handleFactory, ClassLoader sourceClassLoader, Predicate classpathFilter) {
        GradleHandleFactory classpathInjectingHandleFactory = new ClasspathInjectingGradleHandleFactory(sourceClassLoader, handleFactory, classpathFilter);
        return new DefaultGradleRunner(classpathInjectingHandleFactory);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy