List of usage examples for java.nio.file Path toAbsolutePath
Path toAbsolutePath();
From source file:org.sonarsource.scanner.cli.ConfTest.java
@Test public void shouldLoadModuleConfigurationOverrideBasedir() throws Exception { Path projectHome = Paths.get( getClass().getResource("ConfTest/shouldLoadModuleConfigurationOverrideBasedir/project").toURI()); args.setProperty("project.home", projectHome.toAbsolutePath().toString()); Properties properties = conf.properties(); assertThat(properties.getProperty("module1.sonar.projectName")).isEqualTo("Module 1"); assertThat(properties.getProperty("module2.sonar.projectName")).isEqualTo("Module 2"); assertThat(properties.getProperty("module3.sonar.projectName")).isEqualTo("Module 3"); assertThat(properties.getProperty("sonar.projectBaseDir")).isEqualTo(projectHome.toString()); }
From source file:org.sonarsource.scanner.cli.ConfTest.java
@Test public void shouldNotUseCurrentDir() throws Exception { Path projectHome = Paths.get( getClass().getResource("ConfTest/shouldLoadModuleConfigurationOverrideBasedir/project").toURI()); args.setProperty("project.home", projectHome.toAbsolutePath().toString()); Properties properties = conf.properties(); assertThat(properties.getProperty("module1.sonar.projectName")).isEqualTo("Module 1"); assertThat(properties.getProperty("module2.sonar.projectName")).isEqualTo("Module 2"); assertThat(properties.getProperty("module3.sonar.projectName")).isEqualTo("Module 3"); assertThat(properties.getProperty("sonar.projectBaseDir")).isEqualTo(projectHome.toString()); }
From source file:org.sonarsource.scanner.cli.ConfTest.java
@Test public void shouldLoadModuleConfigurationWithoutRootConf() throws Exception { Path projectHome = Paths.get( getClass().getResource("ConfTest/shouldLoadModuleConfigurationWithoutRootConf/project").toURI()); args.setProperty("project.home", projectHome.toAbsolutePath().toString()); args.put("sonar.modules", "module1,module2"); Properties properties = conf.properties(); assertThat(properties.getProperty("module1.sonar.projectName")).isEqualTo("Module 1"); assertThat(properties.getProperty("module2.sonar.projectName")).isEqualTo("Module 2"); assertThat(properties.getProperty("sonar.projectBaseDir")).isEqualTo(projectHome.toString()); }
From source file:org.sonarsource.scanner.cli.ConfTest.java
@Test public void should_load_conf_by_direct_path() throws Exception { Path settings = Paths.get(getClass() .getResource("ConfTest/shouldLoadRunnerSettingsByDirectPath/other-conf.properties").toURI()); args.setProperty("scanner.settings", settings.toAbsolutePath().toString()); assertThat(conf.properties().get("sonar.prop")).isEqualTo("otherValue"); }
From source file:org.sonarsource.scanner.cli.ConfTest.java
@Test public void shouldUseCliToDiscoverModules() throws Exception { Path projectHome = Paths.get( getClass().getResource("ConfTest/shouldLoadModuleConfigurationOverrideBasedir/project").toURI()); args.setProperty("project.home", projectHome.toAbsolutePath().toString()); args.setProperty("sonar.modules", "module1"); args.setProperty("module1.sonar.projectBaseDir", "module_3"); Properties properties = conf.properties(); assertThat(properties.getProperty("module1.sonar.projectName")).isEqualTo("Module 3"); assertThat(properties.getProperty("module2.sonar.projectName")).isNull(); assertThat(properties.getProperty("module3.sonar.projectName")).isNull(); assertThat(properties.getProperty("sonar.projectBaseDir")).isEqualTo(projectHome.toString()); }
From source file:org.sonarsource.scanner.cli.ConfTest.java
@Test public void shouldSupportDeepModuleConfigurationInRoot() throws Exception { Path projectHome = Paths .get(getClass().getResource("ConfTest/shouldSupportDeepModuleConfigurationInRoot/project").toURI()); args.setProperty("project.home", projectHome.toAbsolutePath().toString()); Properties properties = conf.properties(); assertThat(properties.getProperty("1.sonar.projectName")).isEqualTo("Module 1"); assertThat(properties.getProperty("1.11.sonar.projectName")).isEqualTo("Module 11"); assertThat(properties.getProperty("1.11.111.sonar.projectName")).isEqualTo("Module 111"); assertThat(properties.getProperty("1.12.sonar.projectName")).isEqualTo("Module 12"); assertThat(properties.getProperty("2.sonar.projectName")).isEqualTo("Module 2"); // SONARUNNER-125 assertThat(properties.getProperty("11.111.sonar.projectName")).isNull(); assertThat(properties.getProperty("sonar.projectBaseDir")).isEqualTo(projectHome.toString()); }
From source file:org.sonarsource.scanner.cli.ConfTest.java
@Test public void shouldCliOverrideSettingFiles() throws Exception { Path projectHome = Paths.get( getClass().getResource("ConfTest/shouldLoadModuleConfigurationOverrideBasedir/project").toURI()); args.setProperty("project.home", projectHome.toAbsolutePath().toString()); args.setProperty("module1.sonar.projectName", "mod1"); args.setProperty("module2.sonar.projectName", "mod2"); args.setProperty("module3.sonar.projectName", "mod3"); Properties properties = conf.properties(); assertThat(properties.getProperty("module1.sonar.projectName")).isEqualTo("mod1"); assertThat(properties.getProperty("module2.sonar.projectName")).isEqualTo("mod2"); assertThat(properties.getProperty("module3.sonar.projectName")).isEqualTo("mod3"); assertThat(properties.getProperty("sonar.projectBaseDir")).isEqualTo(projectHome.toString()); }
From source file:business.services.FileService.java
@PostConstruct public void init() throws IOException { Path path = fileSystem.getPath(uploadPath).normalize(); if (!path.toFile().exists()) { Files.createDirectory(path); }// w w w . j av a2 s. c om log.info("File upload path: " + path.toAbsolutePath()); }
From source file:org.sonarsource.scanner.cli.ConfTest.java
@Test public void shouldNotResolveSymlinks() throws IOException, URISyntaxException { assumeTrue(SystemUtils.IS_OS_UNIX);/*from w w w .j av a 2 s.c o m*/ Path root = temp.getRoot().toPath(); Path realProjectHome = Paths .get(getClass().getResource("ConfTest/shouldLoadModuleConfiguration/project").toURI()); Path linkProjectHome = root.resolve("link"); try { Files.createSymbolicLink(linkProjectHome, realProjectHome); args.setProperty("project.home", linkProjectHome.toAbsolutePath().toString()); Properties properties = conf.properties(); assertThat(properties.getProperty("module1.sonar.projectName")).isEqualTo("Module 1"); assertThat(properties.getProperty("module2.sonar.projectName")).isEqualTo("Module 2"); assertThat(properties.getProperty("sonar.projectBaseDir")).isEqualTo(linkProjectHome.toString()); assertThat(properties.getProperty("module1.sonar.projectBaseDir")) .isEqualTo(linkProjectHome.resolve("module1").toString()); assertThat(properties.getProperty("module2.sonar.projectBaseDir")) .isEqualTo(linkProjectHome.resolve("module2").toString()); } finally { if (linkProjectHome != null) { Files.delete(linkProjectHome); } } }
From source file:org.craftercms.studio.impl.v1.deployment.EnvironmentStoreGitBranchDeployer.java
private void applyPatch(Repository envStoreRepo, String site) { String tempPath = System.getProperty("java.io.tmpdir"); if (tempPath == null) { tempPath = "temp"; }/*from ww w . j a v a 2 s . co m*/ Path patchPath = Paths.get(tempPath, "patch" + site + ".bin"); Process p; try { ProcessBuilder pb = new ProcessBuilder(); pb.command("git", "apply", patchPath.toAbsolutePath().normalize().toString()); pb.directory(envStoreRepo.getDirectory().getParentFile()); p = pb.start(); p.waitFor(); } catch (Exception e) { logger.error("Error applying patch for site: " + site, e); } }