2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
42
package org.netbeans.bluej.classpath;
45
import java.util.ArrayList;
46
import java.util.Collection;
47
import java.util.List;
48
import java.util.StringTokenizer;
49
import org.netbeans.api.java.classpath.ClassPath;
50
import org.netbeans.api.java.platform.JavaPlatformManager;
51
import org.netbeans.bluej.BluejProject;
52
import org.netbeans.bluej.options.BlueJSettings;
53
import org.netbeans.spi.java.classpath.ClassPathFactory;
54
import org.netbeans.spi.java.classpath.ClassPathImplementation;
55
import org.netbeans.spi.java.classpath.ClassPathProvider;
56
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
57
import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport;
58
import org.openide.filesystems.FileObject;
59
import org.openide.filesystems.FileUtil;
65
public class ClassPathProviderImpl implements ClassPathProvider {
67
private BluejProject project;
69
private ClassPath boot;
70
private ClassPath source;
71
private ClassPath compile;
72
private ClassPath[] boots;
73
private ClassPath[] sources;
74
private ClassPath[] compiles;
76
private CPImpl cpimpl;
79
/** Creates a new instance of ClassPathProviderImpl */
80
public ClassPathProviderImpl(BluejProject prj) {
84
public CPImpl getBluejCPImpl() {
88
public ClassPath findClassPath(FileObject file, String type) {
89
if (type.equals(ClassPath.COMPILE)) {
90
return getCompileTimeClasspath(file);
91
} else if (type.equals(ClassPath.EXECUTE)) {
92
return getRunTimeClasspath(file);
93
} else if (type.equals(ClassPath.SOURCE)) {
94
return getSourcepath(file);
95
} else if (type.equals(ClassPath.BOOT)) {
96
return getBootClassPath();
102
private ClassPath getBootClassPath() {
104
boot = JavaPlatformManager.getDefault().getDefaultPlatform().getBootstrapLibraries();
109
private ClassPath getSourcepath(FileObject file) { //NOPMD we don't care about the file passed in.. always the project dir is root
110
if (source == null) {
111
source = ClassPathSupport.createClassPath(new FileObject[] { project.getProjectDirectory() });
116
private ClassPath getRunTimeClasspath(FileObject file) { //NOPMD we don't care about the file passed in.. always the project dir is root
120
private ClassPath getCompileTimeClasspath(FileObject file) { //NOPMD we don't care about the file passed in.. always the project dir is root
121
if (compile == null) {
122
// do we need ant cp as it is?
123
ClassPath antcp = ClassPathFactory.createClassPath(
124
ProjectClassPathSupport.createPropertyBasedClassPathImplementation(
125
FileUtil.toFile(project.getProjectDirectory()), project.getAntProjectHelper().getStandardPropertyEvaluator(),
126
new String[] {"javac.classpath"})); // NOI18N
127
cpimpl = new CPImpl(project);
128
ClassPath bluejcp = ClassPathFactory.createClassPath(cpimpl);
129
compile = ClassPathSupport.createProxyClassPath( new ClassPath[] {antcp, bluejcp} );
134
public ClassPath[] getCompileTimeClasspath() {
135
if (compiles == null) {
136
compiles = new ClassPath[] { getCompileTimeClasspath(project.getProjectDirectory()),
137
//make source path, becuase it's equal with the built output path..
138
ClassPathSupport.createClassPath(new FileObject[] { project.getProjectDirectory() })};
143
public ClassPath[] getSourcePath() {
144
if (sources == null) {
145
sources = new ClassPath[] { getSourcepath(project.getProjectDirectory()) };
150
public ClassPath[] getBootPath() {
152
boots = new ClassPath[] { getBootClassPath() };