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

(-)a/java.api.common/apichanges.xml (+16 lines)
Lines 105-110 Link Here
105
105
106
    <!-- ACTUAL CHANGES BEGIN HERE: -->
106
    <!-- ACTUAL CHANGES BEGIN HERE: -->
107
    <changes>
107
    <changes>
108
        <change id="BootClassPathImplementation-platform-type">
109
            <api name="java-api-common"/>
110
            <summary>Extended <code>BootClassPathImplementation</code> and <code>ClassPathProviderImpl</code> to support non j2se platforms</summary>
111
            <version major="1" minor="59"/>
112
            <date day="9" month="10" year="2013"/>
113
            <author login="tzezula"/>
114
            <compatibility addition="yes"/>
115
            <description>
116
                <p>
117
                    Extended <code>BootClassPathImplementation</code> and <code>ClassPathProviderImpl</code> to support non j2se platforms.
118
                </p>
119
            </description>
120
            <class package="org.netbeans.modules.java.api.common.classpath" name="ClassPathProviderImpl"/>
121
            <class package="org.netbeans.modules.java.api.common.classpath" name="ClassPathSupportFactory"/>
122
            <class package="org.netbeans.modules.java.api.common.util" name="CommonProjectUtils"/>
123
        </change>
108
        <change id="BaseActionProvider.Callback3">
124
        <change id="BaseActionProvider.Callback3">
109
            <api name="java-api-common"/>
125
            <api name="java-api-common"/>
110
            <summary>Added <code>BaseActionProvider.Callback3</code> with a method providing additional build properties.</summary>
126
            <summary>Added <code>BaseActionProvider.Callback3</code> with a method providing additional build properties.</summary>
(-)a/java.api.common/manifest.mf (-1 / +1 lines)
Lines 1-4 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.java.api.common/0
2
OpenIDE-Module: org.netbeans.modules.java.api.common/0
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/api/common/resources/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/api/common/resources/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.58
4
OpenIDE-Module-Specification-Version: 1.59
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/classpath/BootClassPathImplementation.java (-1 / +8 lines)
Lines 54-59 Link Here
54
import java.util.List;
54
import java.util.List;
55
import java.util.ArrayList;
55
import java.util.ArrayList;
56
import java.util.Collections;
56
import java.util.Collections;
57
import org.netbeans.api.annotations.common.NonNull;
58
import org.netbeans.api.annotations.common.NullAllowed;
57
import org.netbeans.api.java.classpath.ClassPath;
59
import org.netbeans.api.java.classpath.ClassPath;
58
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
60
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
59
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
61
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
Lines 70-75 Link Here
70
    private static final String PLATFORM_ACTIVE = "platform.active"; // NOI18N
72
    private static final String PLATFORM_ACTIVE = "platform.active"; // NOI18N
71
73
72
    private final PropertyEvaluator evaluator;
74
    private final PropertyEvaluator evaluator;
75
    private final String platformType;
73
    private JavaPlatformManager platformManager;
76
    private JavaPlatformManager platformManager;
74
    // name of project active platform
77
    // name of project active platform
75
    private String activePlatformName;
78
    private String activePlatformName;
Lines 80-89 Link Here
80
    private PropertyChangeSupport support = new PropertyChangeSupport(this);
83
    private PropertyChangeSupport support = new PropertyChangeSupport(this);
81
    private ClassPath endorsedClassPath;
84
    private ClassPath endorsedClassPath;
82
85
83
    BootClassPathImplementation(PropertyEvaluator evaluator, ClassPath endorsedClassPath) {
86
    BootClassPathImplementation(
87
            @NonNull final PropertyEvaluator evaluator,
88
            @NullAllowed final ClassPath endorsedClassPath,
89
            @NullAllowed final String platformType) {
84
        assert evaluator != null;
90
        assert evaluator != null;
85
        this.endorsedClassPath = endorsedClassPath;
91
        this.endorsedClassPath = endorsedClassPath;
86
        this.evaluator = evaluator;
92
        this.evaluator = evaluator;
93
        this.platformType = platformType;
87
        evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this, evaluator));
94
        evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this, evaluator));
88
        if (endorsedClassPath != null) {
95
        if (endorsedClassPath != null) {
89
            endorsedClassPath.addPropertyChangeListener(this);
96
            endorsedClassPath.addPropertyChangeListener(this);
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ClassPathProviderImpl.java (-30 / +291 lines)
Lines 43-57 Link Here
43
 */
43
 */
44
package org.netbeans.modules.java.api.common.classpath;
44
package org.netbeans.modules.java.api.common.classpath;
45
45
46
import java.beans.PropertyChangeEvent;
47
import java.beans.PropertyChangeListener;
46
import java.beans.PropertyChangeListener;
48
import java.io.File;
47
import java.io.File;
48
import java.util.Arrays;
49
import java.util.Map;
49
import java.util.Map;
50
import java.util.HashMap;
50
import java.util.HashMap;
51
import org.netbeans.api.annotations.common.CheckForNull;
51
import org.netbeans.api.annotations.common.CheckForNull;
52
import org.netbeans.api.annotations.common.NonNull;
52
import org.netbeans.api.annotations.common.NonNull;
53
import org.netbeans.api.java.classpath.ClassPath;
53
import org.netbeans.api.java.classpath.ClassPath;
54
import org.netbeans.api.java.classpath.JavaClassPathConstants;
54
import org.netbeans.api.java.classpath.JavaClassPathConstants;
55
import org.netbeans.api.java.platform.JavaPlatform;
55
import org.netbeans.api.project.ProjectManager;
56
import org.netbeans.api.project.ProjectManager;
56
import org.netbeans.api.project.SourceGroup;
57
import org.netbeans.api.project.SourceGroup;
57
import org.netbeans.modules.java.api.common.SourceRoots;
58
import org.netbeans.modules.java.api.common.SourceRoots;
Lines 64-70 Link Here
64
import org.openide.filesystems.FileObject;
65
import org.openide.filesystems.FileObject;
65
import org.openide.filesystems.FileUtil;
66
import org.openide.filesystems.FileUtil;
66
import org.openide.util.Mutex;
67
import org.openide.util.Mutex;
67
import org.openide.util.WeakListeners;
68
import org.openide.util.Parameters;
68
69
69
/**
70
/**
70
 * Defines the various class paths for a J2SE project.
71
 * Defines the various class paths for a J2SE project.
Lines 72-94 Link Here
72
 */
73
 */
73
public final class ClassPathProviderImpl implements ClassPathProvider {
74
public final class ClassPathProviderImpl implements ClassPathProvider {
74
75
75
    private String buildClassesDir = "build.classes.dir"; // NOI18N
76
    private static final String buildGeneratedDir = "build.generated.sources.dir"; // NOI18N
76
    private static final String buildGeneratedDir = "build.generated.sources.dir"; // NOI18N
77
    private String distJar = "dist.jar"; // NOI18N
77
    private static final String[] processorTestClasspath = new String[]{"javac.test.processorpath"};  //NOI18N
78
    private String buildTestClassesDir = "build.test.classes.dir"; // NOI18N
79
    private String[] javacClasspath = new String[]{"javac.classpath"};    //NOI18N
80
    private String[] processorClasspath = new String[]{ProjectProperties.JAVAC_PROCESSORPATH};    //NOI18N
81
    private String[] javacTestClasspath = new String[]{"javac.test.classpath"};  //NOI18N
82
    private String[] processorTestClasspath = new String[]{"javac.test.processorpath"};  //NOI18N
83
    private String[] runClasspath = new String[]{"run.classpath"};    //NOI18N
84
    private String[] runTestClasspath = new String[]{"run.test.classpath"};  //NOI18N
85
    private String[] endorsedClasspath = new String[]{ProjectProperties.ENDORSED_CLASSPATH};  //NOI18N
86
78
87
    private final AntProjectHelper helper;
79
    private final AntProjectHelper helper;
88
    private final File projectDirectory;
80
    private final File projectDirectory;
89
    private final PropertyEvaluator evaluator;
81
    private final PropertyEvaluator evaluator;
90
    private final SourceRoots sourceRoots;
82
    private final SourceRoots sourceRoots;
91
    private final SourceRoots testSourceRoots;
83
    private final SourceRoots testSourceRoots;
84
    private final String buildClassesDir;
85
    private final String distJar;
86
    private final String buildTestClassesDir;
87
    private final String[] javacClasspath;
88
    private final String[] processorClasspath;
89
    private final String[] javacTestClasspath;
90
    private final String[] runClasspath;
91
    private final String[] runTestClasspath;
92
    private final String[] endorsedClasspath;
93
    private final String platformType;
92
    /**
94
    /**
93
     * ClassPaths cache
95
     * ClassPaths cache
94
     * Index -> CP mapping
96
     * Index -> CP mapping
Lines 112-129 Link Here
112
114
113
    public ClassPathProviderImpl(AntProjectHelper helper, PropertyEvaluator evaluator, SourceRoots sourceRoots,
115
    public ClassPathProviderImpl(AntProjectHelper helper, PropertyEvaluator evaluator, SourceRoots sourceRoots,
114
                                 SourceRoots testSourceRoots) {
116
                                 SourceRoots testSourceRoots) {
115
        this.helper = helper;
117
        this(
116
        this.projectDirectory = FileUtil.toFile(helper.getProjectDirectory());
118
            helper,
117
        assert this.projectDirectory != null;
119
            evaluator,
118
        this.evaluator = evaluator;
120
            sourceRoots,
119
        this.sourceRoots = sourceRoots;
121
            testSourceRoots,
120
        this.testSourceRoots = testSourceRoots;
122
            Builder.DEFAULT_BUILD_CLASSES_DIR,
121
        listener = new PropertyChangeListener() {
123
            Builder.DEFAULT_DIST_JAR,
122
                public synchronized void propertyChange(PropertyChangeEvent evt) {
124
            Builder.DEFAULT_BUILD_TEST_CLASSES_DIR,
123
                    dirCache.remove(evt.getPropertyName());
125
            Builder.DEFAULT_JAVAC_CLASS_PATH,
124
                }
126
            Builder.DEFAULT_JAVAC_TEST_CLASS_PATH,
125
            };
127
            Builder.DEFAULT_RUN_CLASS_PATH,
126
        evaluator.addPropertyChangeListener(WeakListeners.propertyChange(listener, evaluator));
128
            Builder.DEFAULT_RUN_TEST_CLASS_PATH);
127
    }
129
    }
128
130
129
    public ClassPathProviderImpl(AntProjectHelper helper, PropertyEvaluator evaluator,
131
    public ClassPathProviderImpl(AntProjectHelper helper, PropertyEvaluator evaluator,
Lines 131-137 Link Here
131
            String buildClassesDir, String distJar, String buildTestClassesDir,
133
            String buildClassesDir, String distJar, String buildTestClassesDir,
132
            String[] javacClasspath, String[] javacTestClasspath, String[] runClasspath,
134
            String[] javacClasspath, String[] javacTestClasspath, String[] runClasspath,
133
            String[] runTestClasspath) {
135
            String[] runTestClasspath) {
134
        this(helper,
136
        this(
137
            helper,
135
            evaluator,
138
            evaluator,
136
            sourceRoots,
139
            sourceRoots,
137
            testSourceRoots,
140
            testSourceRoots,
Lines 142-148 Link Here
142
            javacTestClasspath,
145
            javacTestClasspath,
143
            runClasspath,
146
            runClasspath,
144
            runTestClasspath,
147
            runTestClasspath,
145
            new String[]{ProjectProperties.ENDORSED_CLASSPATH});
148
            Builder.DEFAULT_ENDORSED_CLASSPATH);
146
    }
149
    }
147
    /**
150
    /**
148
     * Constructor allowing customization of endorsedClasspath property names.
151
     * Constructor allowing customization of endorsedClasspath property names.
Lines 153-159 Link Here
153
            String buildClassesDir, String distJar, String buildTestClassesDir,
156
            String buildClassesDir, String distJar, String buildTestClassesDir,
154
            String[] javacClasspath, String[] javacTestClasspath, String[] runClasspath,
157
            String[] javacClasspath, String[] javacTestClasspath, String[] runClasspath,
155
            String[] runTestClasspath, String[] endorsedClasspath) {
158
            String[] runTestClasspath, String[] endorsedClasspath) {
156
        this(helper,
159
        this(
160
            helper,
157
            evaluator,
161
            evaluator,
158
            sourceRoots,
162
            sourceRoots,
159
            testSourceRoots,
163
            testSourceRoots,
Lines 161-171 Link Here
161
            distJar,
165
            distJar,
162
            buildTestClassesDir,
166
            buildTestClassesDir,
163
            javacClasspath,
167
            javacClasspath,
164
            javacClasspath,
168
            Builder.DEFAULT_PROCESSOR_PATH,
165
            javacTestClasspath,
169
            javacTestClasspath,
166
            runClasspath,
170
            runClasspath,
167
            runTestClasspath,
171
            runTestClasspath,
168
            new String[]{ProjectProperties.ENDORSED_CLASSPATH});
172
            endorsedClasspath);
169
    }
173
    }
170
174
171
    /**
175
    /**
Lines 177-183 Link Here
177
            String buildClassesDir, String distJar, String buildTestClassesDir,
181
            String buildClassesDir, String distJar, String buildTestClassesDir,
178
            String[] javacClasspath, String[] processorPath, String[] javacTestClasspath, String[] runClasspath,
182
            String[] javacClasspath, String[] processorPath, String[] javacTestClasspath, String[] runClasspath,
179
            String[] runTestClasspath, String[] endorsedClasspath) {
183
            String[] runTestClasspath, String[] endorsedClasspath) {
180
        this(helper, evaluator, sourceRoots, testSourceRoots);
184
        this(
185
            helper,
186
            evaluator,
187
            sourceRoots,
188
            testSourceRoots,
189
            buildClassesDir,
190
            distJar,
191
            buildTestClassesDir,
192
            javacClasspath,
193
            processorPath,
194
            javacTestClasspath,
195
            runClasspath,
196
            runTestClasspath,
197
            endorsedClasspath,
198
            Builder.DEFAULT_PLATFORM_TYPE
199
            );
200
    }
201
202
    private ClassPathProviderImpl(
203
        @NonNull final AntProjectHelper helper,
204
        @NonNull final PropertyEvaluator evaluator,
205
        @NonNull final SourceRoots sourceRoots,
206
        @NonNull final SourceRoots testSourceRoots,
207
        @NonNull final String buildClassesDir,
208
        @NonNull final String distJar,
209
        @NonNull final String buildTestClassesDir,
210
        @NonNull final String[] javacClasspath,
211
        @NonNull final String[] processorPath,
212
        @NonNull final String[] javacTestClasspath,
213
        @NonNull final String[] runClasspath,
214
        @NonNull final String[] runTestClasspath,
215
        @NonNull final String[] endorsedClasspath,
216
        @NonNull final String platformType) {
217
        Parameters.notNull("helper", helper);   //NOI18N
218
        Parameters.notNull("evaluator", evaluator); //NOI18N
219
        Parameters.notNull("sourceRoots", sourceRoots); //NOI18N
220
        Parameters.notNull("testSourceRoots", testSourceRoots); //NOI18N
221
        Parameters.notNull("buildClassesDir", buildClassesDir); //NOI18N
222
        Parameters.notNull("distJar", distJar); //NOI18N
223
        Parameters.notNull("buildTestClassesDir", buildTestClassesDir); //NOI18N
224
        Parameters.notNull("javacClasspath", javacClasspath);   //NOI18N
225
        Parameters.notNull("processorPath", processorPath); //NOI18N
226
        Parameters.notNull("javacTestClasspath", javacTestClasspath);   //NOI18N
227
        Parameters.notNull("runClasspath", runClasspath);   //NOI18N
228
        Parameters.notNull("runTestClasspath", runTestClasspath);   //NOI18N
229
        Parameters.notNull("endorsedClasspath", endorsedClasspath); //NOI18N
230
        Parameters.notNull("platformType", platformType);   //NOI18N
231
        this.helper = helper;
232
        this.projectDirectory = FileUtil.toFile(helper.getProjectDirectory());
233
        assert this.projectDirectory != null;
234
        this.evaluator = evaluator;
235
        this.sourceRoots = sourceRoots;
236
        this.testSourceRoots = testSourceRoots;
181
        this.buildClassesDir = buildClassesDir;
237
        this.buildClassesDir = buildClassesDir;
182
        this.distJar = distJar;
238
        this.distJar = distJar;
183
        this.buildTestClassesDir = buildTestClassesDir;
239
        this.buildTestClassesDir = buildTestClassesDir;
Lines 187-192 Link Here
187
        this.runClasspath = runClasspath;
243
        this.runClasspath = runClasspath;
188
        this.runTestClasspath = runTestClasspath;
244
        this.runTestClasspath = runTestClasspath;
189
        this.endorsedClasspath = endorsedClasspath;
245
        this.endorsedClasspath = endorsedClasspath;
246
        this.platformType = platformType;
247
248
    }
249
250
    /**
251
     * Builder to create ClassPathProviderImpl.
252
     * @since 1.59
253
     */
254
    public static final class Builder {
255
256
        private static final String DEFAULT_PLATFORM_TYPE = "j2se";   //NOI18N
257
        private static final String DEFAULT_BUILD_CLASSES_DIR = "build.classes.dir";   //NOI18N
258
        private static final String DEFAULT_BUILD_TEST_CLASSES_DIR = "build.test.classes.dir"; // NOI18N
259
        private static final String DEFAULT_DIST_JAR = "dist.jar"; // NOI18N
260
        private static final String[] DEFAULT_JAVAC_CLASS_PATH = new String[]{"javac.classpath"};    //NOI18N
261
        private static final String[] DEFAULT_PROCESSOR_PATH = new String[]{ProjectProperties.JAVAC_PROCESSORPATH};    //NOI18N
262
        private static final String[] DEFAULT_JAVAC_TEST_CLASS_PATH = new String[]{"javac.test.classpath"};  //NOI18N
263
        private static final String[] DEFAULT_RUN_CLASS_PATH = new String[]{"run.classpath"};    //NOI18N
264
        private static final String[] DEFAULT_RUN_TEST_CLASS_PATH = new String[]{"run.test.classpath"};  //NOI18N
265
        private static final String[] DEFAULT_ENDORSED_CLASSPATH = new String[]{ProjectProperties.ENDORSED_CLASSPATH};  //NOI18N
266
267
        private final AntProjectHelper helper;
268
        private final PropertyEvaluator evaluator;
269
        private final SourceRoots sourceRoots;
270
        private final SourceRoots testSourceRoots;
271
272
        private String platformType = DEFAULT_PLATFORM_TYPE;
273
        private String buildClassesDir = DEFAULT_BUILD_CLASSES_DIR;
274
        private String buildTestClassesDir = DEFAULT_BUILD_TEST_CLASSES_DIR;
275
        private String distJar = DEFAULT_DIST_JAR;
276
        private String[] javacClasspath = DEFAULT_JAVAC_CLASS_PATH;
277
        private String[] processorPath = DEFAULT_PROCESSOR_PATH;
278
        private String[] javacTestClasspath = DEFAULT_JAVAC_TEST_CLASS_PATH;
279
        private String[] runClasspath = DEFAULT_RUN_CLASS_PATH;
280
        private String[] runTestClasspath = DEFAULT_RUN_TEST_CLASS_PATH;
281
        private String[] endorsedClasspath = DEFAULT_ENDORSED_CLASSPATH;
282
283
        private Builder(
284
            @NonNull final AntProjectHelper helper,
285
            @NonNull final PropertyEvaluator evaluator,
286
            @NonNull final SourceRoots sourceRoots,
287
            @NonNull final SourceRoots testSourceRoots) {
288
            Parameters.notNull("helper", helper);   //NOI18N
289
            Parameters.notNull("evaluator", evaluator); //NOI18N
290
            Parameters.notNull("sourceRoots", sourceRoots); //NOI18N
291
            Parameters.notNull("testSourceRoots", testSourceRoots); //NOI18N
292
            this.helper = helper;
293
            this.evaluator = evaluator;
294
            this.sourceRoots = sourceRoots;
295
            this.testSourceRoots = testSourceRoots;
296
        }
297
298
        /**
299
         * Sets a {@link JavaPlatform} type for boot classpath lookup.
300
         * @param platformType the type of {@link JavaPlatform}, by default "j2se"
301
         * @return {@link Builder}
302
         */
303
        @NonNull
304
        public Builder setPlatformType(@NonNull final String platformType) {
305
            Parameters.notNull("platformType", platformType);   //NOI18N
306
            this.platformType = platformType;
307
            return this;
308
        }
309
310
        /**
311
         * Sets a property name containing build classes directory.
312
         * @param buildClassesDirProperty the name of property containing the build classes directory, by default "build.classes.dir"
313
         * @return {@link Builder}
314
         */
315
        @NonNull
316
        public Builder setBuildClassesDirProperty(@NonNull final String buildClassesDirProperty) {
317
            Parameters.notNull("buildClassesDirProperty", buildClassesDirProperty); //NOI18N
318
            this.buildClassesDir = buildClassesDirProperty;
319
            return this;
320
        }
321
322
        /**
323
         * Sets a property name containing build test classes directory.
324
         * @param buildTestClassesDirProperty the name of property containing the build test classes directory, by default "build.test.classes.dir"
325
         * @return {@link Builder}
326
         */
327
        @NonNull
328
        public Builder setBuildTestClassesDirProperty(@NonNull final String buildTestClassesDirProperty) {
329
            Parameters.notNull("buildTestClassesDirProperty", buildTestClassesDirProperty); //NOI18N
330
            this.buildTestClassesDir = buildTestClassesDirProperty;
331
            return this;
332
        }
333
334
        /**
335
         * Sets a property name containing the distribution jar.
336
         * @param distJarProperty the name of property containing the distribution jar reference, by default "dist.jar"
337
         * @return {@link Builder}
338
         */
339
        @NonNull
340
        public Builder setDistJarProperty(@NonNull final String distJarProperty) {
341
            Parameters.notNull("distJarProperty", distJarProperty); //NOI18N
342
            this.distJar = distJarProperty;
343
            return this;
344
        }
345
346
        /**
347
         * Sets javac classpath properties for source roots.
348
         * @param javacClassPathProperties the names of properties containing the compiler classpath for sources, by default "javac.classpath"
349
         * @return {@link Builder}
350
         */
351
        @NonNull
352
        public Builder setJavacClassPathProperties(@NonNull final String[] javacClassPathProperties) {
353
            Parameters.notNull("javacClassPathProperties", javacClassPathProperties);   //NOI18N
354
            this.javacClasspath = Arrays.copyOf(javacClassPathProperties, javacClassPathProperties.length);
355
            return this;
356
        }
357
358
        /**
359
         * Sets javac processor path properties for source roots.
360
         * @param processorPathProperties the names of properties containing the compiler processor path for sources, by default "javac.processorpath"
361
         * @return {@link Builder}
362
         */
363
        @NonNull
364
        public Builder setProcessorPathProperties(@NonNull final String[] processorPathProperties) {
365
            Parameters.notNull("processorPathProperties", processorPathProperties);
366
            this.processorPath = Arrays.copyOf(processorPathProperties, processorPathProperties.length);
367
            return this;
368
        }
369
370
        /**
371
         * Sets javac classpath properties for test roots.
372
         * @param javacTestClasspathProperties  the names of properties containing the compiler classpath for tests, by default "javac.test.classpath"
373
         * @return {@link Builder}
374
         */
375
        @NonNull
376
        public Builder setJavacTestClasspathProperties(@NonNull final String[] javacTestClasspathProperties) {
377
            Parameters.notNull("javacTestClasspathProperties", javacTestClasspathProperties);   //NOI18N
378
            this.javacTestClasspath = Arrays.copyOf(javacTestClasspathProperties, javacTestClasspathProperties.length);
379
            return this;
380
        }
381
382
        /**
383
         * Sets runtime classpath properties for source roots.
384
         * @param runClasspathProperties the names of properties containing the runtime classpath for sources, by default "run.classpath"
385
         * @return {@link Builder}
386
         */
387
        @NonNull
388
        public Builder setRunClasspathProperties(@NonNull final String[] runClasspathProperties) {
389
            Parameters.notNull("runClasspathProperties", runClasspathProperties);   //NOI18N
390
            this.runClasspath = Arrays.copyOf(runClasspathProperties, runClasspathProperties.length);
391
            return this;
392
        }
393
394
        /**
395
         * Sets runtime classpath properties for test roots.
396
         * @param runTestClasspathProperties  the names of properties containing the runtime classpath for tests, by default "run.test.classpath"
397
         * @return {@link Builder}
398
         */
399
        @NonNull
400
        public Builder setRunTestClasspathProperties(@NonNull final String[] runTestClasspathProperties) {
401
            Parameters.notNull("runTestClasspathProperties", runTestClasspathProperties);   //NOI18N
402
            this.runTestClasspath = Arrays.copyOf(runTestClasspathProperties, runTestClasspathProperties.length);
403
            return this;
404
        }
405
406
        /**
407
         * Sets endorsed classpath properties.
408
         * @param endorsedClasspathProperties the names of properties containing the endorsed classpath, by default "endorsed.classpath"
409
         * @return {@link Builder}
410
         */
411
        @NonNull
412
        public Builder setEndorsedClasspathProperties(@NonNull final String[] endorsedClasspathProperties) {
413
            Parameters.notNull("endorsedClasspathProperties", endorsedClasspathProperties); //NOI18N
414
            this.endorsedClasspath = Arrays.copyOf(endorsedClasspathProperties, endorsedClasspathProperties.length);
415
            return this;
416
        }
417
418
419
        /**
420
         * Creates a configured {@link ClassPathProviderImpl}.
421
         * @return the {@link ClassPathProviderImpl}
422
         */
423
        @NonNull
424
        public ClassPathProviderImpl build() {
425
            return new ClassPathProviderImpl (
426
                helper,
427
                evaluator,
428
                sourceRoots,
429
                testSourceRoots,
430
                buildClassesDir,
431
                distJar,
432
                buildTestClassesDir,
433
                javacClasspath,
434
                processorPath,
435
                javacTestClasspath,
436
                runClasspath,
437
                runTestClasspath,
438
                endorsedClasspath,
439
                platformType);
440
        }
441
442
        @NonNull
443
        public static Builder create(
444
            @NonNull final AntProjectHelper helper,
445
            @NonNull final PropertyEvaluator evaluator,
446
            @NonNull final SourceRoots sourceRoots,
447
            @NonNull final SourceRoots testSourceRoots) {
448
            return new Builder(helper, evaluator, sourceRoots, testSourceRoots);
449
        }
450
190
    }
451
    }
191
452
192
    
453
    
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ClassPathSupportFactory.java (-2 / +21 lines)
Lines 42-48 Link Here
42
42
43
package org.netbeans.modules.java.api.common.classpath;
43
package org.netbeans.modules.java.api.common.classpath;
44
44
45
import org.netbeans.api.annotations.common.NonNull;
46
import org.netbeans.api.annotations.common.NullAllowed;
45
import org.netbeans.api.java.classpath.ClassPath;
47
import org.netbeans.api.java.classpath.ClassPath;
48
import org.netbeans.api.java.platform.JavaPlatform;
46
import org.netbeans.modules.java.api.common.SourceRoots;
49
import org.netbeans.modules.java.api.common.SourceRoots;
47
import org.netbeans.spi.java.classpath.ClassPathImplementation;
50
import org.netbeans.spi.java.classpath.ClassPathImplementation;
48
import org.netbeans.spi.project.support.ant.AntProjectHelper;
51
import org.netbeans.spi.project.support.ant.AntProjectHelper;
Lines 64-70 Link Here
64
     * @return classpath implementation
67
     * @return classpath implementation
65
     */
68
     */
66
    public static ClassPathImplementation createBootClassPathImplementation(PropertyEvaluator evaluator) {
69
    public static ClassPathImplementation createBootClassPathImplementation(PropertyEvaluator evaluator) {
67
        return new BootClassPathImplementation(evaluator, null);
70
        return createBootClassPathImplementation(evaluator, null, null);
68
    }
71
    }
69
72
70
    /**
73
    /**
Lines 76-82 Link Here
76
     * @since org.netbeans.modules.java.api.common/0 1.11
79
     * @since org.netbeans.modules.java.api.common/0 1.11
77
     */
80
     */
78
    public static ClassPathImplementation createBootClassPathImplementation(PropertyEvaluator evaluator, ClassPath endorsedClassPath) {
81
    public static ClassPathImplementation createBootClassPathImplementation(PropertyEvaluator evaluator, ClassPath endorsedClassPath) {
79
        return new BootClassPathImplementation(evaluator, endorsedClassPath);
82
        return createBootClassPathImplementation(evaluator, endorsedClassPath, null);
83
    }
84
85
    /**
86
     * Creates implementation of BOOT classpath based on project's <code>platform.active</code>
87
     * property and given endorsed classpath which will have precedence of platform classpath.
88
     * @param evaluator project's property evaluator
89
     * @param endorsedClassPath endorsed classpath to prepend to boot classpath
90
     * @param platformType the type of {@link JavaPlatform}
91
     * @return classpath implementation
92
     * @since 1.59
93
     */
94
    public static ClassPathImplementation createBootClassPathImplementation(
95
            @NonNull final PropertyEvaluator evaluator,
96
            @NullAllowed final ClassPath endorsedClassPath,
97
            @NullAllowed final String platformType) {
98
        return new BootClassPathImplementation(evaluator, endorsedClassPath, platformType);
80
    }
99
    }
81
100
82
    /**
101
    /**
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/util/CommonProjectUtils.java (-3 / +28 lines)
Lines 49-55 Link Here
49
import java.util.HashMap;
49
import java.util.HashMap;
50
import java.util.Map;
50
import java.util.Map;
51
import javax.lang.model.element.TypeElement;
51
import javax.lang.model.element.TypeElement;
52
import org.netbeans.api.annotations.common.CheckForNull;
52
import org.netbeans.api.annotations.common.NonNull;
53
import org.netbeans.api.annotations.common.NonNull;
54
import org.netbeans.api.annotations.common.NullAllowed;
53
import org.netbeans.api.java.classpath.ClassPath;
55
import org.netbeans.api.java.classpath.ClassPath;
54
import org.netbeans.api.java.platform.JavaPlatform;
56
import org.netbeans.api.java.platform.JavaPlatform;
55
import org.netbeans.api.java.platform.JavaPlatformManager;
57
import org.netbeans.api.java.platform.JavaPlatformManager;
Lines 81-93 Link Here
81
     * @return active {@link JavaPlatform} or null if the project's platform
83
     * @return active {@link JavaPlatform} or null if the project's platform
82
     * is broken
84
     * is broken
83
     */
85
     */
86
    @CheckForNull
84
    public static JavaPlatform getActivePlatform(final String activePlatformId) {
87
    public static JavaPlatform getActivePlatform(final String activePlatformId) {
88
        return getActivePlatform(activePlatformId, null);
89
    }
90
91
    /**
92
     * Returns the active platform used by the project or null if the active
93
     * project platform is broken.
94
     * @param activePlatformId the name of platform used by Ant script or null
95
     * for default platform.
96
     * @param platformType the type of {@link JavaPlatform}
97
     * @return active {@link JavaPlatform} or null if the project's platform
98
     * is broken
99
     * @since 1.59
100
     */
101
    @CheckForNull
102
    public static JavaPlatform getActivePlatform(
103
        @NullAllowed final String activePlatformId,
104
        @NullAllowed String platformType) {
105
        if (platformType == null) {
106
            platformType = "j2se";  //NOI18N
107
        }
85
        final JavaPlatformManager pm = JavaPlatformManager.getDefault();
108
        final JavaPlatformManager pm = JavaPlatformManager.getDefault();
86
        if (activePlatformId == null) {
109
        if (activePlatformId == null) {
87
            return pm.getDefaultPlatform();
110
            final JavaPlatform candidate = pm.getDefaultPlatform();
111
            return candidate == null || !platformType.equals(candidate.getSpecification().getName()) ?
112
                null :
113
                candidate;
88
        }
114
        }
89
115
        JavaPlatform[] installedPlatforms = pm.getPlatforms(null, new Specification(platformType, null)); //NOI18N
90
        JavaPlatform[] installedPlatforms = pm.getPlatforms(null, new Specification("j2se", null)); //NOI18N
91
        for (JavaPlatform javaPlatform : installedPlatforms) {
116
        for (JavaPlatform javaPlatform : installedPlatforms) {
92
            String antName = javaPlatform.getProperties().get("platform.ant.name"); //NOI18N
117
            String antName = javaPlatform.getProperties().get("platform.ant.name"); //NOI18N
93
            if (antName != null && antName.equals(activePlatformId)) {
118
            if (antName != null && antName.equals(activePlatformId)) {

Return to bug 236921