nebula.test.functional.GradleRunnerFactory.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nebula-test Show documentation
Show all versions of nebula-test Show documentation
Test harness for Gradle plugins
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