org.gradle.api.internal.tasks.compile.CompileSpec Java Examples

The following examples show how to use org.gradle.api.internal.tasks.compile.CompileSpec. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InProcessCompilerDaemonFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public CompilerDaemon getDaemon(File workingDir, final DaemonForkOptions forkOptions) {
    return new CompilerDaemon() {
        public <T extends CompileSpec> CompileResult execute(Compiler<T> compiler, T spec) {
            ClassLoader groovyClassLoader = classLoaderFactory.createIsolatedClassLoader(new DefaultClassPath(forkOptions.getClasspath()));
            FilteringClassLoader filteredGroovy = classLoaderFactory.createFilteringClassLoader(groovyClassLoader);
            for (String packageName : forkOptions.getSharedPackages()) {
                filteredGroovy.allowPackage(packageName);
            }

            ClassLoader workerClassLoader = new MutableURLClassLoader(filteredGroovy, ClasspathUtil.getClasspath(compiler.getClass().getClassLoader()));

            try {
                byte[] serializedWorker = GUtil.serialize(new Worker<T>(compiler, spec));
                ClassLoaderObjectInputStream inputStream = new ClassLoaderObjectInputStream(new ByteArrayInputStream(serializedWorker), workerClassLoader);
                Callable<?> worker = (Callable<?>) inputStream.readObject();
                Object result = worker.call();
                byte[] serializedResult = GUtil.serialize(result);
                inputStream = new ClassLoaderObjectInputStream(new ByteArrayInputStream(serializedResult), getClass().getClassLoader());
                return (CompileResult) inputStream.readObject();
            } catch (Exception e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
        }
    };
}
 
Example #2
Source File: InProcessCompilerDaemonFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public CompilerDaemon getDaemon(File workingDir, final DaemonForkOptions forkOptions) {
    return new CompilerDaemon() {
        public <T extends CompileSpec> CompileResult execute(Compiler<T> compiler, T spec) {
            ClassLoader groovyClassLoader = classLoaderFactory.createIsolatedClassLoader(new DefaultClassPath(forkOptions.getClasspath()));
            FilteringClassLoader filteredGroovy = classLoaderFactory.createFilteringClassLoader(groovyClassLoader);
            for (String packageName : forkOptions.getSharedPackages()) {
                filteredGroovy.allowPackage(packageName);
            }

            ClassLoader workerClassLoader = new MutableURLClassLoader(filteredGroovy, ClasspathUtil.getClasspath(compiler.getClass().getClassLoader()));

            try {
                byte[] serializedWorker = GUtil.serialize(new Worker<T>(compiler, spec));
                ClassLoaderObjectInputStream inputStream = new ClassLoaderObjectInputStream(new ByteArrayInputStream(serializedWorker), workerClassLoader);
                Callable<?> worker = (Callable<?>) inputStream.readObject();
                Object result = worker.call();
                byte[] serializedResult = GUtil.serialize(result);
                inputStream = new ClassLoaderObjectInputStream(new ByteArrayInputStream(serializedResult), getClass().getClassLoader());
                return (CompileResult) inputStream.readObject();
            } catch (Exception e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
        }
    };
}
 
Example #3
Source File: CompilerDaemonServer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public <T extends CompileSpec> void execute(Compiler<T> compiler, T spec) {
    try {
        LOGGER.info("Executing {} in compiler daemon.", compiler);
        WorkResult result = compiler.execute(spec);
        LOGGER.info("Successfully executed {} in compiler daemon.", compiler);
        client.executed(new CompileResult(result.getDidWork(), null));
    } catch (Throwable t) {
        LOGGER.info("Exception executing {} in compiler daemon: {}.", compiler, t);
        client.executed(new CompileResult(true, t));
    }
}
 
Example #4
Source File: CompilerDaemonClient.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public <T extends CompileSpec> CompileResult execute(Compiler<T> compiler, T spec) {
    // currently we just allow a single compilation thread at a time (per compiler daemon)
    // one problem to solve when allowing multiple threads is how to deal with memory requirements specified by compile tasks
    try {
        server.execute(compiler, spec);
        return compileResults.take();
    } catch (InterruptedException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
Example #5
Source File: CompilerDaemonServer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public <T extends CompileSpec> void execute(Compiler<T> compiler, T spec) {
    try {
        LOGGER.info("Executing {} in compiler daemon.", compiler);
        WorkResult result = compiler.execute(spec);
        LOGGER.info("Successfully executed {} in compiler daemon.", compiler);
        client.executed(new CompileResult(result.getDidWork(), null));
    } catch (Throwable t) {
        LOGGER.info("Exception executing {} in compiler daemon: {}.", compiler, t);
        client.executed(new CompileResult(true, t));
    }
}
 
Example #6
Source File: CompilerDaemonClient.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public <T extends CompileSpec> CompileResult execute(Compiler<T> compiler, T spec) {
    // currently we just allow a single compilation thread at a time (per compiler daemon)
    // one problem to solve when allowing multiple threads is how to deal with memory requirements specified by compile tasks
    try {
        server.execute(compiler, spec);
        return compileResults.take();
    } catch (InterruptedException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
Example #7
Source File: CompilerDaemon.java    From pushfish-android with BSD 2-Clause "Simplified" License votes vote down vote up
<T extends CompileSpec> CompileResult execute(Compiler<T> compiler, T spec); 
Example #8
Source File: CompilerDaemonServerProtocol.java    From pushfish-android with BSD 2-Clause "Simplified" License votes vote down vote up
<T extends CompileSpec> void execute(Compiler<T> compiler, T spec); 
Example #9
Source File: CompilerDaemon.java    From Pushjet-Android with BSD 2-Clause "Simplified" License votes vote down vote up
<T extends CompileSpec> CompileResult execute(Compiler<T> compiler, T spec); 
Example #10
Source File: CompilerDaemonServerProtocol.java    From Pushjet-Android with BSD 2-Clause "Simplified" License votes vote down vote up
<T extends CompileSpec> void execute(Compiler<T> compiler, T spec);