use of java.nio.file.FileSystem in project wire by square.
the class WireCompilerTest method invokeCompiler.
private void invokeCompiler(String[] sources, String... extraArgs) throws Exception {
List<String> args = new ArrayList<>();
args.add("--proto_path=../wire-runtime/src/test/proto");
args.add("--java_out=" + testDir.getAbsolutePath());
Collections.addAll(args, extraArgs);
Collections.addAll(args, sources);
logger = new StringWireLogger();
FileSystem fs = FileSystems.getDefault();
WireCompiler compiler = WireCompiler.forArgs(fs, logger, args.toArray(new String[args.size()]));
compiler.compile();
}
use of java.nio.file.FileSystem in project bazel by bazelbuild.
the class AndroidDataDeserializer method read.
/**
* Reads the serialized {@link DataKey} and {@link DataValue} to the {@link KeyValueConsumers}.
*
* @param inPath The path to the serialized protocol buffer.
* @param consumers The {@link KeyValueConsumers} for the entries {@link DataKey} ->
* {@link DataValue}.
* @throws DeserializationException Raised for an IOException or when the inPath is not a valid
* proto buffer.
*/
public void read(Path inPath, KeyValueConsumers consumers) {
Stopwatch timer = Stopwatch.createStarted();
try (InputStream in = Files.newInputStream(inPath, StandardOpenOption.READ)) {
FileSystem currentFileSystem = inPath.getFileSystem();
Header header = Header.parseDelimitedFrom(in);
if (header == null) {
throw new DeserializationException("No Header found in " + inPath);
}
readEntriesSegment(consumers, in, currentFileSystem, header);
} catch (IOException e) {
throw new DeserializationException(e);
} finally {
logger.fine(String.format("Deserialized in merged in %sms", timer.elapsed(TimeUnit.MILLISECONDS)));
}
}
use of java.nio.file.FileSystem in project error-prone by google.
the class ErrorProneJavacPluginTest method hello.
@Test
public void hello() throws IOException {
FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix());
Path source = fileSystem.getPath("Test.java");
Files.write(source, ImmutableList.of("import java.util.HashSet;", "import java.util.Set;", "class Test {", " public static void main(String[] args) {", " Set<Short> s = new HashSet<>();", " for (short i = 0; i < 100; i++) {", " s.add(i);", " s.remove(i - 1);", " }", " System.out.println(s.size());", " }", "}"), UTF_8);
JavacFileManager fileManager = new JavacFileManager(new Context(), false, UTF_8);
DiagnosticCollector<JavaFileObject> diagnosticCollector = new DiagnosticCollector<>();
JavacTask task = JavacTool.create().getTask(null, fileManager, diagnosticCollector, ImmutableList.of("-Xplugin:ErrorProne"), ImmutableList.of(), fileManager.getJavaFileObjects(source));
assertThat(task.call()).isFalse();
Diagnostic<? extends JavaFileObject> diagnostic = diagnosticCollector.getDiagnostics().stream().filter(d -> d.getKind() == Diagnostic.Kind.ERROR).collect(onlyElement());
assertThat(diagnostic.getMessage(ENGLISH)).contains("[CollectionIncompatibleType]");
}
use of java.nio.file.FileSystem in project buck by facebook.
the class AppleSdkDiscoveryTest method shouldScanRealDirectoryOnlyOnce.
@Test
public void shouldScanRealDirectoryOnlyOnce() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "sdk-discovery-symlink", temp);
workspace.setUp();
Path root = workspace.getPath("");
FileSystem fileSystem = root.getFileSystem();
Path actualSdkPath = root.resolve("MacOSX10.9.sdk");
Path sdksDir = root.resolve("Platforms/MacOSX.platform/Developer/SDKs");
Files.createDirectories(sdksDir);
// create relative symlink
Files.createSymbolicLink(sdksDir.resolve("MacOSX10.9.sdk"), fileSystem.getPath("MacOSX.sdk"));
// create absolute symlink
Files.createSymbolicLink(sdksDir.resolve("MacOSX.sdk"), actualSdkPath);
ImmutableMap<String, AppleToolchain> toolchains = ImmutableMap.of("com.apple.dt.toolchain.XcodeDefault", getDefaultToolchain(root));
ImmutableMap<AppleSdk, AppleSdkPaths> actual = AppleSdkDiscovery.discoverAppleSdkPaths(Optional.of(root), ImmutableList.of(root), toolchains, new FakeAppleConfig());
// if both symlinks were to be visited, exception would have been thrown during discovery
assertThat(actual.size(), is(2));
}
use of java.nio.file.FileSystem in project cryptomator by cryptomator.
the class Vault method unlock.
public synchronized void unlock(CharSequence passphrase) {
try {
FileSystem fs = getCryptoFileSystem(passphrase);
if (!server.isRunning()) {
server.start();
}
servlet = server.createWebDavServlet(fs.getPath("/"), vaultSettings.getId() + "/" + vaultSettings.mountName().get());
servlet.start();
Platform.runLater(() -> {
unlocked.set(true);
});
} catch (IOException e) {
LOG.error("Unable to provide filesystem", e);
}
}
Aggregations