Search in sources :

Example 96 with FileObject

use of javax.tools.FileObject in project mapstruct by mapstruct.

the class MapperServiceProcessor method createSourceFile.

private void createSourceFile(ServicesEntry model, ModelWriter modelWriter, Filer filer) {
    String fileName = model.getPackageName() + "." + model.getName();
    FileObject sourceFile;
    try {
        sourceFile = filer.createResource(StandardLocation.CLASS_OUTPUT, "", "META-INF/services/" + fileName);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    modelWriter.writeModel(sourceFile, model);
}
Also used : FileObject(javax.tools.FileObject) IOException(java.io.IOException)

Example 97 with FileObject

use of javax.tools.FileObject in project fabric8 by jboss-fuse.

the class AbstractKubernetesAnnotationProcessor method generateYaml.

void generateYaml(String fileName, KubernetesResource resource) {
    try {
        FileObject fileObject = getFileObject(fileName);
        KubernetesHelper.saveYaml(resource, fileObject);
    } catch (IOException e) {
        processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Error generating json " + fileName);
    }
}
Also used : FileObject(javax.tools.FileObject) IOException(java.io.IOException)

Example 98 with FileObject

use of javax.tools.FileObject in project copybara by google.

the class AnnotationProcessor method writeClassList.

private void writeClassList(SetMultimap<Class<? extends Annotation>, Element> elementsByAnnotation) throws IOException {
    List<String> classNames = Streams.concat(elementsByAnnotation.get(Library.class).stream(), elementsByAnnotation.get(StarlarkBuiltin.class).stream()).map(AnnotationProcessor::className).collect(toImmutableList());
    FileObject res = processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT, "", "starlark_class_list.txt");
    try (Writer writer = res.openWriter()) {
        writer.append(Joiner.on("\n").join(classNames)).append("\n");
    }
}
Also used : FileObject(javax.tools.FileObject) Writer(java.io.Writer)

Aggregations

FileObject (javax.tools.FileObject)98 IOException (java.io.IOException)61 File (java.io.File)21 TypeElement (javax.lang.model.element.TypeElement)19 PrintWriter (java.io.PrintWriter)17 Writer (java.io.Writer)16 Filer (javax.annotation.processing.Filer)14 Element (javax.lang.model.element.Element)14 BufferedWriter (java.io.BufferedWriter)12 ArrayList (java.util.ArrayList)12 OutputStream (java.io.OutputStream)11 JavaFileObject (javax.tools.JavaFileObject)11 OutputStreamWriter (java.io.OutputStreamWriter)10 URI (java.net.URI)10 Properties (java.util.Properties)10 InputStream (java.io.InputStream)8 FileWriter (java.io.FileWriter)7 FilerException (javax.annotation.processing.FilerException)7 MainInfo (com.predic8.membrane.annot.model.MainInfo)6 BufferedReader (java.io.BufferedReader)6