Search in sources :

Example 6 with ScalaMethod

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

the class PlayRunAdapterV26X method runDevHttpServer.

@Override
public InetSocketAddress 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), int.class, String.class);
    Object reloadableServer = runMethod.invoke(buildLink, httpPort, "0.0.0.0");
    return JavaReflectionUtil.method(reloadableServer, InetSocketAddress.class, "mainAddress").invoke(reloadableServer);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ScalaMethod(org.gradle.scala.internal.reflect.ScalaMethod)

Example 7 with ScalaMethod

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

the class TwirlCompiler method execute.

@Override
public WorkResult execute(TwirlCompileSpec spec) {
    List<File> outputFiles = Lists.newArrayList();
    ClassLoader cl = getClass().getClassLoader();
    ScalaMethod compile = getCompileMethod(cl);
    Iterable<RelativeFile> sources = spec.getSources();
    for (RelativeFile sourceFile : sources) {
        TwirlTemplateFormat format = findTemplateFormat(spec, sourceFile.getFile());
        try {
            Object result = compile.invoke(buildCompileArguments(spec, cl, sourceFile, format));
            ScalaOptionInvocationWrapper<File> maybeFile = new ScalaOptionInvocationWrapper<File>(result);
            if (maybeFile.isDefined()) {
                File outputFile = maybeFile.get();
                outputFiles.add(outputFile);
            }
        } catch (Exception e) {
            throw new RuntimeException("Error invoking Play Twirl template compiler.", e);
        }
    }
    return WorkResults.didWork(!outputFiles.isEmpty());
}
Also used : RelativeFile(org.gradle.api.internal.file.RelativeFile) ScalaMethod(org.gradle.scala.internal.reflect.ScalaMethod) ScalaOptionInvocationWrapper(org.gradle.scala.internal.reflect.ScalaOptionInvocationWrapper) RelativeFile(org.gradle.api.internal.file.RelativeFile) File(java.io.File) TwirlTemplateFormat(org.gradle.language.twirl.TwirlTemplateFormat)

Aggregations

ScalaMethod (org.gradle.scala.internal.reflect.ScalaMethod)7 InetSocketAddress (java.net.InetSocketAddress)3 File (java.io.File)2 RelativeFile (org.gradle.api.internal.file.RelativeFile)1 TwirlTemplateFormat (org.gradle.language.twirl.TwirlTemplateFormat)1 ScalaOptionInvocationWrapper (org.gradle.scala.internal.reflect.ScalaOptionInvocationWrapper)1