Class SonarUtils

java.lang.Object
org.sonarqube.gradle.SonarUtils

public class SonarUtils extends Object
  • Method Details

    • getMainClassPath

      @Nullable public static org.gradle.api.file.FileCollection getMainClassPath(org.gradle.api.Project project)
    • getTestClassPath

      @Nullable public static org.gradle.api.file.FileCollection getTestClassPath(org.gradle.api.Project project)
    • getClassPath

      @Nullable public static org.gradle.api.file.FileCollection getClassPath(org.gradle.api.Project project, String sourceSetName)
    • getClassPathFromSourceSets

      @Nullable public static org.gradle.api.file.FileCollection getClassPathFromSourceSets(String sourceSetName, @Nullable org.gradle.api.tasks.SourceSetContainer sourceSets)
    • nonEmptyOrNull

      @Nullable public static <T> List<T> nonEmptyOrNull(Collection<T> collection)
    • joinCsvStringsWithoutDuplicates

      public static String joinCsvStringsWithoutDuplicates(String csv1, String csv2)
    • joinAsCsv

      public static String joinAsCsv(List<String> values)
      Joins a list of strings that may contain commas by wrapping those strings in double quotes, like in CSV format.

      For example: values = { "/home/users/me/artifact-123,456.jar", "/opt/lib" } return is the string: "\"/home/users/me/artifact-123,456.jar\",/opt/lib"

      Parameters:
      values -
      Returns:
      a string having all the values separated by commas and each single value that contains a comma wrapped in double quotes
    • splitAsCsv

      public static List<String> splitAsCsv(String joined)
    • extractReportPaths

      public static Set<Path> extractReportPaths(Map<String,Object> properties)
      Returns the paths listed under the external or coverage report path parameters found in the properties.
      Parameters:
      properties - Properties to explore
      Returns:
      The set of paths that point to external reports
    • computeReportPaths

      public static Set<Path> computeReportPaths(Map<String,Object> properties)
      Computes the absolute paths for the report paths extracted from the properties.
      Returns:
      The set of absolute paths to external and coverage reports
      Throws:
      IllegalStateException - if the property "sonar.projectBaseDir" is not defined in the properties argument
    • findProjectFileType

      public static SonarUtils.InputFileType findProjectFileType(Path projectDir, Path filePath)
    • constructPrefixedProjectName

      public static String constructPrefixedProjectName(String projectPath)
      Produces a prefix for property keys that is appropriate and consumable by the scanner-engine