Index: apichanges.xml =================================================================== RCS file: apichanges.xml diff -N apichanges.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ apichanges.xml 1 Nov 2005 10:07:31 -0000 @@ -0,0 +1,136 @@ + + + + + + + + + + + + + General + + + + + + + + + Method getDefaultAntScript added + + + + + +

+ Method org.netbeans.modules.ant.freeform.spi.support.Util.getDefaultAntScript added. +

+
+ 67207 +
+ + + Declare SPI packages for friends only + + + + + Only permitted clients can now use this SPI, and they were all updated. + + +

+ Use of this SPI was restricted to known client modules. +

+
+
+ +
+ + + + + + + Change History for the Ant Freeform SPI + + + + + + +

Introduction

+ +

This document lists changes made to the Ant Freeform SPI.

+ + +
+ + +

@FOOTER@

+ + +
+ +
Index: manifest.mf =================================================================== RCS file: /cvs/ant/freeform/manifest.mf,v retrieving revision 1.9 diff -u -r1.9 manifest.mf --- manifest.mf 24 Sep 2005 00:36:52 -0000 1.9 +++ manifest.mf 1 Nov 2005 10:07:31 -0000 @@ -1,5 +1,5 @@ Manifest-Version: 1.0 -OpenIDE-Module: org.netbeans.modules.ant.freeform -OpenIDE-Module-Specification-Version: 1.7 +OpenIDE-Module: org.netbeans.modules.ant.freeform/1 +OpenIDE-Module-Specification-Version: 1.9 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/ant/freeform/Bundle.properties Index: src/org/netbeans/modules/ant/freeform/FreeformProject.java =================================================================== RCS file: /cvs/ant/freeform/src/org/netbeans/modules/ant/freeform/FreeformProject.java,v retrieving revision 1.37 diff -u -r1.37 FreeformProject.java --- src/org/netbeans/modules/ant/freeform/FreeformProject.java 12 Oct 2005 11:47:54 -0000 1.37 +++ src/org/netbeans/modules/ant/freeform/FreeformProject.java 1 Nov 2005 10:07:31 -0000 @@ -85,6 +85,7 @@ new LookupMergerImpl(), // LookupMerger new FreeformProjectOperations(this), new FreeformSharabilityQuery(helper()), //SharabilityQueryImplementation + this, //FreeformProject }); return new FreeformLookup(baseLookup, this, helper, eval, aux); } Index: src/org/netbeans/modules/ant/freeform/spi/support/Util.java =================================================================== RCS file: /cvs/ant/freeform/src/org/netbeans/modules/ant/freeform/spi/support/Util.java,v retrieving revision 1.3 diff -u -r1.3 Util.java --- src/org/netbeans/modules/ant/freeform/spi/support/Util.java 25 Mar 2005 11:06:46 -0000 1.3 +++ src/org/netbeans/modules/ant/freeform/spi/support/Util.java 1 Nov 2005 10:07:31 -0000 @@ -17,17 +17,24 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectManager; +import org.netbeans.api.project.ProjectUtils; import org.netbeans.api.queries.CollocationQuery; +import org.netbeans.modules.ant.freeform.FreeformProject; +import org.netbeans.modules.ant.freeform.FreeformProjectGenerator; +import org.netbeans.modules.ant.freeform.FreeformProjectType; import org.netbeans.modules.ant.freeform.spi.ProjectConstants; import org.netbeans.spi.project.AuxiliaryConfiguration; import org.netbeans.spi.project.support.ant.AntProjectHelper; import org.netbeans.spi.project.support.ant.PropertyEvaluator; import org.netbeans.spi.project.support.ant.PropertyUtils; import org.openide.ErrorManager; +import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -219,6 +226,26 @@ } } parent.insertBefore(el, insertBefore); + } + + /**Get the "default" (user-specified) ant script for the given freeform project. + * Please note that this method may return 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)); + } + }