Example usage for org.eclipse.jdt.internal.compiler.impl CompilerOptions OPTION_GenerateClassFiles

List of usage examples for org.eclipse.jdt.internal.compiler.impl CompilerOptions OPTION_GenerateClassFiles

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.impl CompilerOptions OPTION_GenerateClassFiles.

Prototype

String OPTION_GenerateClassFiles

To view the source code for org.eclipse.jdt.internal.compiler.impl CompilerOptions OPTION_GenerateClassFiles.

Click Source Link

Usage

From source file:com.google.devtools.j2objc.AnnotationPreProcessor.java

License:Apache License

/**
 * Process the given input files, given in the same format as J2ObjC command line args.
 *///from   w  w w.j a v  a  2s.c  o m
void process(Iterable<String> fileArgs) {
    assert tmpDirectory == null; // Shouldn't run an instance more than once.

    if (!hasAnnotationProcessors()) {
        return;
    }

    try {
        tmpDirectory = FileUtil.createTempDir("annotations");
    } catch (IOException e) {
        ErrorUtil.error("failed creating temporary directory: " + e);
        return;
    }
    String tmpDirPath = tmpDirectory.getAbsolutePath();
    List<String> compileArgs = Lists.newArrayList();
    Joiner pathJoiner = Joiner.on(":");
    List<String> sourcePath = Options.getSourcePathEntries();
    sourcePath.add(tmpDirPath);
    compileArgs.add("-sourcepath");
    compileArgs.add(pathJoiner.join(sourcePath));
    compileArgs.add("-classpath");
    List<String> classPath = Options.getClassPathEntries();
    compileArgs.add(pathJoiner.join(classPath));
    compileArgs.add("-encoding");
    compileArgs.add(Options.getCharset().name());
    compileArgs.add("-source");
    compileArgs.add("1.7");
    compileArgs.add("-s");
    compileArgs.add(tmpDirPath);
    compileArgs.add("-d");
    compileArgs.add(tmpDirPath);
    if (Options.isVerbose()) {
        compileArgs.add("-XprintProcessorInfo");
        compileArgs.add("-XprintRounds");
    }
    for (String fileArg : fileArgs) {
        compileArgs.add(fileArg);
    }
    Map<String, String> batchOptions = Maps.newHashMap();
    batchOptions.put(CompilerOptions.OPTION_Process_Annotations, CompilerOptions.ENABLED);
    batchOptions.put(CompilerOptions.OPTION_GenerateClassFiles, CompilerOptions.DISABLED);
    // Fully qualified name used since "Main" isn't unique.
    org.eclipse.jdt.internal.compiler.batch.Main batchCompiler = new org.eclipse.jdt.internal.compiler.batch.Main(
            new PrintWriter(System.out), new PrintWriter(System.err), false, batchOptions, null);
    if (!batchCompiler.compile(compileArgs.toArray(new String[0]))) {
        // Any compilation errors will already by displayed.
        ErrorUtil.error("failed batch processing sources");
    } else {
        addGeneratedSources(tmpDirectory, "");
    }
}

From source file:com.google.devtools.j2objc.jdt.AnnotationPreProcessor.java

License:Apache License

/**
 * Process the given input files, given in the same format as J2ObjC command line args.
 *
 * @return the list of processor-generated sources
 */// www.ja v  a 2  s  .c om
public List<ProcessingContext> process(Iterable<String> fileArgs, List<ProcessingContext> inputs) {
    assert tmpDirectory == null; // Shouldn't run an instance more than once.

    if (!hasAnnotationProcessors()) {
        return generatedInputs;
    }

    try {
        tmpDirectory = FileUtil.createTempDir("annotations");
    } catch (IOException e) {
        ErrorUtil.error("failed creating temporary directory: " + e);
        return generatedInputs;
    }
    String tmpDirPath = tmpDirectory.getAbsolutePath();
    List<String> compileArgs = Lists.newArrayList();
    Joiner pathJoiner = Joiner.on(":");
    List<String> sourcePath = options.fileUtil().getSourcePathEntries();
    sourcePath.add(tmpDirPath);
    compileArgs.add("-sourcepath");
    compileArgs.add(pathJoiner.join(sourcePath));
    compileArgs.add("-classpath");
    List<String> classPath = options.fileUtil().getClassPathEntries();
    compileArgs.add(pathJoiner.join(classPath));
    compileArgs.add("-encoding");
    compileArgs.add(options.fileUtil().getCharset().name());
    compileArgs.add("-source");
    compileArgs.add(options.getSourceVersion().flag());
    compileArgs.add("-s");
    compileArgs.add(tmpDirPath);
    compileArgs.add("-d");
    compileArgs.add(tmpDirPath);
    List<String> processorPath = options.getProcessorPathEntries();
    if (!processorPath.isEmpty()) {
        compileArgs.add("-processorpath");
        compileArgs.add(pathJoiner.join(processorPath));
    }
    String processorClasses = options.getProcessors();
    if (processorClasses != null) {
        compileArgs.add("-processor");
        compileArgs.add(processorClasses);
    }
    if (options.isVerbose()) {
        compileArgs.add("-XprintProcessorInfo");
        compileArgs.add("-XprintRounds");
    }
    for (String fileArg : fileArgs) {
        compileArgs.add(fileArg);
    }
    Map<String, String> batchOptions = Maps.newHashMap();
    batchOptions.put(CompilerOptions.OPTION_Process_Annotations, CompilerOptions.ENABLED);
    batchOptions.put(CompilerOptions.OPTION_GenerateClassFiles, CompilerOptions.DISABLED);
    AnnotationCompiler batchCompiler = new AnnotationCompiler(compileArgs, batchOptions,
            new PrintWriter(System.out), new PrintWriter(System.err), inputs, options);
    if (!batchCompiler.compile(compileArgs.toArray(new String[0]))) {
        // Any compilation errors will already by displayed.
        ErrorUtil.error("failed batch processing sources");
    }
    if (!options.getHeaderMap().includeGeneratedSources() && tmpDirectory != null) {
        collectGeneratedInputs(tmpDirectory, "", inputs);
    }
    return generatedInputs;
}

From source file:com.google.devtools.j2objc.pipeline.AnnotationPreProcessor.java

License:Apache License

/**
 * Process the given input files, given in the same format as J2ObjC command line args.
 *///from  ww  w .ja va2 s . com
public void process(Iterable<String> fileArgs) {
    assert tmpDirectory == null; // Shouldn't run an instance more than once.

    if (!hasAnnotationProcessors()) {
        return;
    }

    try {
        tmpDirectory = FileUtil.createTempDir("annotations");
    } catch (IOException e) {
        ErrorUtil.error("failed creating temporary directory: " + e);
        return;
    }
    String tmpDirPath = tmpDirectory.getAbsolutePath();
    List<String> compileArgs = Lists.newArrayList();
    Joiner pathJoiner = Joiner.on(":");
    List<String> sourcePath = Options.getSourcePathEntries();
    sourcePath.add(tmpDirPath);
    compileArgs.add("-sourcepath");
    compileArgs.add(pathJoiner.join(sourcePath));
    compileArgs.add("-classpath");
    List<String> classPath = Options.getClassPathEntries();
    compileArgs.add(pathJoiner.join(classPath));
    compileArgs.add("-encoding");
    compileArgs.add(Options.getCharset().name());
    compileArgs.add("-source");
    compileArgs.add(Options.getSourceVersion());
    compileArgs.add("-s");
    compileArgs.add(tmpDirPath);
    compileArgs.add("-d");
    compileArgs.add(tmpDirPath);
    List<String> processorPath = Options.getProcessorPathEntries();
    if (!processorPath.isEmpty()) {
        compileArgs.add("-processorpath");
        compileArgs.add(pathJoiner.join(processorPath));
    }
    String processorClasses = Options.getProcessors();
    if (processorClasses != null) {
        compileArgs.add("-processor");
        compileArgs.add(processorClasses);
    }
    if (Options.isVerbose()) {
        compileArgs.add("-XprintProcessorInfo");
        compileArgs.add("-XprintRounds");
    }
    for (String fileArg : fileArgs) {
        compileArgs.add(fileArg);
    }
    Map<String, String> batchOptions = Maps.newHashMap();
    batchOptions.put(CompilerOptions.OPTION_Process_Annotations, CompilerOptions.ENABLED);
    batchOptions.put(CompilerOptions.OPTION_GenerateClassFiles, CompilerOptions.DISABLED);
    // Fully qualified name used since "Main" isn't unique.
    org.eclipse.jdt.internal.compiler.batch.Main batchCompiler = new org.eclipse.jdt.internal.compiler.batch.Main(
            new PrintWriter(System.out), new PrintWriter(System.err), false, batchOptions, null);
    if (!batchCompiler.compile(compileArgs.toArray(new String[0]))) {
        // Any compilation errors will already by displayed.
        ErrorUtil.error("failed batch processing sources");
    }
}

From source file:org.eclipse.che.jdt.JavaProjectService.java

License:Open Source License

@Inject
public JavaProjectService(EventService eventService, LocalFSMountStrategy fsMountStrategy,
        @Named("che.java.codeassistant.index.dir") String temp) {
    eventService.subscribe(new VirtualFileEventSubscriber());
    this.fsMountStrategy = fsMountStrategy;
    tempDir = temp;// w w w .java2s  .  com
    options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7);
    options.put(JavaCore.CORE_ENCODING, "UTF-8");
    options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7);
    options.put(CompilerOptions.OPTION_TargetPlatform, JavaCore.VERSION_1_7);
    options.put(AssistOptions.OPTION_PerformVisibilityCheck, AssistOptions.ENABLED);
    options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
    options.put(CompilerOptions.OPTION_TaskTags, CompilerOptions.WARNING);
    options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.WARNING);
    options.put(CompilerOptions.OPTION_SuppressWarnings, CompilerOptions.DISABLED);
    options.put(JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX");
    options.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE, JavaCore.ENABLED);
    options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED);
    options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
    options.put(CompilerOptions.OPTION_Process_Annotations, JavaCore.ENABLED);
    options.put(CompilerOptions.OPTION_GenerateClassFiles, JavaCore.ENABLED);
    cache = CacheBuilder.newBuilder().expireAfterAccess(4, TimeUnit.HOURS)
            .removalListener(new RemovalListener<String, JavaProject>() {
                @Override
                public void onRemoval(RemovalNotification<String, JavaProject> notification) {
                    JavaProject value = notification.getValue();
                    if (value != null) {
                        closeProject(value);
                        deleteDependencyDirectory(value.getWsId(), value.getProjectPath());
                    }
                }
            }).build();
}