public final class NbMavenProject extends Object
ProjectServiceProvider
annotation in subfolders of the project Lookup registration area whose names follow a Plugin group and
artifact ID.
@Shows a service, that will become available from project Lookup whenever the project usesProjectServiceProvider
(service=PS.class, projectType=NbMavenProject
.TYPE + "/org.netbeans.modules.maven:test.plugin") public static class PluginService implements PS { public @Override
String
m() { return "special"; } }
org.netbeans.modules.maven:test.plugin
plugin in its model.
Modifier and Type | Field and Description |
---|---|
static String |
PROP_PROJECT
the only property change fired by the class, means that the pom file
has changed.
|
static String |
PROP_RESOURCE
TODO comment
|
static String |
TYPE
ID of the Maven project type.
|
static String |
TYPE_APPCLIENT |
static String |
TYPE_EAR |
static String |
TYPE_EJB |
static String |
TYPE_JAR |
static String |
TYPE_NBM |
static String |
TYPE_NBM_APPLICATION |
static String |
TYPE_OSGI |
static String |
TYPE_POM |
static String |
TYPE_WAR |
Modifier and Type | Method and Description |
---|---|
static void |
addPropertyChangeListener(Project prj,
PropertyChangeListener listener) |
void |
addPropertyChangeListener(PropertyChangeListener propertyChangeListener) |
void |
addWatchedPath(String relPath) |
void |
addWatchedPath(URI uri) |
void |
downloadDependencyAndJavadocSource()
Deprecated.
Use
NbMavenProject.downloadDependencyAndJavadocSource(boolean) with true . |
void |
downloadDependencyAndJavadocSource(boolean synch)
Download binaries and then trigger dependency javadoc/source download (in async mode) if download strategy is not DownloadStrategy.NEVER in options
Not to be called from AWT thread in synch mode; the current thread will continue after downloading binaries and firing project change event.
|
static void |
fireMavenProjectReload(Project prj)
utility method for triggering a maven project reload.
|
URI |
getEarAppDirectory() |
org.apache.maven.project.MavenProject |
getEvaluatedProject(ProjectActionContext context)
Returns a project evaluated for a certain purpose.
|
org.apache.maven.project.MavenProject |
getMavenProject()
Returns the current maven project model from the embedder.
|
File |
getOutputDirectory(boolean test)
Standardized way of finding output directory even for broken projects.
|
String |
getPackagingType()
Gets an "effective" packaging for the project.
|
static org.apache.maven.project.MavenProject |
getPartialProject(org.apache.maven.project.MavenProject project)
Retrieves at least partial project information.
|
org.apache.maven.model.Model |
getRawModel()
Returns the raw pom model for the project.
|
URI[] |
getResources(boolean test) |
URI |
getWebAppDirectory() |
static boolean |
isErrorPlaceholder(org.apache.maven.project.MavenProject project)
Checks whether a given project is just an error placeholder.
|
static boolean |
isIncomplete(org.apache.maven.project.MavenProject project)
Checks if the project resolved using incomplete or missing information.
|
boolean |
isMavenProjectLoaded()
a marginally unreliable, non blocking method for figuring if the model is loaded or not.
|
boolean |
isUnloadable()
Checks if the project is completely broken.
|
org.apache.maven.project.MavenProject |
loadAlternateMavenProject(org.netbeans.modules.maven.embedder.MavenEmbedder embedder,
List<String> activeProfiles,
Properties properties) |
static void |
removePropertyChangeListener(Project prj,
PropertyChangeListener listener) |
void |
removePropertyChangeListener(PropertyChangeListener propertyChangeListener) |
void |
removeWatchedPath(String relPath) |
void |
removeWatchedPath(URI uri) |
void |
synchronousDependencyDownload()
Not to be called from AWT, will wait til the project binary dependency resolution finishes.
|
String |
toString() |
void |
triggerDependencyDownload()
asynchronous dependency download, scheduled to some time in the future.
|
void |
triggerSourceJavadocDownload(boolean javadoc) |
public static final String PROP_PROJECT
public static final String TYPE
public static final String PROP_RESOURCE
public static final String TYPE_JAR
public static final String TYPE_WAR
public static final String TYPE_EAR
public static final String TYPE_EJB
public static final String TYPE_APPCLIENT
public static final String TYPE_NBM
public static final String TYPE_NBM_APPLICATION
public static final String TYPE_OSGI
public static final String TYPE_POM
public boolean isUnloadable()
NbMavenProject.getPartialProject(org.apache.maven.project.MavenProject)
.NbMavenProject.getPartialProject(org.apache.maven.project.MavenProject)
public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
@NonNull public org.apache.maven.project.MavenProject getMavenProject()
NbMavenProject.isErrorPlaceholder(org.apache.maven.project.MavenProject)
if necessary.@NonNull public org.apache.maven.project.MavenProject getEvaluatedProject(ProjectActionContext context)
NbMavenProject.getMavenProject()
works with the active configuration and does not apply any action-specific properties,
this method tries to apply mappings, configurations, etc when loading the project model.
Note that loading an evaluated project may take significant time (comparable to loading the base project itself). The implementation might optimize if the passed context does not prescribe different profiles, properties etc than have been used for the default model.
context
- the loading contextpublic boolean isMavenProjectLoaded()
@NonNull public org.apache.maven.project.MavenProject loadAlternateMavenProject(org.netbeans.modules.maven.embedder.MavenEmbedder embedder, List<String> activeProfiles, Properties properties)
public URI[] getResources(boolean test)
test
- are test resources requested, if false, resources for base sources are returnedpublic File getOutputDirectory(boolean test)
test
- true for target/test-classes
, false for target/classes
public URI getWebAppDirectory()
public URI getEarAppDirectory()
public String getPackagingType()
PackagingProvider
s can affect the decision.
The resulting type will be used to control most IDE functions, including packaging-specific lookup.public org.apache.maven.model.Model getRawModel() throws org.apache.maven.model.building.ModelBuildingException
org.apache.maven.model.building.ModelBuildingException
public void addWatchedPath(String relPath)
relPath
- public void addWatchedPath(URI uri)
uri
- public void triggerDependencyDownload()
public void synchronousDependencyDownload()
@Deprecated public void downloadDependencyAndJavadocSource()
NbMavenProject.downloadDependencyAndJavadocSource(boolean)
with true
.public void downloadDependencyAndJavadocSource(boolean synch)
synch
- true to download dependencies binaries (not source/Javadoc) synchronously; false to download everything asynchpublic void triggerSourceJavadocDownload(boolean javadoc)
public void removeWatchedPath(String relPath)
public void removeWatchedPath(URI uri)
public static void fireMavenProjectReload(Project prj)
prj
- public static void addPropertyChangeListener(Project prj, PropertyChangeListener listener)
public static void removePropertyChangeListener(Project prj, PropertyChangeListener listener)
public static org.apache.maven.project.MavenProject getPartialProject(org.apache.maven.project.MavenProject project)
The result can be checked to be NbMavenProject.isErrorPlaceholder(org.apache.maven.project.MavenProject)
to determine if the result was a returned partial project or not.
Note that partial projects may not resolve all references properly, be prepared for unresolved artifacts and/or plugins. Do not pass
partial projects blindly around.
Returns null
if the passed project is null
project
- the project to checkpublic static boolean isErrorPlaceholder(@NonNull org.apache.maven.project.MavenProject project)
NbMavenProject.isIncomplete(org.apache.maven.project.MavenProject)
project
- a project loaded by e.g. NbMavenProject.getMavenProject()
NbMavenProject.isIncomplete(org.apache.maven.project.MavenProject)
,
NbMavenProject.getPartialProject(org.apache.maven.project.MavenProject)
public static boolean isIncomplete(@NonNull org.apache.maven.project.MavenProject project)
NbMavenProject.isErrorPlaceholder(org.apache.maven.project.MavenProject)
is an incomplete project.
If the project is just missing proper referenced artifacts, it will not be reported as a NbMavenProject.isErrorPlaceholder(org.apache.maven.project.MavenProject)
, but as NbMavenProject.isIncomplete(org.apache.maven.project.MavenProject)
.project
-