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 196455
Collapse All | Expand All

(-)a/j2ee.api.ejbmodule/nbproject/project.xml (+1 lines)
Lines 116-121 Link Here
116
                    <compile-dependency/>
116
                    <compile-dependency/>
117
                    <run-dependency>
117
                    <run-dependency>
118
                        <release-version>1</release-version>
118
                        <release-version>1</release-version>
119
                        <specification-version>1.10</specification-version>
119
                    </run-dependency>
120
                    </run-dependency>
120
                </dependency>
121
                </dependency>
121
                <dependency>
122
                <dependency>
(-)a/j2ee.api.ejbmodule/src/org/netbeans/modules/j2ee/spi/ejbjar/support/EjbEnterpriseReferenceContainerSupport.java (-5 / +5 lines)
Lines 45-56 Link Here
45
package org.netbeans.modules.j2ee.spi.ejbjar.support;
45
package org.netbeans.modules.j2ee.spi.ejbjar.support;
46
46
47
import java.io.IOException;
47
import java.io.IOException;
48
import java.net.URI;
48
import java.util.HashSet;
49
import java.util.HashSet;
49
import java.util.Set;
50
import java.util.Set;
50
import java.util.logging.Level;
51
import java.util.logging.Level;
51
import java.util.logging.Logger;
52
import java.util.logging.Logger;
52
import org.netbeans.api.j2ee.core.Profile;
53
import org.netbeans.api.j2ee.core.Profile;
54
import org.netbeans.api.java.classpath.ClassPath;
53
import org.netbeans.api.java.project.JavaProjectConstants;
55
import org.netbeans.api.java.project.JavaProjectConstants;
56
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
54
import org.netbeans.api.project.FileOwnerQuery;
57
import org.netbeans.api.project.FileOwnerQuery;
55
import org.netbeans.api.project.Project;
58
import org.netbeans.api.project.Project;
56
import org.netbeans.api.project.ProjectManager;
59
import org.netbeans.api.project.ProjectManager;
Lines 71-77 Link Here
71
import org.netbeans.modules.j2ee.dd.api.ejb.EjbJarMetadata;
74
import org.netbeans.modules.j2ee.dd.api.ejb.EjbJarMetadata;
72
import org.netbeans.modules.j2ee.metadata.model.api.MetadataModel;
75
import org.netbeans.modules.j2ee.metadata.model.api.MetadataModel;
73
import org.netbeans.modules.j2ee.metadata.model.api.MetadataModelAction;
76
import org.netbeans.modules.j2ee.metadata.model.api.MetadataModelAction;
74
import org.netbeans.spi.java.project.classpath.ProjectClassPathExtender;
75
import org.netbeans.spi.project.support.ant.AntProjectHelper;
77
import org.netbeans.spi.project.support.ant.AntProjectHelper;
76
import org.netbeans.spi.project.support.ant.EditableProperties;
78
import org.netbeans.spi.project.support.ant.EditableProperties;
77
import org.openide.filesystems.FileObject;
79
import org.openide.filesystems.FileObject;
Lines 113-119 Link Here
113
            return addReference(ref, refType, ejbRefName, true, referencingFile, referencingClass);
115
            return addReference(ref, refType, ejbRefName, true, referencingFile, referencingClass);
114
        }
116
        }
115
        
117
        
116
        private String addReference(final EjbReference ejbReference, final EjbReference.EjbRefIType refType, final String ejbRefName, final boolean local, FileObject referencingFile,
118
        private String addReference(final EjbReference ejbReference, final EjbReference.EjbRefIType refType, final String ejbRefName, final boolean local, final FileObject referencingFile,
117
                final String referencingClass) throws IOException {
119
                final String referencingClass) throws IOException {
118
120
119
            final org.netbeans.modules.j2ee.api.ejbjar.EjbJar ejbModule = findEjbModule(referencingFile);
121
            final org.netbeans.modules.j2ee.api.ejbjar.EjbJar ejbModule = findEjbModule(referencingFile);
Lines 181-189 Link Here
181
                    
183
                    
182
                    if(!fromSameProject) {
184
                    if(!fromSameProject) {
183
                        try {
185
                        try {
184
                            ProjectClassPathExtender pcpe = ejbProject.getLookup().lookup(ProjectClassPathExtender.class);
186
                            ProjectClassPathModifier.addAntArtifacts(new AntArtifact[] {moduleJarTarget}, new URI[] {moduleJarTarget.getArtifactLocations()[0]}, referencingFile, ClassPath.COMPILE);
185
                            assert pcpe != null;
186
                            pcpe.addAntArtifact(moduleJarTarget, moduleJarTarget.getArtifactLocations()[0]);
187
                        } catch (IOException ioe) {
187
                        } catch (IOException ioe) {
188
                            Exceptions.printStackTrace(ioe);
188
                            Exceptions.printStackTrace(ioe);
189
                        }
189
                        }
(-)a/j2ee.clientproject/nbproject/project.xml (-1 / +1 lines)
Lines 226-232 Link Here
226
                    <compile-dependency/>
226
                    <compile-dependency/>
227
                    <run-dependency>
227
                    <run-dependency>
228
                        <release-version>1</release-version>
228
                        <release-version>1</release-version>
229
                        <specification-version>1.37</specification-version>
229
                        <specification-version>1.41</specification-version>
230
                    </run-dependency>
230
                    </run-dependency>
231
                </dependency>
231
                </dependency>
232
                <dependency>
232
                <dependency>
(-)a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientProject.java (-14 / +7 lines)
Lines 49-54 Link Here
49
import java.io.File;
49
import java.io.File;
50
import java.io.IOException;
50
import java.io.IOException;
51
import java.net.URI;
51
import java.net.URI;
52
import java.net.URL;
52
import java.util.Arrays;
53
import java.util.Arrays;
53
import java.util.LinkedList;
54
import java.util.LinkedList;
54
import java.util.List;
55
import java.util.List;
Lines 56-66 Link Here
56
import java.util.logging.Level;
57
import java.util.logging.Level;
57
import java.util.logging.Logger;
58
import java.util.logging.Logger;
58
import javax.swing.Icon;
59
import javax.swing.Icon;
59
import javax.swing.JButton;
60
import org.netbeans.api.j2ee.core.Profile;
60
import org.netbeans.api.j2ee.core.Profile;
61
import org.netbeans.api.java.classpath.ClassPath;
61
import org.netbeans.api.java.classpath.ClassPath;
62
import org.netbeans.api.java.classpath.GlobalPathRegistry;
62
import org.netbeans.api.java.classpath.GlobalPathRegistry;
63
import org.netbeans.api.java.project.JavaProjectConstants;
63
import org.netbeans.api.java.project.JavaProjectConstants;
64
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
64
import org.netbeans.api.project.Project;
65
import org.netbeans.api.project.Project;
65
import org.netbeans.api.project.ProjectManager;
66
import org.netbeans.api.project.ProjectManager;
66
import org.netbeans.api.project.ProjectUtils;
67
import org.netbeans.api.project.ProjectUtils;
Lines 77-83 Link Here
77
import org.netbeans.modules.j2ee.clientproject.wsclient.AppClientProjectWebServicesSupportProvider;
78
import org.netbeans.modules.j2ee.clientproject.wsclient.AppClientProjectWebServicesSupportProvider;
78
import org.netbeans.modules.j2ee.common.SharabilityUtility;
79
import org.netbeans.modules.j2ee.common.SharabilityUtility;
79
import org.netbeans.modules.j2ee.common.Util;
80
import org.netbeans.modules.j2ee.common.Util;
80
import org.netbeans.modules.java.api.common.classpath.ClassPathExtender;
81
import org.netbeans.modules.java.api.common.classpath.ClassPathModifier;
81
import org.netbeans.modules.java.api.common.classpath.ClassPathModifier;
82
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport;
82
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport;
83
import org.netbeans.modules.java.api.common.classpath.ClassPathProviderImpl;
83
import org.netbeans.modules.java.api.common.classpath.ClassPathProviderImpl;
Lines 122-129 Link Here
122
import org.netbeans.spi.project.ui.RecommendedTemplates;
122
import org.netbeans.spi.project.ui.RecommendedTemplates;
123
import org.netbeans.spi.project.ui.support.UILookupMergerSupport;
123
import org.netbeans.spi.project.ui.support.UILookupMergerSupport;
124
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
124
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
125
import org.openide.DialogDisplayer;
126
import org.openide.NotifyDescriptor;
127
import org.openide.filesystems.FileAttributeEvent;
125
import org.openide.filesystems.FileAttributeEvent;
128
import org.openide.filesystems.FileChangeListener;
126
import org.openide.filesystems.FileChangeListener;
129
import org.openide.filesystems.FileEvent;
127
import org.openide.filesystems.FileEvent;
Lines 137-143 Link Here
137
import org.openide.util.ImageUtilities;
135
import org.openide.util.ImageUtilities;
138
import org.openide.util.Lookup;
136
import org.openide.util.Lookup;
139
import org.openide.util.NbBundle;
137
import org.openide.util.NbBundle;
140
import org.openide.util.RequestProcessor;
141
import org.openide.util.lookup.Lookups;
138
import org.openide.util.lookup.Lookups;
142
import org.w3c.dom.Element;
139
import org.w3c.dom.Element;
143
import org.w3c.dom.NodeList;
140
import org.w3c.dom.NodeList;
Lines 178-184 Link Here
178
    private final Car apiJar;
175
    private final Car apiJar;
179
    private JarContainerImpl enterpriseResourceSupport;
176
    private JarContainerImpl enterpriseResourceSupport;
180
    private FileObject libFolder;
177
    private FileObject libFolder;
181
    private final ClassPathExtender classPathExtender;
182
    private final ClassPathModifier cpMod;
178
    private final ClassPathModifier cpMod;
183
    private final ClassPathProviderImpl cpProvider;
179
    private final ClassPathProviderImpl cpProvider;
184
    private ClassPathUiSupport.Callback classPathUiSupportCallback;
180
    private ClassPathUiSupport.Callback classPathUiSupportCallback;
Lines 224-230 Link Here
224
        cpMod = new ClassPathModifier(this, this.updateHelper, eval, refHelper,
220
        cpMod = new ClassPathModifier(this, this.updateHelper, eval, refHelper,
225
            new ClassPathSupportCallbackImpl(helper), createClassPathModifierCallback(), 
221
            new ClassPathSupportCallbackImpl(helper), createClassPathModifierCallback(), 
226
            getClassPathUiSupportCallback());
222
            getClassPathUiSupportCallback());
227
        classPathExtender = new ClassPathExtender(cpMod, ProjectProperties.JAVAC_CLASSPATH, ClassPathSupportCallbackImpl.ELEMENT_INCLUDED_LIBRARIES);
228
        lookup = createLookup(aux, cpProvider);
223
        lookup = createLookup(aux, cpProvider);
229
    }
224
    }
230
    
225
    
Lines 339-345 Link Here
339
            encodingQuery,
334
            encodingQuery,
340
            QuerySupport.createTemplateAttributesProvider(helper, encodingQuery),
335
            QuerySupport.createTemplateAttributesProvider(helper, encodingQuery),
341
            new RecommendedTemplatesImpl(this.updateHelper),
336
            new RecommendedTemplatesImpl(this.updateHelper),
342
            classPathExtender,
337
            ProjectClassPathModifier.extenderForModifier(cpMod),
343
            cpMod,
338
            cpMod,
344
            libMod,
339
            libMod,
345
            buildExtender,
340
            buildExtender,
Lines 457-463 Link Here
457
        
452
        
458
        if (fo.getParent ().equals (libFolder)) {
453
        if (fo.getParent ().equals (libFolder)) {
459
            try {
454
            try {
460
                classPathExtender.addArchiveFile(fo);
455
                cpMod.addRoots(new URL[] {FileUtil.getArchiveRoot(fo.getURL())}, ProjectProperties.JAVAC_CLASSPATH);
461
            } catch (IOException e) {
456
            } catch (IOException e) {
462
                Exceptions.printStackTrace(e);
457
                Exceptions.printStackTrace(e);
463
            }
458
            }
Lines 585-599 Link Here
585
                if (libFolderName != null && helper.resolveFile (libFolderName).isDirectory ()) {
580
                if (libFolderName != null && helper.resolveFile (libFolderName).isDirectory ()) {
586
                    libFolder = helper.resolveFileObject(libFolderName);
581
                    libFolder = helper.resolveFileObject(libFolderName);
587
                        FileObject children [] = libFolder.getChildren ();
582
                        FileObject children [] = libFolder.getChildren ();
588
                        List<FileObject> libs = new LinkedList<FileObject>();
583
                        List<URL> libs = new LinkedList<URL>();
589
                        for (int i = 0; i < children.length; i++) {
584
                        for (int i = 0; i < children.length; i++) {
590
                            if (FileUtil.isArchiveFile(children[i])) {
585
                            if (FileUtil.isArchiveFile(children[i])) {
591
                                libs.add(children[i]);
586
                                libs.add(FileUtil.getArchiveRoot(children[i].getURL()));
592
                            }
587
                            }
593
                        }
588
                        }
594
                        FileObject[] libsArray = new FileObject[libs.size()];
589
                        cpMod.addRoots(libs.toArray(new URL[libs.size()]), ProjectProperties.JAVAC_CLASSPATH);
595
                        libs.toArray(libsArray);
596
                        classPathExtender.addArchiveFiles(ProjectProperties.JAVAC_CLASSPATH, libsArray, ClassPathSupportCallbackImpl.ELEMENT_INCLUDED_LIBRARIES);
597
                        libFolder.addFileChangeListener (AppClientProject.this);
590
                        libFolder.addFileChangeListener (AppClientProject.this);
598
                }
591
                }
599
                
592
                
(-)a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/JarContainerImpl.java (-13 / +8 lines)
Lines 46-56 Link Here
46
46
47
47
48
import java.io.IOException;
48
import java.io.IOException;
49
import java.util.logging.Level;
49
import java.net.URI;
50
import java.util.logging.Logger;
51
import javax.lang.model.element.TypeElement;
50
import javax.lang.model.element.TypeElement;
52
import org.netbeans.api.j2ee.core.Profile;
51
import org.netbeans.api.j2ee.core.Profile;
52
import org.netbeans.api.java.classpath.ClassPath;
53
import org.netbeans.api.java.project.JavaProjectConstants;
53
import org.netbeans.api.java.project.JavaProjectConstants;
54
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
54
import org.netbeans.api.java.source.CompilationController;
55
import org.netbeans.api.java.source.CompilationController;
55
import org.netbeans.api.java.source.JavaSource;
56
import org.netbeans.api.java.source.JavaSource;
56
import org.netbeans.api.project.FileOwnerQuery;
57
import org.netbeans.api.project.FileOwnerQuery;
Lines 72-78 Link Here
72
import org.netbeans.modules.j2ee.dd.api.common.MessageDestinationRef;
73
import org.netbeans.modules.j2ee.dd.api.common.MessageDestinationRef;
73
import org.netbeans.modules.j2ee.dd.api.common.ResourceRef;
74
import org.netbeans.modules.j2ee.dd.api.common.ResourceRef;
74
import org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException;
75
import org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException;
75
import org.netbeans.spi.java.project.classpath.ProjectClassPathExtender;
76
import org.netbeans.spi.project.support.ant.AntProjectHelper;
76
import org.netbeans.spi.project.support.ant.AntProjectHelper;
77
import org.netbeans.spi.project.support.ant.EditableProperties;
77
import org.netbeans.spi.project.support.ant.EditableProperties;
78
import org.netbeans.spi.project.support.ant.ReferenceHelper;
78
import org.netbeans.spi.project.support.ant.ReferenceHelper;
Lines 255-270 Link Here
255
            getAppClient().addEjbRef(newRef);
255
            getAppClient().addEjbRef(newRef);
256
        } catch (ClassNotFoundException ex){}
256
        } catch (ClassNotFoundException ex){}
257
        
257
        
258
        ProjectClassPathExtender cpExtender = webProject.getLookup().lookup(ProjectClassPathExtender.class);
258
        try {
259
        if (cpExtender != null) {
259
            AntArtifact target = getAntArtifact(ejbReference, refType);
260
            try {
260
            ProjectClassPathModifier.addAntArtifacts(new AntArtifact[] {target}, new URI[] {target.getArtifactLocations()[0].normalize()}, referencingFile, ClassPath.COMPILE);
261
                AntArtifact target = getAntArtifact(ejbReference, refType);
261
        } catch (IOException ioe) {
262
                cpExtender.addAntArtifact(target, target.getArtifactLocations()[0].normalize());
262
            Exceptions.printStackTrace(ioe);
263
            } catch (IOException ioe) {
264
                Exceptions.printStackTrace(ioe);
265
            }
266
        } else {
267
            Logger.getLogger("global").log(Level.INFO, "WebProjectClassPathExtender not found in the project lookup of project: " + webProject.getProjectDirectory().getPath());    //NOI18N
268
        }
263
        }
269
        
264
        
270
        writeDD(referencingFile, referencingClass);
265
        writeDD(referencingFile, referencingClass);
(-)a/j2ee.ejbjarproject/nbproject/project.xml (-1 / +1 lines)
Lines 263-269 Link Here
263
                    <compile-dependency/>
263
                    <compile-dependency/>
264
                    <run-dependency>
264
                    <run-dependency>
265
                        <release-version>1</release-version>
265
                        <release-version>1</release-version>
266
                        <specification-version>1.37</specification-version>
266
                        <specification-version>1.41</specification-version>
267
                    </run-dependency>
267
                    </run-dependency>
268
                </dependency>
268
                </dependency>
269
                <dependency>
269
                <dependency>
(-)a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarProject.java (-8 / +7 lines)
Lines 52-57 Link Here
52
import java.io.IOException;
52
import java.io.IOException;
53
import java.io.InputStream;
53
import java.io.InputStream;
54
import java.io.OutputStream;
54
import java.io.OutputStream;
55
import java.net.URL;
55
import java.util.ArrayList;
56
import java.util.ArrayList;
56
import java.util.Arrays;
57
import java.util.Arrays;
57
import java.util.Collections;
58
import java.util.Collections;
Lines 86-92 Link Here
86
import org.netbeans.modules.j2ee.common.SharabilityUtility;
87
import org.netbeans.modules.j2ee.common.SharabilityUtility;
87
import org.netbeans.modules.j2ee.common.Util;
88
import org.netbeans.modules.j2ee.common.Util;
88
import org.netbeans.modules.j2ee.common.project.ArtifactCopyOnSaveSupport;
89
import org.netbeans.modules.j2ee.common.project.ArtifactCopyOnSaveSupport;
89
import org.netbeans.modules.java.api.common.classpath.ClassPathExtender;
90
import org.netbeans.modules.java.api.common.classpath.ClassPathModifier;
90
import org.netbeans.modules.java.api.common.classpath.ClassPathModifier;
91
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport;
91
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport;
92
import org.netbeans.modules.java.api.common.classpath.ClassPathProviderImpl;
92
import org.netbeans.modules.java.api.common.classpath.ClassPathProviderImpl;
Lines 127-132 Link Here
127
import org.netbeans.modules.j2ee.common.project.ui.UserProjectSettings;
127
import org.netbeans.modules.j2ee.common.project.ui.UserProjectSettings;
128
import org.netbeans.modules.j2ee.deployment.devmodules.api.InstanceRemovedException;
128
import org.netbeans.modules.j2ee.deployment.devmodules.api.InstanceRemovedException;
129
import org.netbeans.api.j2ee.core.Profile;
129
import org.netbeans.api.j2ee.core.Profile;
130
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
130
import org.netbeans.api.project.ProjectUtils;
131
import org.netbeans.api.project.ProjectUtils;
131
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule.Type;
132
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule.Type;
132
import org.netbeans.modules.j2ee.deployment.devmodules.spi.ArtifactListener;
133
import org.netbeans.modules.j2ee.deployment.devmodules.spi.ArtifactListener;
Lines 205-211 Link Here
205
    private EjbProjectJAXWSClientSupport jaxWsClientSupport;
206
    private EjbProjectJAXWSClientSupport jaxWsClientSupport;
206
    private SourceRoots sourceRoots;
207
    private SourceRoots sourceRoots;
207
    private SourceRoots testRoots;
208
    private SourceRoots testRoots;
208
    private final ClassPathExtender classPathExtender; 
209
    private final ClassPathModifier classPathModifier; 
209
    private final ClassPathModifier classPathModifier; 
210
    private PropertyChangeListener j2eePlatformListener;
210
    private PropertyChangeListener j2eePlatformListener;
211
    private AntBuildExtender buildExtender;
211
    private AntBuildExtender buildExtender;
Lines 308-314 Link Here
308
        classPathModifier = new ClassPathModifier(this, this.updateHelper, eval, refHelper,
308
        classPathModifier = new ClassPathModifier(this, this.updateHelper, eval, refHelper,
309
            new ClassPathSupportCallbackImpl(helper), createClassPathModifierCallback(), 
309
            new ClassPathSupportCallbackImpl(helper), createClassPathModifierCallback(), 
310
            getClassPathUiSupportCallback());
310
            getClassPathUiSupportCallback());
311
        classPathExtender = new ClassPathExtender(classPathModifier, ProjectProperties.JAVAC_CLASSPATH, ClassPathSupportCallbackImpl.ELEMENT_INCLUDED_LIBRARIES);
312
        lookup = createLookup(aux, cpProvider);
311
        lookup = createLookup(aux, cpProvider);
313
        css = new CopyOnSaveSupport();
312
        css = new CopyOnSaveSupport();
314
        artifactSupport = new ArtifactCopySupport();
313
        artifactSupport = new ArtifactCopySupport();
Lines 448-454 Link Here
448
                encodingQuery,
447
                encodingQuery,
449
                new RecommendedTemplatesImpl(updateHelper),
448
                new RecommendedTemplatesImpl(updateHelper),
450
                refHelper,
449
                refHelper,
451
                classPathExtender,
450
                ProjectClassPathModifier.extenderForModifier(classPathModifier),
452
                classPathModifier,
451
                classPathModifier,
453
                new EjbJarProjectOperations(this),
452
                new EjbJarProjectOperations(this),
454
                new EjbJarPersistenceProvider(this, evaluator(), cpProvider),
453
                new EjbJarPersistenceProvider(this, evaluator(), cpProvider),
Lines 691-697 Link Here
691
        
690
        
692
        if (fo.getParent ().equals (libFolder)) {
691
        if (fo.getParent ().equals (libFolder)) {
693
            try {
692
            try {
694
                classPathExtender.addArchiveFile(fo);
693
                classPathModifier.addRoots(new URL[] {FileUtil.getArchiveRoot(fo.getURL())}, ProjectProperties.JAVAC_CLASSPATH);
695
            }
694
            }
696
            catch (IOException e) {
695
            catch (IOException e) {
697
                Exceptions.printStackTrace(e);
696
                Exceptions.printStackTrace(e);
Lines 770-784 Link Here
770
                if (libFolderName != null && helper.resolveFile (libFolderName).isDirectory ()) {
769
                if (libFolderName != null && helper.resolveFile (libFolderName).isDirectory ()) {
771
                    libFolder = helper.resolveFileObject(libFolderName);
770
                    libFolder = helper.resolveFileObject(libFolderName);
772
                        FileObject[] children = libFolder.getChildren ();
771
                        FileObject[] children = libFolder.getChildren ();
773
                        List<FileObject> libs = new LinkedList<FileObject>();
772
                        List<URL> libs = new LinkedList<URL>();
774
                        for (int i = 0; i < children.length; i++) {
773
                        for (int i = 0; i < children.length; i++) {
775
                            if (FileUtil.isArchiveFile(children[i])) {
774
                            if (FileUtil.isArchiveFile(children[i])) {
776
                                libs.add(children[i]);
775
                                libs.add(FileUtil.getArchiveRoot(children[i].getURL()));
777
                            }
776
                            }
778
                        }
777
                        }
779
                        FileObject[] libsArray = new FileObject[libs.size()];
778
                        FileObject[] libsArray = new FileObject[libs.size()];
780
                        libs.toArray(libsArray);
779
                        libs.toArray(libsArray);
781
                        classPathExtender.addArchiveFiles(ProjectProperties.JAVAC_CLASSPATH, libsArray, ClassPathSupportCallbackImpl.ELEMENT_INCLUDED_LIBRARIES);
780
                        classPathModifier.addRoots(libs.toArray(new URL[libs.size()]), ProjectProperties.JAVAC_CLASSPATH);
782
                        libFolder.addFileChangeListener (EjbJarProject.this);
781
                        libFolder.addFileChangeListener (EjbJarProject.this);
783
                }
782
                }
784
                
783
                
(-)a/java.j2seproject/nbproject/project.xml (-1 / +1 lines)
Lines 159-165 Link Here
159
                    <compile-dependency/>
159
                    <compile-dependency/>
160
                    <run-dependency>
160
                    <run-dependency>
161
                        <release-version>1</release-version>
161
                        <release-version>1</release-version>
162
                        <specification-version>1.37</specification-version>
162
                        <specification-version>1.41</specification-version>
163
                    </run-dependency>
163
                    </run-dependency>
164
                </dependency>
164
                </dependency>
165
                <dependency>
165
                <dependency>
(-)a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java (-3 / +2 lines)
Lines 75-80 Link Here
75
import org.netbeans.api.java.classpath.ClassPath;
75
import org.netbeans.api.java.classpath.ClassPath;
76
import org.netbeans.api.java.classpath.GlobalPathRegistry;
76
import org.netbeans.api.java.classpath.GlobalPathRegistry;
77
import org.netbeans.api.java.project.JavaProjectConstants;
77
import org.netbeans.api.java.project.JavaProjectConstants;
78
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
78
import org.netbeans.api.project.Project;
79
import org.netbeans.api.project.Project;
79
import org.netbeans.api.project.ProjectManager;
80
import org.netbeans.api.project.ProjectManager;
80
import org.netbeans.api.project.SourceGroup;
81
import org.netbeans.api.project.SourceGroup;
Lines 341-348 Link Here
341
    private Lookup createLookup(final AuxiliaryConfiguration aux,
342
    private Lookup createLookup(final AuxiliaryConfiguration aux,
342
            final J2SEActionProvider actionProvider) {
343
            final J2SEActionProvider actionProvider) {
343
        FileEncodingQueryImplementation encodingQuery = QuerySupport.createFileEncodingQuery(evaluator(), J2SEProjectProperties.SOURCE_ENCODING);
344
        FileEncodingQueryImplementation encodingQuery = QuerySupport.createFileEncodingQuery(evaluator(), J2SEProjectProperties.SOURCE_ENCODING);
344
        @SuppressWarnings("deprecation") Object cpe = new org.netbeans.modules.java.api.common.classpath.ClassPathExtender(
345
            cpMod, ProjectProperties.JAVAC_CLASSPATH, null);
346
        final Lookup base = Lookups.fixed(
345
        final Lookup base = Lookups.fixed(
347
            J2SEProject.this,
346
            J2SEProject.this,
348
            QuerySupport.createProjectInformation(updateHelper, this, J2SE_PROJECT_ICON),
347
            QuerySupport.createProjectInformation(updateHelper, this, J2SE_PROJECT_ICON),
Lines 366-372 Link Here
366
            QuerySupport.createSharabilityQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()),
365
            QuerySupport.createSharabilityQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()),
367
            new CoSAwareFileBuiltQueryImpl(QuerySupport.createFileBuiltQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()), this),
366
            new CoSAwareFileBuiltQueryImpl(QuerySupport.createFileBuiltQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()), this),
368
            new RecommendedTemplatesImpl (this.updateHelper),
367
            new RecommendedTemplatesImpl (this.updateHelper),
369
            cpe,
368
            ProjectClassPathModifier.extenderForModifier(cpMod),
370
            buildExtender,
369
            buildExtender,
371
            cpMod,
370
            cpMod,
372
            new J2SEProjectOperations(this, actionProvider),
371
            new J2SEProjectOperations(this, actionProvider),
(-)a/java.project/apichanges.xml (+21 lines)
Lines 109-114 Link Here
109
    <!-- ACTUAL CHANGES BEGIN HERE: -->
109
    <!-- ACTUAL CHANGES BEGIN HERE: -->
110
110
111
    <changes>
111
    <changes>
112
        <change id="ProjectClassPathModifier.extenderForModifier">
113
            <api name="classpath"/>
114
            <summary>Added <code>ProjectClassPathModifier.extenderForModifier</code></summary>
115
            <version major="1" minor="41"/>
116
            <date day="22" month="8" year="2011"/>
117
            <author login="jglick"/>
118
            <compatibility addition="yes">
119
                <p>
120
                    Any modules still implementing <code>ProjectClassPathExtender</code> should cease to do so.
121
                </p>
122
            </compatibility>
123
            <description>
124
                <p>
125
                    Added a bridge from an old SPI to the newer, preferred SPI.
126
                    Also added <code>LookupMergerSupport.createClassPathModifierMerger</code>.
127
                </p>
128
            </description>
129
            <class package="org.netbeans.api.java.project.classpath" name="ProjectClassPathModifier"/>
130
            <class package="org.netbeans.spi.java.project.support" name="LookupMergerSupport"/>
131
            <issue number="196455"/>
132
        </change>
112
        <change id="JAVA_ICON">
133
        <change id="JAVA_ICON">
113
            <api name="general"/>
134
            <api name="general"/>
114
            <summary>Added <code>JavaTemplates.JAVA_ICON</code></summary>
135
            <summary>Added <code>JavaTemplates.JAVA_ICON</code></summary>
(-)a/java.project/manifest.mf (-1 / +1 lines)
Lines 3-9 Link Here
3
OpenIDE-Module-Layer: org/netbeans/modules/java/project/layer.xml
3
OpenIDE-Module-Layer: org/netbeans/modules/java/project/layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/project/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/project/Bundle.properties
5
OpenIDE-Module-Needs: javax.script.ScriptEngine.freemarker
5
OpenIDE-Module-Needs: javax.script.ScriptEngine.freemarker
6
OpenIDE-Module-Specification-Version: 1.40
6
OpenIDE-Module-Specification-Version: 1.41
7
OpenIDE-Module-Recommends: org.netbeans.spi.java.project.runner.JavaRunnerImplementation
7
OpenIDE-Module-Recommends: org.netbeans.spi.java.project.runner.JavaRunnerImplementation
8
AutoUpdate-Show-In-Client: false
8
AutoUpdate-Show-In-Client: false
9
9
(-)a/java.project/src/org/netbeans/api/java/project/classpath/ProjectClassPathModifier.java (+95 lines)
Lines 56-61 Link Here
56
import org.netbeans.api.project.libraries.Library;
56
import org.netbeans.api.project.libraries.Library;
57
import org.netbeans.modules.java.project.classpath.ProjectClassPathModifierAccessor;
57
import org.netbeans.modules.java.project.classpath.ProjectClassPathModifierAccessor;
58
import org.netbeans.spi.java.project.classpath.ProjectClassPathModifierImplementation;
58
import org.netbeans.spi.java.project.classpath.ProjectClassPathModifierImplementation;
59
import org.netbeans.spi.java.project.support.LookupMergerSupport;
59
import org.netbeans.spi.project.libraries.support.LibrariesSupport;
60
import org.netbeans.spi.project.libraries.support.LibrariesSupport;
60
import org.netbeans.spi.project.support.ant.PropertyUtils;
61
import org.netbeans.spi.project.support.ant.PropertyUtils;
61
import org.openide.filesystems.FileObject;
62
import org.openide.filesystems.FileObject;
Lines 455-458 Link Here
455
456
456
    }
457
    }
457
458
459
    /**
460
     * Translates the new SPI into an instance of the old SPI.
461
     * Useful to place in project lookup so that you need not bother implementing the old SPI.
462
     * (Since there was not previously a matching API, old clients may directly look for the old SPI
463
     * interface in a project's lookup.)
464
     * Corresponding methods are called using the first reported source group (if any) and extensible classpath type (if any).
465
     * @param pcpmi the new SPI
466
     * @return a proxy fitting the old SPI
467
     * @see #extenderForModifier(Project)
468
     * @since 1.41
469
     */
470
    @SuppressWarnings("deprecation") // XXX seems ineffective against return type
471
    public static org.netbeans.spi.java.project.classpath.ProjectClassPathExtender extenderForModifier(final ProjectClassPathModifierImplementation pcpmi) {
472
        return new org.netbeans.spi.java.project.classpath.ProjectClassPathExtender() {
473
            @Override public boolean addLibrary(Library library) throws IOException {
474
                SourceGroup[] sgs = ProjectClassPathModifierAccessor.INSTANCE.getExtensibleSourceGroups(pcpmi);
475
                if (sgs.length == 0) {
476
                    return false;
477
                }
478
                String[] types = ProjectClassPathModifierAccessor.INSTANCE.getExtensibleClassPathTypes(pcpmi, sgs[0]);
479
                if (types.length == 0) {
480
                    return false;
481
                }
482
                try {
483
                    return ProjectClassPathModifierAccessor.INSTANCE.addLibraries(new Library[] {library}, pcpmi, sgs[0], types[0]);
484
                } catch (UnsupportedOperationException x) {
485
                    return false;
486
                }
487
            }
488
            @Override public boolean addArchiveFile(FileObject archiveFile) throws IOException {
489
                SourceGroup[] sgs = ProjectClassPathModifierAccessor.INSTANCE.getExtensibleSourceGroups(pcpmi);
490
                if (sgs.length == 0) {
491
                    return false;
492
                }
493
                String[] types = ProjectClassPathModifierAccessor.INSTANCE.getExtensibleClassPathTypes(pcpmi, sgs[0]);
494
                if (types.length == 0) {
495
                    return false;
496
                }
497
                URL r = archiveFile.getURL();
498
                if (FileUtil.isArchiveFile(r)) { // ought to always be true, but Javadoc is vague
499
                    r = FileUtil.getArchiveRoot(r);
500
                }
501
                try {
502
                    return ProjectClassPathModifierAccessor.INSTANCE.addRoots(new URL[] {r}, pcpmi, sgs[0], types[0]);
503
                } catch (UnsupportedOperationException x) {
504
                    return false;
505
                }
506
            }
507
            @Override public boolean addAntArtifact(AntArtifact artifact, URI artifactElement) throws IOException {
508
                SourceGroup[] sgs = ProjectClassPathModifierAccessor.INSTANCE.getExtensibleSourceGroups(pcpmi);
509
                if (sgs.length == 0) {
510
                    return false;
511
                }
512
                String[] types = ProjectClassPathModifierAccessor.INSTANCE.getExtensibleClassPathTypes(pcpmi, sgs[0]);
513
                if (types.length == 0) {
514
                    return false;
515
                }
516
                try {
517
                    return ProjectClassPathModifierAccessor.INSTANCE.addAntArtifacts(new AntArtifact[] {artifact}, new URI[] {artifactElement}, pcpmi, sgs[0], types[0]);
518
                } catch (UnsupportedOperationException x) {
519
                    return false;
520
                }
521
            }
522
523
        };
524
    }
525
526
    /**
527
     * Similar to {@link #extenderForModifier(ProjectClassPathModifierImplementation)} but permits the new SPI to be created lazily.
528
     * This is useful if the project is using {@link LookupMergerSupport#createClassPathModifierMerger} and it is thus impossible to get the final SPI instance
529
     * during construction of the project's lookup.
530
     * The new SPI is located at runtime on each call; if not present, false is returned from all methods.
531
     * @param p a project whose lookup may contain a {@link ProjectClassPathModifierImplementation}
532
     * @return an SPI equivalent
533
     * @since 1.41
534
     */
535
    @SuppressWarnings("deprecation")
536
    public static org.netbeans.spi.java.project.classpath.ProjectClassPathExtender extenderForModifier(final Project p) {
537
        return new org.netbeans.spi.java.project.classpath.ProjectClassPathExtender() {
538
            @Override public boolean addLibrary(Library library) throws IOException {
539
                ProjectClassPathModifierImplementation pcpmi = p.getLookup().lookup(ProjectClassPathModifierImplementation.class);
540
                return pcpmi != null ? extenderForModifier(pcpmi).addLibrary(library) : false;
541
            }
542
            @Override public boolean addArchiveFile(FileObject archiveFile) throws IOException {
543
                ProjectClassPathModifierImplementation pcpmi = p.getLookup().lookup(ProjectClassPathModifierImplementation.class);
544
                return pcpmi != null ? extenderForModifier(pcpmi).addArchiveFile(archiveFile) : false;
545
            }
546
            @Override public boolean addAntArtifact(AntArtifact artifact, URI artifactElement) throws IOException {
547
                ProjectClassPathModifierImplementation pcpmi = p.getLookup().lookup(ProjectClassPathModifierImplementation.class);
548
                return pcpmi != null ? extenderForModifier(pcpmi).addAntArtifact(artifact, artifactElement) : false;
549
            }
550
        };
551
    }
552
458
}
553
}
(-)a/java.project/src/org/netbeans/modules/java/project/classpath/ClassPathModifierLookupMerger.java (+194 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 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 2008 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.java.project.classpath;
44
45
import java.io.IOException;
46
import java.net.URI;
47
import java.net.URL;
48
import java.util.Arrays;
49
import java.util.Collection;
50
import java.util.LinkedHashSet;
51
import org.netbeans.api.project.Project;
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.spi.java.project.classpath.ProjectClassPathModifierImplementation;
56
import org.netbeans.spi.project.LookupMerger;
57
import org.openide.util.Lookup;
58
59
public class ClassPathModifierLookupMerger implements LookupMerger<ProjectClassPathModifierImplementation>{
60
    
61
    @Override public Class<ProjectClassPathModifierImplementation> getMergeableClass() {
62
        return ProjectClassPathModifierImplementation.class;
63
    }
64
65
    @Override public ProjectClassPathModifierImplementation merge(Lookup lookup) {
66
        return new Modifier(lookup);
67
    }
68
69
    private static class Modifier extends ProjectClassPathModifierImplementation {
70
        
71
        private final Lookup context;
72
        
73
        private Modifier(Lookup context) {
74
            this.context = context;
75
        }
76
    
77
        @Override protected SourceGroup[] getExtensibleSourceGroups() {
78
            Collection<SourceGroup> sgs = new LinkedHashSet<SourceGroup>();
79
            for (ProjectClassPathModifierImplementation impl : context.lookupAll(ProjectClassPathModifierImplementation.class)) {
80
                sgs.addAll(Arrays.asList(ProjectClassPathModifierAccessor.INSTANCE.getExtensibleSourceGroups(impl)));
81
            }
82
            return sgs.toArray(new SourceGroup[sgs.size()]);
83
        }
84
85
        @Override protected String[] getExtensibleClassPathTypes(SourceGroup sourceGroup) {
86
            Collection<String> types = new LinkedHashSet<String>();
87
            for (ProjectClassPathModifierImplementation impl : context.lookupAll(ProjectClassPathModifierImplementation.class)) {
88
                types.addAll(Arrays.asList(ProjectClassPathModifierAccessor.INSTANCE.getExtensibleClassPathTypes(impl, sourceGroup)));
89
            }
90
            return types.toArray(new String[types.size()]);
91
        }
92
        
93
        private interface Op {
94
            boolean run(ProjectClassPathModifierImplementation impl) throws IOException, UnsupportedOperationException;
95
        }
96
        
97
        private boolean run(Op op) throws IOException, UnsupportedOperationException {
98
            boolean completedNormally = false;
99
            UnsupportedOperationException uoe = null;
100
            for (ProjectClassPathModifierImplementation impl : context.lookupAll(ProjectClassPathModifierImplementation.class)) {
101
                try {
102
                    if (op.run(impl)) {
103
                        return true;
104
                    } else {
105
                        completedNormally = true;
106
                    }
107
                } catch (UnsupportedOperationException x) {
108
                    uoe = x;
109
                }
110
            }
111
            if (uoe != null && !completedNormally) {
112
                throw uoe;
113
            } else {
114
                return false;
115
            }
116
        }
117
        
118
        // closures would be handy here...
119
120
        @Override protected boolean addLibraries(final Library[] libraries, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
121
            return run(new Op() {
122
                @Override public boolean run(ProjectClassPathModifierImplementation impl) throws IOException, UnsupportedOperationException {
123
                    return ProjectClassPathModifierAccessor.INSTANCE.addLibraries(libraries, impl, sourceGroup, type);
124
                }
125
            });
126
        }
127
128
        @Override protected boolean removeLibraries(final Library[] libraries, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
129
            return run(new Op() {
130
                @Override public boolean run(ProjectClassPathModifierImplementation impl) throws IOException, UnsupportedOperationException {
131
                    return ProjectClassPathModifierAccessor.INSTANCE.removeLibraries(libraries, impl, sourceGroup, type);
132
                }
133
            });
134
        }
135
136
        @Override protected boolean addRoots(final URL[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
137
            return run(new Op() {
138
                @Override public boolean run(ProjectClassPathModifierImplementation impl) throws IOException, UnsupportedOperationException {
139
                    return ProjectClassPathModifierAccessor.INSTANCE.addRoots(classPathRoots, impl, sourceGroup, type);
140
                }
141
            });
142
        }
143
144
        @Override protected boolean removeRoots(final URL[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
145
            return run(new Op() {
146
                @Override public boolean run(ProjectClassPathModifierImplementation impl) throws IOException, UnsupportedOperationException {
147
                    return ProjectClassPathModifierAccessor.INSTANCE.removeRoots(classPathRoots, impl, sourceGroup, type);
148
                }
149
            });
150
        }
151
152
        @Override protected boolean addRoots(final URI[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
153
            return run(new Op() {
154
                @Override public boolean run(ProjectClassPathModifierImplementation impl) throws IOException, UnsupportedOperationException {
155
                    return ProjectClassPathModifierAccessor.INSTANCE.addRoots(classPathRoots, impl, sourceGroup, type);
156
                }
157
            });
158
        }
159
160
        @Override protected boolean removeRoots(final URI[] classPathRoots, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
161
            return run(new Op() {
162
                @Override public boolean run(ProjectClassPathModifierImplementation impl) throws IOException, UnsupportedOperationException {
163
                    return ProjectClassPathModifierAccessor.INSTANCE.removeRoots(classPathRoots, impl, sourceGroup, type);
164
                }
165
            });
166
        }
167
168
        @Override protected boolean addAntArtifacts(final AntArtifact[] artifacts, final URI[] artifactElements, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
169
            return run(new Op() {
170
                @Override public boolean run(ProjectClassPathModifierImplementation impl) throws IOException, UnsupportedOperationException {
171
                    return ProjectClassPathModifierAccessor.INSTANCE.addAntArtifacts(artifacts, artifactElements, impl, sourceGroup, type);
172
                }
173
            });
174
        }
175
176
        @Override protected boolean removeAntArtifacts(final AntArtifact[] artifacts, final URI[] artifactElements, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
177
            return run(new Op() {
178
                @Override public boolean run(ProjectClassPathModifierImplementation impl) throws IOException, UnsupportedOperationException {
179
                    return ProjectClassPathModifierAccessor.INSTANCE.removeAntArtifacts(artifacts, artifactElements, impl, sourceGroup, type);
180
                }
181
            });
182
        }
183
184
        @Override protected boolean addProjects(final Project[] projects, final SourceGroup sourceGroup, final String type) throws IOException, UnsupportedOperationException {
185
            return run(new Op() {
186
                @Override public boolean run(ProjectClassPathModifierImplementation impl) throws IOException, UnsupportedOperationException {
187
                    return ProjectClassPathModifierAccessor.INSTANCE.addProjects(projects, impl, sourceGroup, type);
188
                }
189
            });
190
        }
191
192
    }
193
    
194
}
(-)a/java.project/src/org/netbeans/spi/java/project/classpath/ProjectClassPathExtender.java (-4 / +6 lines)
Lines 46-51 Link Here
46
46
47
import java.io.IOException;
47
import java.io.IOException;
48
import java.net.URI;
48
import java.net.URI;
49
import java.net.URL;
49
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
50
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
50
import org.netbeans.api.project.ant.AntArtifact;
51
import org.netbeans.api.project.ant.AntArtifact;
51
import org.netbeans.api.project.libraries.Library;
52
import org.netbeans.api.project.libraries.Library;
Lines 57-63 Link Here
57
 * allow clients to extend its compilation classpath
58
 * allow clients to extend its compilation classpath
58
 * by a new classpath element (JAR, folder, dependent project, or library).
59
 * by a new classpath element (JAR, folder, dependent project, or library).
59
 * @since org.netbeans.modules.java.project/1 1.3
60
 * @since org.netbeans.modules.java.project/1 1.3
60
 * @deprecated Please use {@link ProjectClassPathModifier} instead.
61
 * @deprecated As a caller, use {@link ProjectClassPathModifier} instead.
62
 *             As an implementor, use {@link ProjectClassPathModifier#extenderForModifier}.
61
 */
63
 */
62
@Deprecated
64
@Deprecated
63
public interface ProjectClassPathExtender {
65
public interface ProjectClassPathExtender {
Lines 68-74 Link Here
68
     * @param library to be added
70
     * @param library to be added
69
     * @return true in case the classpath was changed
71
     * @return true in case the classpath was changed
70
     * @exception IOException in case the project metadata cannot be changed
72
     * @exception IOException in case the project metadata cannot be changed
71
     * @deprecated Please use {@link ProjectClassPathModifier#addLibrary} instead.
73
     * @deprecated Please use {@link ProjectClassPathModifier#addLibraries} instead.
72
     */
74
     */
73
    @Deprecated
75
    @Deprecated
74
    boolean addLibrary(Library library) throws IOException;
76
    boolean addLibrary(Library library) throws IOException;
Lines 79-85 Link Here
79
     * @param archiveFile ZIP/JAR file to be added
81
     * @param archiveFile ZIP/JAR file to be added
80
     * @return true in case the classpath was changed
82
     * @return true in case the classpath was changed
81
     * @exception IOException in case the project metadata cannot be changed
83
     * @exception IOException in case the project metadata cannot be changed
82
     * @deprecated Please use {@link ProjectClassPathModifier#addArchive} instead.
84
     * @deprecated Please use {@link ProjectClassPathModifier#addRoots(URL[], FileObject, String)} instead.
83
     */
85
     */
84
    @Deprecated
86
    @Deprecated
85
    boolean addArchiveFile(FileObject archiveFile) throws IOException;
87
    boolean addArchiveFile(FileObject archiveFile) throws IOException;
Lines 92-98 Link Here
92
     *                        (must be owned by the artifact and be relative to it)
94
     *                        (must be owned by the artifact and be relative to it)
93
     * @return true in case the classpath was changed
95
     * @return true in case the classpath was changed
94
     * @exception IOException in case the project metadata cannot be changed
96
     * @exception IOException in case the project metadata cannot be changed
95
     * @deprecated Please use {@link ProjectClassPathModifier#addAntArtifact} instead.
97
     * @deprecated Please use {@link ProjectClassPathModifier#addAntArtifacts} instead.
96
     */
98
     */
97
    @Deprecated
99
    @Deprecated
98
    boolean addAntArtifact(AntArtifact artifact, URI artifactElement) throws IOException;
100
    boolean addAntArtifact(AntArtifact artifact, URI artifactElement) throws IOException;
(-)a/java.project/src/org/netbeans/spi/java/project/classpath/ProjectClassPathModifierImplementation.java (-21 / +22 lines)
Lines 52-57 Link Here
52
import java.net.URL;
52
import java.net.URL;
53
import java.util.ArrayList;
53
import java.util.ArrayList;
54
import java.util.List;
54
import java.util.List;
55
import org.netbeans.api.java.classpath.ClassPath;
55
import org.netbeans.api.java.project.JavaProjectConstants;
56
import org.netbeans.api.java.project.JavaProjectConstants;
56
import org.netbeans.api.project.Project;
57
import org.netbeans.api.project.Project;
57
import org.netbeans.api.project.SourceGroup;
58
import org.netbeans.api.project.SourceGroup;
Lines 69-75 Link Here
69
70
70
/**
71
/**
71
 * An SPI for project's classpaths modification.
72
 * An SPI for project's classpaths modification.
72
 * A project can provide subclass of this class in its {@link org.netbeans.api.project.Project#getLookup lookup} to
73
 * A project can provide subclass of this class in its {@link Project#getLookup lookup} to
73
 * allow clients to add or remove new classpath elements (JAR, folder, dependent project, or library) to its 
74
 * allow clients to add or remove new classpath elements (JAR, folder, dependent project, or library) to its 
74
 * classpaths.
75
 * classpaths.
75
 * @since org.netbeans.modules.java.project/1 1.10
76
 * @since org.netbeans.modules.java.project/1 1.10
Lines 103-112 Link Here
103
     * Adds libraries into the project's classpath if the
104
     * Adds libraries into the project's classpath if the
104
     * libraries are not already included.
105
     * libraries are not already included.
105
     * @param libraries to be added
106
     * @param libraries to be added
106
     * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA}
107
     * @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA}
107
     * identifying the compilation unit to change
108
     * identifying the compilation unit to change
108
     * @param type the type of the classpath the library should be added to,
109
     * @param type the type of the classpath the library should be added to,
109
     * eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE}
110
     * e.g. {@link ClassPath#COMPILE}
110
     * @return true in case the classpath was changed (at least one library was added to the classpath),
111
     * @return true in case the classpath was changed (at least one library was added to the classpath),
111
     * the value false is returned when all the libraries are already included on the classpath.
112
     * the value false is returned when all the libraries are already included on the classpath.
112
     * @exception IOException in case the project metadata cannot be changed
113
     * @exception IOException in case the project metadata cannot be changed
Lines 120-129 Link Here
120
     * Removes libraries from the project's classpath if the
121
     * Removes libraries from the project's classpath if the
121
     * libraries are included on it.
122
     * libraries are included on it.
122
     * @param libraries to be removed
123
     * @param libraries to be removed
123
     * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA}
124
     * @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA}
124
     * identifying the compilation unit to change
125
     * identifying the compilation unit to change
125
     * @param type the type of the classpath the library should be removed from,
126
     * @param type the type of the classpath the library should be removed from,
126
     * eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE}
127
     * e.g. {@link ClassPath#COMPILE}
127
     * @return true in case the classpath was changed, (at least one library was removed from the classpath),
128
     * @return true in case the classpath was changed, (at least one library was removed from the classpath),
128
     * the value false is returned when none of the libraries was included on the classpath.
129
     * the value false is returned when none of the libraries was included on the classpath.
129
     * @exception IOException in case the project metadata cannot be changed
130
     * @exception IOException in case the project metadata cannot be changed
Lines 136-145 Link Here
136
     * Adds archive files or folders into the project's classpath if the
137
     * Adds archive files or folders into the project's classpath if the
137
     * entries are not already there.
138
     * entries are not already there.
138
     * @param classPathRoots roots to be added, each root has to be either a root of an archive or a folder
139
     * @param classPathRoots roots to be added, each root has to be either a root of an archive or a folder
139
     * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA}
140
     * @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA}
140
     * identifying the compilation unit to change
141
     * identifying the compilation unit to change
141
     * @param type the type of the classpath the root should be added to,
142
     * @param type the type of the classpath the root should be added to,
142
     * eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE}
143
     * e.g. {@link ClassPath#COMPILE}
143
     * @return true in case the classpath was changed, (at least one classpath root was added to the classpath),
144
     * @return true in case the classpath was changed, (at least one classpath root was added to the classpath),
144
     * the value false is returned when all the classpath roots are already included on the classpath.
145
     * the value false is returned when all the classpath roots are already included on the classpath.
145
     * @exception IOException in case the project metadata cannot be changed
146
     * @exception IOException in case the project metadata cannot be changed
Lines 156-165 Link Here
156
     * {@link #addRoots(URL[], SourceGroup, String)}. It throws UnsupportedOperationException
157
     * {@link #addRoots(URL[], SourceGroup, String)}. It throws UnsupportedOperationException
157
     * if URIs are not absolute.
158
     * if URIs are not absolute.
158
     * @param classPathRoots roots to be added, each root has to be either a root of an archive or a folder; URI can be relative
159
     * @param classPathRoots roots to be added, each root has to be either a root of an archive or a folder; URI can be relative
159
     * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA}
160
     * @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA}
160
     * identifying the compilation unit to change
161
     * identifying the compilation unit to change
161
     * @param type the type of the classpath the root should be added to,
162
     * @param type the type of the classpath the root should be added to,
162
     * eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE}
163
     * e.g. {@link ClassPath#COMPILE}
163
     * @return true in case the classpath was changed, (at least one classpath root was added to the classpath),
164
     * @return true in case the classpath was changed, (at least one classpath root was added to the classpath),
164
     * the value false is returned when all the classpath roots are already included on the classpath.
165
     * the value false is returned when all the classpath roots are already included on the classpath.
165
     * @exception IOException in case the project metadata cannot be changed
166
     * @exception IOException in case the project metadata cannot be changed
Lines 206-215 Link Here
206
     * Removes archive files or folders from the project's classpath if the
207
     * Removes archive files or folders from the project's classpath if the
207
     * entries are included on it.
208
     * entries are included on it.
208
     * @param classPathRoots roots to be removed, each root has to be either a root of an archive or a folder
209
     * @param classPathRoots roots to be removed, each root has to be either a root of an archive or a folder
209
     * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA}
210
     * @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA}
210
     * identifying the compilation unit to change
211
     * identifying the compilation unit to change
211
     * @param type the type of the classpath the root should be removed from,
212
     * @param type the type of the classpath the root should be removed from,
212
     * eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE}
213
     * e.g. {@link ClassPath#COMPILE}
213
     * @return true in case the classpath was changed, (at least one classpath root was removed from the classpath),
214
     * @return true in case the classpath was changed, (at least one classpath root was removed from the classpath),
214
     * the value false is returned when none of the classpath roots was included on the classpath.
215
     * the value false is returned when none of the classpath roots was included on the classpath.
215
     * @exception IOException in case the project metadata cannot be changed
216
     * @exception IOException in case the project metadata cannot be changed
Lines 226-235 Link Here
226
     * {@link #removeRoots(URL[], SourceGroup, String)}. It throws UnsupportedOperationException
227
     * {@link #removeRoots(URL[], SourceGroup, String)}. It throws UnsupportedOperationException
227
     * if URIs are not absolute.
228
     * if URIs are not absolute.
228
     * @param classPathRoots roots to be removed, each root has to be either a root of an archive or a folder; URI can be relative
229
     * @param classPathRoots roots to be removed, each root has to be either a root of an archive or a folder; URI can be relative
229
     * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA}
230
     * @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA}
230
     * identifying the compilation unit to change
231
     * identifying the compilation unit to change
231
     * @param type the type of the classpath the root should be removed from,
232
     * @param type the type of the classpath the root should be removed from,
232
     * eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE}
233
     * e.g. {@link ClassPath#COMPILE}
233
     * @return true in case the classpath was changed, (at least one classpath root was removed from the classpath),
234
     * @return true in case the classpath was changed, (at least one classpath root was removed from the classpath),
234
     * the value false is returned when none of the classpath roots was included on the classpath.
235
     * the value false is returned when none of the classpath roots was included on the classpath.
235
     * @exception IOException in case the project metadata cannot be changed
236
     * @exception IOException in case the project metadata cannot be changed
Lines 247-256 Link Here
247
     * @param artifactElements the URIs of the build output, the artifactElements has to have the same length
248
     * @param artifactElements the URIs of the build output, the artifactElements has to have the same length
248
     * as artifacts. 
249
     * as artifacts. 
249
     * (must be owned by the artifact and be relative to it)
250
     * (must be owned by the artifact and be relative to it)
250
     * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA}
251
     * @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA}
251
     * identifying the compilation unit to change
252
     * identifying the compilation unit to change
252
     * @param type the type of the classpath the artifact should be added to,
253
     * @param type the type of the classpath the artifact should be added to,
253
     * eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE}
254
     * e.g. {@link ClassPath#COMPILE}
254
     * @return true in case the classpath was changed, (at least one artifact was added to the classpath),
255
     * @return true in case the classpath was changed, (at least one artifact was added to the classpath),
255
     * the value false is returned when all the artifacts are already included on the classpath.
256
     * the value false is returned when all the artifacts are already included on the classpath.
256
     * @exception IOException in case the project metadata cannot be changed
257
     * @exception IOException in case the project metadata cannot be changed
Lines 266-275 Link Here
266
     * @param artifactElements the URIs of the build output, the artifactElements has to have the same length
267
     * @param artifactElements the URIs of the build output, the artifactElements has to have the same length
267
     * as artifacts.
268
     * as artifacts.
268
     * (must be owned by the artifact and be relative to it)
269
     * (must be owned by the artifact and be relative to it)
269
     * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA}
270
     * @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA}
270
     * identifying the compilation unit to change
271
     * identifying the compilation unit to change
271
     * @param type the type of the classpath the artifact should be removed from,
272
     * @param type the type of the classpath the artifact should be removed from,
272
     * eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE}
273
     * e.g. {@link ClassPath#COMPILE}
273
     * @return true in case the classpath was changed, (at least one artifact was removed from the classpath),
274
     * @return true in case the classpath was changed, (at least one artifact was removed from the classpath),
274
     * the value false is returned when none of the artifacts was included on the classpath.
275
     * the value false is returned when none of the artifacts was included on the classpath.
275
     * @exception IOException in case the project metadata cannot be changed
276
     * @exception IOException in case the project metadata cannot be changed
Lines 285-294 Link Here
285
     * Other project types can override the behaviour.
286
     * Other project types can override the behaviour.
286
     * @param projects to be added
287
     * @param projects to be added
287
     * (must be owned by the artifact and be relative to it)
288
     * (must be owned by the artifact and be relative to it)
288
     * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA}
289
     * @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA}
289
     * identifying the compilation unit to change
290
     * identifying the compilation unit to change
290
     * @param type the type of the classpath the artifact should be added to,
291
     * @param type the type of the classpath the artifact should be added to,
291
     * eg {@link org.netbeans.api.java.classpath.ClassPath#COMPILE}
292
     * e.g. {@link ClassPath#COMPILE}
292
     * @return true in case the classpath was changed, (at least one artifact was added to the classpath),
293
     * @return true in case the classpath was changed, (at least one artifact was added to the classpath),
293
     * the value false is returned when all the artifacts are already included on the classpath.
294
     * the value false is returned when all the artifacts are already included on the classpath.
294
     * @exception IOException in case the project metadata cannot be changed
295
     * @exception IOException in case the project metadata cannot be changed
Lines 296-302 Link Here
296
     * adding of an artifact to the classpath of the given type.
297
     * adding of an artifact to the classpath of the given type.
297
     * @since org.netbeans.modules.java.project/1 1.24
298
     * @since org.netbeans.modules.java.project/1 1.24
298
     */
299
     */
299
    protected boolean addProjects(Project[] projects, SourceGroup sg, String classPathType) throws IOException, UnsupportedOperationException {
300
    protected boolean addProjects(Project[] projects, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
300
        List<AntArtifact> ants = new ArrayList<AntArtifact>();
301
        List<AntArtifact> ants = new ArrayList<AntArtifact>();
301
        List<URI> antUris = new ArrayList<URI>();
302
        List<URI> antUris = new ArrayList<URI>();
302
        for (Project prj : projects) {
303
        for (Project prj : projects) {
Lines 306-312 Link Here
306
                antUris.add(aa.getArtifactLocations()[0]);
307
                antUris.add(aa.getArtifactLocations()[0]);
307
            }
308
            }
308
        }
309
        }
309
        return addAntArtifacts(ants.toArray(new AntArtifact[0]), antUris.toArray(new URI[0]), sg, classPathType);
310
        return addAntArtifacts(ants.toArray(new AntArtifact[0]), antUris.toArray(new URI[0]), sourceGroup, type);
310
    }
311
    }
311
312
312
    /**
313
    /**
(-)a/java.project/src/org/netbeans/spi/java/project/support/LookupMergerSupport.java (-1 / +17 lines)
Lines 42-47 Link Here
42
42
43
package org.netbeans.spi.java.project.support;
43
package org.netbeans.spi.java.project.support;
44
44
45
import java.io.IOException;
45
import java.net.URL;
46
import java.net.URL;
46
import java.util.Arrays;
47
import java.util.Arrays;
47
import java.util.Collection;
48
import java.util.Collection;
Lines 54-60 Link Here
54
import org.netbeans.api.java.queries.JavadocForBinaryQuery;
55
import org.netbeans.api.java.queries.JavadocForBinaryQuery;
55
import org.netbeans.api.java.queries.SourceForBinaryQuery;
56
import org.netbeans.api.java.queries.SourceForBinaryQuery;
56
import org.netbeans.api.project.ProjectManager;
57
import org.netbeans.api.project.ProjectManager;
58
import org.netbeans.modules.java.project.classpath.ClassPathModifierLookupMerger;
57
import org.netbeans.spi.java.classpath.ClassPathProvider;
59
import org.netbeans.spi.java.classpath.ClassPathProvider;
60
import org.netbeans.spi.java.project.classpath.ProjectClassPathModifierImplementation;
58
import org.netbeans.spi.java.queries.JavadocForBinaryQueryImplementation;
61
import org.netbeans.spi.java.queries.JavadocForBinaryQueryImplementation;
59
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
62
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
60
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation2;
63
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation2;
Lines 106-112 Link Here
106
    public static LookupMerger<ClassPathProvider> createClassPathProviderMerger(ClassPathProvider defaultProvider) {
109
    public static LookupMerger<ClassPathProvider> createClassPathProviderMerger(ClassPathProvider defaultProvider) {
107
        return new ClassPathProviderMerger(defaultProvider);
110
        return new ClassPathProviderMerger(defaultProvider);
108
    }    
111
    }    
109
    
112
113
    /**
114
     * Creates a merger of class path modifiers.
115
     * All supported source groups and classpath types are unified.
116
     * The first modifier implementation to return true (or throw {@link IOException}) is accepted.
117
     * False is returned if all of the implementations do so.
118
     * {@link UnsupportedOperationException} is thrown only if all of the implementations do so.
119
     * @return a merger
120
     * @since 1.41
121
     */
122
    public static LookupMerger<ProjectClassPathModifierImplementation> createClassPathModifierMerger() {
123
        return new ClassPathModifierLookupMerger();
124
    }
125
110
    private static class SFBLookupMerger implements LookupMerger<SourceForBinaryQueryImplementation> {
126
    private static class SFBLookupMerger implements LookupMerger<SourceForBinaryQueryImplementation> {
111
127
112
        public Class<SourceForBinaryQueryImplementation> getMergeableClass() {
128
        public Class<SourceForBinaryQueryImplementation> getMergeableClass() {
(-)a/maven.persistence/manifest.mf (-1 / +1 lines)
Lines 3-7 Link Here
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/persistence/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/persistence/Bundle.properties
4
OpenIDE-Module-Public-Packages: -
4
OpenIDE-Module-Public-Packages: -
5
AutoUpdate-Show-In-Client: false
5
AutoUpdate-Show-In-Client: false
6
OpenIDE-Module-Specification-Version: 1.12
6
OpenIDE-Module-Specification-Version: 1.13
7
7
(-)a/maven.persistence/nbproject/project.xml (-2 / +2 lines)
Lines 91-97 Link Here
91
                    <compile-dependency/>
91
                    <compile-dependency/>
92
                    <run-dependency>
92
                    <run-dependency>
93
                        <release-version>1</release-version>
93
                        <release-version>1</release-version>
94
                        <specification-version>1.18</specification-version>
94
                        <specification-version>1.41</specification-version>
95
                    </run-dependency>
95
                    </run-dependency>
96
                </dependency>
96
                </dependency>
97
                <dependency>
97
                <dependency>
Lines 100-106 Link Here
100
                    <compile-dependency/>
100
                    <compile-dependency/>
101
                    <run-dependency>
101
                    <run-dependency>
102
                        <release-version>2</release-version>
102
                        <release-version>2</release-version>
103
                        <specification-version>2.0</specification-version>
103
                        <specification-version>2.19</specification-version>
104
                    </run-dependency>
104
                    </run-dependency>
105
                </dependency>
105
                </dependency>
106
                <dependency>
106
                <dependency>
(-)a/maven.persistence/src/org/netbeans/modules/maven/persistence/CPExtender.java (-9 / +12 lines)
Lines 53-71 Link Here
53
import org.netbeans.api.project.ant.AntArtifact;
53
import org.netbeans.api.project.ant.AntArtifact;
54
import org.netbeans.api.project.libraries.Library;
54
import org.netbeans.api.project.libraries.Library;
55
import org.netbeans.modules.maven.api.ModelUtils;
55
import org.netbeans.modules.maven.api.ModelUtils;
56
import org.netbeans.spi.java.project.classpath.ProjectClassPathExtender;
57
import org.netbeans.spi.java.project.classpath.ProjectClassPathModifierImplementation;
56
import org.netbeans.spi.java.project.classpath.ProjectClassPathModifierImplementation;
58
import org.netbeans.spi.project.ProjectServiceProvider;
57
import org.netbeans.spi.project.ProjectServiceProvider;
59
import org.openide.filesystems.FileObject;
60
import org.openide.util.Exceptions;
58
import org.openide.util.Exceptions;
61
59
62
/**
60
/**
63
 *
61
 *
64
 * @author mkleint
62
 * @author mkleint
65
 */
63
 */
66
@ProjectServiceProvider(service={ProjectClassPathModifierImplementation.class, ProjectClassPathExtender.class},
64
@ProjectServiceProvider(service=ProjectClassPathModifierImplementation.class,
67
projectType="org-netbeans-modules-maven")
65
projectType="org-netbeans-modules-maven")
68
public class CPExtender extends ProjectClassPathModifierImplementation implements ProjectClassPathExtender {
66
public class CPExtender extends ProjectClassPathModifierImplementation {
69
    private static final String SL_15 = "1.5"; //NOI18N
67
    private static final String SL_15 = "1.5"; //NOI18N
70
    private Project project;
68
    private Project project;
71
    /** Creates a new instance of CPExtender */
69
    /** Creates a new instance of CPExtender */
Lines 119-125 Link Here
119
        return false;
117
        return false;
120
    }
118
    }
121
119
122
    public boolean addLibrary(Library library) throws IOException {
120
    private boolean addLibrary(Library library) throws IOException {
123
        if ("toplink".equals(library.getName())) { //NOI18N
121
        if ("toplink".equals(library.getName())) { //NOI18N
124
            //TODO would be nice if the toplink lib shipping with netbeans be the same binary
122
            //TODO would be nice if the toplink lib shipping with netbeans be the same binary
125
            // then we could just copy the pieces to local repo.
123
            // then we could just copy the pieces to local repo.
Lines 130-135 Link Here
130
                ModelHandle handle = ModelHandleUtils.createModelHandle(project);
128
                ModelHandle handle = ModelHandleUtils.createModelHandle(project);
131
                
129
                
132
                // checking source doesn't work anymore, the wizard requires the level to be 1.5 up front.
130
                // checking source doesn't work anymore, the wizard requires the level to be 1.5 up front.
131
                // XXX this seems wrong; what if the source level is already 1.6 or higher? (or "5" or "6"?)
133
                ModelUtils.checkSourceLevel(handle, SL_15);
132
                ModelUtils.checkSourceLevel(handle, SL_15);
134
                ModelHandleUtils.writeModelHandle(handle, project);
133
                ModelHandleUtils.writeModelHandle(handle, project);
135
                
134
                
Lines 142-153 Link Here
142
        }
141
        }
143
        return false;
142
        return false;
144
    }
143
    }
145
    
144
146
    public boolean addArchiveFile(FileObject arg0) throws IOException {
145
    @Override protected boolean addRoots(URI[] classPathRoots, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
147
        return false;
146
        return false;
148
    }
147
    }
149
    
148
150
    public boolean addAntArtifact(AntArtifact arg0, URI arg1) throws IOException {
149
    @Override protected boolean removeRoots(URI[] classPathRoots, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
150
        return false;
151
    }
152
153
    @Override protected boolean addProjects(Project[] projects, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
151
        return false;
154
        return false;
152
    }
155
    }
153
    
156
    
(-)a/maven/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.maven/2
2
OpenIDE-Module: org.netbeans.modules.maven/2
3
OpenIDE-Module-Specification-Version: 2.18
3
OpenIDE-Module-Specification-Version: 2.19
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/Bundle.properties
5
OpenIDE-Module-Layer: org/netbeans/modules/maven/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/maven/layer.xml
6
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Show-In-Client: false
(-)a/maven/nbproject/project.xml (-1 / +1 lines)
Lines 153-159 Link Here
153
                    <compile-dependency/>
153
                    <compile-dependency/>
154
                    <run-dependency>
154
                    <run-dependency>
155
                        <release-version>1</release-version>
155
                        <release-version>1</release-version>
156
                        <specification-version>1.25</specification-version>
156
                        <specification-version>1.41</specification-version>
157
                    </run-dependency>
157
                    </run-dependency>
158
                </dependency>
158
                </dependency>
159
                <dependency>
159
                <dependency>
(-)a/maven/src/org/netbeans/modules/maven/NbMavenProjectImpl.java (-4 / +5 lines)
Lines 87-92 Link Here
87
import org.netbeans.api.annotations.common.CheckForNull;
87
import org.netbeans.api.annotations.common.CheckForNull;
88
import org.netbeans.api.annotations.common.NonNull;
88
import org.netbeans.api.annotations.common.NonNull;
89
import org.netbeans.api.java.project.JavaProjectConstants;
89
import org.netbeans.api.java.project.JavaProjectConstants;
90
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
90
import org.netbeans.api.project.Project;
91
import org.netbeans.api.project.Project;
91
import org.netbeans.api.project.ProjectInformation;
92
import org.netbeans.api.project.ProjectInformation;
92
import org.netbeans.api.project.ProjectManager;
93
import org.netbeans.api.project.ProjectManager;
Lines 99-106 Link Here
99
import org.netbeans.modules.maven.api.PluginPropertyUtils;
100
import org.netbeans.modules.maven.api.PluginPropertyUtils;
100
import org.netbeans.modules.maven.api.problem.ProblemReport;
101
import org.netbeans.modules.maven.api.problem.ProblemReport;
101
import org.netbeans.modules.maven.classpath.CPExtender;
102
import org.netbeans.modules.maven.classpath.CPExtender;
102
import org.netbeans.modules.maven.classpath.CPExtenderLookupMerger;
103
import org.netbeans.modules.maven.classpath.CPModifierLookupMerger;
104
import org.netbeans.modules.maven.classpath.ClassPathProviderImpl;
103
import org.netbeans.modules.maven.classpath.ClassPathProviderImpl;
105
import org.netbeans.modules.maven.classpath.MavenSourcesImpl;
104
import org.netbeans.modules.maven.classpath.MavenSourcesImpl;
106
import org.netbeans.modules.maven.configurations.M2ConfigProvider;
105
import org.netbeans.modules.maven.configurations.M2ConfigProvider;
Lines 128-133 Link Here
128
import org.netbeans.modules.maven.queries.MavenSharabilityQueryImpl;
127
import org.netbeans.modules.maven.queries.MavenSharabilityQueryImpl;
129
import org.netbeans.modules.maven.queries.MavenSourceLevelImpl;
128
import org.netbeans.modules.maven.queries.MavenSourceLevelImpl;
130
import org.netbeans.modules.maven.queries.MavenTestForSourceImpl;
129
import org.netbeans.modules.maven.queries.MavenTestForSourceImpl;
130
import org.netbeans.spi.java.project.support.LookupMergerSupport;
131
import org.netbeans.spi.project.LookupMerger;
131
import org.netbeans.spi.project.LookupMerger;
132
import org.netbeans.spi.project.ProjectState;
132
import org.netbeans.spi.project.ProjectState;
133
import org.netbeans.spi.project.SubprojectProvider;
133
import org.netbeans.spi.project.SubprojectProvider;
Lines 909-916 Link Here
909
                    UILookupMergerSupport.createPrivilegedTemplatesMerger(),
909
                    UILookupMergerSupport.createPrivilegedTemplatesMerger(),
910
                    UILookupMergerSupport.createRecommendedTemplatesMerger(),
910
                    UILookupMergerSupport.createRecommendedTemplatesMerger(),
911
                    LookupProviderSupport.createSourcesMerger(),
911
                    LookupProviderSupport.createSourcesMerger(),
912
                    new CPExtenderLookupMerger(extender),
912
                    ProjectClassPathModifier.extenderForModifier(this),
913
                    new CPModifierLookupMerger(extender),
913
                    extender,
914
                    LookupMergerSupport.createClassPathModifierMerger(),
914
                    new BackwardCompatibilityWithMevenideChecker(),
915
                    new BackwardCompatibilityWithMevenideChecker(),
915
                    new DebuggerChecker(),
916
                    new DebuggerChecker(),
916
                    new CosChecker(this),
917
                    new CosChecker(this),
(-)a/maven/src/org/netbeans/modules/maven/classpath/CPExtender.java (-52 / +1 lines)
Lines 85-92 Link Here
85
 * maven dependencies to the way classpath items are added through this api.
85
 * maven dependencies to the way classpath items are added through this api.
86
 * @author mkleint
86
 * @author mkleint
87
 */
87
 */
88
@SuppressWarnings("deprecation")
88
public class CPExtender extends ProjectClassPathModifierImplementation {
89
public class CPExtender extends ProjectClassPathModifierImplementation implements org.netbeans.spi.java.project.classpath.ProjectClassPathExtender {
90
89
91
    private NbMavenProjectImpl project;
90
    private NbMavenProjectImpl project;
92
    private static final String POM_XML = "pom.xml"; //NOI18N
91
    private static final String POM_XML = "pom.xml"; //NOI18N
Lines 105-156 Link Here
105
        this.project = project;
104
        this.project = project;
106
    }
105
    }
107
    
106
    
108
    public boolean addLibrary(final Library library) throws IOException {
109
        final Boolean[] added = new Boolean[1];
110
        ModelOperation<POMModel> operation = new ModelOperation<POMModel>() {
111
            public void performOperation(POMModel model) {
112
                try {
113
                    added[0] = addRemoveLibrary(library, model, null, true);
114
                } catch (IOException ex) {
115
                    Exceptions.printStackTrace(ex);
116
                    added[0] = Boolean.FALSE;
117
                }
118
            }
119
        };
120
        FileObject pom = project.getProjectDirectory().getFileObject(POM_XML);//NOI18N
121
        org.netbeans.modules.maven.model.Utilities.performPOMModelOperations(pom, Collections.singletonList(operation));
122
        //TODO is the manual reload necessary if pom.xml file is being saved?
123
//                NbMavenProject.fireMavenProjectReload(project);
124
        if (added[0]) {
125
            project.getLookup().lookup(NbMavenProject.class).triggerDependencyDownload();
126
        }
127
128
        return added[0];
129
    }
130
    
131
    public boolean addArchiveFile(FileObject arch) throws IOException {
132
        final File jar = FileUtil.archiveOrDirForURL(arch.getURL());
133
        if (jar == null || jar.isDirectory()) {
134
            throw new IOException("Cannot add folders to Maven projects as dependencies: " + arch); //NOI18N
135
        }
136
        final AtomicBoolean added = new AtomicBoolean();
137
        ModelOperation<POMModel> operation = new ModelOperation<POMModel>() {
138
            public void performOperation(POMModel model) {
139
                try {
140
                    added.compareAndSet(false, addRemoveJAR(jar, model, null, true));
141
                } catch (IOException ex) {
142
                    Exceptions.printStackTrace(ex);
143
                }
144
            }
145
        };
146
        FileObject pom = project.getProjectDirectory().getFileObject(POM_XML);//NOI18N
147
        org.netbeans.modules.maven.model.Utilities.performPOMModelOperations(pom, Collections.singletonList(operation));
148
        if (added.get()) {
149
            project.getLookup().lookup(NbMavenProject.class).triggerDependencyDownload();
150
        }
151
        return added.get();
152
    }
153
154
    private boolean addRemoveLibrary(Library library, POMModel model, String scope, boolean add) throws IOException {
107
    private boolean addRemoveLibrary(Library library, POMModel model, String scope, boolean add) throws IOException {
155
        Boolean modified = checkLibraryForPoms(library, model, scope, add);
108
        Boolean modified = checkLibraryForPoms(library, model, scope, add);
156
        if (modified == null) {
109
        if (modified == null) {
Lines 260-269 Link Here
260
        return modified;
213
        return modified;
261
    }
214
    }
262
        
215
        
263
    public boolean addAntArtifact(AntArtifact arg0, URI arg1) throws IOException {
264
        throw new IOException("Cannot add Ant based projects as subprojecs to Maven projects."); //NOI18N
265
    }
266
    
267
    public SourceGroup[] getExtensibleSourceGroups() {
216
    public SourceGroup[] getExtensibleSourceGroups() {
268
        Sources s = this.project.getLookup().lookup(Sources.class);
217
        Sources s = this.project.getLookup().lookup(Sources.class);
269
        assert s != null;
218
        assert s != null;
(-)a/maven/src/org/netbeans/modules/maven/classpath/CPExtenderLookupMerger.java (-121 lines)
Lines 1-121 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 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 2008 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.maven.classpath;
44
45
import java.io.IOException;
46
import java.net.URI;
47
import java.util.Collection;
48
import org.netbeans.api.project.ant.AntArtifact;
49
import org.netbeans.api.project.libraries.Library;
50
import org.netbeans.spi.java.project.classpath.ProjectClassPathExtender;
51
import org.netbeans.spi.project.LookupMerger;
52
import org.openide.filesystems.FileObject;
53
import org.openide.util.Lookup;
54
55
/**
56
 *
57
 * @author mkleint
58
 */
59
@SuppressWarnings("deprecation")
60
public class CPExtenderLookupMerger implements LookupMerger<ProjectClassPathExtender> {
61
62
    private CPExtender fallback;
63
    
64
    /** Creates a new instance of CPExtenderLookupMerger */
65
    public CPExtenderLookupMerger(CPExtender fallbck) {
66
        fallback = fallbck;
67
        assert fallback != null;
68
    }
69
    
70
    public Class<ProjectClassPathExtender> getMergeableClass() {
71
        return ProjectClassPathExtender.class;
72
    }
73
74
    public synchronized ProjectClassPathExtender merge(Lookup lookup) {
75
        return new Extender(lookup);
76
    }
77
78
    @SuppressWarnings("deprecation")
79
    private class Extender implements ProjectClassPathExtender {
80
        
81
        private final Lookup context;
82
        
83
        private Extender(Lookup context) {
84
            this.context = context;
85
        }
86
    
87
        public boolean addLibrary(Library arg0) throws IOException {
88
            Collection<? extends ProjectClassPathExtender> list = context.lookupAll(ProjectClassPathExtender.class);
89
            for (ProjectClassPathExtender ext : list) {
90
                boolean added = ext.addLibrary(arg0);
91
                if (added) {
92
                    return added;
93
                }
94
            }
95
            return fallback.addLibrary(arg0);
96
        }
97
98
        public boolean addArchiveFile(FileObject arg0) throws IOException {
99
            Collection<? extends ProjectClassPathExtender> list = context.lookupAll(ProjectClassPathExtender.class);
100
            for (ProjectClassPathExtender ext : list) {
101
                boolean added = ext.addArchiveFile(arg0);
102
                if (added) {
103
                    return added;
104
                }
105
            }
106
            return fallback.addArchiveFile(arg0);
107
        }
108
109
        public boolean addAntArtifact(AntArtifact arg0, URI arg1) throws IOException {
110
            Collection<? extends ProjectClassPathExtender> list = context.lookupAll(ProjectClassPathExtender.class);
111
            for (ProjectClassPathExtender ext : list) {
112
                boolean added = ext.addAntArtifact(arg0, arg1);
113
                if (added) {
114
                    return added;
115
                }
116
            }
117
            return fallback.addAntArtifact(arg0, arg1);
118
        }
119
120
    }
121
}
(-)a/maven/src/org/netbeans/modules/maven/classpath/CPModifierLookupMerger.java (-247 lines)
Lines 1-247 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 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 2008 Sun Microsystems, Inc.
41
 */
42
43
44
package org.netbeans.modules.maven.classpath;
45
46
import java.io.IOException;
47
import java.lang.reflect.InvocationTargetException;
48
import java.lang.reflect.Method;
49
import java.net.URI;
50
import java.net.URL;
51
import java.util.Arrays;
52
import java.util.Collection;
53
import java.util.HashSet;
54
import org.netbeans.api.project.Project;
55
import org.netbeans.api.project.SourceGroup;
56
import org.netbeans.api.project.ant.AntArtifact;
57
import org.netbeans.api.project.libraries.Library;
58
import org.netbeans.spi.java.project.classpath.ProjectClassPathModifierImplementation;
59
import org.netbeans.spi.project.LookupMerger;
60
import org.openide.util.Lookup;
61
62
/**
63
 * TODO: The idea of having a LookupMerger for this class is not 100% semantically correct.
64
 * The original add/remove methods return values have different meaning than here.
65
 * if true is returned from impls means everything is done no further processing necessary, 
66
 * false means not relevant, try another impl or fallback to default.
67
 * a proper solution would be to create our own api that would reflect this difference.
68
 * @author mkleint
69
 */
70
public class CPModifierLookupMerger implements LookupMerger<ProjectClassPathModifierImplementation>{
71
    
72
    private CPExtender fallback;
73
    
74
    /** Creates a new instance of CPExtenderLookupMerger */
75
    public CPModifierLookupMerger(CPExtender fallbck) {
76
        fallback = fallbck;
77
        assert fallback != null;
78
    }
79
    
80
    public Class<ProjectClassPathModifierImplementation> getMergeableClass() {
81
        return ProjectClassPathModifierImplementation.class;
82
    }
83
84
    public synchronized ProjectClassPathModifierImplementation merge(Lookup lookup) {
85
        return new Extender(lookup);
86
    }
87
88
    private class Extender extends ProjectClassPathModifierImplementation {
89
        
90
        private final Lookup context;
91
        
92
        private Extender(Lookup context) {
93
            this.context = context;
94
        }
95
    
96
        private Object retVal(String methodName, ProjectClassPathModifierImplementation impl, 
97
                              Class<?>[] paramTypes,
98
                              Object... params) throws IOException {
99
            try {
100
                Method meth = impl.getClass().getDeclaredMethod(methodName, paramTypes);
101
                meth.setAccessible(true);
102
                return meth.invoke(impl, params);
103
            } catch (InvocationTargetException x) {
104
                if (x.getCause() instanceof IOException) {
105
                    throw (IOException)x.getCause();
106
                }
107
                //JDK16 can replace with new IOException(x.getCause());
108
                IOException ex = new IOException(x.getCause().getMessage());
109
                ex.initCause(x.getCause());
110
                throw ex;
111
            } catch (Exception e) {
112
                e.printStackTrace();
113
                throw new AssertionError("Cannot use reflection on " + impl + " method:" + methodName);
114
            }
115
        }
116
117
        protected SourceGroup[] getExtensibleSourceGroups() {
118
            Collection<? extends ProjectClassPathModifierImplementation> list = context.lookupAll(ProjectClassPathModifierImplementation.class);
119
            Collection<SourceGroup> sg = new HashSet<SourceGroup>();
120
            for (ProjectClassPathModifierImplementation ext : list) {
121
                try {
122
                    SourceGroup[] sgs = (SourceGroup[])retVal("getExtensibleSourceGroups", ext, null);//NOI18N
123
                    sg.addAll(Arrays.asList(sgs));
124
                } catch (IOException e) {
125
                    //should not happen at all.
126
                }
127
            }
128
            sg.addAll(Arrays.asList(fallback.getExtensibleSourceGroups()));
129
            return sg.toArray(new SourceGroup[sg.size()]);
130
        }
131
132
        protected String[] getExtensibleClassPathTypes(SourceGroup arg0) {
133
            Collection<? extends ProjectClassPathModifierImplementation> list = context.lookupAll(ProjectClassPathModifierImplementation.class);
134
            Collection<String> retVal = new HashSet<String>();
135
            for (ProjectClassPathModifierImplementation ext : list) {
136
                try {
137
                    String[] ret = (String[])retVal("getExtensibleClassPathTypes", ext, //NOI18N
138
                            new Class<?>[] {SourceGroup.class}, arg0 );
139
                    retVal.addAll(Arrays.asList(ret));
140
                } catch (IOException e) {
141
                    //should not happen at all.
142
                }
143
            }
144
            retVal.addAll(Arrays.asList(fallback.getExtensibleClassPathTypes(arg0)));
145
            return retVal.toArray(new String[retVal.size()]);
146
        }
147
148
        protected boolean addLibraries(Library[] arg0, SourceGroup arg1,
149
                                       String arg2) throws IOException,
150
                                                           UnsupportedOperationException {
151
            Collection<? extends ProjectClassPathModifierImplementation> list = context.lookupAll(ProjectClassPathModifierImplementation.class);
152
            for (ProjectClassPathModifierImplementation ext : list) {
153
                Boolean ret = (Boolean)retVal("addLibraries", ext, //NOI18N
154
                        new Class<?>[] { new Library[0].getClass(), SourceGroup.class, String.class}, arg0, arg1, arg2);
155
                if (ret.booleanValue()) {
156
                    return ret.booleanValue();
157
                }
158
            }
159
            return fallback.addLibraries(arg0, arg1, arg2);
160
        }
161
162
        protected boolean removeLibraries(Library[] arg0, SourceGroup arg1,
163
                                          String arg2) throws IOException,
164
                                                              UnsupportedOperationException {
165
            Collection<? extends ProjectClassPathModifierImplementation> list = context.lookupAll(ProjectClassPathModifierImplementation.class);
166
            for (ProjectClassPathModifierImplementation ext : list) {
167
                Boolean ret = (Boolean)retVal("removeLibraries", ext, //NOI18N
168
                        new Class<?>[] { new Library[0].getClass(), SourceGroup.class, String.class}, arg0, arg1, arg2);
169
                if (ret.booleanValue()) {
170
                    return ret.booleanValue();
171
                }
172
            }
173
            return fallback.removeLibraries(arg0, arg1, arg2);
174
        }
175
176
        protected boolean addRoots(URL[] arg0, SourceGroup arg1, String arg2) throws IOException,
177
                                                                                     UnsupportedOperationException {
178
            Collection<? extends ProjectClassPathModifierImplementation> list = context.lookupAll(ProjectClassPathModifierImplementation.class);
179
            for (ProjectClassPathModifierImplementation ext : list) {
180
                Boolean ret = (Boolean)retVal("addRoots", ext, //NOI18N
181
                        new Class<?>[] { new URL[0].getClass(), SourceGroup.class, String.class}, arg0, arg1, arg2);
182
                if (ret.booleanValue()) {
183
                    return ret.booleanValue();
184
                }
185
            }
186
            return fallback.addRoots(arg0, arg1, arg2);
187
        }
188
189
        protected boolean removeRoots(URL[] arg0, SourceGroup arg1, String arg2) throws IOException,
190
                                                                                        UnsupportedOperationException {
191
            Collection<? extends ProjectClassPathModifierImplementation> list = context.lookupAll(ProjectClassPathModifierImplementation.class);
192
            for (ProjectClassPathModifierImplementation ext : list) {
193
                Boolean ret = (Boolean)retVal("removeRoots", ext, //NOI18N
194
                        new Class<?>[] { new URL[0].getClass(), SourceGroup.class, String.class}, arg0, arg1, arg2);
195
                if (ret.booleanValue()) {
196
                    return ret.booleanValue();
197
                }
198
            }
199
            return fallback.removeRoots(arg0, arg1, arg2);
200
        }
201
202
        protected boolean addAntArtifacts(AntArtifact[] arg0, URI[] arg1,
203
                                          SourceGroup arg2, String arg3) throws IOException,
204
                                                                                UnsupportedOperationException {
205
            Collection<? extends ProjectClassPathModifierImplementation> list = context.lookupAll(ProjectClassPathModifierImplementation.class);
206
            for (ProjectClassPathModifierImplementation ext : list) {
207
                Boolean ret = (Boolean)retVal("addAntArtifacts", ext, //NOI18N
208
                        new Class<?>[] { new AntArtifact[0].getClass(), new URI[0].getClass(), SourceGroup.class, String.class}, arg0, arg1, arg2, arg3);
209
                if (ret.booleanValue()) {
210
                    return ret.booleanValue();
211
                }
212
            }
213
            return fallback.addAntArtifacts(arg0, arg1, arg2, arg3);
214
        }
215
216
        protected boolean removeAntArtifacts(AntArtifact[] arg0, URI[] arg1,
217
                                             SourceGroup arg2, String arg3) throws IOException,
218
                                                                                   UnsupportedOperationException {
219
            Collection<? extends ProjectClassPathModifierImplementation> list = context.lookupAll(ProjectClassPathModifierImplementation.class);
220
            for (ProjectClassPathModifierImplementation ext : list) {
221
                Boolean ret = (Boolean)retVal("addAntArtifacts", ext, //NOI18N
222
                        new Class<?>[] { new AntArtifact[0].getClass(), new URI[0].getClass(), SourceGroup.class, String.class}, arg0, arg1, arg2, arg3);
223
                if (ret.booleanValue()) {
224
                    return ret.booleanValue();
225
                }
226
            }
227
            return fallback.addAntArtifacts(arg0, arg1, arg2, arg3);
228
        }
229
230
        @Override
231
        protected boolean addProjects(Project[] projects, SourceGroup sg, String classPathType) throws IOException, UnsupportedOperationException {
232
//            Collection<? extends ProjectClassPathModifierImplementation> list = context.lookupAll(ProjectClassPathModifierImplementation.class);
233
//            for (ProjectClassPathModifierImplementation ext : list) {
234
//                Boolean ret = (Boolean)retVal("addProjects", ext, //NOI18N
235
//                        new Class<?>[] { new Project[0].getClass(), SourceGroup.class, String.class}, projects, sg, classPathType);
236
//                if (ret.booleanValue()) {
237
//                    return ret.booleanValue();
238
//                }
239
//            }
240
            //use only the fallback, as that's the man with correct impl. others might have the ant based default method implementation preserved..
241
            return fallback.addProjects(projects, sg, classPathType);
242
        }
243
244
245
    }
246
    
247
}
(-)a/projectimport.jbuilder/nbproject/project.xml (+1 lines)
Lines 116-121 Link Here
116
                    <compile-dependency/>
116
                    <compile-dependency/>
117
                    <run-dependency>
117
                    <run-dependency>
118
                        <release-version>1</release-version>
118
                        <release-version>1</release-version>
119
                        <specification-version>1.10</specification-version>
119
                    </run-dependency>
120
                    </run-dependency>
120
                </dependency>
121
                </dependency>
121
                <dependency>
122
                <dependency>
(-)a/projectimport.jbuilder/src/org/netbeans/modules/projectimport/j2seimport/ImportUtils.java (-16 / +14 lines)
Lines 46-51 Link Here
46
46
47
import java.io.File;
47
import java.io.File;
48
import java.io.IOException;
48
import java.io.IOException;
49
import java.net.URI;
49
import java.net.URL;
50
import java.net.URL;
50
import java.util.ArrayList;
51
import java.util.ArrayList;
51
import java.util.Collection;
52
import java.util.Collection;
Lines 54-62 Link Here
54
import java.util.List;
55
import java.util.List;
55
import java.util.Map;
56
import java.util.Map;
56
import java.util.logging.Logger;
57
import java.util.logging.Logger;
58
import org.netbeans.api.java.classpath.ClassPath;
57
import org.netbeans.api.java.platform.JavaPlatform;
59
import org.netbeans.api.java.platform.JavaPlatform;
58
import org.netbeans.api.java.platform.JavaPlatformManager;
60
import org.netbeans.api.java.platform.JavaPlatformManager;
59
import org.netbeans.api.java.project.JavaProjectConstants;
61
import org.netbeans.api.java.project.JavaProjectConstants;
62
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
60
import org.netbeans.api.progress.ProgressHandle;
63
import org.netbeans.api.progress.ProgressHandle;
61
import org.netbeans.api.progress.ProgressHandleFactory;
64
import org.netbeans.api.progress.ProgressHandleFactory;
62
import org.netbeans.api.project.Project;
65
import org.netbeans.api.project.Project;
Lines 68-74 Link Here
68
import org.netbeans.modules.java.j2seproject.J2SEProject;
71
import org.netbeans.modules.java.j2seproject.J2SEProject;
69
import org.netbeans.modules.java.j2seproject.J2SEProjectGenerator;
72
import org.netbeans.modules.java.j2seproject.J2SEProjectGenerator;
70
import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties;
73
import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties;
71
import org.netbeans.spi.java.project.classpath.ProjectClassPathExtender;
72
import org.netbeans.spi.project.support.ant.AntProjectHelper;
74
import org.netbeans.spi.project.support.ant.AntProjectHelper;
73
import org.netbeans.spi.project.support.ant.EditableProperties;
75
import org.netbeans.spi.project.support.ant.EditableProperties;
74
import org.openide.filesystems.FileObject;
76
import org.openide.filesystems.FileObject;
Lines 317-329 Link Here
317
    
319
    
318
    public  void addDependency(final J2SEProject nbProject,
320
    public  void addDependency(final J2SEProject nbProject,
319
            final J2SEProject nbSubProject) throws IOException {
321
            final J2SEProject nbSubProject) throws IOException {
320
        ProjectClassPathExtender nbClsPath = (ProjectClassPathExtender)
321
        nbProject.getLookup().lookup(ProjectClassPathExtender.class);
322
        
323
        AntArtifact[] artifact = AntArtifactQuery.findArtifactsByType(nbSubProject,
322
        AntArtifact[] artifact = AntArtifactQuery.findArtifactsByType(nbSubProject,
324
                JavaProjectConstants.ARTIFACT_TYPE_JAR);
323
                JavaProjectConstants.ARTIFACT_TYPE_JAR);
325
        
324
        FileObject[] roots = nbProject.getSourceRoots().getRoots();
326
        nbClsPath.addAntArtifact(artifact[0], artifact[0].getArtifactLocations()[0]);
325
        if (roots.length > 0) {
326
            ProjectClassPathModifier.addAntArtifacts(artifact, new URI[] {artifact[0].getArtifactLocations()[0]}, roots[0], ClassPath.COMPILE);
327
        }
327
    }
328
    }
328
    
329
    
329
    private WarningContainer/*<String> warnings*/ addSourceRoots(final ProjectModel projectDefinition,
330
    private WarningContainer/*<String> warnings*/ addSourceRoots(final ProjectModel projectDefinition,
Lines 361-374 Link Here
361
        
362
        
362
        for (Iterator it = projectDefinition.getUserLibraries().iterator(); it.hasNext();) {
363
        for (Iterator it = projectDefinition.getUserLibraries().iterator(); it.hasNext();) {
363
            ProjectModel.UserLibrary userLibrary = (ProjectModel.UserLibrary)it.next();
364
            ProjectModel.UserLibrary userLibrary = (ProjectModel.UserLibrary)it.next();
364
            ProjectClassPathExtender nbClsPath = (ProjectClassPathExtender) nbProject.getLookup().lookup(ProjectClassPathExtender.class);
365
            assert nbClsPath != null;
366
            List allLibs = getAllLibraries(null, userLibrary);
365
            List allLibs = getAllLibraries(null, userLibrary);
367
            
366
            
368
            for (Iterator itUL = allLibs.iterator(); itUL.hasNext();) {
367
            for (Iterator itUL = allLibs.iterator(); itUL.hasNext();) {
369
                ProjectModel.Library lEntry = (ProjectModel.Library)itUL.next();
368
                ProjectModel.Library lEntry = (ProjectModel.Library)itUL.next();
370
                try {
369
                try {
371
                    warnings.addAll(addLibrary(nbClsPath, lEntry, projectDefinition));
370
                    warnings.addAll(addLibrary(nbProject, lEntry, projectDefinition));
372
                } catch(IOException iex) {
371
                } catch(IOException iex) {
373
                    ImportUtils.addWarning(warnings,iex.getLocalizedMessage());
372
                    ImportUtils.addWarning(warnings,iex.getLocalizedMessage());
374
                }
373
                }
Lines 394-406 Link Here
394
            final J2SEProject nbProject) throws IOException {
393
            final J2SEProject nbProject) throws IOException {
395
        
394
        
396
        WarningContainer warnings = new WarningContainer();
395
        WarningContainer warnings = new WarningContainer();
397
        ProjectClassPathExtender nbClsPath = (ProjectClassPathExtender) nbProject.getLookup().lookup(ProjectClassPathExtender.class);
398
        assert nbClsPath != null;
399
        
400
        for (Iterator it = projectDefinition.getLibraries().iterator(); it.hasNext();) {
396
        for (Iterator it = projectDefinition.getLibraries().iterator(); it.hasNext();) {
401
            ProjectModel.Library lEntry = (ProjectModel.Library)it.next();
397
            ProjectModel.Library lEntry = (ProjectModel.Library)it.next();
402
            try {
398
            try {
403
                warnings.addAll(addLibrary(nbClsPath, lEntry, projectDefinition));
399
                warnings.addAll(addLibrary(nbProject, lEntry, projectDefinition));
404
            } catch(IOException iex) {
400
            } catch(IOException iex) {
405
                ImportUtils.addWarning(warnings,iex.getLocalizedMessage());
401
                ImportUtils.addWarning(warnings,iex.getLocalizedMessage());
406
            }
402
            }
Lines 410-421 Link Here
410
    }
406
    }
411
    
407
    
412
    
408
    
413
    private WarningContainer  addLibrary(final ProjectClassPathExtender nbClsPath,
409
    private WarningContainer  addLibrary(final J2SEProject nbProject,
414
            final ProjectModel.Library lEntry, final ProjectModel projectDefinition) throws IOException {
410
            final ProjectModel.Library lEntry, final ProjectModel projectDefinition) throws IOException {
415
        WarningContainer warnings = new WarningContainer();
411
        WarningContainer warnings = new WarningContainer();
416
        FileObject archiv = FileUtil.toFileObject(lEntry.getArchiv());
412
        FileObject archiv = FileUtil.toFileObject(lEntry.getArchiv());
417
        
413
        FileObject[] roots = nbProject.getSourceRoots().getRoots();
418
        nbClsPath.addArchiveFile(archiv);
414
        if (roots.length == 0 || !ProjectClassPathModifier.addRoots(new URL[] {FileUtil.getArchiveRoot(archiv.getURL())}, roots[0], ClassPath.COMPILE)) {
415
            addWarning(warnings, "No Java source roots in: " + FileUtil.getFileDisplayName(nbProject.getProjectDirectory())); // XXX I18N
416
        }
419
        return warnings;
417
        return warnings;
420
    }
418
    }
421
    
419
    
(-)a/web.project/nbproject/project.xml (-10 / +10 lines)
Lines 216-230 Link Here
216
                    </run-dependency>
216
                    </run-dependency>
217
                </dependency>
217
                </dependency>
218
                <dependency>
218
                <dependency>
219
                    <code-name-base>org.netbeans.modules.javaee.specs.support</code-name-base>
220
                    <build-prerequisite/>
221
                    <compile-dependency/>
222
                    <run-dependency>
223
                        <release-version>0</release-version>
224
                        <specification-version>1.0</specification-version>
225
                    </run-dependency>
226
                </dependency>
227
                <dependency>
228
                    <code-name-base>org.netbeans.modules.j2eeserver</code-name-base>
219
                    <code-name-base>org.netbeans.modules.j2eeserver</code-name-base>
229
                    <build-prerequisite/>
220
                    <build-prerequisite/>
230
                    <compile-dependency/>
221
                    <compile-dependency/>
Lines 256-262 Link Here
256
                    <compile-dependency/>
247
                    <compile-dependency/>
257
                    <run-dependency>
248
                    <run-dependency>
258
                        <release-version>1</release-version>
249
                        <release-version>1</release-version>
259
                        <specification-version>1.37</specification-version>
250
                        <specification-version>1.41</specification-version>
260
                    </run-dependency>
251
                    </run-dependency>
261
                </dependency>
252
                </dependency>
262
                <dependency>
253
                <dependency>
Lines 268-273 Link Here
268
                    </run-dependency>
259
                    </run-dependency>
269
                </dependency>
260
                </dependency>
270
                <dependency>
261
                <dependency>
262
                    <code-name-base>org.netbeans.modules.javaee.specs.support</code-name-base>
263
                    <build-prerequisite/>
264
                    <compile-dependency/>
265
                    <run-dependency>
266
                        <release-version>0</release-version>
267
                        <specification-version>1.0</specification-version>
268
                    </run-dependency>
269
                </dependency>
270
                <dependency>
271
                    <code-name-base>org.netbeans.modules.junit</code-name-base>
271
                    <code-name-base>org.netbeans.modules.junit</code-name-base>
272
                    <run-dependency>
272
                    <run-dependency>
273
                        <release-version>2</release-version>
273
                        <release-version>2</release-version>
(-)a/web.project/src/org/netbeans/modules/web/project/WebProject.java (-8 / +2 lines)
Lines 59-65 Link Here
59
import java.util.zip.ZipEntry;
59
import java.util.zip.ZipEntry;
60
import java.util.zip.ZipFile;
60
import java.util.zip.ZipFile;
61
import javax.swing.Icon;
61
import javax.swing.Icon;
62
import javax.swing.JButton;
63
import javax.swing.event.ChangeEvent;
62
import javax.swing.event.ChangeEvent;
64
import javax.swing.event.ChangeListener;
63
import javax.swing.event.ChangeListener;
65
import org.netbeans.api.java.classpath.ClassPath;
64
import org.netbeans.api.java.classpath.ClassPath;
Lines 68-77 Link Here
68
import org.netbeans.api.project.ant.AntBuildExtender;
67
import org.netbeans.api.project.ant.AntBuildExtender;
69
import org.netbeans.api.queries.FileBuiltQuery.Status;
68
import org.netbeans.api.queries.FileBuiltQuery.Status;
70
import org.netbeans.api.j2ee.core.Profile;
69
import org.netbeans.api.j2ee.core.Profile;
70
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
71
import org.netbeans.modules.j2ee.dd.api.ejb.EjbJarMetadata;
71
import org.netbeans.modules.j2ee.dd.api.ejb.EjbJarMetadata;
72
import org.netbeans.modules.j2ee.metadata.model.api.MetadataModelAction;
72
import org.netbeans.modules.j2ee.metadata.model.api.MetadataModelAction;
73
import org.netbeans.modules.java.api.common.Roots;
73
import org.netbeans.modules.java.api.common.Roots;
74
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item;
75
import org.netbeans.modules.j2ee.deployment.devmodules.spi.ArtifactListener.Artifact;
74
import org.netbeans.modules.j2ee.deployment.devmodules.spi.ArtifactListener.Artifact;
76
import org.netbeans.modules.web.common.spi.ProjectWebRootProvider;
75
import org.netbeans.modules.web.common.spi.ProjectWebRootProvider;
77
import org.netbeans.modules.web.jsfapi.spi.JsfSupportHandle;
76
import org.netbeans.modules.web.jsfapi.spi.JsfSupportHandle;
Lines 118-124 Link Here
118
import org.netbeans.modules.j2ee.common.Util;
117
import org.netbeans.modules.j2ee.common.Util;
119
import org.netbeans.modules.j2ee.common.dd.DDHelper;
118
import org.netbeans.modules.j2ee.common.dd.DDHelper;
120
import org.netbeans.modules.j2ee.common.project.ArtifactCopyOnSaveSupport;
119
import org.netbeans.modules.j2ee.common.project.ArtifactCopyOnSaveSupport;
121
import org.netbeans.modules.java.api.common.classpath.ClassPathExtender;
122
import org.netbeans.modules.java.api.common.classpath.ClassPathModifier;
120
import org.netbeans.modules.java.api.common.classpath.ClassPathModifier;
123
import org.netbeans.modules.java.api.common.classpath.ClassPathModifierSupport;
121
import org.netbeans.modules.java.api.common.classpath.ClassPathModifierSupport;
124
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
122
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
Lines 176-183 Link Here
176
import org.netbeans.spi.project.support.ant.PropertyProvider;
174
import org.netbeans.spi.project.support.ant.PropertyProvider;
177
import org.netbeans.spi.project.support.ant.PropertyUtils;
175
import org.netbeans.spi.project.support.ant.PropertyUtils;
178
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
176
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
179
import org.openide.DialogDisplayer;
180
import org.openide.NotifyDescriptor;
181
import org.openide.filesystems.FileLock;
177
import org.openide.filesystems.FileLock;
182
import org.openide.filesystems.FileSystem;
178
import org.openide.filesystems.FileSystem;
183
import org.openide.filesystems.FileSystem.AtomicAction;
179
import org.openide.filesystems.FileSystem.AtomicAction;
Lines 226-232 Link Here
226
    private final UpdateHelper updateHelper;
222
    private final UpdateHelper updateHelper;
227
    private final UpdateProjectImpl updateProject;
223
    private final UpdateProjectImpl updateProject;
228
    private final AuxiliaryConfiguration aux;
224
    private final AuxiliaryConfiguration aux;
229
    private final ClassPathExtender classPathExtender;
230
    private final ClassPathModifier cpMod;
225
    private final ClassPathModifier cpMod;
231
    private final WebProjectLibrariesModifierImpl libMod;
226
    private final WebProjectLibrariesModifierImpl libMod;
232
    private final ClassPathProviderImpl cpProvider;
227
    private final ClassPathProviderImpl cpProvider;
Lines 392-398 Link Here
392
        cpMod = new ClassPathModifier(this, this.updateHelper, eval, refHelper,
387
        cpMod = new ClassPathModifier(this, this.updateHelper, eval, refHelper,
393
            new ClassPathSupportCallbackImpl(helper), createClassPathModifierCallback(), getClassPathUiSupportCallback());
388
            new ClassPathSupportCallbackImpl(helper), createClassPathModifierCallback(), getClassPathUiSupportCallback());
394
        libMod = new WebProjectLibrariesModifierImpl(this, this.updateHelper, eval, refHelper);
389
        libMod = new WebProjectLibrariesModifierImpl(this, this.updateHelper, eval, refHelper);
395
        classPathExtender = new ClassPathExtender(cpMod, ProjectProperties.JAVAC_CLASSPATH, ClassPathSupportCallbackImpl.TAG_WEB_MODULE_LIBRARIES);
396
        lookup = createLookup(aux, cpProvider);
390
        lookup = createLookup(aux, cpProvider);
397
        css = new CopyOnSaveSupport();
391
        css = new CopyOnSaveSupport();
398
        artifactSupport = new ArtifactCopySupport();
392
        artifactSupport = new ArtifactCopySupport();
Lines 569-575 Link Here
569
                getTestSourceRoots(), WebProjectProperties.WEB_DOCBASE_DIR),
563
                getTestSourceRoots(), WebProjectProperties.WEB_DOCBASE_DIR),
570
            new RecommendedTemplatesImpl(this),
564
            new RecommendedTemplatesImpl(this),
571
            new CoSAwareFileBuiltQueryImpl(QuerySupport.createFileBuiltQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()), this),
565
            new CoSAwareFileBuiltQueryImpl(QuerySupport.createFileBuiltQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()), this),
572
            classPathExtender,
566
            ProjectClassPathModifier.extenderForModifier(cpMod),
573
            buildExtender,
567
            buildExtender,
574
            cpMod,
568
            cpMod,
575
            new WebProjectOperations(this),
569
            new WebProjectOperations(this),
(-)a/web.struts/nbproject/project.xml (+1 lines)
Lines 183-188 Link Here
183
                    <compile-dependency/>
183
                    <compile-dependency/>
184
                    <run-dependency>
184
                    <run-dependency>
185
                        <release-version>1</release-version>
185
                        <release-version>1</release-version>
186
                        <specification-version>1.10</specification-version>
186
                    </run-dependency>
187
                    </run-dependency>
187
                </dependency>
188
                </dependency>
188
                <dependency>
189
                <dependency>
(-)a/web.struts/src/org/netbeans/modules/web/struts/StrutsFrameworkProvider.java (-7 / +5 lines)
Lines 60-66 Link Here
60
import java.util.logging.Level;
60
import java.util.logging.Level;
61
import java.util.logging.Logger;
61
import java.util.logging.Logger;
62
import javax.swing.SwingUtilities;
62
import javax.swing.SwingUtilities;
63
import org.netbeans.api.java.classpath.ClassPath;
63
import org.netbeans.api.java.project.JavaProjectConstants;
64
import org.netbeans.api.java.project.JavaProjectConstants;
65
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
64
import org.netbeans.api.project.ProjectUtils;
66
import org.netbeans.api.project.ProjectUtils;
65
import org.netbeans.api.project.SourceGroup;
67
import org.netbeans.api.project.SourceGroup;
66
import org.netbeans.modules.j2ee.dd.api.common.CreateCapability;
68
import org.netbeans.modules.j2ee.dd.api.common.CreateCapability;
Lines 94-100 Link Here
94
96
95
import org.netbeans.modules.web.struts.ui.StrutsConfigurationPanel;
97
import org.netbeans.modules.web.struts.ui.StrutsConfigurationPanel;
96
98
97
import org.netbeans.spi.java.project.classpath.ProjectClassPathExtender;
98
import org.openide.DialogDescriptor;
99
import org.openide.DialogDescriptor;
99
import org.openide.DialogDisplayer;
100
import org.openide.DialogDisplayer;
100
import org.openide.NotifyDescriptor;
101
import org.openide.NotifyDescriptor;
Lines 129-144 Link Here
129
        
130
        
130
        Library lib = LibraryManager.getDefault().getLibrary("struts");                         //NOI18N
131
        Library lib = LibraryManager.getDefault().getLibrary("struts");                         //NOI18N
131
        if (lib != null) {
132
        if (lib != null) {
132
            ProjectClassPathExtender cpExtender = (ProjectClassPathExtender) project.getLookup().lookup(ProjectClassPathExtender.class);
133
            SourceGroup[] sgs = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
133
            if (cpExtender != null) {
134
            if (sgs.length > 0) {
134
                try {
135
                try {
135
                    cpExtender.addLibrary(lib);
136
                    ProjectClassPathModifier.addLibraries(new Library[] {lib}, sgs[0].getRootFolder(), ClassPath.COMPILE);
136
                } catch (IOException ioe) {
137
                } catch (IOException ioe) {
137
                    Exceptions.printStackTrace(ioe);
138
                    Exceptions.printStackTrace(ioe);
138
                }
139
                }
139
            } else {
140
                Logger.getLogger("global").log(Level.INFO,
141
                        "WebProjectClassPathExtender not found in the project lookup of project: " + project.getProjectDirectory().getPath());    //NOI18N
142
            }
140
            }
143
141
144
            try {
142
            try {
(-)a/websvc.core/nbproject/project.xml (+1 lines)
Lines 228-233 Link Here
228
                    <compile-dependency/>
228
                    <compile-dependency/>
229
                    <run-dependency>
229
                    <run-dependency>
230
                        <release-version>1</release-version>
230
                        <release-version>1</release-version>
231
                        <specification-version>1.10</specification-version>
231
                    </run-dependency>
232
                    </run-dependency>
232
                </dependency>
233
                </dependency>
233
                <dependency>
234
                <dependency>
(-)a/websvc.core/src/org/netbeans/modules/websvc/core/dev/wizard/JaxWsServiceCreator.java (-5 / +4 lines)
Lines 81-86 Link Here
81
import javax.lang.model.type.TypeKind;
81
import javax.lang.model.type.TypeKind;
82
import org.netbeans.api.java.classpath.ClassPath;
82
import org.netbeans.api.java.classpath.ClassPath;
83
import org.netbeans.api.java.project.JavaProjectConstants;
83
import org.netbeans.api.java.project.JavaProjectConstants;
84
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
84
import org.netbeans.api.java.source.CancellableTask;
85
import org.netbeans.api.java.source.CancellableTask;
85
import org.netbeans.api.java.source.Comment;
86
import org.netbeans.api.java.source.Comment;
86
import org.netbeans.api.java.source.GeneratorUtilities;
87
import org.netbeans.api.java.source.GeneratorUtilities;
Lines 108-114 Link Here
108
import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlService;
109
import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlService;
109
import org.netbeans.modules.websvc.core.JaxWsUtils;
110
import org.netbeans.modules.websvc.core.JaxWsUtils;
110
import org.netbeans.modules.websvc.jaxws.api.JAXWSSupport;
111
import org.netbeans.modules.websvc.jaxws.api.JAXWSSupport;
111
import org.netbeans.spi.java.project.classpath.ProjectClassPathExtender;
112
import org.netbeans.spi.project.ui.templates.support.Templates;
112
import org.netbeans.spi.project.ui.templates.support.Templates;
113
import org.openide.DialogDisplayer;
113
import org.openide.DialogDisplayer;
114
import org.openide.ErrorManager;
114
import org.openide.ErrorManager;
Lines 308-324 Link Here
308
308
309
        // check if the wsimport class is already present - this means we don't need to add the library
309
        // check if the wsimport class is already present - this means we don't need to add the library
310
        SourceGroup[] sgs = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
310
        SourceGroup[] sgs = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
311
        if (sgs.length > 0) {
311
        ClassPath classPath = ClassPath.getClassPath(sgs[0].getRootFolder(), ClassPath.COMPILE);
312
        ClassPath classPath = ClassPath.getClassPath(sgs[0].getRootFolder(), ClassPath.COMPILE);
312
        FileObject wsimportFO = classPath.findResource("com/sun/tools/ws/ant/WsImport.class"); // NOI18N
313
        FileObject wsimportFO = classPath.findResource("com/sun/tools/ws/ant/WsImport.class"); // NOI18N
313
        if (wsimportFO != null) {
314
        if (wsimportFO != null) {
314
            return;
315
            return;
315
        }
316
        }
316
317
317
        ProjectClassPathExtender pce = (ProjectClassPathExtender) project.getLookup().lookup(ProjectClassPathExtender.class);
318
        Library jaxws21_ext = LibraryManager.getDefault().getLibrary("jaxws21"); //NOI18N
318
        Library jaxws21_ext = LibraryManager.getDefault().getLibrary("jaxws21"); //NOI18N
319
        if (pce != null && jaxws21_ext != null) {
319
        if (jaxws21_ext != null) {
320
            try {
320
            try {
321
                pce.addLibrary(jaxws21_ext);
321
                ProjectClassPathModifier.addLibraries(new Library[] {jaxws21_ext}, sgs[0].getRootFolder(), ClassPath.COMPILE);
322
            } catch (IOException e) {
322
            } catch (IOException e) {
323
                throw new Exception("Unable to add JAXWS 21 Library. " + e.getMessage());
323
                throw new Exception("Unable to add JAXWS 21 Library. " + e.getMessage());
324
            }
324
            }
Lines 327-333 Link Here
327
                    "ProjectClassPathExtender or library not found");
327
                    "ProjectClassPathExtender or library not found");
328
        }
328
        }
329
329
330
        if (sgs.length > 0) {
331
            try {
330
            try {
332
                FileObject srcRoot = sgs[0].getRootFolder();
331
                FileObject srcRoot = sgs[0].getRootFolder();
333
                WSUtils.addJaxWsApiEndorsed(project, srcRoot);
332
                WSUtils.addJaxWsApiEndorsed(project, srcRoot);
(-)a/websvc.jaxrpc/src/org/netbeans/modules/websvc/jaxrpc/client/wizard/JaxRpcClientCreator.java (-5 / +3 lines)
Lines 58-63 Link Here
58
import java.util.Set;
58
import java.util.Set;
59
import org.netbeans.api.java.classpath.ClassPath;
59
import org.netbeans.api.java.classpath.ClassPath;
60
import org.netbeans.api.java.project.JavaProjectConstants;
60
import org.netbeans.api.java.project.JavaProjectConstants;
61
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
61
import org.netbeans.api.java.queries.UnitTestForSourceQuery;
62
import org.netbeans.api.java.queries.UnitTestForSourceQuery;
62
import org.netbeans.api.progress.ProgressHandle;
63
import org.netbeans.api.progress.ProgressHandle;
63
import org.netbeans.api.progress.ProgressHandleFactory;
64
import org.netbeans.api.progress.ProgressHandleFactory;
Lines 74-81 Link Here
74
import org.netbeans.modules.websvc.api.support.ClientCreator;
75
import org.netbeans.modules.websvc.api.support.ClientCreator;
75
import org.netbeans.modules.websvc.core.ClientWizardProperties;
76
import org.netbeans.modules.websvc.core.ClientWizardProperties;
76
import org.netbeans.modules.websvc.core.WsdlRetriever;
77
import org.netbeans.modules.websvc.core.WsdlRetriever;
77
import org.netbeans.modules.websvc.core.WsdlRetriever;
78
import org.netbeans.spi.java.project.classpath.ProjectClassPathExtender;
79
import org.openide.DialogDisplayer;
78
import org.openide.DialogDisplayer;
80
import org.openide.ErrorManager;
79
import org.openide.ErrorManager;
81
import org.openide.NotifyDescriptor;
80
import org.openide.NotifyDescriptor;
Lines 301-310 Link Here
301
        FileObject wscompileFO = classPath.findResource("com/sun/xml/rpc/tools/ant/Wscompile.class");
300
        FileObject wscompileFO = classPath.findResource("com/sun/xml/rpc/tools/ant/Wscompile.class");
302
        if (wscompileFO==null) {
301
        if (wscompileFO==null) {
303
            // add jax-rpc16 if webservice is not on classpath
302
            // add jax-rpc16 if webservice is not on classpath
304
            ProjectClassPathExtender pce = (ProjectClassPathExtender)project.getLookup().lookup(ProjectClassPathExtender.class);
305
            Library jaxrpclib = LibraryManager.getDefault().getLibrary("jaxrpc16"); //NOI18N
303
            Library jaxrpclib = LibraryManager.getDefault().getLibrary("jaxrpc16"); //NOI18N
306
            if ((pce!=null) && (jaxrpclib != null)) {
304
            if (jaxrpclib != null) {
307
                pce.addLibrary(jaxrpclib);
305
                ProjectClassPathModifier.addLibraries(new Library[] {jaxrpclib}, sgs[0].getRootFolder(), ClassPath.COMPILE);
308
            }
306
            }
309
        }
307
        }
310
        
308
        

Return to bug 196455