| java.lang.Object org.netbeans.spi.project.support.ant.GeneratedFilesHelper
GeneratedFilesHelper | final public class GeneratedFilesHelper (Code) | | Helps a project type (re-)generate, and manage the state and versioning of,
build.xml and build-impl.xml .
author: Jesse Glick |
Field Summary | |
final public static String | BUILD_IMPL_XML_PATH Relative path from project directory to the implementation build script,
build-impl.xml . | final public static String | BUILD_XML_PATH Relative path from project directory to the user build script,
build.xml . | final public static int | FLAG_MISSING A build script is missing from disk. | final public static int | FLAG_MODIFIED A build script has been modified since last generated by
GeneratedFilesHelper.generateBuildScriptFromStylesheet . | final public static int | FLAG_OLD_PROJECT_XML A build script was generated from an older version of project.xml . | final public static int | FLAG_OLD_STYLESHEET A build script was generated from an older version of a stylesheet. | final public static int | FLAG_UNKNOWN The build script exists, but nothing else is known about it. | final static String | GENFILES_PROPERTIES_PATH Path to file storing information about generated files.
It should be kept in version control, since it applies equally after a fresh
project checkout; it does not apply to running Ant, so should not be in
project.properties ; and it includes a CRC of project.xml
so it cannot be in that file either. |
Method Summary | |
static String | computeCrc32(InputStream is) Compute the CRC-32 of the contents of a stream. | public void | generateBuildScriptFromStylesheet(String path, URL stylesheet) Create build.xml or nbproject/build-impl.xml
from project.xml plus a supplied XSLT stylesheet.
This is the recommended way to create the build scripts from
project metadata.
You may wish to first check
GeneratedFilesHelper.getBuildScriptState to decide whether
you really want to overwrite an existing build script. | public int | getBuildScriptState(String path, URL stylesheet) Find what state a build script is in.
This may be used by a project type provider to decide whether to create
or overwrite it, and whether to produce a backup in the latter case.
Various abnormal conditions are detected:
GeneratedFilesHelper.FLAG_MISSING ,
GeneratedFilesHelper.FLAG_MODIFIED ,
GeneratedFilesHelper.FLAG_OLD_PROJECT_XML ,
GeneratedFilesHelper.FLAG_OLD_STYLESHEET , and
GeneratedFilesHelper.FLAG_UNKNOWN .
Currently
GeneratedFilesHelper.FLAG_MODIFIED ,
GeneratedFilesHelper.FLAG_OLD_STYLESHEET , and
GeneratedFilesHelper.FLAG_OLD_PROJECT_XML are detected by computing a CRC-32
of the script when it is created, as well as the CRC-32s of the
stylesheet and project.xml . | public boolean | refreshBuildScript(String path, URL stylesheet, boolean checkForProjectXmlModified) Convenience method to refresh a build script if it can and should be. |
BUILD_IMPL_XML_PATH | final public static String BUILD_IMPL_XML_PATH(Code) | | Relative path from project directory to the implementation build script,
build-impl.xml .
|
BUILD_XML_PATH | final public static String BUILD_XML_PATH(Code) | | Relative path from project directory to the user build script,
build.xml .
|
FLAG_OLD_PROJECT_XML | final public static int FLAG_OLD_PROJECT_XML(Code) | | A build script was generated from an older version of project.xml .
It was last generated using a different version of project.xml ,
so using the current project.xml might produce a different
result.
This is quite likely in the case of
build.xml ; in the case of build-impl.xml , it
probably means that the user edited project.xml manually,
since if that were modified from
AntProjectHelper methods and
the project were saved, the script would have been regenerated
already.
See Also: GeneratedFilesHelper.getBuildScriptState |
FLAG_OLD_STYLESHEET | final public static int FLAG_OLD_STYLESHEET(Code) | | A build script was generated from an older version of a stylesheet.
It was last generated using a different (probably older) version of the
XSLT stylesheet, so using the current stylesheet might produce a different
result.
Probably this means the project type
provider module has been upgraded since the project was last saved (in
the case of build-impl.xml ) or created (in the case of
build.xml ).
See Also: GeneratedFilesHelper.getBuildScriptState |
GENFILES_PROPERTIES_PATH | final static String GENFILES_PROPERTIES_PATH(Code) | | Path to file storing information about generated files.
It should be kept in version control, since it applies equally after a fresh
project checkout; it does not apply to running Ant, so should not be in
project.properties ; and it includes a CRC of project.xml
so it cannot be in that file either. It could be stored in some special
comment at the end of the build script (e.g.) but many users would just
compulsively delete it in this case since it looks weird.
|
GeneratedFilesHelper | public GeneratedFilesHelper(AntProjectHelper h)(Code) | | Create a helper based on the supplied project helper handle.
Parameters: h - an Ant-based project helper supplied to the project type provider |
GeneratedFilesHelper | public GeneratedFilesHelper(AntProjectHelper h, AntBuildExtender ex)(Code) | | Create a helper based on the supplied project helper handle. The created
instance is capable of extending the generated files with 3rd party content.
Parameters: h - an Ant-based project helper supplied to the project type provider Parameters: ex - build extensibility support since: org.netbeans.modules.project.ant 1.16 |
GeneratedFilesHelper | public GeneratedFilesHelper(FileObject d)(Code) | | Create a helper based only on a project directory.
This can be used to perform the basic refresh functionality
without being the owner of the project.
It is only intended for use from the offline Ant task to
refresh a project, and similar special situations.
For normal circumstances please use only
GeneratedFilesHelper.GeneratedFilesHelper(AntProjectHelper) .
Parameters: d - the project directory throws: IllegalArgumentException - if the supplied directory has no project.xml |
computeCrc32 | static String computeCrc32(InputStream is) throws IOException(Code) | | Compute the CRC-32 of the contents of a stream.
\r\n and \r are both normalized to \n for purposes of the calculation.
|
getBuildScriptState | public int getBuildScriptState(String path, URL stylesheet) throws IllegalStateException(Code) | | Find what state a build script is in.
This may be used by a project type provider to decide whether to create
or overwrite it, and whether to produce a backup in the latter case.
Various abnormal conditions are detected:
GeneratedFilesHelper.FLAG_MISSING ,
GeneratedFilesHelper.FLAG_MODIFIED ,
GeneratedFilesHelper.FLAG_OLD_PROJECT_XML ,
GeneratedFilesHelper.FLAG_OLD_STYLESHEET , and
GeneratedFilesHelper.FLAG_UNKNOWN .
Currently
GeneratedFilesHelper.FLAG_MODIFIED ,
GeneratedFilesHelper.FLAG_OLD_STYLESHEET , and
GeneratedFilesHelper.FLAG_OLD_PROJECT_XML are detected by computing a CRC-32
of the script when it is created, as well as the CRC-32s of the
stylesheet and project.xml . These CRCs are stored
in a special file nbproject/genfiles.properties .
The CRCs are based on the textual
contents of the files (so even changed to whitespace etc. are considered
changes), but are independent of platform newline conventions (since e.g.
CVS will by default replace \n with \r\n when checking out on Windows).
Changes to external files included into project.xml or the
stylesheet (e.g. using XSLT's import facility) are not detected.
If there is some kind of I/O error reading any files,
GeneratedFilesHelper.FLAG_UNKNOWN is returned (in conjunction with
GeneratedFilesHelper.FLAG_MODIFIED ,
GeneratedFilesHelper.FLAG_OLD_STYLESHEET , and
GeneratedFilesHelper.FLAG_OLD_PROJECT_XML to be safe).
Acquires read access.
Parameters: path - a project-relative path such as GeneratedFilesHelper.BUILD_XML_PATH or GeneratedFilesHelper.BUILD_IMPL_XML_PATH Parameters: stylesheet - a URL to an XSLT stylesheet accepting project.xml as input and producing the build script as output(should match that given to GeneratedFilesHelper.generateBuildScriptFromStylesheet) a bitwise OR of various flags, or 0 if the scriptis present on disk and fully up-to-date throws: IllegalStateException - if the project was modified |
|
|