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

(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/classpath/ClassPathProviderImpl.java (-5 / +11 lines)
Lines 20-25 Link Here
20
import org.netbeans.api.java.classpath.ClassPath;
20
import org.netbeans.api.java.classpath.ClassPath;
21
import org.netbeans.spi.java.classpath.ClassPathFactory;
21
import org.netbeans.spi.java.classpath.ClassPathFactory;
22
import org.netbeans.spi.java.classpath.ClassPathProvider;
22
import org.netbeans.spi.java.classpath.ClassPathProvider;
23
import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport;
23
import org.netbeans.spi.project.support.ant.AntProjectHelper;
24
import org.netbeans.spi.project.support.ant.AntProjectHelper;
24
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
25
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
25
import org.netbeans.modules.java.j2seproject.SourceRoots;
26
import org.netbeans.modules.java.j2seproject.SourceRoots;
Lines 143-153 Link Here
143
        if ( cp == null) {
144
        if ( cp == null) {
144
            if (type == 0) {
145
            if (type == 0) {
145
                cp = ClassPathFactory.createClassPath(
146
                cp = ClassPathFactory.createClassPath(
146
                new ProjectClassPathImplementation(helper, "javac.classpath", evaluator)); // NOI18N
147
                    ProjectClassPathSupport.createPropertyBasedClassPathImplementation(
148
                    helper, evaluator, "javac.classpath")); // NOI18N
147
            }
149
            }
148
            else {
150
            else {
149
                cp = ClassPathFactory.createClassPath(
151
                cp = ClassPathFactory.createClassPath(
150
                new ProjectClassPathImplementation(helper, "javac.test.classpath", evaluator)); // NOI18N
152
                    ProjectClassPathSupport.createPropertyBasedClassPathImplementation(
153
                    helper, evaluator, "javac.test.classpath")); // NOI18N
151
            }
154
            }
152
            cache[2+type] = cp;
155
            cache[2+type] = cp;
153
        }
156
        }
Lines 169-185 Link Here
169
        if ( cp == null) {
172
        if ( cp == null) {
170
            if (type == 0) {
173
            if (type == 0) {
171
                cp = ClassPathFactory.createClassPath(
174
                cp = ClassPathFactory.createClassPath(
172
                new ProjectClassPathImplementation(helper, "run.classpath", evaluator)); // NOI18N
175
                    ProjectClassPathSupport.createPropertyBasedClassPathImplementation(
176
                    helper, evaluator, "run.classpath")); // NOI18N
173
            }
177
            }
174
            else if (type == 1) {
178
            else if (type == 1) {
175
                cp = ClassPathFactory.createClassPath(
179
                cp = ClassPathFactory.createClassPath(
176
                new ProjectClassPathImplementation(helper, "run.test.classpath", evaluator)); // NOI18N
180
                    ProjectClassPathSupport.createPropertyBasedClassPathImplementation(
181
                    helper, evaluator,"run.test.classpath")); // NOI18N
177
            }
182
            }
178
            else if (type == 2) {
183
            else if (type == 2) {
179
                //Only to make the CompiledDataNode hapy
184
                //Only to make the CompiledDataNode hapy
180
                //Todo: Strictly it should return ${run.classpath} - ${build.classes.dir} + ${dist.jar}
185
                //Todo: Strictly it should return ${run.classpath} - ${build.classes.dir} + ${dist.jar}
181
                cp = ClassPathFactory.createClassPath(
186
                cp = ClassPathFactory.createClassPath(
182
                new ProjectClassPathImplementation(helper, DIST_JAR, evaluator)); // NOI18N
187
                    ProjectClassPathSupport.createPropertyBasedClassPathImplementation(
188
                    helper, evaluator, DIST_JAR)); // NOI18N
183
            }
189
            }
184
            cache[4+type] = cp;
190
            cache[4+type] = cp;
185
        }
191
        }
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/classpath/ProjectClassPathImplementation.java (-132 lines)
Removed Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.java.j2seproject.classpath;
15
16
import java.beans.PropertyChangeEvent;
17
import java.beans.PropertyChangeListener;
18
import java.beans.PropertyChangeSupport;
19
import java.io.File;
20
import java.net.MalformedURLException;
21
import java.net.URL;
22
import java.util.ArrayList;
23
import java.util.Collections;
24
import java.util.List;
25
import org.netbeans.api.project.ProjectManager;
26
import org.netbeans.spi.java.classpath.ClassPathImplementation;
27
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
28
import org.netbeans.spi.project.support.ant.AntProjectHelper;
29
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
30
import org.netbeans.spi.project.support.ant.PropertyUtils;
31
import org.openide.filesystems.FileUtil;
32
import org.openide.util.WeakListeners;
33
34
// XXX needs unit test!
35
36
/**
37
 * Implementation of a single classpath that is derived from one Ant property.
38
 */
39
final class ProjectClassPathImplementation implements ClassPathImplementation, PropertyChangeListener, Runnable {
40
    
41
    private PropertyChangeSupport support = new PropertyChangeSupport(this);
42
    private AntProjectHelper helper;
43
    private String propertyName;
44
    private List resources;
45
    private final PropertyEvaluator evaluator;
46
    private boolean dirty = false;
47
48
    /**
49
     * Construct the implementation.
50
     * @param helper an Ant project, used to resolve file paths
51
     * @param propertyName the name of an Ant property which will supply the classpath
52
     * @param evaluator a property evaluator used to find the value of the classpath
53
     */
54
    public ProjectClassPathImplementation(AntProjectHelper helper, String propertyName, PropertyEvaluator evaluator) {
55
        assert helper != null && propertyName != null;
56
        this.helper = helper;
57
        this.evaluator = evaluator;
58
        this.propertyName = propertyName;
59
        evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this, evaluator));
60
    }
61
62
    public synchronized List /*<PathResourceImplementation>*/ getResources() {
63
        if (this.resources == null) {
64
            this.resources = this.getPath ();
65
        }
66
        return this.resources;
67
    }
68
69
    public void addPropertyChangeListener(PropertyChangeListener listener) {
70
        support.addPropertyChangeListener (listener);
71
    }
72
73
    public void removePropertyChangeListener(PropertyChangeListener listener) {
74
        support.removePropertyChangeListener (listener);
75
    }
76
77
78
    public void propertyChange(PropertyChangeEvent evt) {
79
        if (!evt.getPropertyName().equals(propertyName)) {
80
            // Not interesting to us.
81
            return;
82
        }
83
        // Coalesce changes; can come in fast after huge CP changes (#47910):
84
        if (!dirty) {
85
            dirty = true;
86
            ProjectManager.mutex().postReadRequest(this);
87
        }
88
    }
89
    
90
    public void run() {
91
        dirty = false;
92
        List newRoots = getPath ();
93
        boolean fire = false;
94
        synchronized (this) {
95
            if (this.resources != null && !this.resources.equals(newRoots)) {
96
                this.resources = newRoots;
97
                fire = true;
98
            }
99
        }
100
        if (fire) {
101
            support.firePropertyChange (PROP_RESOURCES,null,null);
102
        }
103
    }
104
    
105
    private List getPath() {
106
        List result = new ArrayList ();
107
        String prop = evaluator.getProperty(propertyName);
108
        if (prop != null) {
109
            String[] pieces = PropertyUtils.tokenizePath(prop);
110
            for (int i = 0; i < pieces.length; i++) {
111
                File f = helper.resolveFile(pieces[i]);
112
                try {
113
                    URL entry = f.toURI().toURL();
114
                    if (FileUtil.isArchiveFile(entry) || (f.isFile() && f.length()<4)) {    //XXX: Not yet closed archive file
115
                        entry = FileUtil.getArchiveRoot(entry);
116
                    } else if (!f.exists()) {
117
                        // if file does not exist (e.g. build/classes folder
118
                        // was not created yet) then corresponding File will
119
                        // not be ended with slash. Fix that.
120
                        assert !entry.toExternalForm().endsWith("/") : f; // NOI18N
121
                        entry = new URL(entry.toExternalForm() + "/"); // NOI18N
122
                    }
123
                    result.add(ClassPathSupport.createResource(entry));
124
                } catch (MalformedURLException mue) {
125
                    assert false : mue;
126
                }
127
            }
128
        }
129
        return Collections.unmodifiableList(result);
130
    }
131
132
}
(-)java/project/apichanges.xml (-1 / +17 lines)
Lines 69-80 Link Here
69
    <!-- First, a list of API names you may use: -->
69
    <!-- First, a list of API names you may use: -->
70
    <apidefs>
70
    <apidefs>
71
        <apidef name="general">Java Project API</apidef>
71
        <apidef name="general">Java Project API</apidef>
72
        <apidef name="classpath">Classpath Support SPI</apidef>
72
        <!-- etc. -->
73
        <!-- etc. -->
73
    </apidefs>
74
    </apidefs>
74
75
75
    <!-- ACTUAL CHANGES BEGIN HERE: -->
76
    <!-- ACTUAL CHANGES BEGIN HERE: -->
76
77
77
    <changes>
78
       <change>
79
            <api name="Classpath"/>
80
            <summary>Added helper method for creating ClassPathImplementation based on the ant property</summary>
81
            <version major="1" minor="3"/>
82
            <date day="6" month="1" year="2005"/>
83
            <author login="tzezula"/>
84
            <compatibility addition="yes"/>
85
            <description>
86
                <p>
87
                Added new helper class org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport
88
                with a static method createPropertyBasedClassPathImplementation (AntProjectHelper, PropertyEvaluator, String).
89
                This method creates a live classpath based on the single Ant property holding the path. The classpath
90
                implementation listens on changes of the property value updates its state and fires events to clients.
91
                </p>
92
            </description>
93
        </change>    
78
94
79
        <change id="rel-vers-1">
95
        <change id="rel-vers-1">
80
            <api name="general"/>
96
            <api name="general"/>
(-)java/project/arch.xml (+6 lines)
Lines 57-62 Link Here
57
    classpath of a J2SE project automatically.
57
    classpath of a J2SE project automatically.
58
   </p>
58
   </p>
59
  </api>
59
  </api>
60
  <api group="java" name="ProjectClassPathSupport" type="export" category="devel">
61
   <p>
62
    Support class containg helper method for creating ClassPathImplementation based
63
    on the Ant propery.
64
   </p>
65
  </api>
60
   </li>
66
   </li>
61
  </ul>
67
  </ul>
62
 </answer>
68
 </answer>
(-)java/project/nbproject/project.properties (-2 / +5 lines)
Lines 17-27 Link Here
17
javadoc.arch=${basedir}/arch.xml
17
javadoc.arch=${basedir}/arch.xml
18
javadoc.apichanges=${basedir}/apichanges.xml
18
javadoc.apichanges=${basedir}/apichanges.xml
19
19
20
test.unit.cp.extra=${nb_all}/projects/projectapi/build/test/unit/classes
20
test.unit.cp.extra=${nb_all}/projects/projectapi/build/test/unit/classes:\
21
    ${nb_all}/ant/project/build/test/unit/classes
21
# masterfs needed for the usual reasons; tools.jar needed for Ant's <javac> to work
22
# masterfs needed for the usual reasons; tools.jar needed for Ant's <javac> to work
22
test.unit.run.cp.extra=\
23
test.unit.run.cp.extra=\
23
    ${openide/masterfs.dir}/${nb.modules.dir}/org-netbeans-modules-masterfs.jar:\
24
    ${openide/masterfs.dir}/${nb.modules.dir}/org-netbeans-modules-masterfs.jar:\
24
    ${jdkhome}/lib/tools.jar
25
    ${jdkhome}/lib/tools.jar:\
26
    ${diff.dir}/${nb.modules.dir}/org-netbeans-modules-diff.jar:\
27
    ${libs/xerces.dir}/${nb.modules/autoload.dir}/ext/xerces-2.6.2.jar
25
test-unit-sys-prop.test.data.dir=${nb_all}/java/project/test/unit/data
28
test-unit-sys-prop.test.data.dir=${nb_all}/java/project/test/unit/data
26
test-unit-sys-prop.test.bridge.jar=${ant.dir}/ant/nblib/bridge.jar
29
test-unit-sys-prop.test.bridge.jar=${ant.dir}/ant/nblib/bridge.jar
27
# May be overridden to e.g. test against a different version of Ant:
30
# May be overridden to e.g. test against a different version of Ant:
(-)java/project/nbproject/project.xml (+1 lines)
Lines 134-139 Link Here
134
                <package>org.netbeans.api.java.project</package>
134
                <package>org.netbeans.api.java.project</package>
135
                <package>org.netbeans.spi.java.project.support.ui</package>
135
                <package>org.netbeans.spi.java.project.support.ui</package>
136
                <package>org.netbeans.spi.java.project.support.ui.templates</package>
136
                <package>org.netbeans.spi.java.project.support.ui.templates</package>
137
		<package>org.netbeans.spi.java.project.classpath.support</package>
137
            </public-packages>
138
            </public-packages>
138
            <javadoc/>
139
            <javadoc/>
139
        </data>
140
        </data>
(-)java/project/src/org/netbeans/spi/java/project/classpath/support/ProjectClassPathImplementation.java (+131 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.spi.java.project.classpath.support;
15
16
import java.beans.PropertyChangeEvent;
17
import java.beans.PropertyChangeListener;
18
import java.beans.PropertyChangeSupport;
19
import java.io.File;
20
import java.net.MalformedURLException;
21
import java.net.URL;
22
import java.util.ArrayList;
23
import java.util.Collections;
24
import java.util.List;
25
import org.netbeans.api.project.ProjectManager;
26
import org.netbeans.spi.java.classpath.ClassPathImplementation;
27
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
28
import org.netbeans.spi.project.support.ant.AntProjectHelper;
29
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
30
import org.netbeans.spi.project.support.ant.PropertyUtils;
31
import org.openide.filesystems.FileUtil;
32
import org.openide.util.WeakListeners;
33
34
35
/**
36
 * Implementation of a single classpath that is derived from one Ant property.
37
 */
38
final class ProjectClassPathImplementation implements ClassPathImplementation, PropertyChangeListener, Runnable {
39
    
40
    private PropertyChangeSupport support = new PropertyChangeSupport(this);
41
    private AntProjectHelper helper;
42
    private String propertyName;
43
    private List resources;
44
    private final PropertyEvaluator evaluator;
45
    private boolean dirty = false;
46
47
    /**
48
     * Construct the implementation.
49
     * @param helper an Ant project, used to resolve file paths
50
     * @param propertyName the name of an Ant property which will supply the classpath
51
     * @param evaluator a property evaluator used to find the value of the classpath
52
     */
53
    public ProjectClassPathImplementation(AntProjectHelper helper, String propertyName, PropertyEvaluator evaluator) {
54
        assert helper != null && propertyName != null;
55
        this.helper = helper;
56
        this.evaluator = evaluator;
57
        this.propertyName = propertyName;
58
        evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this, evaluator));
59
    }
60
61
    public synchronized List /*<PathResourceImplementation>*/ getResources() {
62
        if (this.resources == null) {
63
            this.resources = this.getPath ();
64
        }
65
        return this.resources;
66
    }
67
68
    public void addPropertyChangeListener(PropertyChangeListener listener) {
69
        support.addPropertyChangeListener (listener);
70
    }
71
72
    public void removePropertyChangeListener(PropertyChangeListener listener) {
73
        support.removePropertyChangeListener (listener);
74
    }
75
76
77
    public void propertyChange(PropertyChangeEvent evt) {
78
        if (!evt.getPropertyName().equals(propertyName)) {
79
            // Not interesting to us.
80
            return;
81
        }
82
        // Coalesce changes; can come in fast after huge CP changes (#47910):
83
        if (!dirty) {
84
            dirty = true;
85
            ProjectManager.mutex().postReadRequest(this);
86
        }
87
    }
88
    
89
    public void run() {
90
        dirty = false;
91
        List newRoots = getPath ();
92
        boolean fire = false;
93
        synchronized (this) {
94
            if (this.resources != null && !this.resources.equals(newRoots)) {
95
                this.resources = newRoots;
96
                fire = true;
97
            }
98
        }
99
        if (fire) {
100
            support.firePropertyChange (PROP_RESOURCES,null,null);
101
        }
102
    }
103
    
104
    private List getPath() {
105
        List result = new ArrayList ();
106
        String prop = evaluator.getProperty(propertyName);
107
        if (prop != null) {
108
            String[] pieces = PropertyUtils.tokenizePath(prop);
109
            for (int i = 0; i < pieces.length; i++) {
110
                File f = helper.resolveFile(pieces[i]);
111
                try {
112
                    URL entry = f.toURI().toURL();
113
                    if (FileUtil.isArchiveFile(entry) || (f.isFile() && f.length()<4)) {    //XXX: Not yet closed archive file
114
                        entry = FileUtil.getArchiveRoot(entry);
115
                    } else if (!f.exists()) {
116
                        // if file does not exist (e.g. build/classes folder
117
                        // was not created yet) then corresponding File will
118
                        // not be ended with slash. Fix that.
119
                        assert !entry.toExternalForm().endsWith("/") : f; // NOI18N
120
                        entry = new URL(entry.toExternalForm() + "/"); // NOI18N
121
                    }
122
                    result.add(ClassPathSupport.createResource(entry));
123
                } catch (MalformedURLException mue) {
124
                    assert false : mue;
125
                }
126
            }
127
        }
128
        return Collections.unmodifiableList(result);
129
    }
130
131
}
(-)java/project/src/org/netbeans/spi/java/project/classpath/support/ProjectClassPathSupport.java (+45 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
package org.netbeans.spi.java.project.classpath.support;
14
15
import org.netbeans.spi.java.classpath.ClassPathImplementation;
16
import org.netbeans.spi.project.support.ant.AntProjectHelper;
17
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
18
19
/**
20
 * ProjectClassPathSupport is a support class for creating classpath based
21
 * on the single ant property.
22
 * @since org.netbeans.modules.java.project 1.3 
23
 * @author Tomas Zezula
24
 */
25
public class ProjectClassPathSupport {
26
        
27
    /** Creates a new instance of NewClass */
28
    private ProjectClassPathSupport() {
29
    }
30
    
31
    
32
    /**
33
     * Creates new classpath based on the ant property. The returned classpath
34
     * listens on changes of property value.
35
     * @param helper {@link AntProjectHelper} used to resolve files
36
     * @param evaluator {@link PropertyEvaluator} used for obtaining the value of
37
     * given property and listening on value changes.
38
     * @param propertyName the name of ant property holding the classpath
39
     */
40
    public static ClassPathImplementation createPropertyBasedClassPathImplementation (AntProjectHelper helper,
41
            PropertyEvaluator evaluator, String propertyName) {
42
        return new ProjectClassPathImplementation (helper, propertyName, evaluator);
43
    }
44
    
45
}
(-)java/project/test/unit/src/org/netbeans/spi/java/project/classpath/support/ProjectClassPathImplementationTest.java (+130 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.spi.java.project.classpath.support;
15
16
17
import java.io.File;
18
import java.io.IOException;
19
import java.net.URL;
20
import java.util.Arrays;
21
import java.util.Collection;
22
import java.util.Collections;
23
import java.util.List;
24
import java.util.Map;
25
import java.util.Properties;
26
import org.netbeans.api.java.classpath.ClassPath;
27
import org.netbeans.api.project.Project;
28
import org.netbeans.api.project.ProjectManager;
29
import org.netbeans.junit.NbTestCase;
30
import org.netbeans.spi.java.classpath.ClassPathFactory;
31
import org.netbeans.spi.java.classpath.ClassPathImplementation;
32
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
33
import org.netbeans.spi.project.support.ant.AntBasedTestUtil;
34
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
35
import org.netbeans.spi.project.support.ant.PropertyUtils;
36
import org.openide.filesystems.FileObject;
37
import org.netbeans.api.project.TestUtil;
38
import org.netbeans.spi.project.support.ant.AntProjectHelper;
39
import org.netbeans.spi.project.support.ant.EditableProperties;
40
import org.netbeans.spi.project.support.ant.ProjectGenerator;
41
import org.openide.filesystems.FileUtil;
42
import org.openide.filesystems.Repository;
43
import org.openide.util.Lookup;
44
45
/**
46
 * Tests for {@link ProjectClassPathImplementation}.
47
 * @author Tomas Zezula
48
 */
49
public class ProjectClassPathImplementationTest extends NbTestCase {
50
    
51
    private static final String PROP_NAME = "classpath"; //NOI18N
52
    
53
    public ProjectClassPathImplementationTest(String testName) {
54
        super(testName);
55
    }
56
    
57
    private FileObject scratch;
58
    private FileObject projdir;
59
    private FileObject[] cpRoots;
60
    private AntProjectHelper helper;
61
    private PropertyEvaluator evaluator;
62
    
63
    protected void setUp() throws Exception {
64
        super.setUp();
65
        TestUtil.setLookup(new Object[] {
66
            new org.netbeans.modules.projectapi.SimpleFileOwnerQueryImplementation(),
67
            AntBasedTestUtil.testAntBasedProjectType(),
68
        }, ProjectClassPathImplementation.class.getClassLoader());
69
    }
70
71
    protected void tearDown() throws Exception {
72
        scratch = null;
73
        projdir = null;
74
        cpRoots = null;
75
        helper = null;
76
        evaluator = null;
77
        TestUtil.setLookup(Lookup.EMPTY);
78
        super.tearDown();
79
    }
80
    
81
    
82
    private void prepareProject () throws IOException {
83
        scratch = TestUtil.makeScratchDir(this);
84
        projdir = scratch.createFolder("proj"); //NOI18N
85
        cpRoots = new FileObject[2];
86
        cpRoots[0] = scratch.createFolder("cpRoot1"); //NOI18N
87
        cpRoots[1] = scratch.createFolder("cpRoot2"); //NOI18N
88
        helper = ProjectGenerator.createProject(projdir, "test"); //NOI18N                
89
        evaluator = helper.getStandardPropertyEvaluator();
90
        setClassPath(cpRoots);
91
    }
92
    
93
    public void testBootClassPathImplementation () throws Exception {
94
        prepareProject();
95
        ClassPathImplementation cpImpl = ProjectClassPathSupport.createPropertyBasedClassPathImplementation(helper, evaluator, PROP_NAME);
96
        ClassPath cp = ClassPathFactory.createClassPath(cpImpl);
97
        FileObject[] fo = cp.getRoots();
98
        assertEquals ("Wrong ClassPath roots",Arrays.asList(cpRoots), Arrays.asList(fo));   //NOI18N
99
        cpRoots = new FileObject[] {cpRoots[0]};
100
        setClassPath(cpRoots);
101
        fo = cp.getRoots();
102
        assertEquals ("Wrong ClassPath roots",Arrays.asList(cpRoots), Arrays.asList(fo));   //NOI18N
103
    }        
104
    
105
    
106
    
107
    private void setClassPath (FileObject[] cpRoots) {
108
        EditableProperties props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
109
        props.setProperty (PROP_NAME,toPath(cpRoots));
110
        helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props);
111
    }
112
    
113
    
114
    private static String toPath (FileObject[] cpRoots) {
115
        StringBuffer result = new StringBuffer ();
116
        for (int i=0; i<cpRoots.length; i++) {
117
            if (i>0) {
118
                result.append(':'); //NOI18N
119
            }
120
            File f = FileUtil.toFile (cpRoots[i]);
121
            result.append (f.getAbsolutePath());
122
        }
123
        return result.toString();
124
    }
125
    
126
    
127
    
128
    
129
    
130
}
(-)ide/golden/public-packages.txt (+1 lines)
Lines 230-235 Link Here
230
org.netbeans.spi.java.classpath
230
org.netbeans.spi.java.classpath
231
org.netbeans.spi.java.classpath.support
231
org.netbeans.spi.java.classpath.support
232
org.netbeans.spi.java.platform
232
org.netbeans.spi.java.platform
233
org.netbeans.spi.java.project.classpath.support
233
org.netbeans.spi.java.project.support.ui
234
org.netbeans.spi.java.project.support.ui
234
org.netbeans.spi.java.project.support.ui.templates
235
org.netbeans.spi.java.project.support.ui.templates
235
org.netbeans.spi.java.queries
236
org.netbeans.spi.java.queries

Return to bug 53056