Search in sources :

Example 1 with JavaCompilingTool

use of org.jetbrains.jps.builders.java.JavaCompilingTool in project intellij-community by JetBrains.

the class JavaBuilder method buildStarted.

@Override
public void buildStarted(CompileContext context) {
    final String compilerId = getUsedCompilerId(context);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Java compiler ID: " + compilerId);
    }
    JavaCompilingTool compilingTool = JavaBuilderUtil.findCompilingTool(compilerId);
    COMPILING_TOOL.set(context, compilingTool);
    COMPILER_USAGE_STATISTICS.set(context, new ConcurrentHashMap<>());
}
Also used : JavaCompilingTool(org.jetbrains.jps.builders.java.JavaCompilingTool)

Example 2 with JavaCompilingTool

use of org.jetbrains.jps.builders.java.JavaCompilingTool in project intellij-community by JetBrains.

the class ExternalJavacProcess method compile.

private static JavacRemoteProto.Message compile(final ChannelHandlerContext context, final UUID sessionId, List<String> options, Collection<File> files, Collection<File> classpath, Collection<File> platformCp, Collection<File> modulePath, Collection<File> sourcePath, Map<File, Set<File>> outs, final CanceledStatus canceledStatus) {
    //final long compileStart = System.currentTimeMillis();
    //System.err.println("Compile start; since global start: " + (compileStart - myGlobalStart));
    final DiagnosticOutputConsumer diagnostic = new DiagnosticOutputConsumer() {

        @Override
        public void javaFileLoaded(File file) {
            context.channel().writeAndFlush(JavacProtoUtil.toMessage(sessionId, JavacProtoUtil.createSourceFileLoadedResponse(file)));
        }

        @Override
        public void outputLineAvailable(String line) {
            context.channel().writeAndFlush(JavacProtoUtil.toMessage(sessionId, JavacProtoUtil.createStdOutputResponse(line)));
        }

        @Override
        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
            final JavacRemoteProto.Message.Response response = JavacProtoUtil.createBuildMessageResponse(diagnostic);
            context.channel().writeAndFlush(JavacProtoUtil.toMessage(sessionId, response));
        }

        @Override
        public void registerImports(String className, Collection<String> imports, Collection<String> staticImports) {
            final JavacRemoteProto.Message.Response response = JavacProtoUtil.createClassDataResponse(className, imports, staticImports);
            context.channel().writeAndFlush(JavacProtoUtil.toMessage(sessionId, response));
        }

        @Override
        public void customOutputData(String pluginId, String dataName, byte[] data) {
            final JavacRemoteProto.Message.Response response = JavacProtoUtil.createCustomDataResponse(pluginId, dataName, data);
            context.channel().writeAndFlush(JavacProtoUtil.toMessage(sessionId, response));
        }
    };
    final OutputFileConsumer outputSink = new OutputFileConsumer() {

        @Override
        public void save(@NotNull OutputFileObject fileObject) {
            context.channel().writeAndFlush(JavacProtoUtil.toMessage(sessionId, JavacProtoUtil.createOutputObjectResponse(fileObject)));
        }
    };
    try {
        JavaCompilingTool tool = getCompilingTool();
        final boolean rc = JavacMain.compile(options, files, classpath, platformCp, modulePath, sourcePath, outs, diagnostic, outputSink, canceledStatus, tool);
        return JavacProtoUtil.toMessage(sessionId, JavacProtoUtil.createBuildCompletedResponse(rc));
    } catch (Throwable e) {
        //noinspection UseOfSystemOutOrSystemErr
        e.printStackTrace(System.err);
        return JavacProtoUtil.toMessage(sessionId, JavacProtoUtil.createFailure(e.getMessage(), e));
    }
//finally {
//  final long compileEnd = System.currentTimeMillis();
//  System.err.println("Compiled in " + (compileEnd - compileStart) + " ms; since global start: " + (compileEnd - myGlobalStart));
//}
}
Also used : JavaCompilingTool(org.jetbrains.jps.builders.java.JavaCompilingTool) Diagnostic(javax.tools.Diagnostic) NotNull(org.jetbrains.annotations.NotNull) JavaFileObject(javax.tools.JavaFileObject) File(java.io.File)

Aggregations

JavaCompilingTool (org.jetbrains.jps.builders.java.JavaCompilingTool)2 File (java.io.File)1 Diagnostic (javax.tools.Diagnostic)1 JavaFileObject (javax.tools.JavaFileObject)1 NotNull (org.jetbrains.annotations.NotNull)1