Index: nbbuild/antsrc/org/netbeans/nbbuild/Arch-default-dep-nb.xsl =================================================================== RCS file: nbbuild/antsrc/org/netbeans/nbbuild/Arch-default-dep-nb.xsl diff -N nbbuild/antsrc/org/netbeans/nbbuild/Arch-default-dep-nb.xsl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ nbbuild/antsrc/org/netbeans/nbbuild/Arch-default-dep-nb.xsl 12 Jul 2005 17:58:13 -0000 @@ -0,0 +1,56 @@ + + + + + + + + +

+ These modules are required in project.xml file: +

    + +
+

+
+ + +
  • + import + java + devel + + + + + @ + + @/overview-summary.html + + + + The module is needed for compilation. + + + The module is used during runtime. + + Specification version + + is required. + + +
  • +
    +
    + Index: nbbuild/antsrc/org/netbeans/nbbuild/Arch.dtd =================================================================== RCS file: /cvs/nbbuild/antsrc/org/netbeans/nbbuild/Arch.dtd,v retrieving revision 1.17 diff -u -r1.17 Arch.dtd --- nbbuild/antsrc/org/netbeans/nbbuild/Arch.dtd 27 Sep 2004 11:03:06 -0000 1.17 +++ nbbuild/antsrc/org/netbeans/nbbuild/Arch.dtd 12 Jul 2005 17:58:13 -0000 @@ -20,7 +20,7 @@ can occur in HTML --> - + %xhtml; @@ -45,6 +45,11 @@ + + + Index: nbbuild/antsrc/org/netbeans/nbbuild/Arch.java =================================================================== RCS file: /cvs/nbbuild/antsrc/org/netbeans/nbbuild/Arch.java,v retrieving revision 1.35 diff -u -r1.35 Arch.java --- nbbuild/antsrc/org/netbeans/nbbuild/Arch.java 12 Jul 2005 10:50:11 -0000 1.35 +++ nbbuild/antsrc/org/netbeans/nbbuild/Arch.java 12 Jul 2005 17:58:14 -0000 @@ -15,6 +15,9 @@ import java.io.*; import java.text.DateFormat; import java.util.*; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.stream.StreamSource; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.taskdefs.Ant; @@ -88,6 +91,11 @@ public void setApichanges (File apichanges) { this.apichanges = apichanges; } + + private File project = null; + public void setProject (File x) { + this.project = x; + } /** Run the conversion */ public void execute () throws BuildException { @@ -259,6 +267,80 @@ qSource = new DOMSource(q); } + + + if (project != null) { + // read also project file and apply transformation on defaultanswer tags + log("Reading project from " + project); + + + + org.w3c.dom.Document prj; + try { + DocumentBuilderFactory fack = DocumentBuilderFactory.newInstance(); + fack.setNamespaceAware(false); + prj = fack.newDocumentBuilder().parse (project); + } catch (SAXParseException ex) { + log(ex.getSystemId() + ":" + ex.getLineNumber() + ": " + ex.getLocalizedMessage(), Project.MSG_ERR); + throw new BuildException(project.getAbsolutePath() + " is malformed or invalid", ex, getLocation()); + } catch (Exception ex) { + throw new BuildException ("File " + project + " cannot be parsed: " + ex.getLocalizedMessage(), ex, getLocation()); + } + + DOMSource prjSrc = new DOMSource(prj); + + NodeList node = prj.getElementsByTagName("project"); + if (node.getLength() != 1) { + throw new BuildException("Expected one element in " + project + "but was: " + node.getLength()); + } + + NodeList list= q.getElementsByTagName("answer"); + for (int i = 0; i < list.getLength(); i++) { + Node n = list.item(i); + String id = n.getAttributes().getNamedItem("id").getNodeValue(); + java.net.URL u = Arch.class.getResource("Arch-default-" + id + ".xsl"); + if (u != null) { + log("Found default answer to " + id + " question", Project.MSG_VERBOSE); + Node defaultAnswer = findDefaultAnswer(n); + if (defaultAnswer != null && + "none".equals(defaultAnswer.getAttributes().getNamedItem("generate").getNodeValue()) + ) { + log("Skipping answer as there is here")); + para.appendChild(q.createElement("br")); + para.appendChild(res.getNode()); + n.appendChild(para); + } + } + } + + + qSource = new DOMSource(q); + } // apply the transform operation try { @@ -352,11 +434,16 @@ //w.write("\n\n\n"); - w.write(" \n

    \n XXX no answer for " + s + "\n

    \n
    \n\n"); + + java.net.URL u = Arch.class.getResource("Arch-default-" + s + ".xsl"); + if (u != null) { + // there is default answer + w.write(" \n \n \n\n"); + } else { + w.write(" \n

    \n XXX no answer for " + s + "\n

    \n
    \n\n"); + } } } @@ -469,5 +556,19 @@ throw (IOException)new IOException(x.toString()).initCause(x); } } - + + private static Node findDefaultAnswer(Node n) { + if (n.getNodeName().equals ("defaultanswer")) { + return n; + } + + NodeList arr = n.getChildNodes(); + for (int i = 0; i < arr.getLength(); i++) { + Node found = findDefaultAnswer(arr.item(i)); + if (found != null) { + return found; + } + } + return null; + } } Index: nbbuild/antsrc/org/netbeans/nbbuild/Arch.xsl =================================================================== RCS file: /cvs/nbbuild/antsrc/org/netbeans/nbbuild/Arch.xsl,v retrieving revision 1.25 diff -u -r1.25 Arch.xsl --- nbbuild/antsrc/org/netbeans/nbbuild/Arch.xsl 10 Jul 2005 13:41:36 -0000 1.25 +++ nbbuild/antsrc/org/netbeans/nbbuild/Arch.xsl 12 Jul 2005 17:58:14 -0000 @@ -167,12 +167,18 @@ + - + + Index: nbbuild/javadoctools/exportOverview.xsl =================================================================== RCS file: /cvs/nbbuild/javadoctools/exportOverview.xsl,v retrieving revision 1.2 diff -u -r1.2 exportOverview.xsl --- nbbuild/javadoctools/exportOverview.xsl 12 Jul 2005 10:50:12 -0000 1.2 +++ nbbuild/javadoctools/exportOverview.xsl 12 Jul 2005 17:58:14 -0000 @@ -62,14 +62,19 @@

    Dependencies

    -
    What do other modules need to do to declare a dependency on this one?
    - + +
    What do other modules need to do to declare a dependency on this one?
    + +
    -
    Other dependencies
    - - PENDING: Need project.xml to list what projects this one depends on from project.xml & - arch.xml and - other imported interfaces from arch.xml +
    This module depends on following projects
    + + + + + + + Index: nbbuild/javadoctools/template.xml =================================================================== RCS file: /cvs/nbbuild/javadoctools/template.xml,v retrieving revision 1.49 diff -u -r1.49 template.xml --- nbbuild/javadoctools/template.xml 12 Jul 2005 10:50:12 -0000 1.49 +++ nbbuild/javadoctools/template.xml 12 Jul 2005 17:58:14 -0000 @@ -129,7 +129,7 @@ - + @@ -362,7 +368,7 @@ - + Index: nbbuild/templates/projectized.xml =================================================================== RCS file: /cvs/nbbuild/templates/projectized.xml,v retrieving revision 1.56 diff -u -r1.56 projectized.xml --- nbbuild/templates/projectized.xml 30 Jun 2005 06:50:18 -0000 1.56 +++ nbbuild/templates/projectized.xml 12 Jul 2005 17:58:14 -0000 @@ -80,6 +80,7 @@ + Index: nbbuild/test/unit/src/org/netbeans/nbbuild/ArchQuestionsTest.java =================================================================== RCS file: /cvs/nbbuild/test/unit/src/org/netbeans/nbbuild/ArchQuestionsTest.java,v retrieving revision 1.3 diff -u -r1.3 ArchQuestionsTest.java --- nbbuild/test/unit/src/org/netbeans/nbbuild/ArchQuestionsTest.java 12 Jul 2005 10:50:12 -0000 1.3 +++ nbbuild/test/unit/src/org/netbeans/nbbuild/ArchQuestionsTest.java 12 Jul 2005 17:58:14 -0000 @@ -21,6 +21,7 @@ import junit.framework.*; import org.netbeans.junit.*; +import org.w3c.dom.Document; /** Check the behaviour Arch task. @@ -52,6 +53,49 @@ assertTrue ("File is generated", answers.exists ()); } + + public void testGenerateArchFileWhenEmptyWithDefaultAnswerForNbDepsQuestion() throws Exception { + java.io.File answers = PublicPackagesInProjectizedXMLTest.extractString (""); + answers.delete (); + assertFalse ("Really deleted", answers.exists ()); + + java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( + "" + + "" + + " " + + " " + + "" + + " " + + "" + + "" + + ); + PublicPackagesInProjectizedXMLTest.execute (f, new String[] { }); + + assertTrue ("File is generated", answers.exists ()); + + String res = PublicPackagesInProjectizedXMLTest.readFile(answers); + + org.w3c.dom.Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(answers); + + org.w3c.dom.NodeList list = dom.getElementsByTagName("defaultanswer"); + assertTrue("There is at least one defaultanswer: " + res, list.getLength() > 0); + for (int i = 0; i < list.getLength(); i++) { + org.w3c.dom.Node n = list.item(i); + while (n != null) { + n = n.getParentNode(); + if (n.getNodeName().equals ("answer")) { + String id = n.getAttributes().getNamedItem("id").getNodeValue(); + if (id.equals ("dep-nb")) { + // ok, we were searching for answer to dep-nb question + return; + } + } + } + } + + fail ("dep-nb question should have a defaultanswer: " + res); + } public void testDoNotCorruptTheFileWhenItExists() throws Exception { java.io.File answers = PublicPackagesInProjectizedXMLTest.extractString ( @@ -315,6 +359,247 @@ list = dom.getElementsByTagName("change"); assertEquals("Two change elements:\n" + txt, 2, list.getLength()); + } + + + public void testReadNbDepsFromProjectXML() throws Exception { + String[] txt = new String[1]; + Document dom = doReadNbDepsFromProjectXML("", txt); + + + org.w3c.dom.NodeList list; + list = dom.getElementsByTagName("api"); + assertTrue("There is more than one api tag: " + txt[0], list.getLength() > 0); + + for (int i = 0; i < list.getLength(); i++) { + org.w3c.dom.Node n = list.item(i); + + assertEquals ("group is java", "java", n.getAttributes().getNamedItem("group").getNodeValue()); + assertEquals ("type is import", "import", n.getAttributes().getNamedItem("type").getNodeValue()); + } + } + + + public void testReadNbDepsFromProjectXMLWhenDefaultAnswerRequested() throws Exception { + String[] txt = new String[1]; + Document dom = doReadNbDepsFromProjectXML(" ", txt); + + + org.w3c.dom.NodeList list; + list = dom.getElementsByTagName("api"); + assertTrue("There is more than one api tag: " + txt[0], list.getLength() > 0); + + for (int i = 0; i < list.getLength(); i++) { + org.w3c.dom.Node n = list.item(i); + + assertEquals ("group is java", "java", n.getAttributes().getNamedItem("group").getNodeValue()); + assertEquals ("type is import", "import", n.getAttributes().getNamedItem("type").getNodeValue()); + } + + assertEquals("Warnings are not included if defaultanswer is present: " + txt[0], -1, txt[0].indexOf("Default answer to this question")); + } + + public void testReadNbDepsFromProjectXMLWhenDefaultAnswerProhibited () throws Exception { + String[] txt = new String[1]; + Document dom = doReadNbDepsFromProjectXML(" ", txt); + + + org.w3c.dom.NodeList list; + list = dom.getElementsByTagName("api"); + + assertEquals("There is no api tag", 0, list.getLength()); + } + + private Document doReadNbDepsFromProjectXML(String inlinedCode, String[] txt) throws Exception { + java.io.File answers = PublicPackagesInProjectizedXMLTest.extractString ( +"\n" + +"\n" + + // "\n" + + //"]>\n" + +"\n" + +"\n" + +"\n" + + // "&api-questions;\n" + + // replaced by part of api-questions entity +"\n" + + "\n" + + "\n" + + "What other nb project this one depends on?\n" + + "\n" + + "Please provide here a few lines describing the project, \n" + + "what problem it should solve, provide links to documentation, \n" + + "specifications, etc.\n" + + "\n" + + "\n" + + "\n" + +" \n" + +// end of Arch-api-questionx.xmls +"\n" + +"\n" + +"\n" + +"The Input/Output API is a small API module\n" + +"which contains InputOutput and related interfaces used in\n" + +"driving the Output Window. The normal implementation is org.netbeans.core.output2.\n" + + inlinedCode + "\n" + +"\n" + +"\n" + +" \n" + ); + + java.io.File project = PublicPackagesInProjectizedXMLTest.extractString( +"\n" + +"\n" + +"\n" + + "org.netbeans.modules.apisupport.project\n" + + "\n" + + "\n" + + "org.openide.loaders\n" + + "\n" + + "\n" + + "org.openide.util\n" + + "\n" + + "\n" + + "\n" + + "6.2\n" + + "\n" + + "\n" + + "\n" + + "org.openide.filesystems\n" + + "\n" + + "\n" + + "\n" + + "6.2\n" + + "\n" + + "\n" + + "\n" + + "org.openide.nodes\n" + + "\n" + + "\n" + + "\n" + + "6.2\n" + + "\n" + + "\n" + + "\n" + + "org.openide.dialogs\n" + + "\n" + + "\n" + + "\n" + + "6.2\n" + + "\n" + + "\n" + + "\n" + + "org.openide.modules\n" + + "\n" + + "\n" + + "\n" + + "6.2\n" + + "\n" + + "\n" + + "\n" + + "org.openide.awt\n" + + "\n" + + "\n" + + "\n" + + "6.2\n" + + "\n" + + "\n" + + "\n" + + "org.openide.explorer\n" + + "\n" + + "\n" + + "\n" + + "6.2\n" + + "\n" + + "\n" + + "\n" + + "org.openide.actions\n" + + "\n" + + "\n" + + "\n" + + "6.2\n" + + "\n" + + "\n" + + "\n" + + "org.openide.text\n" + + "\n" + + "\n" + + "\n" + + "6.2\n" + + "\n" + + "\n" + + "\n" + + "org.openide.windows\n" + + "\n" + + "\n" + + "\n" + + "6.2\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "org.openide.awt\n" + + "org.openide.actions\n" + + "org.openide.loaders\n" + + "org.openide.text\n" + + "\n" + + "\n" + + "\n" + +"\n" + +""); + + + java.io.File output = PublicPackagesInProjectizedXMLTest.extractString(""); + assertTrue("File can be deleted: " + output, output.delete()); + + java.io.File xsl = PublicPackagesInProjectizedXMLTest.extractString( +"\n" + +"\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + +" \n" + ); + + java.io.File f = PublicPackagesInProjectizedXMLTest.extractString ( + "" + + "" + + " " + + " \n" + + "" + + " " + + "" + + "" + + ); + PublicPackagesInProjectizedXMLTest.execute (f, new String[] { + "-Darch.private.disable.validation.for.test.purposes=true", + }); + + assertTrue ("Answers still exists", answers.exists ()); + assertTrue ("Output file generated", output.exists ()); + + txt[0] = PublicPackagesInProjectizedXMLTest.readFile(output); + + org.w3c.dom.Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(output); + return dom; } } Index: editor/build.xml =================================================================== RCS file: /cvs/editor/build.xml,v retrieving revision 1.57 diff -u -r1.57 build.xml --- editor/build.xml 25 Apr 2005 12:44:26 -0000 1.57 +++ editor/build.xml 12 Jul 2005 17:58:14 -0000 @@ -33,6 +33,7 @@ +