|
org.apache.tools.ant.module/3 3.27.0 2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.tools.ant.module.api.support.ActionUtils
public final class ActionUtils
Makes it easier to implement org.netbeans.spi.project.ActionProvider
in a standard way
by running targets in Ant scripts.
ActionProvider
Method Summary | |
---|---|
static String |
antIncludesList(FileObject[] files,
FileObject dir)
Create an "includes" string such as is accepted by many Ant commands as well as filesets. |
static String |
antIncludesList(FileObject[] files,
FileObject dir,
boolean recursive)
Create an "includes" string such as is accepted by many Ant commands as well as filesets. |
static FileObject[] |
findSelectedFiles(Lookup context,
FileObject dir,
String suffix,
boolean strict)
Convenience method to find a file selection in a selection (context). |
static FileObject[] |
regexpMapFiles(FileObject[] fromFiles,
FileObject fromDir,
Pattern fromRx,
FileObject toDir,
String toSubst,
boolean strict)
Map files of one kind in a source directory to files of another kind in a target directory. |
static ExecutorTask |
runTarget(FileObject buildXml,
String[] targetNames,
Properties properties)
Runs an Ant target (or a sequence of them). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ExecutorTask runTarget(FileObject buildXml, String[] targetNames, Properties properties) throws IOException, IllegalArgumentException
buildXml
- an Ant build scripttargetNames
- one or more targets to run; or null for the default targetproperties
- any Ant properties to define, or null
IOException
- if there was a problem starting Ant
IllegalArgumentException
- if you did not provide any targetspublic static FileObject[] findSelectedFiles(Lookup context, FileObject dir, String suffix, boolean strict)
FileUtil.toFile(org.openide.filesystems.FileObject)
).
If a constraining directory is supplied, they must also be contained in it.
If a constraining file suffix is supplied, the base names of the files
must end with that suffix.
The return value is null if there are no matching files; or if the strict
parameter is true and some of the files in the selection did not match
the constraints (disk files, directory, and/or suffix).
Typically DataNode
s will form a node selection
which will be placed in the context. This method does not directly
look for nodes in the selection; but generally the lookups of the nodes in
a node selection are spliced into the context as well, so the DataObject
s
should be available. A corollary of not checking nodes directly is that any
nodes in the context which do not correspond to files at all (i.e. do not have
DataObject
as a cookie) are ignored, even with the strict parameter on;
and that multiple nodes in the context with the same associated file are treated
as a single entry.
context
- a selection as provided to e.g. ActionProvider.isActionEnabled(...)
dir
- a constraining parent directory, or null to not check for a parent directorysuffix
- a file suffix (e.g. .java) to constrain files by,
or null to not check suffixesstrict
- if true, all files in the selection have to be accepted
ActionProvider.isActionEnabled(...)
public static FileObject[] regexpMapFiles(FileObject[] fromFiles, FileObject fromDir, Pattern fromRx, FileObject toDir, String toSubst, boolean strict) throws IllegalArgumentException
Typical usage to map a set of Java source files to corresponding tests:
regexpMapFiles(files, srcDir, Pattern.compile("/([^/]+)\\.java"), testSrcDir, "/\\1Test.java", true)
fromFiles
- a list of source files to start with (may be empty)fromDir
- a directory in which all the source files residefromRx
- a regular expression to match against the source files
(or null to keep the same relative file names); only one
match (somewhere in the path) is checked for; failure to match
prevents the file from being includedtoDir
- a target directory that results will reside intoSubst
- replacement text for fromRx
(may include regexp references),
or must be null if fromRx
was nullstrict
- true to return null in case some starting files did not match any target file
IllegalArgumentException
- in case some source file is not in the source directorypublic static String antIncludesList(FileObject[] files, FileObject dir) throws IllegalArgumentException
files
- a list of files or folders to include, in the case of folder
the generated include contains recursively all files under the folder.dir
- a directory in which all the files reside
IllegalArgumentException
- in case some file is not in the directorypublic static String antIncludesList(FileObject[] files, FileObject dir, boolean recursive) throws IllegalArgumentException
files
- a list of files or folders to include, in the case of folder
the generated include contains recursively all files under the folder.dir
- a directory in which all the files residerecursive
- if true the include list for directory is recursive
IllegalArgumentException
- in case some file is not in the directory
|
org.apache.tools.ant.module/3 3.27.0 2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |