| 
 | org.netbeans.modules.project.ant/1 1.12.22 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.netbeans.spi.project.support.ant.GeneratedFilesHelper
public final class GeneratedFilesHelper
Helps a project type (re-)generate, and manage the state and versioning of,
 build.xml and build-impl.xml.
| Field Summary | |
|---|---|
| static String | BUILD_IMPL_XML_PATHRelative path from project directory to the implementation build script, build-impl.xml. | 
| static String | BUILD_XML_PATHRelative path from project directory to the user build script, build.xml. | 
| static int | FLAG_MISSINGA build script is missing from disk. | 
| static int | FLAG_MODIFIEDA build script has been modified since last generated by generateBuildScriptFromStylesheet(java.lang.String, java.net.URL). | 
| static int | FLAG_OLD_PROJECT_XMLA build script was generated from an older version of project.xml. | 
| static int | FLAG_OLD_STYLESHEETA build script was generated from an older version of a stylesheet. | 
| static int | FLAG_UNKNOWNThe build script exists, but nothing else is known about it. | 
| Constructor Summary | |
|---|---|
| GeneratedFilesHelper(AntProjectHelper h)Create a helper based on the supplied project helper handle. | |
| GeneratedFilesHelper(FileObject d)Create a helper based only on a project directory. | |
| Method Summary | |
|---|---|
|  void | generateBuildScriptFromStylesheet(String path,
                                  URL stylesheet)Create build.xmlornbproject/build-impl.xmlfromproject.xmlplus a supplied XSLT stylesheet. | 
|  int | getBuildScriptState(String path,
                    URL stylesheet)Find what state a build script is in. | 
|  boolean | refreshBuildScript(String path,
                   URL stylesheet,
                   boolean checkForProjectXmlModified)Convenience method to refresh a build script if it can and should be. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final String BUILD_XML_PATH
build.xml.
public static final String BUILD_IMPL_XML_PATH
build-impl.xml.
public static final int FLAG_MISSING
public static final int FLAG_MODIFIED
generateBuildScriptFromStylesheet(java.lang.String, java.net.URL).
 Probably this means it was edited by the user.
public static final int FLAG_OLD_PROJECT_XML
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.
 
public static final int FLAG_OLD_STYLESHEET
 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).
 
public static final int FLAG_UNKNOWN
FLAG_MISSING but
 when set also sets FLAG_MODIFIED, FLAG_OLD_STYLESHEET,
 and FLAG_OLD_PROJECT_XML - since it is not known whether these
 conditions might obtain, it is safest to assume they do.
 
 Probably this means that nbproject/genfiles.properties was
 deleted by the user.
 
| Constructor Detail | 
|---|
public GeneratedFilesHelper(AntProjectHelper h)
h - an Ant-based project helper supplied to the project type providerpublic GeneratedFilesHelper(FileObject d)
GeneratedFilesHelper(AntProjectHelper).
d - the project directory
IllegalArgumentException - if the supplied directory has no project.xml| Method Detail | 
|---|
public void generateBuildScriptFromStylesheet(String path, URL stylesheet) throws IOException, IllegalStateException
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 getBuildScriptState(java.lang.String, java.net.URL) to decide whether
 you really want to overwrite an existing build script. Typically if you
 find FLAG_MODIFIED you should not overwrite it; or ask for confirmation
 first; or make a backup. Of course if you find neither of FLAG_OLD_STYLESHEET
 nor FLAG_OLD_PROJECT_XML then there is no reason to overwrite the
 script to begin with.
 
Acquires write access.
path - a project-relative file path such as BUILD_XML_PATH or BUILD_IMPL_XML_PATHstylesheet - a URL to an XSLT stylesheet accepting project.xml
                   as input and producing the build script as output
IOException - if transforming or writing the output failed
IllegalStateException - if the project was modified (and not being saved)public int getBuildScriptState(String path, URL stylesheet) throws IllegalStateException
FLAG_MISSING, FLAG_MODIFIED, FLAG_OLD_PROJECT_XML,
 FLAG_OLD_STYLESHEET, and FLAG_UNKNOWN.
 
 Currently FLAG_MODIFIED, FLAG_OLD_STYLESHEET, and
 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, FLAG_UNKNOWN
 is returned (in conjunction with FLAG_MODIFIED,
 FLAG_OLD_STYLESHEET, and FLAG_OLD_PROJECT_XML to be safe).
 
Acquires read access.
path - a project-relative path such as BUILD_XML_PATH or BUILD_IMPL_XML_PATHstylesheet - a URL to an XSLT stylesheet accepting project.xml
                   as input and producing the build script as output
                   (should match that given to generateBuildScriptFromStylesheet(java.lang.String, java.net.URL))
0 if the script
         is present on disk and fully up-to-date
IllegalStateException - if the project was modifiedpublic boolean refreshBuildScript(String path, URL stylesheet, boolean checkForProjectXmlModified) throws IOException, IllegalStateException
 If the script is not modified, and it is either missing, or the flag
 checkForProjectXmlModified is false, or it is out of date with
 respect to either project.xml or the stylesheet (or both),
 it is (re-)generated.
 
Acquires write access.
 Typical usage from ProjectXmlSavedHook.projectXmlSaved() is to call
 this method for both BUILD_XML_PATH and BUILD_IMPL_XML_PATH
 with the appropriate stylesheets and with checkForProjectXmlModified
 false (the script is certainly out of date relative to project.xml).
 Typical usage from ProjectOpenedHook is to call
 this method for both scripts with the appropriate stylesheets and with
 checkForProjectXmlModified true.
 
path - a project-relative path such as BUILD_XML_PATH or BUILD_IMPL_XML_PATHstylesheet - a URL to an XSLT stylesheet accepting project.xml
                   as input and producing the build script as outputcheckForProjectXmlModified - true if it is necessary to check whether the
                                script is out of date with respect to
                                project.xml and/or the stylesheet
IOException - if transforming or writing the output failed
IllegalStateException - if the project was modified| 
 | org.netbeans.modules.project.ant/1 1.12.22 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||