hightide-devassist/src/test/java/io/hightide/devassist/AbstractAnnotationProcessorTest.java
/**
     * Attempts to compile the given compilation units using the Java Compiler API.
     * <p>
     * The compilation units and all their dependencies are expected to be on the classpath.
     *
     * @param compilationUnitPaths
     *            the paths of the source files to compile, as would be expected
     *            by {@link ClassLoader#getResource(String)}
     * @return the {@link Diagnostic diagnostics} returned by the compilation,
     *         as demonstrated in the documentation for {@link JavaCompiler}
     * @see #compileTestCase(Class...)
     *
     */
Attempts to compile the given compilation units using the Java Compiler API.

The compilation units and all their dependencies are expected to be on the classpath.

@param compilationUnitPaths
the paths of the source files to compile, as would be expected
by  ClassLoader#getResource(String)
@return the  Diagnostic diagnostics returned by the compilation,
as demonstrated in the documentation for  JavaCompiler
@see #compileTestCase(Class...)
Attempts to compile the given compilation units using the Java Compiler API . The compilation units and all their dependencies are expected to be on the classpath . @param compilationUnitPaths the paths of the source files to compile as would be expected by ClassLoader#getResource ( String ) @return the Diagnostic diagnostics returned by the compilation as demonstrated in the documentation for JavaCompiler @see #compileTestCase ( Class ... )
protected List<Diagnostic<? extends JavaFileObject>> compileTestCase(
            String... compilationUnitPaths) {
        assert (compilationUnitPaths != null);
        DiagnosticCollector<JavaFileObject> diagnosticCollector =
            new DiagnosticCollector<>();
        StandardJavaFileManager fileManager =
            COMPILER.getStandardFileManager(diagnosticCollector, null, null);
        /*
         * Call the compiler with the "-proc:only" option. The "class names"
         * option (which could, in principle, be used instead of compilation
         * units for annotation processing) isn't useful in this case because
         * only annotations on the classes being compiled are accessible.
         *
         * Information about the classes being compiled (such as what they are annotated
         * with) is *not* available via the RoundEnvironment. However, if these classes
         * are annotations, they certainly need to be validated.
         */
        CompilationTask task = COMPILER.getTask(null, fileManager, diagnosticCollector,
                Arrays.asList("-proc:only"), null,
                fileManager.getJavaFileObjects(compilationUnitPaths));
        task.setProcessors(getProcessors());
        task.call();
        try {
            fileManager.close();
        } catch (IOException exception) {}
        return diagnosticCollector.getDiagnostics();
    }
protected List < Diagnostic < ? extends JavaFileObject > > compileTestCase ( String ... compilationUnitPaths ) { assert ( compilationUnitPaths != null ) ; DiagnosticCollector < JavaFileObject > diagnosticCollector = new DiagnosticCollector < > ( ) ; StandardJavaFileManager fileManager = COMPILER . getStandardFileManager ( diagnosticCollector , null , null ) ; /*
         * Call the compiler with the "-proc:only" option. The "class names"
         * option (which could, in principle, be used instead of compilation
         * units for annotation processing) isn't useful in this case because
         * only annotations on the classes being compiled are accessible.
         *
         * Information about the classes being compiled (such as what they are annotated
         * with) is *not* available via the RoundEnvironment. However, if these classes
         * are annotations, they certainly need to be validated.
         */ CompilationTask task = COMPILER . getTask ( null , fileManager , diagnosticCollector , Arrays . asList ( "-proc:only" ) , null , fileManager . getJavaFileObjects ( compilationUnitPaths ) ) ; task . setProcessors ( getProcessors ( ) ) ; task . call ( ) ; try { fileManager . close ( ) ; } catch ( IOException exception ) { } return diagnosticCollector . getDiagnostics ( ) ; }
Attempts to compile the given compilation units using the Java Compiler API.
Attempts to compile the given compilation units using the Java Compiler API .