@Override public javax.tools.FileObject getFileForOutput(Location l, String pkgName, String relativeName, javax.tools.FileObject sibling) throws IOException, UnsupportedOperationException, IllegalArgumentException { if (StandardLocation.SOURCE_OUTPUT != l) { throw new UnsupportedOperationException("Only apt output is supported."); // NOI18N } final FileObject aptRoot = getAptRoot(sibling); if (aptRoot == null) { throw new UnsupportedOperationException(noAptRootDebug(sibling)); } final String nameStr = pkgName.length() == 0 ? relativeName : pkgName.replace('.', File.separatorChar) + File.separatorChar + relativeName; //NOI18N //Always on master fs -> file is save. File rootFile = FileUtil.toFile(aptRoot); return fileTx.createFileObject(l, new File(rootFile,nameStr), rootFile, null, null); }
private String noAptRootDebug(final javax.tools.FileObject sibling) { final StringBuilder sb = new StringBuilder("No apt root for source root: "); //NOI18N sb.append(getOwnerRoot(sibling)); sb.append(" sibling: "); //NOI18N if (siblings.hasSibling()) { sb.append(siblings.getSibling()); } else if (sibling != null) { sb.append(sibling.toUri()); } else { sb.append("none"); //NOI18N } return sb.toString(); }
private URL getOwnerRoot (final javax.tools.FileObject sibling) { try { return siblings.hasSibling() ? getOwnerRootSib(siblings.getSibling()) : (sibling == null ? getOwnerRootNoSib() : getOwnerRootSib(sibling.toUri().toURL())); } catch (MalformedURLException ex) { Exceptions.printStackTrace(ex); return null; } }
: new SourceFileManager (this.cachedSrcClassPath, ignoreExcludes)) : null, cachedAptSrcClassPath != null ? new AptSourceFileManager( this.cachedSrcClassPath, this.cachedAptSrcClassPath,
@Override public JavaFileObject getJavaFileForOutput (Location l, String className, JavaFileObject.Kind kind, javax.tools.FileObject sibling) throws IOException, UnsupportedOperationException, IllegalArgumentException { if (StandardLocation.SOURCE_OUTPUT != l) { throw new UnsupportedOperationException("Only apt output is supported."); // NOI18N } final FileObject aptRoot = getAptRoot(sibling); if (aptRoot == null) { throw new UnsupportedOperationException(noAptRootDebug(sibling)); } final String nameStr = className.replace('.', File.separatorChar) + kind.extension; //NOI18N //Always on master fs -> file is save. File rootFile = FileUtil.toFile(aptRoot); final JavaFileObject result = fileTx.createFileObject(l, new File(rootFile,nameStr), rootFile, null, null); return result; }
private FileObject getAptRoot (final javax.tools.FileObject sibling) { final URL ownerRoot = getOwnerRoot (sibling); if (ownerRoot == null) { return null; } final URL aptRoot = AptCacheForSourceQuery.getAptFolder(ownerRoot); return aptRoot == null ? null : URLMapper.findFileObject(aptRoot); }