Class MavenUtils

java.lang.Object
org.sonarsource.scanner.maven.bootstrap.MavenUtils

public final class MavenUtils extends Object
An utility class to manipulate Maven concepts
Since:
1.10
  • Field Details

  • Method Details

    • getSourceEncoding

      @CheckForNull public static String getSourceEncoding(org.apache.maven.project.MavenProject pom)
      Parameters:
      pom - the project pom
      Returns:
      source encoding
    • getPluginSetting

      public static String getPluginSetting(org.apache.maven.project.MavenProject project, String groupId, String artifactId, String optionName, @Nullable String defaultValue)
      Search for a configuration setting of an other plugin for a configuration setting.
      Parameters:
      project - the current maven project to get the configuration from.
      groupId - the group id of the plugin to search for
      artifactId - the artifact id of the plugin to search for
      optionName - the option to get from the configuration
      defaultValue - the default value if the configuration was not found
      Returns:
      the value of the option configured in the plugin configuration
    • coalesce

      @SafeVarargs public static <T> T coalesce(T... objs)
      Returns first non null object or null if all objects are null
      Parameters:
      objs -
      Returns:
      First null argument, or null if they are all null
    • 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)