| java.lang.Object org.netbeans.spi.project.support.ant.AntProjectHelper
AntProjectHelper | final public class AntProjectHelper (Code) | | Support class for implementing Ant-based projects.
author: Jesse Glick |
Method Summary | |
public void | addAntProjectListener(AntProjectListener listener) Add a listener to changes in the project configuration. | void | cancelPendingHook() | public AuxiliaryConfiguration | createAuxiliaryConfiguration() Create an object permitting this project to store auxiliary configuration. | public CacheDirectoryProvider | createCacheDirectoryProvider() Create an object permitting this project to expose a cache directory. | public FileBuiltQueryImplementation | createGlobFileBuiltQuery(PropertyEvaluator eval, String[] from, String[] to) Create an implementation of
org.netbeans.api.queries.FileBuiltQuery that works with files
within the project based on simple glob pattern mappings. | public SharabilityQueryImplementation | createSharabilityQuery(PropertyEvaluator eval, String[] sourceRoots, String[] buildDirectories) Create an implementation of the file sharability query.
You may specify a list of source roots to include that should be considered sharable,
as well as a list of build directories that should not be considered sharable.
The project directory itself is automatically included in the list of sharable directories
so you need not explicitly specify it.
Similarly, the nbproject/private subdirectory is automatically excluded
from VCS, so you do not need to explicitly specify it.
Any file (or directory) mentioned (explicitly or implicity) in the source
directory list but not in any of the build directory lists, and not containing
any build directories inside it, will be given as sharable. | public AntArtifact | createSimpleAntArtifact(String type, String locationProperty, PropertyEvaluator eval, String targetName, String cleanTargetName) Create a basic implementation of
AntArtifact which assumes everything of interest
is in a fixed location under a standard Ant-based project.
Parameters: type - the type of artifact, e.g. | void | fireExternalChange(String path) Fire a change of external provenance to all listeners. | Element | getConfigurationFragment(String elementName, String namespace, boolean shared) Get a piece of the configuration subtree by name.
Parameters: elementName - the simple XML element name expected Parameters: namespace - the XML namespace expected Parameters: shared - to use project.xml vs. | public String | getLibrariesLocation() Returns location of shared libraries associated with this project or null. | public Element | getPrimaryConfigurationData(boolean shared) Get the primary configuration data for this project. | public FileObject | getProjectDirectory() Get the top-level project directory. | public PropertyProvider | getProjectLibrariesPropertyProvider() Creates a property provider which can load definitions of project libraries. | public EditableProperties | getProperties(String path) Load a property file from some location in the project. | public PropertyProvider | getPropertyProvider(String path) Get a property provider that works with loadable project properties. | public PropertyEvaluator | getStandardPropertyEvaluator() Get a property evaluator that can evaluate properties according to the default
file layout for Ant-based projects. | public PropertyProvider | getStockPropertyPreprovider() Get a property provider which defines basedir according to
the project directory and also copies all system properties in the current VM. | AntBasedProjectType | getType() Get the corresponding Ant-based project type factory. | boolean | isProjectXmlModified() Check whether this project is currently modified including modifications
to project.xml . | public boolean | isSharableProject() Is this project shared with other or not, that is is it using shrared
libraries or not. | void | markModified() Mark this project as being modified without actually changing anything in it. | void | maybeCallPendingHook() See issue #57794. | void | needPendingHook() | public void | notifyDeleted() Notification that this project has been deleted. | void | putConfigurationFragment(Element fragment, boolean shared) Store a piece of the configuration subtree by name.
Parameters: fragment - a piece of the subtree to store (overwrite or add) Parameters: shared - to use project.xml vs. | public void | putPrimaryConfigurationData(Element data, boolean shared) Store the primary configuration data for this project.
The supplied element must be named according to
AntBasedProjectType.getPrimaryConfigurationDataElementName and
AntBasedProjectType.getPrimaryConfigurationDataElementNamespace .
The project may save this document fragment to set custom information
in nbproject/project.xml and nbproject/private/private.xml .
The fragment will be cloned and so further modifications will have no effect.
Acquires write access from
ProjectManager.mutex . | public void | putProperties(String path, EditableProperties props) Store a property file to some location in the project.
A clone will be made of the supplied properties file so as to snapshot it.
The new properties are not actually stored to disk immediately, but the project
is marked modified so that they will be later.
You can store to a path that does not yet exist and the file will be created
if and when the project is saved.
If the old value is the same as the new, nothing is done.
Otherwise an expected properties change event is fired.
Acquires write access from
ProjectManager.mutex . | public void | removeAntProjectListener(AntProjectListener listener) Remove a listener to changes in the project configuration. | boolean | removeConfigurationFragment(String elementName, String namespace, boolean shared) Remove a piece of the configuration subtree by name.
Parameters: elementName - the simple XML element name expected Parameters: namespace - the XML namespace expected Parameters: shared - to use project.xml vs. | public File | resolveFile(String filename) Find an absolute file path from a possibly project-relative path. | public FileObject | resolveFileObject(String filename) Same as
AntProjectHelper.resolveFile , but produce a FileObject if possible. | public String | resolvePath(String path) Take an Ant-style path specification and convert it to a platform-specific absolute path. | public void | setLibrariesLocation(String location) Change project's associated shared libraries location. | public String | toString() |
PRIVATE_NS | final static String PRIVATE_NS(Code) | | XML namespace of private component of Ant projects.
|
PRIVATE_PROPERTIES_PATH | final public static String PRIVATE_PROPERTIES_PATH(Code) | | Relative path from project directory to the customary private properties file.
|
PRIVATE_XML_PATH | final public static String PRIVATE_XML_PATH(Code) | | Relative path from project directory to the required private project metadata file.
|
PROJECT_NS | final static String PROJECT_NS(Code) | | XML namespace of Ant projects.
|
PROJECT_PROPERTIES_PATH | final public static String PROJECT_PROPERTIES_PATH(Code) | | Relative path from project directory to the customary shared properties file.
|
PROJECT_XML_PATH | final public static String PROJECT_XML_PATH(Code) | | Relative path from project directory to the required shared project metadata file.
|
QUIETLY_SWALLOW_XML_LOAD_ERRORS | static boolean QUIETLY_SWALLOW_XML_LOAD_ERRORS(Code) | | If true, do not report XML load errors.
For use only by unit tests.
|
addAntProjectListener | public void addAntProjectListener(AntProjectListener listener)(Code) | | Add a listener to changes in the project configuration.
Thread-safe.
Parameters: listener - a listener to add |
cancelPendingHook | void cancelPendingHook()(Code) | | |
createAuxiliaryConfiguration | public AuxiliaryConfiguration createAuxiliaryConfiguration()(Code) | | Create an object permitting this project to store auxiliary configuration.
Would be placed into the project's lookup.
an auxiliary configuration provider object suitable for the project lookup |
createCacheDirectoryProvider | public CacheDirectoryProvider createCacheDirectoryProvider()(Code) | | Create an object permitting this project to expose a cache directory.
Would be placed into the project's lookup.
a cache directory provider object suitable for the project lookup |
createGlobFileBuiltQuery | public FileBuiltQueryImplementation createGlobFileBuiltQuery(PropertyEvaluator eval, String[] from, String[] to) throws IllegalArgumentException(Code) | | Create an implementation of
org.netbeans.api.queries.FileBuiltQuery that works with files
within the project based on simple glob pattern mappings.
It is intended to be
placed in
org.netbeans.api.project.Project.getLookup .
It will return status objects for any files in the project matching a source
glob pattern - this must include exactly one asterisk (* )
representing a variable portion of a source file path (always slash-separated
and relative to the project directory) and may include some Ant property
references which will be resolved as per the property evaluator.
A file is considered out of date if there is no file represented by the
matching target pattern (which has the same format), or the target file is older
than the source file, or the source file is modified as per
org.openide.loaders.DataObject.isModified .
An attempt is made to fire changes from the status object whenever the result
should change from one call to the next.
The (evaluated) source and target patterns may be relative, resolved against
the project directory (perhaps going outside it), or absolute.
A typical set of source and target patterns would be:
- ${src.dir}/*.java
- ${test.src.dir}/*.java
- ${build.classes.dir}/*.class
- ${test.build.classes.dir}/*.class
Parameters: eval - a property evaluator to interpret the patterns with Parameters: from - a list of glob patterns for source files Parameters: to - a matching list of glob patterns for built files a query implementation throws: IllegalArgumentException - if either from or to patternshave zero or multiple asterisks,or the arrays are not of equal lengths |
createSharabilityQuery | public SharabilityQueryImplementation createSharabilityQuery(PropertyEvaluator eval, String[] sourceRoots, String[] buildDirectories)(Code) | | Create an implementation of the file sharability query.
You may specify a list of source roots to include that should be considered sharable,
as well as a list of build directories that should not be considered sharable.
The project directory itself is automatically included in the list of sharable directories
so you need not explicitly specify it.
Similarly, the nbproject/private subdirectory is automatically excluded
from VCS, so you do not need to explicitly specify it.
Any file (or directory) mentioned (explicitly or implicity) in the source
directory list but not in any of the build directory lists, and not containing
any build directories inside it, will be given as sharable. If a directory itself
is sharable but some directory inside it is not, it will be given as mixed.
A file or directory inside some build directory will be listed as not sharable.
A file or directory matching neither the source list nor the build directory list
will be treated as of unknown status, but in practice such a file should never
have been passed to this implementation anyway -
org.netbeans.api.queries.SharabilityQuery will
normally only call an implementation in project lookup if the file is owned by
that project.
Each entry in either list should be a string evaluated first for Ant property
escapes (if any), then treated as a file path relative to the project directory
(or it may be absolute).
It is permitted, and harmless, to include items that overlap others. For example,
you can have both a directory and one of its children in the include list.
Whether or not you use this method, all files named *-private.properties
outside the project are marked unsharable, as are such files inside the project if currently referenced
as project libraries. (See
AntProjectHelper.getProjectLibrariesPropertyProvider .)
Typical usage would be:
helper.createSharabilityQuery(helper.getStandardPropertyEvaluator(),
new String[] {"${src.dir}", "${test.src.dir}"},
new String[] {"${build.dir}", "${dist.dir}"})
A quick rule of thumb is that the include list should contain any
source directories which might reside outside the project directory;
and the exclude list should contain any directories which you would want
to add to a .cvsignore file if using CVS (for example).
Note that in this case ${src.dir} and ${test.src.dir}
may be relative paths inside the project directory; relative paths pointing
outside of the project directory; or absolute paths (generally outside of the
project directory). If they refer to locations inside the project directory,
including them does nothing but is harmless - since the project directory itself
is always treated as sharable. If they refer to external locations, you will
need to also make sure that
org.netbeans.api.project.FileOwnerQuery actually maps files in those
directories to this project, or else
org.netbeans.api.queries.SharabilityQuery will never find
this implementation in your project lookup and may return UNKNOWN .
Parameters: eval - a property evaluator to interpret paths with Parameters: sourceRoots - a list of additional paths to treat as sharable Parameters: buildDirectories - a list of paths to treat as not sharable a sharability query implementation suitable for the project lookup See Also: Project.getLookup |
createSimpleAntArtifact | public AntArtifact createSimpleAntArtifact(String type, String locationProperty, PropertyEvaluator eval, String targetName, String cleanTargetName)(Code) | | Create a basic implementation of
AntArtifact which assumes everything of interest
is in a fixed location under a standard Ant-based project.
Parameters: type - the type of artifact, e.g. JavaProjectConstants.ARTIFACT_TYPE_JAR Parameters: locationProperty - an Ant property name giving the project-relativelocation of the artifact, e.g. dist.jar Parameters: eval - a way to evaluate the location property (e.g. AntProjectHelper.getStandardPropertyEvaluator) Parameters: targetName - the name of an Ant target which will build the artifact,e.g. jar Parameters: cleanTargetName - the name of an Ant target which will delete the artifact(and maybe other build products), e.g. clean an artifact |
fireExternalChange | void fireExternalChange(String path)(Code) | | Fire a change of external provenance to all listeners.
Acquires write access.
Parameters: path - path to the changed file (XML or properties) |
getConfigurationFragment | Element getConfigurationFragment(String elementName, String namespace, boolean shared)(Code) | | Get a piece of the configuration subtree by name.
Parameters: elementName - the simple XML element name expected Parameters: namespace - the XML namespace expected Parameters: shared - to use project.xml vs. private.xml (a clone of) the named configuration fragment, or null if it does not exist |
getLibrariesLocation | public String getLibrariesLocation()(Code) | | Returns location of shared libraries associated with this project or null.
relative or absolute OS path or null since: org.netbeans.modules.project.ant/1 1.19 |
getProjectDirectory | public FileObject getProjectDirectory()(Code) | | Get the top-level project directory.
the project directory beneath which everything in the project lies |
getProjectLibrariesPropertyProvider | public PropertyProvider getProjectLibrariesPropertyProvider()(Code) | | Creates a property provider which can load definitions of project libraries.
If this project refers to any project library definition files, they will
be included, with ${base} replaced by the appropriate value.
a property provider since: org.netbeans.modules.project.ant/1 1.19 See Also: Schema for project library references |
getStockPropertyPreprovider | public PropertyProvider getStockPropertyPreprovider()(Code) | | Get a property provider which defines basedir according to
the project directory and also copies all system properties in the current VM.
It may also define ant.home and ant.core.lib if it is able.
a stock property provider for initial Ant-related definitions See Also: PropertyUtils.sequentialPropertyEvaluator |
isProjectXmlModified | boolean isProjectXmlModified()(Code) | | Check whether this project is currently modified including modifications
to project.xml .
Access from GeneratedFilesHelper.
|
isSharableProject | public boolean isSharableProject()(Code) | | Is this project shared with other or not, that is is it using shrared
libraries or not.
true for shared project since: org.netbeans.modules.project.ant/1 1.19 |
maybeCallPendingHook | void maybeCallPendingHook()(Code) | | See issue #57794.
|
needPendingHook | void needPendingHook()(Code) | | |
putConfigurationFragment | void putConfigurationFragment(Element fragment, boolean shared)(Code) | | Store a piece of the configuration subtree by name.
Parameters: fragment - a piece of the subtree to store (overwrite or add) Parameters: shared - to use project.xml vs. private.xml |
putProperties | public void putProperties(String path, EditableProperties props)(Code) | | Store a property file to some location in the project.
A clone will be made of the supplied properties file so as to snapshot it.
The new properties are not actually stored to disk immediately, but the project
is marked modified so that they will be later.
You can store to a path that does not yet exist and the file will be created
if and when the project is saved.
If the old value is the same as the new, nothing is done.
Otherwise an expected properties change event is fired.
Acquires write access from
ProjectManager.mutex . However, you are well
advised to explicitly enclose a complete operation within write access,
starting with
AntProjectHelper.getProperties , to prevent race conditions.
Parameters: path - a relative URI in the project directory, e.g.AntProjectHelper.PROJECT_PROPERTIES_PATH or AntProjectHelper.PRIVATE_PROPERTIES_PATH Parameters: props - a set of properties to store, or null to delete any existing properties file there |
removeAntProjectListener | public void removeAntProjectListener(AntProjectListener listener)(Code) | | Remove a listener to changes in the project configuration.
Thread-safe.
Parameters: listener - a listener to remove |
removeConfigurationFragment | boolean removeConfigurationFragment(String elementName, String namespace, boolean shared)(Code) | | Remove a piece of the configuration subtree by name.
Parameters: elementName - the simple XML element name expected Parameters: namespace - the XML namespace expected Parameters: shared - to use project.xml vs. private.xml true if anything was actually removed |
resolveFile | public File resolveFile(String filename)(Code) | | Find an absolute file path from a possibly project-relative path.
Parameters: filename - a pathname which may be project-relative or absolute and mayuse / or \ as the path separator an absolute file corresponding to it |
resolveFileObject | public FileObject resolveFileObject(String filename)(Code) | | Same as
AntProjectHelper.resolveFile , but produce a FileObject if possible.
Parameters: filename - a pathname according to Ant conventions a file object it represents, or null if there is no such file object in known filesystems |
resolvePath | public String resolvePath(String path)(Code) | | Take an Ant-style path specification and convert it to a platform-specific absolute path.
The path separator characters are converted to the local convention, and individual
path components are resolved and cleaned up as for
AntProjectHelper.resolveFile .
Parameters: path - an Ant-style abstract path an absolute, locally usable path |
setLibrariesLocation | public void setLibrariesLocation(String location)(Code) | | Change project's associated shared libraries location. If location is
null then project will not have shared libraries and will
be considered as not being shared.
Parameters: location - project relative or absolute OS path or null since: org.netbeans.modules.project.ant/1 1.18 |
|
|