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;
return workingDir;
}
+ @CheckForNull
File buildDir() {
return buildDir;
}
* 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);
}
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;
}
}
+ @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;
+ }
}
*/
package org.sonar.api.component;
+import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.resources.Resource;
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
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;
/**
* @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);