Class BuildHelper


  • public class BuildHelper
    extends java.lang.Object
    Helper to detect info about build info in a MavenProject, as configured in plugins.
    Since:
    3.6.5
    • Constructor Summary

      Constructors 
      Constructor Description
      BuildHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String discoverJavaRelease​(org.apache.maven.project.MavenProject project)
      Tries to determine the target Java release from the following sources (until one is found) use release configuration of org.apache.maven.plugins:maven-compiler-plugin use maven.compiler.release< property use target configuration of org.apache.maven.plugins:maven-compiler-plugin use maven.compiler.target property
      static org.apache.maven.model.Plugin getCompilerPlugin​(org.apache.maven.project.MavenProject project)  
      static org.apache.maven.model.Plugin getPlugin​(org.apache.maven.project.MavenProject project, java.lang.String pluginGa)
      Get plugin from project based on coordinates groupId:artifactId.
      static java.lang.String getPluginParameter​(org.apache.maven.project.MavenProject project, org.apache.maven.model.Plugin plugin, java.lang.String parameter, java.lang.String defaultValueProperty)
      Get plugin parameter value if configured in current project.
      static java.lang.String normalizeJavaVersion​(java.lang.String jdk)
      Normalize Java version, for versions 5 to 8 where there is a 1.x alias.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BuildHelper

        public BuildHelper()
    • Method Detail

      • discoverJavaRelease

        public static java.lang.String discoverJavaRelease​(org.apache.maven.project.MavenProject project)
        Tries to determine the target Java release from the following sources (until one is found)
        1. use release configuration of org.apache.maven.plugins:maven-compiler-plugin
        2. use maven.compiler.release< property
        3. use target configuration of org.apache.maven.plugins:maven-compiler-plugin
        4. use maven.compiler.target property
        Parameters:
        project - not null
        Returns:
        the Java release version configured in the project, or null if not configured
      • normalizeJavaVersion

        public static java.lang.String normalizeJavaVersion​(java.lang.String jdk)
        Normalize Java version, for versions 5 to 8 where there is a 1.x alias.
        Parameters:
        jdk - can be null
        Returns:
        normalized version if an alias was used
      • getCompilerPlugin

        public static org.apache.maven.model.Plugin getCompilerPlugin​(org.apache.maven.project.MavenProject project)
      • getPlugin

        public static org.apache.maven.model.Plugin getPlugin​(org.apache.maven.project.MavenProject project,
                                                              java.lang.String pluginGa)
        Get plugin from project based on coordinates groupId:artifactId.
        Parameters:
        project - not null
        pluginGa - groupId:artifactId
        Returns:
        the plugin from build or pluginManagement, if available in project
      • getPluginParameter

        public static java.lang.String getPluginParameter​(org.apache.maven.project.MavenProject project,
                                                          org.apache.maven.model.Plugin plugin,
                                                          java.lang.String parameter,
                                                          java.lang.String defaultValueProperty)
        Get plugin parameter value if configured in current project.
        Parameters:
        project - not null
        plugin - can be null
        parameter - the parameter name when configured in plugin's configuration
        defaultValueProperty - the property name when default value is used for the plugin parameter
        Returns:
        the value, or null if not configured at all, but using internal default from plugin.