+ Method org.netbeans.modules.ant.freeform.spi.support.Util.getDefaultAntScript added. +
++ Use of this SPI was restricted to known client modules. +
+This document lists changes made to the Ant Freeform SPI.
+ + +@FOOTER@
+ + +null
if there is no such script.
+ *
+ * WARNING: This method is there only for a limited set of usecases like the profiler plugin.
+ * It should not be used by the freeform project natures.
+ *
+ * @param prj the freeform project
+ * @return the "default" ant script or null
if there is no such a script
+ * @throws IllegalArgumentException if the passed project is not a freeform project.
+ */
+ public static FileObject getDefaultAntScript(Project prj) throws IllegalArgumentException {
+ FreeformProject fp = (FreeformProject) prj.getLookup().lookup(FreeformProject.class);
+
+ if (fp == null) {
+ throw new IllegalArgumentException("Only FreeformProjects are supported.");
+ }
+
+ return FreeformProjectGenerator.getAntScript(fp.helper(), fp.evaluator());
}
}
Index: test/unit/src/org/netbeans/modules/ant/freeform/TestBase.java
===================================================================
RCS file: /cvs/ant/freeform/test/unit/src/org/netbeans/modules/ant/freeform/TestBase.java,v
retrieving revision 1.12
diff -u -r1.12 TestBase.java
--- test/unit/src/org/netbeans/modules/ant/freeform/TestBase.java 30 Jun 2005 09:20:53 -0000 1.12
+++ test/unit/src/org/netbeans/modules/ant/freeform/TestBase.java 1 Nov 2005 10:07:31 -0000
@@ -54,6 +54,7 @@
protected FreeformProject simple2;
protected FreeformProject extsrcroot;
protected FreeformProject extbuildroot;
+ protected FreeformProject extbuildscript;
protected FileObject myAppJava;
protected FileObject specialTaskJava;
protected FileObject buildProperties;
@@ -89,6 +90,11 @@
Project _extbuildroot = ProjectManager.getDefault().findProject(projdir);
assertNotNull("have a project", _extbuildroot);
extbuildroot = (FreeformProject) _extbuildroot;
+ projdir = egdirFO.getFileObject("extbuildscript");
+ assertNotNull("found projdir", projdir);
+ Project _extbuildscript = ProjectManager.getDefault().findProject(projdir);
+ assertNotNull("have a project", _extbuildscript);
+ extbuildscript = (FreeformProject) _extbuildscript;
datadir = FileUtil.normalizeFile(getDataDir());
assertTrue("data dir exists", datadir.exists());
}
Index: test/unit/src/org/netbeans/modules/ant/freeform/spi/support/UtilTest.java
===================================================================
RCS file: /cvs/ant/freeform/test/unit/src/org/netbeans/modules/ant/freeform/spi/support/UtilTest.java,v
retrieving revision 1.4
diff -u -r1.4 UtilTest.java
--- test/unit/src/org/netbeans/modules/ant/freeform/spi/support/UtilTest.java 14 Apr 2005 15:15:56 -0000 1.4
+++ test/unit/src/org/netbeans/modules/ant/freeform/spi/support/UtilTest.java 1 Nov 2005 10:07:31 -0000
@@ -16,8 +16,8 @@
import java.io.File;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager;
-import org.netbeans.junit.NbTestCase;
import org.netbeans.modules.ant.freeform.FreeformProjectGenerator;
+import org.netbeans.modules.ant.freeform.TestBase;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.openide.filesystems.FileObject;
@@ -26,13 +26,14 @@
/**
* @author David Konecny
*/
-public class UtilTest extends NbTestCase {
+public class UtilTest extends TestBase {
public UtilTest(String name) {
super(name);
}
protected void setUp() throws Exception {
+ super.setUp();
clearWorkDir();
}
@@ -63,4 +64,10 @@
assertEquals("${project.dir}", Util.relativizeLocation(srcApp, projApp, srcApp));
}
+ public void testGetDefaultAntScript() throws Exception {
+ assertNull("no default ant script", Util.getDefaultAntScript(extsrcroot));
+ assertEquals("found build.xml", simple.getProjectDirectory().getFileObject("build.xml"), Util.getDefaultAntScript(simple));
+ assertEquals("found build.xml", extbuildscript.getProjectDirectory().getFileObject("scripts/build.xml"), Util.getDefaultAntScript(extbuildscript));
+ }
+
}