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

(-)a/j2ee.ejbcore/nbproject/project.xml (+1 lines)
Lines 263-268 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.24</specification-version>
266
                    </run-dependency>
267
                    </run-dependency>
267
                </dependency>
268
                </dependency>
268
                <dependency>
269
                <dependency>
(-)a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/Utils.java (-6 / +14 lines)
Lines 380-385 Link Here
380
380
381
    public static AntArtifact getAntArtifact(final EjbReference ejbReference) throws IOException {
381
    public static AntArtifact getAntArtifact(final EjbReference ejbReference) throws IOException {
382
        
382
        
383
        Project project = getProject(ejbReference);
384
        if (project == null) {
385
            return null;
386
        }
387
        AntArtifact[] antArtifacts = AntArtifactQuery.findArtifactsByType(project, JavaProjectConstants.ARTIFACT_TYPE_JAR);
388
        boolean hasArtifact = (antArtifacts != null && antArtifacts.length > 0);
389
        
390
        return hasArtifact ? antArtifacts[0] : null;
391
        
392
    }
393
394
    public static Project getProject(final EjbReference ejbReference) throws IOException {
395
383
        MetadataModel<EjbJarMetadata> ejbReferenceMetadataModel = ejbReference.getEjbModule().getMetadataModel();
396
        MetadataModel<EjbJarMetadata> ejbReferenceMetadataModel = ejbReference.getEjbModule().getMetadataModel();
384
        FileObject ejbReferenceEjbClassFO = ejbReferenceMetadataModel.runReadAction(new MetadataModelAction<EjbJarMetadata, FileObject>() {
397
        FileObject ejbReferenceEjbClassFO = ejbReferenceMetadataModel.runReadAction(new MetadataModelAction<EjbJarMetadata, FileObject>() {
385
            public FileObject run(EjbJarMetadata metadata) throws Exception {
398
            public FileObject run(EjbJarMetadata metadata) throws Exception {
Lines 390-401 Link Here
390
        if (ejbReferenceEjbClassFO == null) {
403
        if (ejbReferenceEjbClassFO == null) {
391
            return null;
404
            return null;
392
        }
405
        }
393
        Project project = FileOwnerQuery.getOwner(ejbReferenceEjbClassFO);
406
        return FileOwnerQuery.getOwner(ejbReferenceEjbClassFO);
394
        AntArtifact[] antArtifacts = AntArtifactQuery.findArtifactsByType(project, JavaProjectConstants.ARTIFACT_TYPE_JAR);
395
        boolean hasArtifact = (antArtifacts != null && antArtifacts.length > 0);
396
        
397
        return hasArtifact ? antArtifacts[0] : null;
398
        
399
    }
407
    }
400
 
408
 
401
    /**
409
    /**
(-)a/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/action/CallEjbGenerator.java (-10 / +10 lines)
Lines 51-56 Link Here
51
import javax.lang.model.element.VariableElement;
51
import javax.lang.model.element.VariableElement;
52
import javax.lang.model.type.TypeKind;
52
import javax.lang.model.type.TypeKind;
53
import javax.naming.NamingException;
53
import javax.naming.NamingException;
54
import org.netbeans.api.java.classpath.ClassPath;
55
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
54
import org.netbeans.api.java.source.ElementHandle;
56
import org.netbeans.api.java.source.ElementHandle;
55
import org.netbeans.api.java.source.GeneratorUtilities;
57
import org.netbeans.api.java.source.GeneratorUtilities;
56
import org.netbeans.api.java.source.JavaSource;
58
import org.netbeans.api.java.source.JavaSource;
Lines 59-65 Link Here
59
import org.netbeans.api.java.source.WorkingCopy;
61
import org.netbeans.api.java.source.WorkingCopy;
60
import org.netbeans.api.project.FileOwnerQuery;
62
import org.netbeans.api.project.FileOwnerQuery;
61
import org.netbeans.api.project.Project;
63
import org.netbeans.api.project.Project;
62
import org.netbeans.api.project.ant.AntArtifact;
63
import org.netbeans.modules.j2ee.api.ejbjar.EjbReference;
64
import org.netbeans.modules.j2ee.api.ejbjar.EjbReference;
64
import org.netbeans.modules.j2ee.api.ejbjar.EnterpriseReferenceContainer;
65
import org.netbeans.modules.j2ee.api.ejbjar.EnterpriseReferenceContainer;
65
import org.netbeans.modules.j2ee.common.method.MethodModel;
66
import org.netbeans.modules.j2ee.common.method.MethodModel;
Lines 81-87 Link Here
81
import org.netbeans.modules.j2ee.ejbcore.ui.logicalview.entres.ServiceLocatorStrategy;
82
import org.netbeans.modules.j2ee.ejbcore.ui.logicalview.entres.ServiceLocatorStrategy;
82
import org.netbeans.modules.j2ee.metadata.model.api.MetadataModel;
83
import org.netbeans.modules.j2ee.metadata.model.api.MetadataModel;
83
import org.netbeans.modules.j2ee.metadata.model.api.MetadataModelAction;
84
import org.netbeans.modules.j2ee.metadata.model.api.MetadataModelAction;
84
import org.netbeans.spi.java.project.classpath.ProjectClassPathExtender;
85
import org.openide.filesystems.FileObject;
85
import org.openide.filesystems.FileObject;
86
import org.openide.util.Exceptions;
86
import org.openide.util.Exceptions;
87
87
Lines 150-156 Link Here
150
150
151
        if (remote) {
151
        if (remote) {
152
            if (enterpriseProjectIsJavaEE5 && InjectionTargetQuery.isInjectionTarget(referencingFO, referencingClassName)) {
152
            if (enterpriseProjectIsJavaEE5 && InjectionTargetQuery.isInjectionTarget(referencingFO, referencingClassName)) {
153
                addProjectToClassPath(enterpriseProject, ejbReference);
153
                addProjectToClassPath(enterpriseProject, ejbReference, referencingFO);
154
            } else if (nodeProjectIsJavaEE5 == enterpriseProjectIsJavaEE5){ // see #75876
154
            } else if (nodeProjectIsJavaEE5 == enterpriseProjectIsJavaEE5){ // see #75876
155
                erc.addEjbReference(ejbReference, ejbReferenceName, referencingFO, referencingClassName);
155
                erc.addEjbReference(ejbReference, ejbReferenceName, referencingFO, referencingClassName);
156
            }
156
            }
Lines 161-167 Link Here
161
            }
161
            }
162
        } else {
162
        } else {
163
            if (enterpriseProjectIsJavaEE5 && InjectionTargetQuery.isInjectionTarget(referencingFO, referencingClassName)) {
163
            if (enterpriseProjectIsJavaEE5 && InjectionTargetQuery.isInjectionTarget(referencingFO, referencingClassName)) {
164
                addProjectToClassPath(enterpriseProject, ejbReference);
164
                addProjectToClassPath(enterpriseProject, ejbReference, referencingFO);
165
            } else if (nodeProjectIsJavaEE5 == enterpriseProjectIsJavaEE5){ // see #75876
165
            } else if (nodeProjectIsJavaEE5 == enterpriseProjectIsJavaEE5){ // see #75876
166
                erc.addEjbLocalReference(ejbReference, ejbReferenceName, referencingFO, referencingClassName);
166
                erc.addEjbLocalReference(ejbReference, ejbReferenceName, referencingFO, referencingClassName);
167
            }
167
            }
Lines 537-551 Link Here
537
        return caps.toString();
537
        return caps.toString();
538
    }
538
    }
539
    
539
    
540
    private static void addProjectToClassPath(final Project enterpriseProject, final EjbReference ref) throws IOException {
540
    private static void addProjectToClassPath(final Project enterpriseProject, final EjbReference ref, FileObject refFO) throws IOException {
541
        
541
        
542
        AntArtifact target = Utils.getAntArtifact(ref);
542
        Project target = Utils.getProject(ref);
543
        
543
        
544
        boolean differentProject = target != null && !enterpriseProject.equals(target.getProject());
544
        boolean differentProject = target != null && !enterpriseProject.equals(target);
545
        if (differentProject) {
545
        if (differentProject) {
546
            ProjectClassPathExtender pcpe = enterpriseProject.getLookup().lookup(ProjectClassPathExtender.class);
546
//            Sources sg = ProjectUtils.getSources(target);
547
            assert pcpe != null;
547
//            SourceGroup[] grp = sg.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
548
            pcpe.addAntArtifact(target, target.getArtifactLocations()[0]);
548
            ProjectClassPathModifier.addProjects(new Project[] {target} , refFO, ClassPath.COMPILE);
549
        }
549
        }
550
    }
550
    }
551
    
551
    
(-)a/java.project/apichanges.xml (+19 lines)
Lines 106-111 Link Here
106
    <!-- ACTUAL CHANGES BEGIN HERE: -->
106
    <!-- ACTUAL CHANGES BEGIN HERE: -->
107
107
108
    <changes>
108
    <changes>
109
        <change id="CPModifier-addProject">
110
            <api name="general"/>
111
            <summary>Addition of ProjectClassPathModifier.addProject() method</summary>
112
            <version major="1" minor="24"/>
113
            <date day="11" month="2" year="2008"/>
114
            <author login="mkleint"/>
115
            <compatibility addition="yes"/>
116
            <description>
117
                <p>
118
                    <code>ProjectClassPathModifier.addProject(Project[], FileObject, String)</code> is a partial replacement for
119
                    <code>ProjectClassPathModifier.addAntArtifact()</code> that is capable of working with non-ant based project types as well.
120
                    It's not guaranteed that the source and target project will connect in cases when each is of different class of project. Eg.
121
                    Ant-based vs Maven project types. A way to check is to attempt to retrieve AntArtifact from the source and target projects..
122
                </p>
123
            </description>
124
            <class package="org.netbeans.api.java.project.classpath" name="ProjectClassPathModifier"/>
125
            <class package="org.netbeans.spi.java.project.classpath" name="ProjectClassPathModifierImplementation"/>
126
            <issue number="157985"/>
127
        </change>
109
        
128
        
110
        <change id="javadoc-root-and-source-root-detection">
129
        <change id="javadoc-root-and-source-root-detection">
111
            <api name="general"/>
130
            <api name="general"/>
(-)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.23
6
OpenIDE-Module-Specification-Version: 1.24
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 (+30 lines)
Lines 279-284 Link Here
279
            return result;
279
            return result;
280
        }
280
        }
281
    }
281
    }
282
283
    /**
284
     * Adds projects into project's classpath if the
285
     * artifacts are not already on it.
286
     * <p>
287
     *  It's not guaranteed that the source and target project will connect in cases when each is of different class of project. Eg.
288
     * Ant-based vs Maven project types. A way to check is to attempt to retrieve AntArtifact from the source and target projects..
289
     *
290
     * @param projects to be added
291
     * @param projectArtifact a file whose classpath should be extended
292
     * @param classPathType the type of classpath to be extended, @see ClassPath
293
     * @return true in case the classpath was changed, (at least one artifact was added to the classpath),
294
     * the value false is returned when all the artifacts are already included on the classpath.
295
     * @exception IOException in case the project metadata cannot be changed
296
     * @exception UnsupportedOperationException is thrown when the project does not support
297
     * adding of an artifact to the classpath of the given type.
298
     * @since org.netbeans.modules.java.project/1 1.24
299
     */
300
    @SuppressWarnings("deprecation")        //NOI18N
301
    public static boolean addProjects (final Project[] projects,
302
            final FileObject projectArtifact, final String classPathType) throws IOException, UnsupportedOperationException {
303
        final Extensible extensible = findExtensible (projectArtifact, classPathType);
304
        if (extensible.pcmi != null) {
305
            assert extensible.sg != null;
306
            assert extensible.classPathType != null;
307
            return ProjectClassPathModifierAccessor.INSTANCE.addProjects (projects, extensible.pcmi, extensible.sg, extensible.classPathType);
308
        } else {
309
            throw new UnsupportedOperationException("Cannot add project as dependency. Missing ProjectClassPathModifierImplementation service in project type.");
310
        }
311
    }
282
    
312
    
283
    /**
313
    /**
284
     * Removes artifacts (e.g. subprojects) from project's classpath if the
314
     * Removes artifacts (e.g. subprojects) from project's classpath if the
(-)a/java.project/src/org/netbeans/modules/java/project/classpath/ProjectClassPathModifierAccessor.java (-2 / +5 lines)
Lines 44-49 Link Here
44
import java.io.IOException;
44
import java.io.IOException;
45
import java.net.URI;
45
import java.net.URI;
46
import java.net.URL;
46
import java.net.URL;
47
import org.netbeans.api.project.Project;
47
import org.netbeans.api.project.SourceGroup;
48
import org.netbeans.api.project.SourceGroup;
48
import org.netbeans.api.project.ant.AntArtifact;
49
import org.netbeans.api.project.ant.AntArtifact;
49
import org.netbeans.api.project.libraries.Library;
50
import org.netbeans.api.project.libraries.Library;
Lines 70-76 Link Here
70
    /** Creates a new instance of ProjectClassPathModifierAccessor */
71
    /** Creates a new instance of ProjectClassPathModifierAccessor */
71
    public ProjectClassPathModifierAccessor() {
72
    public ProjectClassPathModifierAccessor() {
72
    }
73
    }
73
    
74
74
    public abstract SourceGroup[] getExtensibleSourceGroups (ProjectClassPathModifierImplementation m);
75
    public abstract SourceGroup[] getExtensibleSourceGroups (ProjectClassPathModifierImplementation m);
75
    
76
    
76
    public abstract String[] getExtensibleClassPathTypes (ProjectClassPathModifierImplementation m, SourceGroup sg);
77
    public abstract String[] getExtensibleClassPathTypes (ProjectClassPathModifierImplementation m, SourceGroup sg);
Lines 90-94 Link Here
90
    public abstract boolean addAntArtifacts (AntArtifact[] artifacts, URI[] artifactElements, ProjectClassPathModifierImplementation m, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException;
91
    public abstract boolean addAntArtifacts (AntArtifact[] artifacts, URI[] artifactElements, ProjectClassPathModifierImplementation m, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException;
91
92
92
    public abstract boolean removeAntArtifacts (AntArtifact[] artifacts, URI[] artifactElements, ProjectClassPathModifierImplementation m, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException;
93
    public abstract boolean removeAntArtifacts (AntArtifact[] artifacts, URI[] artifactElements, ProjectClassPathModifierImplementation m, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException;
93
    
94
95
    public abstract boolean addProjects(Project[] projects, ProjectClassPathModifierImplementation pcmi, SourceGroup sg, String classPathType) throws IOException, UnsupportedOperationException;
96
94
}
97
}
(-)a/java.project/src/org/netbeans/spi/java/project/classpath/ProjectClassPathModifierImplementation.java (-2 / +42 lines)
Lines 49-56 Link Here
49
import java.net.URL;
49
import java.net.URL;
50
import java.util.ArrayList;
50
import java.util.ArrayList;
51
import java.util.List;
51
import java.util.List;
52
import org.netbeans.api.java.project.JavaProjectConstants;
53
import org.netbeans.api.project.Project;
52
import org.netbeans.api.project.SourceGroup;
54
import org.netbeans.api.project.SourceGroup;
53
import org.netbeans.api.project.ant.AntArtifact;
55
import org.netbeans.api.project.ant.AntArtifact;
56
import org.netbeans.api.project.ant.AntArtifactQuery;
54
import org.netbeans.api.project.libraries.Library;
57
import org.netbeans.api.project.libraries.Library;
55
import org.netbeans.api.queries.CollocationQuery;
58
import org.netbeans.api.queries.CollocationQuery;
56
import org.netbeans.modules.java.project.classpath.ProjectClassPathModifierAccessor;
59
import org.netbeans.modules.java.project.classpath.ProjectClassPathModifierAccessor;
Lines 271-277 Link Here
271
     * removing of an artifact from the classpath of the given type.
274
     * removing of an artifact from the classpath of the given type.
272
     */
275
     */
273
    protected abstract boolean removeAntArtifacts (AntArtifact[] artifacts, URI[] artifactElements, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException;
276
    protected abstract boolean removeAntArtifacts (AntArtifact[] artifacts, URI[] artifactElements, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException;
274
    
277
278
279
    /**
280
     * Adds projects as dependencies into project's classpath if the
281
     * artifacts are not already on it. The default behaviour will behave as {@link #addAntArtifacts(org.netbeans.api.project.ant.AntArtifact[], java.net.URI[], org.netbeans.api.project.SourceGroup, java.lang.String)}
282
     * Other project types can override the behaviour.
283
     * @param projects to be added
284
     * (must be owned by the artifact and be relative to it)
285
     * @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA}
286
     * identifying the compilation unit to change
287
     * @param type the type of the classpath the artifact should be added to,
288
     * eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE}
289
     * @return true in case the classpath was changed, (at least one artifact was added to the classpath),
290
     * the value false is returned when all the artifacts are already included on the classpath.
291
     * @exception IOException in case the project metadata cannot be changed
292
     * @exception UnsupportedOperationException is thrown when the project does not support
293
     * adding of an artifact to the classpath of the given type.
294
     * @since org.netbeans.modules.java.project/1 1.24
295
     */
296
    protected boolean addProjects(Project[] projects, SourceGroup sg, String classPathType) throws IOException, UnsupportedOperationException {
297
        List<AntArtifact> ants = new ArrayList<AntArtifact>();
298
        List<URI> antUris = new ArrayList<URI>();
299
        for (Project prj : projects) {
300
            AntArtifact[] antArtifacts = AntArtifactQuery.findArtifactsByType(prj, JavaProjectConstants.ARTIFACT_TYPE_JAR);
301
            for (AntArtifact aa : antArtifacts) {
302
                ants.add(aa);
303
                antUris.add(aa.getArtifactLocations()[0]);
304
            }
305
        }
306
        return addAntArtifacts(ants.toArray(new AntArtifact[0]), antUris.toArray(new URI[0]), sg, classPathType);
307
    }
308
275
    /**
309
    /**
276
     * Takes a classpath root and tries to figure the best way to reference that file for that particular project.
310
     * Takes a classpath root and tries to figure the best way to reference that file for that particular project.
277
     * The possible actions include relativization of path, copying to sharable libraries folder etc.
311
     * The possible actions include relativization of path, copying to sharable libraries folder etc.
Lines 322-327 Link Here
322
        }
356
        }
323
        return f;
357
        return f;
324
    }
358
    }
359
325
    
360
    
326
    private File copyFile(File file, FileObject newRoot) throws IOException {
361
    private File copyFile(File file, FileObject newRoot) throws IOException {
327
        FileObject fo = FileUtil.toFileObject(file);
362
        FileObject fo = FileUtil.toFileObject(file);
Lines 410-415 Link Here
410
        public boolean addRoots (URI[] classPathRoots, ProjectClassPathModifierImplementation m, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
445
        public boolean addRoots (URI[] classPathRoots, ProjectClassPathModifierImplementation m, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
411
            assert m!= null;
446
            assert m!= null;
412
            return m.addRoots (classPathRoots, sourceGroup, type);
447
            return m.addRoots (classPathRoots, sourceGroup, type);
413
        }       
448
        }
449
450
        public boolean addProjects(Project[] projects, ProjectClassPathModifierImplementation pcmi, SourceGroup sg, String classPathType) throws IOException, UnsupportedOperationException {
451
            assert pcmi != null;
452
            return pcmi.addProjects(projects, sg, classPathType);
453
        }
414
    }
454
    }
415
}
455
}
(-)a/maven/nbproject/project.xml (-1 / +1 lines)
Lines 123-129 Link Here
123
                    <compile-dependency/>
123
                    <compile-dependency/>
124
                    <run-dependency>
124
                    <run-dependency>
125
                        <release-version>1</release-version>
125
                        <release-version>1</release-version>
126
                        <specification-version>1.18</specification-version>
126
                        <specification-version>1.24</specification-version>
127
                    </run-dependency>
127
                    </run-dependency>
128
                </dependency>
128
                </dependency>
129
                <dependency>
129
                <dependency>
(-)a/maven/src/org/netbeans/modules/maven/CPExtender.java (-3 / +41 lines)
Lines 52-57 Link Here
52
import java.util.logging.Logger;
52
import java.util.logging.Logger;
53
import java.util.regex.Matcher;
53
import java.util.regex.Matcher;
54
import java.util.regex.Pattern;
54
import java.util.regex.Pattern;
55
import org.apache.maven.artifact.Artifact;
56
import org.apache.maven.project.MavenProject;
57
import org.netbeans.api.project.Project;
55
import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
58
import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
56
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
59
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
57
import org.netbeans.modules.maven.indexer.api.RepositoryPreferences;
60
import org.netbeans.modules.maven.indexer.api.RepositoryPreferences;
Lines 346-352 Link Here
346
    public boolean addLibraries(final Library[] libraries, SourceGroup grp, String type) throws IOException {
349
    public boolean addLibraries(final Library[] libraries, SourceGroup grp, String type) throws IOException {
347
        final Boolean[] added = new Boolean[1];
350
        final Boolean[] added = new Boolean[1];
348
        added[0] = libraries.length > 0;
351
        added[0] = libraries.length > 0;
349
        String scope = ClassPath.EXECUTE.equals(type) ? "runtime" : null; //NOI18N
352
        String scope = ClassPath.EXECUTE.equals(type) ? Artifact.SCOPE_RUNTIME : null; //NOI18N
350
        //figure if we deal with test or regular sources.
353
        //figure if we deal with test or regular sources.
351
        String name = grp.getName();
354
        String name = grp.getName();
352
        if (MavenSourcesImpl.NAME_TESTSOURCE.equals(name)) {
355
        if (MavenSourcesImpl.NAME_TESTSOURCE.equals(name)) {
Lines 384-390 Link Here
384
    public boolean addRoots(final URL[] urls, SourceGroup grp, String type) throws IOException {
387
    public boolean addRoots(final URL[] urls, SourceGroup grp, String type) throws IOException {
385
        final Boolean[] added = new Boolean[1];
388
        final Boolean[] added = new Boolean[1];
386
        added[0] = urls.length > 0;
389
        added[0] = urls.length > 0;
387
        String scope = ClassPath.EXECUTE.equals(type) ? "runtime" : null;//NOI18N
390
        String scope = ClassPath.EXECUTE.equals(type) ? Artifact.SCOPE_RUNTIME : null;//NOI18N
388
        //figure if we deal with test or regular sources.
391
        //figure if we deal with test or regular sources.
389
        String name = grp.getName();
392
        String name = grp.getName();
390
        if (MavenSourcesImpl.NAME_TESTSOURCE.equals(name)) {
393
        if (MavenSourcesImpl.NAME_TESTSOURCE.equals(name)) {
Lines 419-425 Link Here
419
        }
422
        }
420
        return added[0];
423
        return added[0];
421
    }
424
    }
422
    
425
426
    @Override
427
    protected boolean addProjects(final Project[] projects, SourceGroup sg, String classPathType) throws IOException, UnsupportedOperationException {
428
        final Boolean[] added = new Boolean[1];
429
430
        added[0] = projects.length > 0;
431
        String scope = ClassPath.EXECUTE.equals(classPathType) ? Artifact.SCOPE_RUNTIME : null;//NOI18N
432
        //figure if we deal with test or regular sources.
433
        String name = sg.getName();
434
        if (MavenSourcesImpl.NAME_TESTSOURCE.equals(name)) {
435
            scope = "test"; //NOI18N
436
        }
437
        final String fScope = scope;
438
        ModelOperation<POMModel> operation = new ModelOperation<POMModel>() {
439
            public void performOperation(POMModel model) {
440
                for (Project prj: projects) {
441
                    NbMavenProject nbprj = prj.getLookup().lookup(NbMavenProject.class);
442
                    if (nbprj != null) {
443
                        MavenProject mp = nbprj.getMavenProject();
444
                        Dependency dependency = ModelUtils.checkModelDependency(model, mp.getGroupId(), mp.getArtifactId(), true);
445
                        dependency.setVersion(mp.getVersion());
446
                        if (fScope != null) {
447
                            dependency.setScope(fScope);
448
                        }
449
                    } else {
450
                        Logger.getLogger(CPExtender.class.getName()).warning("Attempting to add a non-Maven project dependency to a Maven project. Skipping."); //NOI18N
451
                    }
452
                }
453
            }
454
        };
455
        FileObject pom = project.getProjectDirectory().getFileObject(POM_XML);//NOI18N
456
        org.netbeans.modules.maven.model.Utilities.performPOMModelOperations(pom, Collections.singletonList(operation));
457
        return added[0];
458
459
    }
460
423
    public boolean removeRoots(URL[] arg0, SourceGroup arg1, String arg2) throws IOException,
461
    public boolean removeRoots(URL[] arg0, SourceGroup arg1, String arg2) throws IOException,
424
                                                                                    UnsupportedOperationException {
462
                                                                                    UnsupportedOperationException {
425
        throw new UnsupportedOperationException("Removing binary dependencies is not supported by Maven projects.");
463
        throw new UnsupportedOperationException("Removing binary dependencies is not supported by Maven projects.");
(-)a/maven/src/org/netbeans/modules/maven/CPModifierLookupMerger.java (+16 lines)
Lines 48-53 Link Here
48
import java.util.Arrays;
48
import java.util.Arrays;
49
import java.util.Collection;
49
import java.util.Collection;
50
import java.util.HashSet;
50
import java.util.HashSet;
51
import org.netbeans.api.project.Project;
51
import org.netbeans.api.project.SourceGroup;
52
import org.netbeans.api.project.SourceGroup;
52
import org.netbeans.api.project.ant.AntArtifact;
53
import org.netbeans.api.project.ant.AntArtifact;
53
import org.netbeans.api.project.libraries.Library;
54
import org.netbeans.api.project.libraries.Library;
Lines 231-236 Link Here
231
            return fallback.addAntArtifacts(arg0, arg1, arg2, arg3);
232
            return fallback.addAntArtifacts(arg0, arg1, arg2, arg3);
232
        }
233
        }
233
234
235
        @Override
236
        protected boolean addProjects(Project[] projects, SourceGroup sg, String classPathType) throws IOException, UnsupportedOperationException {
237
//            Collection<? extends ProjectClassPathModifierImplementation> list = context.lookupAll(ProjectClassPathModifierImplementation.class);
238
//            for (ProjectClassPathModifierImplementation ext : list) {
239
//                Boolean ret = (Boolean)retVal("addProjects", ext, //NOI18N
240
//                        new Class<?>[] { new Project[0].getClass(), SourceGroup.class, String.class}, projects, sg, classPathType);
241
//                if (ret.booleanValue()) {
242
//                    return ret.booleanValue();
243
//                }
244
//            }
245
            //use only the fallback, as that's the man with correct impl. others might have the ant based default method implementation preserved..
246
            return fallback.addProjects(projects, sg, classPathType);
247
        }
248
249
234
    }
250
    }
235
    
251
    
236
}
252
}

Return to bug 157985