org.sonar.api.resources
Class ProjectUtils

java.lang.Object
  extended by org.sonar.api.resources.ProjectUtils

public final class ProjectUtils
extends java.lang.Object


Method Summary
static java.io.File getFileFromBuildDirectory(Project project, java.lang.String filename)
           
static java.lang.String getJavaVersion(Project project)
           
static java.lang.String getRelativePath(java.io.File file, java.io.File dir)
          getRelativePath("c:/foo/src/my/package/Hello.java", "c:/foo/src") is "my/package/Hello.java"
static java.lang.String getRelativePath(java.io.File file, java.util.List<java.io.File> dirs)
          getRelativePath("c:/foo/src/my/package/Hello.java", ["c:/bar", "c:/foo/src"]) is "my/package/Hello.java".
static boolean hasJavaSources(Project project)
          Does the project have at least one java source file ? It does not check test files.
static boolean isDynamicAnalysis(Project project, boolean includeReuseReportMode)
           
protected static java.io.File writeToFile(java.lang.String content, java.io.File dir, java.lang.String fileName)
           
static java.io.File writeToWorkingDirectory(Project project, java.lang.String content, java.lang.String fileName)
          Save data into a new file of Sonar working directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

hasJavaSources

public static boolean hasJavaSources(Project project)
Does the project have at least one java source file ? It does not check test files.


isDynamicAnalysis

public static boolean isDynamicAnalysis(Project project,
                                        boolean includeReuseReportMode)

getJavaVersion

public static java.lang.String getJavaVersion(Project project)

writeToWorkingDirectory

public static java.io.File writeToWorkingDirectory(Project project,
                                                   java.lang.String content,
                                                   java.lang.String fileName)
                                            throws java.io.IOException
Save data into a new file of Sonar working directory.

Returns:
the created file
Throws:
java.io.IOException

writeToFile

protected static java.io.File writeToFile(java.lang.String content,
                                          java.io.File dir,
                                          java.lang.String fileName)
                                   throws java.io.IOException
Throws:
java.io.IOException

getRelativePath

public static java.lang.String getRelativePath(java.io.File file,
                                               java.io.File dir)
getRelativePath("c:/foo/src/my/package/Hello.java", "c:/foo/src") is "my/package/Hello.java"

Returns:
null if file is not in dir (including recursive subdirectories)

getRelativePath

public static java.lang.String getRelativePath(java.io.File file,
                                               java.util.List<java.io.File> dirs)
getRelativePath("c:/foo/src/my/package/Hello.java", ["c:/bar", "c:/foo/src"]) is "my/package/Hello.java".

Relative path is composed of slashes. Windows backslaches are replaced by /

Returns:
null if file is not in dir (including recursive subdirectories)

getFileFromBuildDirectory

public static java.io.File getFileFromBuildDirectory(Project project,
                                                     java.lang.String filename)


Copyright © 2009 SonarSource SA. All Rights Reserved.