]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5389 Update APIs to ease migration of language plugins
authorJulien HENRY <julien.henry@sonarsource.com>
Mon, 15 Sep 2014 14:07:27 +0000 (16:07 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Wed, 17 Sep 2014 08:48:31 +0000 (10:48 +0200)
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/FileSystem.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java
sonar-plugin-api/src/main/java/org/sonar/api/component/ResourcePerspectives.java
sonar-plugin-api/src/main/java/org/sonar/api/resources/ProjectFileSystem.java

index fa79c8e682d9264441f2fce6ea35005eab93043c..2c9c2473194abf5be664e99604eba7222aff06b1 100644 (file)
@@ -26,6 +26,8 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.scan.filesystem.PathResolver;
 import org.sonar.api.utils.TempFolder;
 
+import javax.annotation.CheckForNull;
+
 import java.io.File;
 import java.util.List;
 
@@ -94,6 +96,7 @@ public class ModuleFileSystemInitializer implements BatchComponent {
     return workingDir;
   }
 
+  @CheckForNull
   File buildDir() {
     return buildDir;
   }
index 0c285f686e2b4075cc89021a5bd9e9de74f3e523..cd8bf7c1a36a3502a9afcd411eff01d6f6f794f9 100644 (file)
@@ -141,4 +141,12 @@ public interface FileSystem extends BatchComponent {
    * Languages detected in all files, whatever their type (main or test)
    */
   SortedSet<String> languages();
+
+  /**
+   * Utility method mainly used to resolve location of reports.
+   * @return file in canonical form from specified path. Path can be absolute or relative to project basedir.
+   *         For example resolvePath("pom.xml") or resolvePath("src/main/java")
+   * @since 5.0
+   */
+  File resolvePath(String path);
 }
index 55c5303cbaeea07cd9a6ef345f7b3d0c5289dcc6..0e67c3cf9acb53b68bf505978da614cf3bf3128c 100644 (file)
@@ -32,6 +32,7 @@ import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 
 import java.io.File;
+import java.io.IOException;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -281,4 +282,16 @@ public class DefaultFileSystem implements FileSystem {
     }
   }
 
+  @Override
+  public File resolvePath(String path) {
+    File file = new File(path);
+    if (!file.isAbsolute()) {
+      try {
+        file = new File(baseDir(), path).getCanonicalFile();
+      } catch (IOException e) {
+        throw new IllegalArgumentException("Unable to resolve path '" + path + "'", e);
+      }
+    }
+    return file;
+  }
 }
index d992b57100139abac09717a613f427d73f1d64ee..e3233de0a7f52cc47e30de9c9f1ea6cf55e65cf4 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.api.component;
 
+import org.sonar.api.batch.sensor.SensorContext;
 import org.sonar.api.resources.Resource;
 
 import javax.annotation.CheckForNull;
@@ -27,7 +28,9 @@ import javax.annotation.CheckForNull;
  * Only on batch-side.
  *
  * @since 3.5
+ * @deprecated since 5.0 everything you need is available in {@link SensorContext}
  */
+@Deprecated
 public interface ResourcePerspectives extends Perspectives {
 
   @CheckForNull
index 944b1278a6afedf5e7e75c59e8925e8e754e95e6..ea393f5805c211f9a4933a672232c8203fce0ed9 100644 (file)
@@ -20,6 +20,7 @@
 package org.sonar.api.resources;
 
 import org.sonar.api.BatchComponent;
+import org.sonar.api.batch.fs.FileSystem;
 
 import java.io.File;
 import java.io.IOException;
@@ -97,6 +98,7 @@ public interface ProjectFileSystem extends BatchComponent {
   /**
    * @return file in canonical form from specified path. Path can be absolute or relative to project basedir.
    *         For example resolvePath("pom.xml") or resolvePath("src/main/java")
+   * @deprecated since 5.0 use {@link FileSystem#resolvePath(String)}
    */
   File resolvePath(String path);