diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientProject.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientProject.java --- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientProject.java +++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientProject.java @@ -70,6 +70,7 @@ import org.netbeans.api.project.ant.AntBuildExtender; import org.netbeans.modules.j2ee.api.ejbjar.Car; import org.netbeans.modules.j2ee.clientproject.classpath.ClassPathSupportCallbackImpl; +import org.netbeans.modules.j2ee.clientproject.classpath.DelagatingProjectClassPathModifierImpl; import org.netbeans.modules.j2ee.clientproject.ui.AppClientLogicalViewProvider; import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties; import org.netbeans.modules.j2ee.clientproject.ui.customizer.CustomizerProviderImpl; @@ -175,7 +176,7 @@ private final Car apiJar; private JarContainerImpl enterpriseResourceSupport; private FileObject libFolder; - private final ClassPathModifier cpMod; + private final DelagatingProjectClassPathModifierImpl cpMod; private final ClassPathProviderImpl cpProvider; private ClassPathUiSupport.Callback classPathUiSupportCallback; private final AppClientCompilationClassPathModifierImpl libMod; @@ -217,9 +218,10 @@ appClient = new AppClientProvider(this, helper, cpProvider); apiJar = CarFactory.createCar(new CarImpl2(appClient)); enterpriseResourceSupport = new JarContainerImpl(this, refHelper, helper); - cpMod = new ClassPathModifier(this, this.updateHelper, eval, refHelper, + ClassPathModifier cpModPrevious = new ClassPathModifier(this, this.updateHelper, eval, refHelper, new ClassPathSupportCallbackImpl(helper), createClassPathModifierCallback(), getClassPathUiSupportCallback()); + cpMod = new DelagatingProjectClassPathModifierImpl(cpModPrevious, libMod); lookup = createLookup(aux, cpProvider); } @@ -452,7 +454,7 @@ if (fo.getParent ().equals (libFolder)) { try { - cpMod.addRoots(new URL[] {FileUtil.getArchiveRoot(fo.getURL())}, ProjectProperties.JAVAC_CLASSPATH); + cpMod.getClassPathModifier().addRoots(new URL[] {FileUtil.getArchiveRoot(fo.getURL())}, ProjectProperties.JAVAC_CLASSPATH); } catch (IOException e) { Exceptions.printStackTrace(e); } @@ -588,7 +590,7 @@ libs.add(FileUtil.getArchiveRoot(children[i].getURL())); } } - cpMod.addRoots(libs.toArray(new URL[libs.size()]), ProjectProperties.JAVAC_CLASSPATH); + cpMod.getClassPathModifier().addRoots(libs.toArray(new URL[libs.size()]), ProjectProperties.JAVAC_CLASSPATH); libFolder.addFileChangeListener (AppClientProject.this); } diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/DelagatingProjectClassPathModifierImpl.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/DelagatingProjectClassPathModifierImpl.java new file mode 100644 --- /dev/null +++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/DelagatingProjectClassPathModifierImpl.java @@ -0,0 +1,152 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.j2ee.clientproject.classpath; + +import java.io.IOException; +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.netbeans.api.java.classpath.JavaClassPathConstants; +import org.netbeans.api.project.SourceGroup; +import org.netbeans.api.project.ant.AntArtifact; +import org.netbeans.api.project.libraries.Library; +import org.netbeans.modules.j2ee.clientproject.AppClientCompilationClassPathModifierImpl; +import org.netbeans.modules.java.api.common.classpath.ClassPathModifier; +import org.netbeans.modules.java.api.common.classpath.ClassPathSupport; +import org.netbeans.spi.java.project.classpath.ProjectClassPathModifierImplementation; + +/** + * In order to handle properly new COMPILE_ONLY classpath this class delegates + * handling of some classpath types to ClassPathModifier and handling of COMPILE_ONLY + * is delegated to AppClientCompilationClassPathModifierImpl. + */ +public class DelagatingProjectClassPathModifierImpl extends ProjectClassPathModifierImplementation { + + private final ClassPathModifier cpMod; + private final AppClientCompilationClassPathModifierImpl compileOnlyClassPathSupport; + + public DelagatingProjectClassPathModifierImpl(ClassPathModifier cpMod, + AppClientCompilationClassPathModifierImpl compileOnlyClassPathSupport) { + this.compileOnlyClassPathSupport = compileOnlyClassPathSupport; + this.cpMod = cpMod; + } + + @Override + protected SourceGroup[] getExtensibleSourceGroups() { + return cpMod.getExtensibleSourceGroups(); + } + + @Override + protected String[] getExtensibleClassPathTypes(SourceGroup sourceGroup) { + List res = new ArrayList(Arrays.asList(cpMod.getExtensibleClassPathTypes(sourceGroup))); + res.add(JavaClassPathConstants.COMPILE_ONLY); + return res.toArray(new String[res.size()]); + } + + @Override + protected boolean addLibraries(Library[] libraries, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException { + if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) { + return compileOnlyClassPathSupport.addCompileLibraries(libraries); + } else { + return cpMod.addLibraries(libraries, sourceGroup, type); + } + } + + @Override + protected boolean removeLibraries(Library[] libraries, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException { + if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) { + return compileOnlyClassPathSupport.removeCompileLibraries(libraries); + } else { + return cpMod.removeLibraries(libraries, sourceGroup, type); + } + } + + @Override + protected boolean addRoots(URL[] classPathRoots, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException { + if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) { + return compileOnlyClassPathSupport.addCompileRoots(classPathRoots); + } else { + return cpMod.addRoots(classPathRoots, sourceGroup, type); + } + } + + @Override + protected boolean removeRoots(URL[] classPathRoots, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException { + if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) { + return compileOnlyClassPathSupport.removeCompileRoots(classPathRoots); + } else { + return cpMod.removeRoots(classPathRoots, sourceGroup, type); + } + } + + @Override + protected boolean addAntArtifacts(AntArtifact[] artifacts, URI[] artifactElements, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException { + if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) { + return compileOnlyClassPathSupport.addCompileAntArtifacts(artifacts, artifactElements); + } else { + return cpMod.addAntArtifacts(artifacts, artifactElements, sourceGroup, type); + } + } + + @Override + protected boolean removeAntArtifacts(AntArtifact[] artifacts, URI[] artifactElements, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException { + if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) { + return compileOnlyClassPathSupport.removeCompileAntArtifacts(artifacts, artifactElements); + } else { + return cpMod.removeAntArtifacts(artifacts, artifactElements, sourceGroup, type); + } + } + + public ClassPathSupport getClassPathSupport() { + return cpMod.getClassPathSupport(); + } + + // TODO: remove + public ClassPathModifier getClassPathModifier() { + return cpMod; + } + + +} diff --git a/j2ee.common/src/org/netbeans/modules/j2ee/common/project/CompilationOnlyClassPathModifier.java b/j2ee.common/src/org/netbeans/modules/j2ee/common/project/CompilationOnlyClassPathModifier.java --- a/j2ee.common/src/org/netbeans/modules/j2ee/common/project/CompilationOnlyClassPathModifier.java +++ b/j2ee.common/src/org/netbeans/modules/j2ee/common/project/CompilationOnlyClassPathModifier.java @@ -57,6 +57,8 @@ * project's build artifact. * * @since org.netbeans.modules.j2ee.common/1 1.53 + * @deprecated use regular classpath modifier with classpath type + * JavaClassPathConstants.COMPILE_ONLY instead */ public interface CompilationOnlyClassPathModifier { diff --git a/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ClassPathModifier.java b/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ClassPathModifier.java --- a/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ClassPathModifier.java +++ b/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ClassPathModifier.java @@ -109,7 +109,8 @@ return s.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); } - protected String[] getExtensibleClassPathTypes (SourceGroup sg) { + @Override + public String[] getExtensibleClassPathTypes (SourceGroup sg) { return new String[] { ClassPath.COMPILE, ClassPath.EXECUTE, @@ -118,17 +119,19 @@ }; } - protected boolean removeRoots(final URL[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { + @Override + public boolean removeRoots(final URL[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { return removeRoots(convertURLsToURIs(classPathRoots), sourceGroup, type); } @Override - protected boolean removeRoots(final URI[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { + public boolean removeRoots(final URI[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { String classPathProperty = cpModifierCallback.getClassPathProperty(sourceGroup, type); return handleRoots (classPathRoots, classPathProperty, cpModifierCallback.getElementName(classPathProperty), REMOVE); } - protected boolean addRoots (final URL[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { + @Override + public boolean addRoots (final URL[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { return addRoots(convertURLsToURIs(classPathRoots), sourceGroup, type); } @@ -137,7 +140,7 @@ } @Override - protected boolean addRoots (final URI[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { + public boolean addRoots (final URI[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { return addRoots(classPathRoots, sourceGroup, type, ADD); } @@ -152,12 +155,14 @@ return ClassPathModifierSupport.handleRoots(project, updateHelper, cs, eval, refHelper, cpUiSupportCallback, classPathRoots, classPathProperty, projectXMLElementName, operation); } - protected boolean removeAntArtifacts(final AntArtifact[] artifacts, final URI[] artifactElements, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { + @Override + public boolean removeAntArtifacts(final AntArtifact[] artifacts, final URI[] artifactElements, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { String classPathProperty = cpModifierCallback.getClassPathProperty(sourceGroup, type); return handleAntArtifacts (artifacts, artifactElements, classPathProperty, cpModifierCallback.getElementName(classPathProperty), REMOVE); } - protected boolean addAntArtifacts(final AntArtifact[] artifacts, final URI[] artifactElements, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { + @Override + public boolean addAntArtifacts(final AntArtifact[] artifacts, final URI[] artifactElements, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { String classPathProperty = cpModifierCallback.getClassPathProperty(sourceGroup, type); return handleAntArtifacts (artifacts, artifactElements, classPathProperty, cpModifierCallback.getElementName(classPathProperty), ADD); } @@ -166,12 +171,14 @@ return ClassPathModifierSupport.handleAntArtifacts(project, updateHelper, cs, eval, refHelper, cpUiSupportCallback, artifacts, artifactElements, classPathProperty, projectXMLElementName, operation); } - protected boolean removeLibraries(final Library[] libraries, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { + @Override + public boolean removeLibraries(final Library[] libraries, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { String classPathProperty = cpModifierCallback.getClassPathProperty(sourceGroup, type); return handleLibraries (libraries, classPathProperty, cpModifierCallback.getElementName(classPathProperty), REMOVE); } - protected boolean addLibraries(final Library[] libraries, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { + @Override + public boolean addLibraries(final Library[] libraries, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException { String classPathProperty = cpModifierCallback.getClassPathProperty(sourceGroup, type); return handleLibraries (libraries, classPathProperty, cpModifierCallback.getElementName(classPathProperty), ADD); } diff --git a/web.project/src/org/netbeans/modules/web/project/WebProject.java b/web.project/src/org/netbeans/modules/web/project/WebProject.java --- a/web.project/src/org/netbeans/modules/web/project/WebProject.java +++ b/web.project/src/org/netbeans/modules/web/project/WebProject.java @@ -157,6 +157,7 @@ import org.netbeans.modules.web.api.webmodule.WebProjectConstants; import org.netbeans.modules.web.project.api.WebProjectUtilities; import org.netbeans.modules.web.project.classpath.ClassPathSupportCallbackImpl; +import org.netbeans.modules.web.project.classpath.DelagatingProjectClassPathModifierImpl; import org.netbeans.modules.web.project.classpath.WebProjectLibrariesModifierImpl; import org.netbeans.modules.web.project.spi.BrokenLibraryRefFilter; import org.netbeans.modules.web.project.spi.BrokenLibraryRefFilterProvider; @@ -223,7 +224,7 @@ private final UpdateHelper updateHelper; private final UpdateProjectImpl updateProject; private final AuxiliaryConfiguration aux; - private final ClassPathModifier cpMod; + private final DelagatingProjectClassPathModifierImpl cpMod; private final WebProjectLibrariesModifierImpl libMod; private final ClassPathProviderImpl cpProvider; private ClassPathUiSupport.Callback classPathUiSupportCallback; @@ -386,9 +387,10 @@ apiWebServicesClientSupport = WebServicesClientSupportFactory.createWebServicesClientSupport (webProjectWebServicesClientSupport); apiJAXWSClientSupport = JAXWSClientSupportFactory.createJAXWSClientSupport(jaxWsClientSupport); enterpriseResourceSupport = new WebContainerImpl(this, refHelper, helper); - cpMod = new ClassPathModifier(this, this.updateHelper, eval, refHelper, + ClassPathModifier cpModTemp = new ClassPathModifier(this, this.updateHelper, eval, refHelper, new ClassPathSupportCallbackImpl(helper), createClassPathModifierCallback(), getClassPathUiSupportCallback()); libMod = new WebProjectLibrariesModifierImpl(this, this.updateHelper, eval, refHelper); + cpMod = new DelagatingProjectClassPathModifierImpl(cpModTemp, libMod); lookup = createLookup(aux, cpProvider); css = new CopyOnSaveSupport(); artifactSupport = new ArtifactCopySupport(); @@ -403,7 +405,7 @@ this.projectPropertiesSave.set(value); } - public ClassPathModifier getClassPathModifier() { + public DelagatingProjectClassPathModifierImpl getClassPathModifier() { return cpMod; } diff --git a/web.project/src/org/netbeans/modules/web/project/api/WebProjectLibrariesModifier.java b/web.project/src/org/netbeans/modules/web/project/api/WebProjectLibrariesModifier.java --- a/web.project/src/org/netbeans/modules/web/project/api/WebProjectLibrariesModifier.java +++ b/web.project/src/org/netbeans/modules/web/project/api/WebProjectLibrariesModifier.java @@ -52,6 +52,9 @@ import org.netbeans.api.project.libraries.Library; import org.netbeans.modules.j2ee.common.project.CompilationOnlyClassPathModifier; +/** + * @deprecated use WebProjectLibrariesModifier2 instead of WebProjectLibrariesModifier + */ public interface WebProjectLibrariesModifier extends CompilationOnlyClassPathModifier { /** diff --git a/web.project/src/org/netbeans/modules/web/project/api/WebProjectLibrariesModifier.java b/web.project/src/org/netbeans/modules/web/project/api/WebProjectLibrariesModifier2.java copy from web.project/src/org/netbeans/modules/web/project/api/WebProjectLibrariesModifier.java copy to web.project/src/org/netbeans/modules/web/project/api/WebProjectLibrariesModifier2.java --- a/web.project/src/org/netbeans/modules/web/project/api/WebProjectLibrariesModifier.java +++ b/web.project/src/org/netbeans/modules/web/project/api/WebProjectLibrariesModifier2.java @@ -50,9 +50,8 @@ import org.netbeans.api.project.ant.AntArtifact; import org.netbeans.api.project.libraries.Library; -import org.netbeans.modules.j2ee.common.project.CompilationOnlyClassPathModifier; -public interface WebProjectLibrariesModifier extends CompilationOnlyClassPathModifier { +public interface WebProjectLibrariesModifier2 { /** * Adds libraries into the project. These libraries will not be added into the projects's classpath diff --git a/web.project/src/org/netbeans/modules/web/project/api/WebProjectUtilities.java b/web.project/src/org/netbeans/modules/web/project/api/WebProjectUtilities.java --- a/web.project/src/org/netbeans/modules/web/project/api/WebProjectUtilities.java +++ b/web.project/src/org/netbeans/modules/web/project/api/WebProjectUtilities.java @@ -580,7 +580,7 @@ libs.add(URLMapper.findURL(FileUtil.getArchiveRoot(children[i]), URLMapper.EXTERNAL)); } } - p.getClassPathModifier().addRoots(libs.toArray(new URL[libs.size()]), ProjectProperties.JAVAC_CLASSPATH); + p.getClassPathModifier().getClassPathModifier().addRoots(libs.toArray(new URL[libs.size()]), ProjectProperties.JAVAC_CLASSPATH); //do we really need to add the listener? commenting it out //libFolder.addFileChangeListener(p); } diff --git a/web.project/src/org/netbeans/modules/web/project/classpath/DelagatingProjectClassPathModifierImpl.java b/web.project/src/org/netbeans/modules/web/project/classpath/DelagatingProjectClassPathModifierImpl.java new file mode 100644 --- /dev/null +++ b/web.project/src/org/netbeans/modules/web/project/classpath/DelagatingProjectClassPathModifierImpl.java @@ -0,0 +1,151 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.web.project.classpath; + +import java.io.IOException; +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.netbeans.api.java.classpath.JavaClassPathConstants; +import org.netbeans.api.project.SourceGroup; +import org.netbeans.api.project.ant.AntArtifact; +import org.netbeans.api.project.libraries.Library; +import org.netbeans.modules.java.api.common.classpath.ClassPathModifier; +import org.netbeans.modules.java.api.common.classpath.ClassPathSupport; +import org.netbeans.spi.java.project.classpath.ProjectClassPathModifierImplementation; + +/** + * In order to handle properly new COMPILE_ONLY classpath this class delegates + * handling of some classpath types to ClassPathModifier and handling of COMPILE_ONLY + * is delegated to WebProjectLibrariesModifierImpl. + */ +public class DelagatingProjectClassPathModifierImpl extends ProjectClassPathModifierImplementation { + + private final ClassPathModifier cpMod; + private final WebProjectLibrariesModifierImpl compileOnlyClassPathSupport; + + public DelagatingProjectClassPathModifierImpl(ClassPathModifier cpMod, + WebProjectLibrariesModifierImpl compileOnlyClassPathSupport) { + this.compileOnlyClassPathSupport = compileOnlyClassPathSupport; + this.cpMod = cpMod; + } + + @Override + protected SourceGroup[] getExtensibleSourceGroups() { + return cpMod.getExtensibleSourceGroups(); + } + + @Override + protected String[] getExtensibleClassPathTypes(SourceGroup sourceGroup) { + List res = new ArrayList(Arrays.asList(cpMod.getExtensibleClassPathTypes(sourceGroup))); + res.add(JavaClassPathConstants.COMPILE_ONLY); + return res.toArray(new String[res.size()]); + } + + @Override + protected boolean addLibraries(Library[] libraries, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException { + if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) { + return compileOnlyClassPathSupport.addCompileLibraries(libraries); + } else { + return cpMod.addLibraries(libraries, sourceGroup, type); + } + } + + @Override + protected boolean removeLibraries(Library[] libraries, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException { + if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) { + return compileOnlyClassPathSupport.removeCompileLibraries(libraries); + } else { + return cpMod.removeLibraries(libraries, sourceGroup, type); + } + } + + @Override + protected boolean addRoots(URL[] classPathRoots, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException { + if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) { + return compileOnlyClassPathSupport.addCompileRoots(classPathRoots); + } else { + return cpMod.addRoots(classPathRoots, sourceGroup, type); + } + } + + @Override + protected boolean removeRoots(URL[] classPathRoots, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException { + if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) { + return compileOnlyClassPathSupport.removeCompileRoots(classPathRoots); + } else { + return cpMod.removeRoots(classPathRoots, sourceGroup, type); + } + } + + @Override + protected boolean addAntArtifacts(AntArtifact[] artifacts, URI[] artifactElements, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException { + if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) { + return compileOnlyClassPathSupport.addCompileAntArtifacts(artifacts, artifactElements); + } else { + return cpMod.addAntArtifacts(artifacts, artifactElements, sourceGroup, type); + } + } + + @Override + protected boolean removeAntArtifacts(AntArtifact[] artifacts, URI[] artifactElements, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException { + if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) { + return compileOnlyClassPathSupport.removeCompileAntArtifacts(artifacts, artifactElements); + } else { + return cpMod.removeAntArtifacts(artifacts, artifactElements, sourceGroup, type); + } + } + + public ClassPathSupport getClassPathSupport() { + return cpMod.getClassPathSupport(); + } + + // TODO: remove + public ClassPathModifier getClassPathModifier() { + return cpMod; + } + + +} diff --git a/web.project/src/org/netbeans/modules/web/project/classpath/WebProjectLibrariesModifierImpl.java b/web.project/src/org/netbeans/modules/web/project/classpath/WebProjectLibrariesModifierImpl.java --- a/web.project/src/org/netbeans/modules/web/project/classpath/WebProjectLibrariesModifierImpl.java +++ b/web.project/src/org/netbeans/modules/web/project/classpath/WebProjectLibrariesModifierImpl.java @@ -44,27 +44,28 @@ package org.netbeans.modules.web.project.classpath; -import java.net.URL; -import org.netbeans.api.project.ant.AntArtifact; -import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item; -import org.netbeans.modules.web.project.api.*; import java.io.IOException; import java.net.URI; +import java.net.URL; import java.util.ArrayList; import java.util.List; +import org.netbeans.api.project.ant.AntArtifact; import org.netbeans.api.project.libraries.Library; +import org.netbeans.modules.java.api.common.ant.UpdateHelper; import org.netbeans.modules.java.api.common.classpath.ClassPathModifier; import org.netbeans.modules.java.api.common.classpath.ClassPathModifierSupport; import org.netbeans.modules.java.api.common.classpath.ClassPathSupport; +import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item; +import org.netbeans.modules.java.api.common.project.ProjectProperties; import org.netbeans.modules.java.api.common.project.ui.ClassPathUiSupport; -import org.netbeans.modules.java.api.common.ant.UpdateHelper; -import org.netbeans.modules.java.api.common.project.ProjectProperties; import org.netbeans.modules.web.project.WebProject; +import org.netbeans.modules.web.project.api.*; import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties; import org.netbeans.spi.project.support.ant.PropertyEvaluator; import org.netbeans.spi.project.support.ant.ReferenceHelper; -public class WebProjectLibrariesModifierImpl implements WebProjectLibrariesModifier { +@SuppressWarnings("deprecation") +public class WebProjectLibrariesModifierImpl implements WebProjectLibrariesModifier, WebProjectLibrariesModifier2 { private final WebProject project; private final UpdateHelper helper;