Index: j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java =================================================================== RCS file: /cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java,v retrieving revision 1.60 diff -u -r1.60 J2SEProject.java --- j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java 4 Jan 2006 17:48:38 -0000 1.60 +++ j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java 3 May 2006 14:34:54 -0000 @@ -28,6 +28,7 @@ import org.netbeans.api.project.ant.AntArtifact; import org.netbeans.modules.java.j2seproject.classpath.ClassPathProviderImpl; import org.netbeans.modules.java.j2seproject.classpath.J2SEProjectClassPathExtender; +import org.netbeans.modules.java.j2seproject.classpath.J2SEProjectClassPathModifier; import org.netbeans.modules.java.j2seproject.queries.CompiledSourceForBinaryQuery; import org.netbeans.modules.java.j2seproject.queries.JavadocForBinaryQueryImpl; import org.netbeans.modules.java.j2seproject.queries.SourceLevelQueryImpl; @@ -144,6 +145,7 @@ private Lookup createLookup(AuxiliaryConfiguration aux) { SubprojectProvider spp = refHelper.createSubprojectProvider(); + final J2SEProjectClassPathModifier cpMod = new J2SEProjectClassPathModifier(this, this.updateHelper, eval, refHelper); return Lookups.fixed(new Object[] { new Info(), aux, @@ -165,7 +167,8 @@ new J2SESharabilityQuery (this.helper, evaluator(), getSourceRoots(), getTestSourceRoots()), //Does not use APH to get/put properties/cfgdata new J2SEFileBuiltQuery (this.helper, evaluator(),getSourceRoots(),getTestSourceRoots()), //Does not use APH to get/put properties/cfgdata new RecommendedTemplatesImpl (this.updateHelper), - new J2SEProjectClassPathExtender(this, this.updateHelper, eval,refHelper), + new J2SEProjectClassPathExtender(cpMod), + cpMod, this, // never cast an externally obtained Project to J2SEProject - use lookup instead new J2SEProjectOperations(this), new J2SEProjectWebServicesSupportProvider() Index: j2seproject/src/org/netbeans/modules/java/j2seproject/classpath/ClassPathProviderImpl.java =================================================================== RCS file: /cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/classpath/ClassPathProviderImpl.java,v retrieving revision 1.17 diff -u -r1.17 ClassPathProviderImpl.java --- j2seproject/src/org/netbeans/modules/java/j2seproject/classpath/ClassPathProviderImpl.java 23 Nov 2005 11:00:04 -0000 1.17 +++ j2seproject/src/org/netbeans/modules/java/j2seproject/classpath/ClassPathProviderImpl.java 3 May 2006 14:34:55 -0000 @@ -19,6 +19,7 @@ import java.util.HashMap; import org.netbeans.api.java.classpath.ClassPath; +import org.netbeans.api.project.SourceGroup; import org.netbeans.spi.java.classpath.ClassPathFactory; import org.netbeans.spi.java.classpath.ClassPathProvider; import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport; @@ -38,6 +39,12 @@ private static final String DIST_JAR = "dist.jar"; // NOI18N private static final String BUILD_TEST_CLASSES_DIR = "build.test.classes.dir"; // NOI18N + private static final String JAVAC_CLASSPATH = "javac.classpath"; //NOI18N + private static final String JAVAC_TEST_CLASSPATH = "javac.test.classpath"; //NOI18N + private static final String RUN_CLASSPATH = "run.classpath"; //NOI18N + private static final String RUN_TEST_CLASSPATH = "run.test.classpath"; //NOI18N + + private final AntProjectHelper helper; private final File projectDirectory; private final PropertyEvaluator evaluator; @@ -149,12 +156,12 @@ if (type == 0) { cp = ClassPathFactory.createClassPath( ProjectClassPathSupport.createPropertyBasedClassPathImplementation( - projectDirectory, evaluator, new String[] {"javac.classpath"})); // NOI18N + projectDirectory, evaluator, new String[] {JAVAC_CLASSPATH})); // NOI18N } else { cp = ClassPathFactory.createClassPath( ProjectClassPathSupport.createPropertyBasedClassPathImplementation( - projectDirectory, evaluator, new String[] {"javac.test.classpath"})); // NOI18N + projectDirectory, evaluator, new String[] {JAVAC_TEST_CLASSPATH})); // NOI18N } cache[2+type] = cp; } @@ -177,12 +184,12 @@ if (type == 0) { cp = ClassPathFactory.createClassPath( ProjectClassPathSupport.createPropertyBasedClassPathImplementation( - projectDirectory, evaluator, new String[] {"run.classpath"})); // NOI18N + projectDirectory, evaluator, new String[] {RUN_CLASSPATH})); // NOI18N } else if (type == 1) { cp = ClassPathFactory.createClassPath( ProjectClassPathSupport.createPropertyBasedClassPathImplementation( - projectDirectory, evaluator, new String[] {"run.test.classpath"})); // NOI18N + projectDirectory, evaluator, new String[] {RUN_TEST_CLASSPATH})); // NOI18N } else if (type == 2) { //Only to make the CompiledDataNode hapy @@ -269,6 +276,39 @@ public synchronized void propertyChange(PropertyChangeEvent evt) { dirCache.remove(evt.getPropertyName()); + } + + public String getPropertyName (SourceGroup sg, String classPathId) { + FileObject root = sg.getRootFolder(); + FileObject[] path = getPrimarySrcPath(); + for (int i=0; i + + + New ProjectClassPathModifier SPI for modification of project's classpath + + + + + + The new SPI interface ProjectClassPathModifier was created to allow extension modules to + add or remove classpath elements (archive files, folders, libraries, subprojects) from the + project's classpath. + + + + + + + Semantic changes in the BrokenReferencesModel.updateReference behavior Index: project/manifest.mf =================================================================== RCS file: /cvs/java/project/manifest.mf,v retrieving revision 1.18 diff -u -r1.18 manifest.mf --- project/manifest.mf 12 Dec 2005 15:40:01 -0000 1.18 +++ project/manifest.mf 3 May 2006 14:34:56 -0000 @@ -2,6 +2,6 @@ OpenIDE-Module: org.netbeans.modules.java.project/1 OpenIDE-Module-Layer: org/netbeans/modules/java/project/layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/project/Bundle.properties -OpenIDE-Module-Specification-Version: 1.9 +OpenIDE-Module-Specification-Version: 1.10 OpenIDE-Module-Requires: org.netbeans.modules.project.uiapi.ActionsFactory Index: project/nbproject/project.properties =================================================================== RCS file: /cvs/java/project/nbproject/project.properties,v retrieving revision 1.20 diff -u -r1.20 project.properties --- project/nbproject/project.properties 17 Apr 2006 15:48:42 -0000 1.20 +++ project/nbproject/project.properties 3 May 2006 14:34:56 -0000 @@ -11,6 +11,7 @@ is.autoload=true +javac.source=1.5 javadoc.title=Java Project API javadoc.overview=${basedir}/overview.html javadoc.arch=${basedir}/arch.xml Index: project/src/org/netbeans/spi/java/project/classpath/ProjectClassPathExtender.java =================================================================== RCS file: /cvs/java/project/src/org/netbeans/spi/java/project/classpath/ProjectClassPathExtender.java,v retrieving revision 1.3 diff -u -r1.3 ProjectClassPathExtender.java --- project/src/org/netbeans/spi/java/project/classpath/ProjectClassPathExtender.java 12 Jul 2005 04:06:10 -0000 1.3 +++ project/src/org/netbeans/spi/java/project/classpath/ProjectClassPathExtender.java 3 May 2006 14:34:56 -0000 @@ -24,9 +24,10 @@ * A project can provide this interface in its {@link org.netbeans.api.project.Project#getLookup lookup} to * allow clients to extend its compilation classpath * by a new classpath element (JAR, folder, dependent project, or library). - * @since org.netbeans.modules.java.project/1 1.3 + * @since org.netbeans.modules.java.project/1 1.3 + * @deprecated Please use the {@link ProjectClassPathModifier} instead. */ -public interface ProjectClassPathExtender { +public @Deprecated interface ProjectClassPathExtender { /** * Adds a library into the project's compile classpath if the @@ -34,6 +35,7 @@ * @param library to be added * @return true in case the classpath was changed * @exception IOException in case the project metadata cannot be changed + * @deprecated Please use {@link ProjectClassPathModifier#addLibrary} instead. */ boolean addLibrary(Library library) throws IOException; @@ -43,6 +45,7 @@ * @param archiveFile ZIP/JAR file to be added * @return true in case the classpath was changed * @exception IOException in case the project metadata cannot be changed + * @deprecated Please use {@link ProjectClassPathModifier#addArchive} instead. */ boolean addArchiveFile(FileObject archiveFile) throws IOException; @@ -54,6 +57,7 @@ * (must be owned by the artifact and be relative to it) * @return true in case the classpath was changed * @exception IOException in case the project metadata cannot be changed + * @deprecated Please use {@link ProjectClassPathModifier#addAntArtifact} instead. */ boolean addAntArtifact(AntArtifact artifact, URI artifactElement) throws IOException; Index: project/src/org/netbeans/spi/java/project/classpath/ProjectClassPathModifier.java =================================================================== RCS file: project/src/org/netbeans/spi/java/project/classpath/ProjectClassPathModifier.java diff -N project/src/org/netbeans/spi/java/project/classpath/ProjectClassPathModifier.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ project/src/org/netbeans/spi/java/project/classpath/ProjectClassPathModifier.java 3 May 2006 14:34:56 -0000 @@ -0,0 +1,128 @@ +/* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.netbeans.spi.java.project.classpath; + +import java.io.IOException; +import java.net.URI; +import java.net.URL; +import org.netbeans.api.project.SourceGroup; +import org.netbeans.api.project.ant.AntArtifact; +import org.netbeans.api.project.libraries.Library; +import org.openide.filesystems.FileObject; + +/** + * Interface for project's classpaths modification. + * A project can provide this interface in its {@link org.netbeans.api.project.Project#getLookup lookup} to + * allow clients to add or remove new classpath elements (JAR, folder, dependent project, or library) to its + * classpaths. + * @since org.netbeans.modules.java.project/1 1.10 + */ +public interface ProjectClassPathModifier { + + /** + * Adds a library into the project's classpath if the + * library is not already included. + * @param library to be added + * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA} + * identifying the compilation unit to change + * @param classPathId the id of the classpath the library should be added to, + * eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE} + * @return true in case the classpath was changed + * @exception IOException in case the project metadata cannot be changed + * @exception UnsupportedOperationException is thrown when the project does not support + * adding of a library to the classpath of the given id. + */ + boolean addLibrary (Library library, SourceGroup sourceGroup, String classPathId) throws IOException, UnsupportedOperationException; + + + /** + * Removes a library from the project's classpath if the + * library is included on it. + * @param library to be removed + * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA} + * identifying the compilation unit to change + * @param classPathId the id of the classpath the library should be removed from, + * eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE} + * @return true in case the classpath was changed + * @exception IOException in case the project metadata cannot be changed + * @exception UnsupportedOperationException is thrown when the project does not support + * removing of a library from the classpath of the given id. + */ + boolean removeLibrary (Library library, SourceGroup sourceGroup, String classPathId) throws IOException, UnsupportedOperationException; + + /** + * Adds an archive file or folder into the project's classpath if the + * entry is not already there. + * @param classPathRoot root to be added, either root of an archive or folder + * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA} + * identifying the compilation unit to change + * @param classPathId the id of the classpath the root should be added to, + * eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE} + * @return true in case the classpath was changed + * @exception IOException in case the project metadata cannot be changed + * @exception UnsupportedOperationException is thrown when the project does not support + * adding of a root to the classpath of the given id. + */ + boolean addRoot (URL classPathRoot, SourceGroup sourceGroup, String classPathId) throws IOException, UnsupportedOperationException; + + /** + * Removes an archive file or folder from the project's classpath if the + * entry is included on it. + * @param classPathRoot root to be removed, either root of an archive or folder + * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA} + * identifying the compilation unit to change + * @param classPathId the id of the classpath the root should be removed from, + * eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE} + * @return true in case the classpath was changed + * @exception IOException in case the project metadata cannot be changed + * @exception UnsupportedOperationException is thrown when the project does not support + * removing of a root from the classpath of the given id. + */ + boolean removeRoot (URL classPathRoot, SourceGroup sourceGroup, String classPathId) throws IOException, UnsupportedOperationException; + + /** + * Adds an artifact (e.g. subproject) into project's classpath if the + * artifact is not already on it. + * @param artifact to be added + * @param artifactElement the URI of the build output + * (must be owned by the artifact and be relative to it) + * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA} + * identifying the compilation unit to change + * @param classPathId the id of the classpath the artifact should be added to, + * eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE} + * @return true in case the classpath was changed + * @exception IOException in case the project metadata cannot be changed + * @exception UnsupportedOperationException is thrown when the project does not support + * adding of an artifact to the classpath of the given id. + */ + boolean addAntArtifact (AntArtifact artifact, URI artifactElement, SourceGroup sourceGroup, String classPathId) throws IOException, UnsupportedOperationException; + + /** + * Removes an artifact (e.g. subproject) from project's classpath if the + * artifact is not already on it. + * @param artifact to be added + * @param artifactElement the URI of the build output + * (must be owned by the artifact and be relative to it) + * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA} + * identifying the compilation unit to change + * @param classPathId the id of the classpath the artifact should be removed from, + * eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE} + * @return true in case the classpath was changed + * @exception IOException in case the project metadata cannot be changed + * @exception UnsupportedOperationException is thrown when the project does not support + * removing of an artifact from the classpath of the given id. + */ + boolean removeAntArtifact (AntArtifact artifact, URI artifactElement, SourceGroup sourceGroup, String classPathId) throws IOException, UnsupportedOperationException; + +}