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. Hopefully retiring in favor of Gradle TestKit
package nebula.test.functional
import com.google.common.base.Predicate
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
@CompileStatic
class GradleRunnerFactory {
public static GradleRunner createTooling(boolean fork = false, String version = null, Predicate classpathFilter = null) {
GradleHandleFactory toolingApiHandleFactory = new ToolingApiGradleHandleFactory(fork, version);
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);
}
}