Class ModelUtils
java.lang.Object
org.netbeans.modules.maven.api.ModelUtils
Various maven model related utilities.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
static final class
static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
library descriptor property containing whitespace separated list of maven coordinate values groupid:artifactId:version:[classifier:]typestatic final String
library descriptor property containing whitespace separated list of maven coordinate values repo_type:repo_url -
Method Summary
Modifier and TypeMethodDescriptionstatic 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) static ModelUtils.Descriptor
checkLibraries
(org.netbeans.api.project.libraries.Library library) return a descriptor for entireLibrary
containing recognized dependencies and repositories, both in old (volume) and new (properties) formatstatic ModelUtils.LibraryDescriptor
checkLibrary
(URL pom) Deprecated.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 parameterstatic 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)
-
Field Details
-
LIBRARY_PROP_DEPENDENCIES
library descriptor property containing whitespace separated list of maven coordinate values groupid:artifactId:version:[classifier:]type- See Also:
-
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 POMgroup
-artifact
-version
-type
-scope
-classifier
-acceptNull
- accept null values to scope,type and classifier. If true null values will remove corresponding tag.
-
checkModelDependency
-
hasModelDependency
-
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
-
updatePluginVersion
-
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). UsePluginPropertyUtils.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 modelsourceLevel
- 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 elementlocalQName
- local name of the childpomModel
- whole pom model- Returns:
- existing or newly created child
-
checkLibrary
Deprecated.in favor ofcheckLibraries(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 entireLibrary
containing recognized dependencies and repositories, both in old (volume) and new (properties) format- Parameters:
library
-- Returns:
-
checkLibraries(Library)