private static JavaFileObject filterJavaFileObject ( JavaFileObject fobj ) { String path = fobj . getName ( ) ; if ( path . endsWith ( "module-info.java" ) ) { String pkgName = null ; try { pkgName = moduleName ( fobj . getCharContent ( true ) . toString ( ) ) ; String source = "package " + pkgName + ";" ; return new MemoryFileObject ( path , JavaFileObject . Kind . SOURCE , source ) ; } catch ( IOException e ) { // Fall-through } } return fobj ; }
To allow Java 9 libraries like GSON to be transpiled using - source 1 . 8 stub out the module - info source . This creates an empty . o file like package - info . java files without annotations . Skipping the file isn t feasible because of build tool output file expectations .