Search in sources :

Example 1 with ScalaMethod

use of org.gradle.scala.internal.reflect.ScalaMethod in project gradle by gradle.

the class RoutesCompiler method compile.

private Boolean compile(File sourceFile, RoutesCompileSpec spec) {
    try {
        ClassLoader cl = getClass().getClassLoader();
        ScalaMethod compile = adapter.getCompileMethod(cl);
        Object ret = compile.invoke(adapter.createCompileParameters(cl, sourceFile, spec.getDestinationDir(), spec.isJavaProject(), spec.isNamespaceReverseRouter(), spec.isGenerateReverseRoutes(), spec.isInjectedRoutesGenerator(), spec.getAdditionalImports()));
        if (ret != null && ret instanceof Boolean) {
            return (Boolean) ret;
        } else {
            //assume we did some work
            return true;
        }
    } catch (Exception e) {
        throw new RuntimeException("Error invoking the Play routes compiler.", e);
    }
}
Also used : ScalaMethod(org.gradle.scala.internal.reflect.ScalaMethod)

Example 2 with ScalaMethod

use of org.gradle.scala.internal.reflect.ScalaMethod in project gradle by gradle.

the class PlayRunAdapterV24X method runDevHttpServer.

@Override
public void runDevHttpServer(ClassLoader classLoader, ClassLoader docsClassLoader, Object buildLink, Object buildDocHandler, int httpPort) throws ClassNotFoundException {
    ScalaMethod runMethod = ScalaReflectionUtil.scalaMethod(classLoader, "play.core.server.DevServerStart", "mainDevHttpMode", getBuildLinkClass(classLoader), getBuildDocHandlerClass(docsClassLoader), int.class, String.class);
    runMethod.invoke(buildLink, buildDocHandler, httpPort, "0.0.0.0");
}
Also used : ScalaMethod(org.gradle.scala.internal.reflect.ScalaMethod)

Example 3 with ScalaMethod

use of org.gradle.scala.internal.reflect.ScalaMethod in project gradle by gradle.

the class PlayRunAdapterV25X method runDevHttpServer.

@Override
public void runDevHttpServer(ClassLoader classLoader, ClassLoader docsClassLoader, Object buildLink, Object buildDocHandler, int httpPort) throws ClassNotFoundException {
    ScalaMethod runMethod = ScalaReflectionUtil.scalaMethod(classLoader, "play.core.server.DevServerStart", "mainDevHttpMode", getBuildLinkClass(classLoader), getBuildDocHandlerClass(docsClassLoader), int.class, String.class);
    runMethod.invoke(buildLink, buildDocHandler, httpPort, "0.0.0.0");
}
Also used : ScalaMethod(org.gradle.scala.internal.reflect.ScalaMethod)

Example 4 with ScalaMethod

use of org.gradle.scala.internal.reflect.ScalaMethod in project gradle by gradle.

the class DefaultVersionedPlayRunAdapter method runDevHttpServer.

@Override
public void runDevHttpServer(ClassLoader classLoader, ClassLoader docsClassLoader, Object buildLink, Object buildDocHandler, int httpPort) throws ClassNotFoundException {
    ScalaMethod runMethod = ScalaReflectionUtil.scalaMethod(classLoader, "play.core.server.NettyServer", "mainDevHttpMode", getBuildLinkClass(classLoader), getBuildDocHandlerClass(docsClassLoader), int.class);
    runMethod.invoke(buildLink, buildDocHandler, httpPort);
}
Also used : ScalaMethod(org.gradle.scala.internal.reflect.ScalaMethod)

Example 5 with ScalaMethod

use of org.gradle.scala.internal.reflect.ScalaMethod in project gradle by gradle.

the class PlayRunAdapterV23X method createAssetsClassLoader.

@Override
protected ClassLoader createAssetsClassLoader(File assetsJar, Iterable<File> assetsDirs, ClassLoader classLoader) {
    Class<?> assetsClassLoaderClass;
    assetsClassLoaderClass = loadClass(classLoader, "play.runsupport.AssetsClassLoader");
    final Class<?> tuple2Class = loadClass(classLoader, "scala.Tuple2");
    List<?> tuples = CollectionUtils.collect(assetsDirs, new Transformer<Object, File>() {

        @Override
        public Object transform(File file) {
            return DirectInstantiator.instantiate(tuple2Class, "public", file);
        }
    });
    ScalaMethod listToScalaSeqMethod = ScalaReflectionUtil.scalaMethod(classLoader, "scala.collection.convert.WrapAsScala", "asScalaBuffer", List.class);
    Object scalaTuples = listToScalaSeqMethod.invoke(tuples);
    return Cast.uncheckedCast(DirectInstantiator.instantiate(assetsClassLoaderClass, classLoader, scalaTuples));
}
Also used : ScalaMethod(org.gradle.scala.internal.reflect.ScalaMethod) File(java.io.File)

Aggregations

ScalaMethod (org.gradle.scala.internal.reflect.ScalaMethod)6 File (java.io.File)2 RelativeFile (org.gradle.api.internal.file.RelativeFile)1 SimpleWorkResult (org.gradle.api.internal.tasks.SimpleWorkResult)1 ScalaOptionInvocationWrapper (org.gradle.scala.internal.reflect.ScalaOptionInvocationWrapper)1