This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 207717
Collapse All | Expand All

(-)a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientProject.java (-4 / +6 lines)
Lines 70-75 Link Here
70
import org.netbeans.api.project.ant.AntBuildExtender;
70
import org.netbeans.api.project.ant.AntBuildExtender;
71
import org.netbeans.modules.j2ee.api.ejbjar.Car;
71
import org.netbeans.modules.j2ee.api.ejbjar.Car;
72
import org.netbeans.modules.j2ee.clientproject.classpath.ClassPathSupportCallbackImpl;
72
import org.netbeans.modules.j2ee.clientproject.classpath.ClassPathSupportCallbackImpl;
73
import org.netbeans.modules.j2ee.clientproject.classpath.DelagatingProjectClassPathModifierImpl;
73
import org.netbeans.modules.j2ee.clientproject.ui.AppClientLogicalViewProvider;
74
import org.netbeans.modules.j2ee.clientproject.ui.AppClientLogicalViewProvider;
74
import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties;
75
import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties;
75
import org.netbeans.modules.j2ee.clientproject.ui.customizer.CustomizerProviderImpl;
76
import org.netbeans.modules.j2ee.clientproject.ui.customizer.CustomizerProviderImpl;
Lines 175-181 Link Here
175
    private final Car apiJar;
176
    private final Car apiJar;
176
    private JarContainerImpl enterpriseResourceSupport;
177
    private JarContainerImpl enterpriseResourceSupport;
177
    private FileObject libFolder;
178
    private FileObject libFolder;
178
    private final ClassPathModifier cpMod;
179
    private final DelagatingProjectClassPathModifierImpl cpMod;
179
    private final ClassPathProviderImpl cpProvider;
180
    private final ClassPathProviderImpl cpProvider;
180
    private ClassPathUiSupport.Callback classPathUiSupportCallback;
181
    private ClassPathUiSupport.Callback classPathUiSupportCallback;
181
    private final AppClientCompilationClassPathModifierImpl libMod;
182
    private final AppClientCompilationClassPathModifierImpl libMod;
Lines 217-225 Link Here
217
        appClient = new AppClientProvider(this, helper, cpProvider);
218
        appClient = new AppClientProvider(this, helper, cpProvider);
218
        apiJar = CarFactory.createCar(new CarImpl2(appClient));
219
        apiJar = CarFactory.createCar(new CarImpl2(appClient));
219
        enterpriseResourceSupport = new JarContainerImpl(this, refHelper, helper);
220
        enterpriseResourceSupport = new JarContainerImpl(this, refHelper, helper);
220
        cpMod = new ClassPathModifier(this, this.updateHelper, eval, refHelper,
221
        ClassPathModifier cpModPrevious = new ClassPathModifier(this, this.updateHelper, eval, refHelper,
221
            new ClassPathSupportCallbackImpl(helper), createClassPathModifierCallback(), 
222
            new ClassPathSupportCallbackImpl(helper), createClassPathModifierCallback(), 
222
            getClassPathUiSupportCallback());
223
            getClassPathUiSupportCallback());
224
        cpMod = new DelagatingProjectClassPathModifierImpl(cpModPrevious, libMod);
223
        lookup = createLookup(aux, cpProvider);
225
        lookup = createLookup(aux, cpProvider);
224
    }
226
    }
225
    
227
    
Lines 452-458 Link Here
452
        
454
        
453
        if (fo.getParent ().equals (libFolder)) {
455
        if (fo.getParent ().equals (libFolder)) {
454
            try {
456
            try {
455
                cpMod.addRoots(new URL[] {FileUtil.getArchiveRoot(fo.getURL())}, ProjectProperties.JAVAC_CLASSPATH);
457
                cpMod.getClassPathModifier().addRoots(new URL[] {FileUtil.getArchiveRoot(fo.getURL())}, ProjectProperties.JAVAC_CLASSPATH);
456
            } catch (IOException e) {
458
            } catch (IOException e) {
457
                Exceptions.printStackTrace(e);
459
                Exceptions.printStackTrace(e);
458
            }
460
            }
Lines 588-594 Link Here
588
                                libs.add(FileUtil.getArchiveRoot(children[i].getURL()));
590
                                libs.add(FileUtil.getArchiveRoot(children[i].getURL()));
589
                            }
591
                            }
590
                        }
592
                        }
591
                        cpMod.addRoots(libs.toArray(new URL[libs.size()]), ProjectProperties.JAVAC_CLASSPATH);
593
                        cpMod.getClassPathModifier().addRoots(libs.toArray(new URL[libs.size()]), ProjectProperties.JAVAC_CLASSPATH);
592
                        libFolder.addFileChangeListener (AppClientProject.this);
594
                        libFolder.addFileChangeListener (AppClientProject.this);
593
                }
595
                }
594
                
596
                
(-)a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/DelagatingProjectClassPathModifierImpl.java (+152 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.j2ee.clientproject.classpath;
44
45
import java.io.IOException;
46
import java.net.URI;
47
import java.net.URL;
48
import java.util.ArrayList;
49
import java.util.Arrays;
50
import java.util.List;
51
import org.netbeans.api.java.classpath.JavaClassPathConstants;
52
import org.netbeans.api.project.SourceGroup;
53
import org.netbeans.api.project.ant.AntArtifact;
54
import org.netbeans.api.project.libraries.Library;
55
import org.netbeans.modules.j2ee.clientproject.AppClientCompilationClassPathModifierImpl;
56
import org.netbeans.modules.java.api.common.classpath.ClassPathModifier;
57
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport;
58
import org.netbeans.spi.java.project.classpath.ProjectClassPathModifierImplementation;
59
60
/**
61
 * In order to handle properly new COMPILE_ONLY classpath this class delegates
62
 * handling of some classpath types to ClassPathModifier and handling of COMPILE_ONLY
63
 * is delegated to AppClientCompilationClassPathModifierImpl.
64
 */
65
public class DelagatingProjectClassPathModifierImpl extends ProjectClassPathModifierImplementation {
66
67
    private final ClassPathModifier cpMod;
68
    private final AppClientCompilationClassPathModifierImpl compileOnlyClassPathSupport;
69
    
70
    public DelagatingProjectClassPathModifierImpl(ClassPathModifier cpMod,
71
            AppClientCompilationClassPathModifierImpl compileOnlyClassPathSupport) {
72
        this.compileOnlyClassPathSupport = compileOnlyClassPathSupport;
73
        this.cpMod = cpMod;
74
    }
75
76
    @Override
77
    protected SourceGroup[] getExtensibleSourceGroups() {
78
        return cpMod.getExtensibleSourceGroups();
79
    }
80
81
    @Override
82
    protected String[] getExtensibleClassPathTypes(SourceGroup sourceGroup) {
83
        List<String> res = new ArrayList<String>(Arrays.asList(cpMod.getExtensibleClassPathTypes(sourceGroup)));
84
        res.add(JavaClassPathConstants.COMPILE_ONLY);
85
        return res.toArray(new String[res.size()]);
86
    }
87
88
    @Override
89
    protected boolean addLibraries(Library[] libraries, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
90
        if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) {
91
            return compileOnlyClassPathSupport.addCompileLibraries(libraries);
92
        } else {
93
            return cpMod.addLibraries(libraries, sourceGroup, type);
94
        }
95
    }
96
97
    @Override
98
    protected boolean removeLibraries(Library[] libraries, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
99
        if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) {
100
            return compileOnlyClassPathSupport.removeCompileLibraries(libraries);
101
        } else {
102
            return cpMod.removeLibraries(libraries, sourceGroup, type);
103
        }
104
    }
105
106
    @Override
107
    protected boolean addRoots(URL[] classPathRoots, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
108
        if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) {
109
            return compileOnlyClassPathSupport.addCompileRoots(classPathRoots);
110
        } else {
111
            return cpMod.addRoots(classPathRoots, sourceGroup, type);
112
        }
113
    }
114
115
    @Override
116
    protected boolean removeRoots(URL[] classPathRoots, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
117
        if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) {
118
            return compileOnlyClassPathSupport.removeCompileRoots(classPathRoots);
119
        } else {
120
            return cpMod.removeRoots(classPathRoots, sourceGroup, type);
121
        }
122
    }
123
124
    @Override
125
    protected boolean addAntArtifacts(AntArtifact[] artifacts, URI[] artifactElements, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
126
        if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) {
127
            return compileOnlyClassPathSupport.addCompileAntArtifacts(artifacts, artifactElements);
128
        } else {
129
            return cpMod.addAntArtifacts(artifacts, artifactElements, sourceGroup, type);
130
        }
131
    }
132
133
    @Override
134
    protected boolean removeAntArtifacts(AntArtifact[] artifacts, URI[] artifactElements, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
135
        if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) {
136
            return compileOnlyClassPathSupport.removeCompileAntArtifacts(artifacts, artifactElements);
137
        } else {
138
            return cpMod.removeAntArtifacts(artifacts, artifactElements, sourceGroup, type);
139
        }
140
    }
141
142
    public ClassPathSupport getClassPathSupport() {
143
        return cpMod.getClassPathSupport();
144
    }
145
146
    // TODO: remove
147
    public ClassPathModifier getClassPathModifier() {
148
        return cpMod;
149
    }
150
151
    
152
}
(-)a/j2ee.common/src/org/netbeans/modules/j2ee/common/project/CompilationOnlyClassPathModifier.java (+2 lines)
Lines 57-62 Link Here
57
 * project's build artifact.
57
 * project's build artifact.
58
 *
58
 *
59
 * @since org.netbeans.modules.j2ee.common/1 1.53
59
 * @since org.netbeans.modules.j2ee.common/1 1.53
60
 * @deprecated use regular classpath modifier with classpath type
61
 *    JavaClassPathConstants.COMPILE_ONLY instead
60
 */
62
 */
61
public interface CompilationOnlyClassPathModifier {
63
public interface CompilationOnlyClassPathModifier {
62
    
64
    
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ClassPathModifier.java (-9 / +16 lines)
Lines 109-115 Link Here
109
        return s.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
109
        return s.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
110
    }
110
    }
111
    
111
    
112
    protected String[] getExtensibleClassPathTypes (SourceGroup sg) {
112
    @Override
113
    public String[] getExtensibleClassPathTypes (SourceGroup sg) {
113
        return new String[] {
114
        return new String[] {
114
            ClassPath.COMPILE,
115
            ClassPath.COMPILE,
115
            ClassPath.EXECUTE,
116
            ClassPath.EXECUTE,
Lines 118-134 Link Here
118
        };
119
        };
119
    }
120
    }
120
121
121
    protected boolean removeRoots(final URL[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
122
    @Override
123
    public boolean removeRoots(final URL[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
122
        return removeRoots(convertURLsToURIs(classPathRoots), sourceGroup, type);
124
        return removeRoots(convertURLsToURIs(classPathRoots), sourceGroup, type);
123
    }
125
    }
124
126
125
    @Override
127
    @Override
126
    protected boolean removeRoots(final URI[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
128
    public boolean removeRoots(final URI[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
127
        String classPathProperty = cpModifierCallback.getClassPathProperty(sourceGroup, type);
129
        String classPathProperty = cpModifierCallback.getClassPathProperty(sourceGroup, type);
128
        return handleRoots (classPathRoots, classPathProperty, cpModifierCallback.getElementName(classPathProperty), REMOVE);
130
        return handleRoots (classPathRoots, classPathProperty, cpModifierCallback.getElementName(classPathProperty), REMOVE);
129
    }
131
    }
130
132
131
    protected boolean addRoots (final URL[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {        
133
    @Override
134
    public boolean addRoots (final URL[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {        
132
        return addRoots(convertURLsToURIs(classPathRoots), sourceGroup, type);
135
        return addRoots(convertURLsToURIs(classPathRoots), sourceGroup, type);
133
    }
136
    }
134
    
137
    
Lines 137-143 Link Here
137
    }
140
    }
138
    
141
    
139
    @Override
142
    @Override
140
    protected boolean addRoots (final URI[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {        
143
    public boolean addRoots (final URI[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {        
141
        return addRoots(classPathRoots, sourceGroup, type, ADD);
144
        return addRoots(classPathRoots, sourceGroup, type, ADD);
142
    }
145
    }
143
    
146
    
Lines 152-163 Link Here
152
        return ClassPathModifierSupport.handleRoots(project, updateHelper, cs, eval, refHelper, cpUiSupportCallback, classPathRoots, classPathProperty, projectXMLElementName, operation);
155
        return ClassPathModifierSupport.handleRoots(project, updateHelper, cs, eval, refHelper, cpUiSupportCallback, classPathRoots, classPathProperty, projectXMLElementName, operation);
153
    }
156
    }
154
    
157
    
155
    protected boolean removeAntArtifacts(final AntArtifact[] artifacts, final URI[] artifactElements, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
158
    @Override
159
    public boolean removeAntArtifacts(final AntArtifact[] artifacts, final URI[] artifactElements, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
156
        String classPathProperty = cpModifierCallback.getClassPathProperty(sourceGroup, type);
160
        String classPathProperty = cpModifierCallback.getClassPathProperty(sourceGroup, type);
157
        return handleAntArtifacts (artifacts, artifactElements, classPathProperty, cpModifierCallback.getElementName(classPathProperty), REMOVE);
161
        return handleAntArtifacts (artifacts, artifactElements, classPathProperty, cpModifierCallback.getElementName(classPathProperty), REMOVE);
158
    }
162
    }
159
163
160
    protected boolean addAntArtifacts(final AntArtifact[] artifacts, final URI[] artifactElements, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
164
    @Override
165
    public boolean addAntArtifacts(final AntArtifact[] artifacts, final URI[] artifactElements, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
161
        String classPathProperty = cpModifierCallback.getClassPathProperty(sourceGroup, type);
166
        String classPathProperty = cpModifierCallback.getClassPathProperty(sourceGroup, type);
162
        return handleAntArtifacts (artifacts, artifactElements, classPathProperty, cpModifierCallback.getElementName(classPathProperty), ADD);
167
        return handleAntArtifacts (artifacts, artifactElements, classPathProperty, cpModifierCallback.getElementName(classPathProperty), ADD);
163
    }
168
    }
Lines 166-177 Link Here
166
        return ClassPathModifierSupport.handleAntArtifacts(project, updateHelper, cs, eval, refHelper, cpUiSupportCallback, artifacts, artifactElements, classPathProperty, projectXMLElementName, operation);
171
        return ClassPathModifierSupport.handleAntArtifacts(project, updateHelper, cs, eval, refHelper, cpUiSupportCallback, artifacts, artifactElements, classPathProperty, projectXMLElementName, operation);
167
    }
172
    }
168
    
173
    
169
    protected boolean removeLibraries(final Library[] libraries, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
174
    @Override
175
    public boolean removeLibraries(final Library[] libraries, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
170
        String classPathProperty = cpModifierCallback.getClassPathProperty(sourceGroup, type);
176
        String classPathProperty = cpModifierCallback.getClassPathProperty(sourceGroup, type);
171
        return handleLibraries (libraries, classPathProperty, cpModifierCallback.getElementName(classPathProperty), REMOVE);
177
        return handleLibraries (libraries, classPathProperty, cpModifierCallback.getElementName(classPathProperty), REMOVE);
172
    }
178
    }
173
179
174
    protected boolean addLibraries(final Library[] libraries, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
180
    @Override
181
    public boolean addLibraries(final Library[] libraries, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
175
        String classPathProperty = cpModifierCallback.getClassPathProperty(sourceGroup, type);
182
        String classPathProperty = cpModifierCallback.getClassPathProperty(sourceGroup, type);
176
        return handleLibraries (libraries, classPathProperty, cpModifierCallback.getElementName(classPathProperty), ADD);
183
        return handleLibraries (libraries, classPathProperty, cpModifierCallback.getElementName(classPathProperty), ADD);
177
    }
184
    }
(-)a/web.project/src/org/netbeans/modules/web/project/WebProject.java (-3 / +5 lines)
Lines 157-162 Link Here
157
import org.netbeans.modules.web.api.webmodule.WebProjectConstants;
157
import org.netbeans.modules.web.api.webmodule.WebProjectConstants;
158
import org.netbeans.modules.web.project.api.WebProjectUtilities;
158
import org.netbeans.modules.web.project.api.WebProjectUtilities;
159
import org.netbeans.modules.web.project.classpath.ClassPathSupportCallbackImpl;
159
import org.netbeans.modules.web.project.classpath.ClassPathSupportCallbackImpl;
160
import org.netbeans.modules.web.project.classpath.DelagatingProjectClassPathModifierImpl;
160
import org.netbeans.modules.web.project.classpath.WebProjectLibrariesModifierImpl;
161
import org.netbeans.modules.web.project.classpath.WebProjectLibrariesModifierImpl;
161
import org.netbeans.modules.web.project.spi.BrokenLibraryRefFilter;
162
import org.netbeans.modules.web.project.spi.BrokenLibraryRefFilter;
162
import org.netbeans.modules.web.project.spi.BrokenLibraryRefFilterProvider;
163
import org.netbeans.modules.web.project.spi.BrokenLibraryRefFilterProvider;
Lines 223-229 Link Here
223
    private final UpdateHelper updateHelper;
224
    private final UpdateHelper updateHelper;
224
    private final UpdateProjectImpl updateProject;
225
    private final UpdateProjectImpl updateProject;
225
    private final AuxiliaryConfiguration aux;
226
    private final AuxiliaryConfiguration aux;
226
    private final ClassPathModifier cpMod;
227
    private final DelagatingProjectClassPathModifierImpl cpMod;
227
    private final WebProjectLibrariesModifierImpl libMod;
228
    private final WebProjectLibrariesModifierImpl libMod;
228
    private final ClassPathProviderImpl cpProvider;
229
    private final ClassPathProviderImpl cpProvider;
229
    private ClassPathUiSupport.Callback classPathUiSupportCallback;
230
    private ClassPathUiSupport.Callback classPathUiSupportCallback;
Lines 386-394 Link Here
386
        apiWebServicesClientSupport = WebServicesClientSupportFactory.createWebServicesClientSupport (webProjectWebServicesClientSupport);
387
        apiWebServicesClientSupport = WebServicesClientSupportFactory.createWebServicesClientSupport (webProjectWebServicesClientSupport);
387
        apiJAXWSClientSupport = JAXWSClientSupportFactory.createJAXWSClientSupport(jaxWsClientSupport);
388
        apiJAXWSClientSupport = JAXWSClientSupportFactory.createJAXWSClientSupport(jaxWsClientSupport);
388
        enterpriseResourceSupport = new WebContainerImpl(this, refHelper, helper);
389
        enterpriseResourceSupport = new WebContainerImpl(this, refHelper, helper);
389
        cpMod = new ClassPathModifier(this, this.updateHelper, eval, refHelper,
390
        ClassPathModifier cpModTemp = new ClassPathModifier(this, this.updateHelper, eval, refHelper,
390
            new ClassPathSupportCallbackImpl(helper), createClassPathModifierCallback(), getClassPathUiSupportCallback());
391
            new ClassPathSupportCallbackImpl(helper), createClassPathModifierCallback(), getClassPathUiSupportCallback());
391
        libMod = new WebProjectLibrariesModifierImpl(this, this.updateHelper, eval, refHelper);
392
        libMod = new WebProjectLibrariesModifierImpl(this, this.updateHelper, eval, refHelper);
393
        cpMod = new DelagatingProjectClassPathModifierImpl(cpModTemp, libMod);
392
        lookup = createLookup(aux, cpProvider);
394
        lookup = createLookup(aux, cpProvider);
393
        css = new CopyOnSaveSupport();
395
        css = new CopyOnSaveSupport();
394
        artifactSupport = new ArtifactCopySupport();
396
        artifactSupport = new ArtifactCopySupport();
Lines 403-409 Link Here
403
        this.projectPropertiesSave.set(value);
405
        this.projectPropertiesSave.set(value);
404
    }
406
    }
405
    
407
    
406
    public ClassPathModifier getClassPathModifier() {
408
    public DelagatingProjectClassPathModifierImpl getClassPathModifier() {
407
        return cpMod;
409
        return cpMod;
408
    }
410
    }
409
411
(-)a/web.project/src/org/netbeans/modules/web/project/api/WebProjectLibrariesModifier.java (+3 lines)
Lines 52-57 Link Here
52
import org.netbeans.api.project.libraries.Library;
52
import org.netbeans.api.project.libraries.Library;
53
import org.netbeans.modules.j2ee.common.project.CompilationOnlyClassPathModifier;
53
import org.netbeans.modules.j2ee.common.project.CompilationOnlyClassPathModifier;
54
54
55
/**
56
 * @deprecated use WebProjectLibrariesModifier2 instead of WebProjectLibrariesModifier
57
 */
55
public interface WebProjectLibrariesModifier extends CompilationOnlyClassPathModifier {
58
public interface WebProjectLibrariesModifier extends CompilationOnlyClassPathModifier {
56
    
59
    
57
    /**
60
    /**
(-)a/web.project/src/org/netbeans/modules/web/project/api/WebProjectLibrariesModifier.java (-2 / +1 lines)
Lines 50-58 Link Here
50
50
51
import org.netbeans.api.project.ant.AntArtifact;
51
import org.netbeans.api.project.ant.AntArtifact;
52
import org.netbeans.api.project.libraries.Library;
52
import org.netbeans.api.project.libraries.Library;
53
import org.netbeans.modules.j2ee.common.project.CompilationOnlyClassPathModifier;
54
53
55
public interface WebProjectLibrariesModifier extends CompilationOnlyClassPathModifier {
54
public interface WebProjectLibrariesModifier2 {
56
    
55
    
57
    /**
56
    /**
58
     * Adds libraries into the project. These libraries will not be added into the projects's classpath
57
     * Adds libraries into the project. These libraries will not be added into the projects's classpath
(-)a/web.project/src/org/netbeans/modules/web/project/api/WebProjectUtilities.java (-1 / +1 lines)
Lines 580-586 Link Here
580
                        libs.add(URLMapper.findURL(FileUtil.getArchiveRoot(children[i]), URLMapper.EXTERNAL));
580
                        libs.add(URLMapper.findURL(FileUtil.getArchiveRoot(children[i]), URLMapper.EXTERNAL));
581
                    }
581
                    }
582
                }
582
                }
583
                p.getClassPathModifier().addRoots(libs.toArray(new URL[libs.size()]), ProjectProperties.JAVAC_CLASSPATH);
583
                p.getClassPathModifier().getClassPathModifier().addRoots(libs.toArray(new URL[libs.size()]), ProjectProperties.JAVAC_CLASSPATH);
584
                //do we really need to add the listener? commenting it out
584
                //do we really need to add the listener? commenting it out
585
                //libFolder.addFileChangeListener(p);
585
                //libFolder.addFileChangeListener(p);
586
            }
586
            }
(-)a/web.project/src/org/netbeans/modules/web/project/classpath/DelagatingProjectClassPathModifierImpl.java (+151 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.web.project.classpath;
44
45
import java.io.IOException;
46
import java.net.URI;
47
import java.net.URL;
48
import java.util.ArrayList;
49
import java.util.Arrays;
50
import java.util.List;
51
import org.netbeans.api.java.classpath.JavaClassPathConstants;
52
import org.netbeans.api.project.SourceGroup;
53
import org.netbeans.api.project.ant.AntArtifact;
54
import org.netbeans.api.project.libraries.Library;
55
import org.netbeans.modules.java.api.common.classpath.ClassPathModifier;
56
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport;
57
import org.netbeans.spi.java.project.classpath.ProjectClassPathModifierImplementation;
58
59
/**
60
 * In order to handle properly new COMPILE_ONLY classpath this class delegates
61
 * handling of some classpath types to ClassPathModifier and handling of COMPILE_ONLY
62
 * is delegated to WebProjectLibrariesModifierImpl.
63
 */
64
public class DelagatingProjectClassPathModifierImpl extends ProjectClassPathModifierImplementation {
65
66
    private final ClassPathModifier cpMod;
67
    private final WebProjectLibrariesModifierImpl compileOnlyClassPathSupport;
68
    
69
    public DelagatingProjectClassPathModifierImpl(ClassPathModifier cpMod,
70
            WebProjectLibrariesModifierImpl compileOnlyClassPathSupport) {
71
        this.compileOnlyClassPathSupport = compileOnlyClassPathSupport;
72
        this.cpMod = cpMod;
73
    }
74
75
    @Override
76
    protected SourceGroup[] getExtensibleSourceGroups() {
77
        return cpMod.getExtensibleSourceGroups();
78
    }
79
80
    @Override
81
    protected String[] getExtensibleClassPathTypes(SourceGroup sourceGroup) {
82
        List<String> res = new ArrayList<String>(Arrays.asList(cpMod.getExtensibleClassPathTypes(sourceGroup)));
83
        res.add(JavaClassPathConstants.COMPILE_ONLY);
84
        return res.toArray(new String[res.size()]);
85
    }
86
87
    @Override
88
    protected boolean addLibraries(Library[] libraries, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
89
        if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) {
90
            return compileOnlyClassPathSupport.addCompileLibraries(libraries);
91
        } else {
92
            return cpMod.addLibraries(libraries, sourceGroup, type);
93
        }
94
    }
95
96
    @Override
97
    protected boolean removeLibraries(Library[] libraries, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
98
        if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) {
99
            return compileOnlyClassPathSupport.removeCompileLibraries(libraries);
100
        } else {
101
            return cpMod.removeLibraries(libraries, sourceGroup, type);
102
        }
103
    }
104
105
    @Override
106
    protected boolean addRoots(URL[] classPathRoots, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
107
        if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) {
108
            return compileOnlyClassPathSupport.addCompileRoots(classPathRoots);
109
        } else {
110
            return cpMod.addRoots(classPathRoots, sourceGroup, type);
111
        }
112
    }
113
114
    @Override
115
    protected boolean removeRoots(URL[] classPathRoots, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
116
        if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) {
117
            return compileOnlyClassPathSupport.removeCompileRoots(classPathRoots);
118
        } else {
119
            return cpMod.removeRoots(classPathRoots, sourceGroup, type);
120
        }
121
    }
122
123
    @Override
124
    protected boolean addAntArtifacts(AntArtifact[] artifacts, URI[] artifactElements, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
125
        if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) {
126
            return compileOnlyClassPathSupport.addCompileAntArtifacts(artifacts, artifactElements);
127
        } else {
128
            return cpMod.addAntArtifacts(artifacts, artifactElements, sourceGroup, type);
129
        }
130
    }
131
132
    @Override
133
    protected boolean removeAntArtifacts(AntArtifact[] artifacts, URI[] artifactElements, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
134
        if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) {
135
            return compileOnlyClassPathSupport.removeCompileAntArtifacts(artifacts, artifactElements);
136
        } else {
137
            return cpMod.removeAntArtifacts(artifacts, artifactElements, sourceGroup, type);
138
        }
139
    }
140
141
    public ClassPathSupport getClassPathSupport() {
142
        return cpMod.getClassPathSupport();
143
    }
144
145
    // TODO: remove
146
    public ClassPathModifier getClassPathModifier() {
147
        return cpMod;
148
    }
149
150
    
151
}
(-)a/web.project/src/org/netbeans/modules/web/project/classpath/WebProjectLibrariesModifierImpl.java (-7 / +8 lines)
Lines 44-70 Link Here
44
44
45
package org.netbeans.modules.web.project.classpath;
45
package org.netbeans.modules.web.project.classpath;
46
46
47
import java.net.URL;
48
import org.netbeans.api.project.ant.AntArtifact;
49
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item;
50
import org.netbeans.modules.web.project.api.*;
51
import java.io.IOException;
47
import java.io.IOException;
52
import java.net.URI;
48
import java.net.URI;
49
import java.net.URL;
53
import java.util.ArrayList;
50
import java.util.ArrayList;
54
import java.util.List;
51
import java.util.List;
52
import org.netbeans.api.project.ant.AntArtifact;
55
import org.netbeans.api.project.libraries.Library;
53
import org.netbeans.api.project.libraries.Library;
54
import org.netbeans.modules.java.api.common.ant.UpdateHelper;
56
import org.netbeans.modules.java.api.common.classpath.ClassPathModifier;
55
import org.netbeans.modules.java.api.common.classpath.ClassPathModifier;
57
import org.netbeans.modules.java.api.common.classpath.ClassPathModifierSupport;
56
import org.netbeans.modules.java.api.common.classpath.ClassPathModifierSupport;
58
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport;
57
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport;
58
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item;
59
import org.netbeans.modules.java.api.common.project.ProjectProperties;
59
import org.netbeans.modules.java.api.common.project.ui.ClassPathUiSupport;
60
import org.netbeans.modules.java.api.common.project.ui.ClassPathUiSupport;
60
import org.netbeans.modules.java.api.common.ant.UpdateHelper;
61
import org.netbeans.modules.java.api.common.project.ProjectProperties;
62
import org.netbeans.modules.web.project.WebProject;
61
import org.netbeans.modules.web.project.WebProject;
62
import org.netbeans.modules.web.project.api.*;
63
import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties;
63
import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties;
64
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
64
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
65
import org.netbeans.spi.project.support.ant.ReferenceHelper;
65
import org.netbeans.spi.project.support.ant.ReferenceHelper;
66
66
67
public class WebProjectLibrariesModifierImpl implements WebProjectLibrariesModifier {
67
@SuppressWarnings("deprecation")
68
public class WebProjectLibrariesModifierImpl implements WebProjectLibrariesModifier, WebProjectLibrariesModifier2 {
68
    
69
    
69
    private final WebProject project;
70
    private final WebProject project;
70
    private final UpdateHelper helper;
71
    private final UpdateHelper helper;

Return to bug 207717