Class ModelUtils

java.lang.Object
org.netbeans.modules.maven.api.ModelUtils

public final class ModelUtils extends Object
Various maven model related utilities.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
     
    static final class 
     
    static final class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    library descriptor property containing whitespace separated list of maven coordinate values groupid:artifactId:version:[classifier:]type
    static final String
    library descriptor property containing whitespace separated list of maven coordinate values repo_type:repo_url
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addDependency(org.openide.filesystems.FileObject pom, String group, String artifact, String version, String type, String scope, String classifier, boolean acceptNull)
     
    static org.netbeans.modules.maven.model.pom.Repository
    addModelRepository(org.apache.maven.project.MavenProject project, org.netbeans.modules.maven.model.pom.POMModel mdl, String url)
     
    static boolean
    checkByCLIMavenValidationLevel(org.apache.maven.model.building.ModelProblem problem)
     
    checkLibraries(org.netbeans.api.project.libraries.Library library)
    return a descriptor for entire Library containing recognized dependencies and repositories, both in old (volume) and new (properties) format
    Deprecated.
    in favor of checkLibraries(Library)
    static org.netbeans.modules.maven.model.pom.Dependency
    checkModelDependency(org.netbeans.modules.maven.model.pom.POMModel pom, String groupId, String artifactId, boolean add)
     
    static org.netbeans.modules.maven.model.pom.POMExtensibilityElement
    getOrCreateChild(org.netbeans.modules.maven.model.pom.POMComponent parent, String localQName, org.netbeans.modules.maven.model.pom.POMModel pomModel)
    Returns child element of given parent, specified by its local name.
    static boolean
    hasModelDependency(org.netbeans.modules.maven.model.pom.POMModel mdl, String groupid, String artifactid)
     
    static void
    openAtPlugin(org.netbeans.modules.maven.model.pom.POMModel model, String groupId, String artifactId)
    Opens pom at a plugin with the given groupId and artifactId.
    static void
    openAtSource(org.apache.maven.model.InputLocation location)
    Opens a pom file at location defined in InputLocation parameter
    static void
    setSourceLevel(org.netbeans.modules.maven.model.pom.POMModel mdl, String sourceLevel)
    Sets the Java source and target level of a project (will set release if previously set).
    static void
    updatePluginVersion(String groupId, String artifactId, String version, org.netbeans.modules.maven.model.pom.Project prj)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LIBRARY_PROP_DEPENDENCIES

      public static final String LIBRARY_PROP_DEPENDENCIES
      library descriptor property containing whitespace separated list of maven coordinate values groupid:artifactId:version:[classifier:]type
      See Also:
    • LIBRARY_PROP_REPOSITORIES

      public static final String LIBRARY_PROP_REPOSITORIES
      library descriptor property containing whitespace separated list of maven coordinate values repo_type:repo_url
      See Also:
  • Method Details

    • addDependency

      public static void addDependency(org.openide.filesystems.FileObject pom, String group, String artifact, String version, String type, String scope, String classifier, boolean acceptNull)
      Parameters:
      pom - FileObject that represents POM
      group -
      artifact -
      version -
      type -
      scope -
      classifier -
      acceptNull - accept null values to scope,type and classifier. If true null values will remove corresponding tag.
    • checkModelDependency

      public static org.netbeans.modules.maven.model.pom.Dependency checkModelDependency(org.netbeans.modules.maven.model.pom.POMModel pom, String groupId, String artifactId, boolean add)
    • hasModelDependency

      public static boolean hasModelDependency(org.netbeans.modules.maven.model.pom.POMModel mdl, String groupid, String artifactid)
    • openAtSource

      public static void openAtSource(org.apache.maven.model.InputLocation location)
      Opens a pom file at location defined in InputLocation parameter
      Parameters:
      location -
      Since:
      2.77
    • openAtPlugin

      public static void openAtPlugin(org.netbeans.modules.maven.model.pom.POMModel model, String groupId, String artifactId)
      Opens pom at a plugin with the given groupId and artifactId.
      Parameters:
      model - the model to open
      groupId - the plugin groupId
      artifactId - the plugin artifactId
    • updatePluginVersion

      public static void updatePluginVersion(String groupId, String artifactId, String version, org.netbeans.modules.maven.model.pom.Project prj)
    • addModelRepository

      public static org.netbeans.modules.maven.model.pom.Repository addModelRepository(org.apache.maven.project.MavenProject project, org.netbeans.modules.maven.model.pom.POMModel mdl, String url)
      Parameters:
      mdl -
      url - of the repository
      Returns:
      null if repository with given url exists, otherwise a returned newly created item.
    • checkByCLIMavenValidationLevel

      public static boolean checkByCLIMavenValidationLevel(org.apache.maven.model.building.ModelProblem problem)
    • setSourceLevel

      public static void setSourceLevel(org.netbeans.modules.maven.model.pom.POMModel mdl, String sourceLevel)
      Sets the Java source and target level of a project (will set release if previously set). Use PluginPropertyUtils.getPluginProperty(org.netbeans.api.project.Project,String,String,String,String,String) first (Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER, Constants.SOURCE_PARAM, "compile") to make sure that the current level is actually not what you want. Please Note: This method will not take existing properties into account (maven.compiler.source, maven.compiler.target or maven.compiler.release), it is only updating the plugin configuration itself.
      Parameters:
      mdl - a POM model
      sourceLevel - the desired source level
      Since:
      2.19
    • getOrCreateChild

      public static org.netbeans.modules.maven.model.pom.POMExtensibilityElement getOrCreateChild(org.netbeans.modules.maven.model.pom.POMComponent parent, String localQName, org.netbeans.modules.maven.model.pom.POMModel pomModel)
      Returns child element of given parent, specified by its local name. Creates such child in case it doesn't exist.
      Parameters:
      parent - parent element
      localQName - local name of the child
      pomModel - whole pom model
      Returns:
      existing or newly created child
    • checkLibrary

      @Deprecated public static ModelUtils.LibraryDescriptor checkLibrary(URL pom)
      Deprecated.
      in favor of checkLibraries(Library)
      Returns a library descriptor corresponding to the given library, or null if not recognized successfully.
      Parameters:
      pom - library to check
      Returns:
      LibraryDescriptor corresponding to the library, or null if the pom URL format is not recognized.
    • checkLibraries

      public static ModelUtils.Descriptor checkLibraries(org.netbeans.api.project.libraries.Library library)
      return a descriptor for entire Library containing recognized dependencies and repositories, both in old (volume) and new (properties) format
      Parameters:
      library -
      Returns: