Search in sources :

Example 1 with AnnotationProcessingOptions

use of spoon.compiler.builder.AnnotationProcessingOptions in project spoon by INRIA.

the class JDTBasedSpoonCompiler method compile.

@Override
public boolean compile(InputType... types) {
    factory.getEnvironment().debugMessage("compiling sources: " + factory.CompilationUnit().getMap().keySet());
    long t = System.currentTimeMillis();
    javaCompliance = factory.getEnvironment().getComplianceLevel();
    JDTBatchCompiler batchCompiler = createBatchCompiler(types);
    final String[] args = // 
    new JDTBuilderImpl().classpathOptions(// 
    new ClasspathOptions().encoding(this.getEnvironment().getEncoding().displayName()).classpath(getSourceClasspath()).binaries(getBinaryOutputDirectory())).complianceOptions(// 
    new ComplianceOptions().compliance(javaCompliance)).annotationProcessingOptions(// 
    new AnnotationProcessingOptions().compileProcessors()).advancedOptions(// 
    new AdvancedOptions().preserveUnusedVars().continueExecution().enableJavadoc()).sources(// no sources, handled by the JDTBatchCompiler
    new SourceOptions().sources(sources.getAllJavaFiles())).build();
    getFactory().getEnvironment().debugMessage("compile args: " + Arrays.toString(args));
    System.setProperty("jdt.compiler.useSingleThread", "true");
    batchCompiler.compile(args);
    reportProblems(factory.getEnvironment());
    factory.getEnvironment().debugMessage("compiled in " + (System.currentTimeMillis() - t) + " ms");
    return probs.size() == 0;
}
Also used : AdvancedOptions(spoon.compiler.builder.AdvancedOptions) AnnotationProcessingOptions(spoon.compiler.builder.AnnotationProcessingOptions) SourceOptions(spoon.compiler.builder.SourceOptions) JDTBuilderImpl(spoon.compiler.builder.JDTBuilderImpl) ComplianceOptions(spoon.compiler.builder.ComplianceOptions) ClasspathOptions(spoon.compiler.builder.ClasspathOptions)

Example 2 with AnnotationProcessingOptions

use of spoon.compiler.builder.AnnotationProcessingOptions in project spoon by INRIA.

the class JDTBuilderTest method testJdtBuilder.

@Test
public void testJdtBuilder() throws Exception {
    final String[] builder = // 
    new JDTBuilderImpl().classpathOptions(// 
    new ClasspathOptions().classpath(TEST_CLASSPATH).bootclasspath(TEST_CLASSPATH).binaries(".").encoding("UTF-8")).complianceOptions(// 
    new ComplianceOptions().compliance(8)).annotationProcessingOptions(// 
    new AnnotationProcessingOptions().compileProcessors()).advancedOptions(// 
    new AdvancedOptions().continueExecution().enableJavadoc().preserveUnusedVars()).sources(// 
    new SourceOptions().sources(".")).build();
    assertEquals("-cp", builder[0]);
    assertEquals(TEST_CLASSPATH, builder[1]);
    assertEquals("-bootclasspath", builder[2]);
    assertEquals(TEST_CLASSPATH, builder[3]);
    assertEquals("-d", builder[4]);
    assertEquals(new File(".").getAbsolutePath(), builder[5]);
    assertEquals("-encoding", builder[6]);
    assertEquals("UTF-8", builder[7]);
    assertEquals("-1.8", builder[8]);
    assertEquals("-proc:none", builder[9]);
    assertEquals("-noExit", builder[10]);
    assertEquals("-enableJavadoc", builder[11]);
    assertEquals("-preserveAllLocals", builder[12]);
    assertEquals(".", builder[13]);
}
Also used : AdvancedOptions(spoon.compiler.builder.AdvancedOptions) AnnotationProcessingOptions(spoon.compiler.builder.AnnotationProcessingOptions) SourceOptions(spoon.compiler.builder.SourceOptions) JDTBuilderImpl(spoon.compiler.builder.JDTBuilderImpl) ComplianceOptions(spoon.compiler.builder.ComplianceOptions) File(java.io.File) ClasspathOptions(spoon.compiler.builder.ClasspathOptions) Test(org.junit.Test)

Aggregations

AdvancedOptions (spoon.compiler.builder.AdvancedOptions)2 AnnotationProcessingOptions (spoon.compiler.builder.AnnotationProcessingOptions)2 ClasspathOptions (spoon.compiler.builder.ClasspathOptions)2 ComplianceOptions (spoon.compiler.builder.ComplianceOptions)2 JDTBuilderImpl (spoon.compiler.builder.JDTBuilderImpl)2 SourceOptions (spoon.compiler.builder.SourceOptions)2 File (java.io.File)1 Test (org.junit.Test)1