Lines 52-57
Link Here
|
52 |
import java.net.URL; |
52 |
import java.net.URL; |
53 |
import java.util.ArrayList; |
53 |
import java.util.ArrayList; |
54 |
import java.util.List; |
54 |
import java.util.List; |
|
|
55 |
import org.netbeans.api.java.classpath.ClassPath; |
55 |
import org.netbeans.api.java.project.JavaProjectConstants; |
56 |
import org.netbeans.api.java.project.JavaProjectConstants; |
56 |
import org.netbeans.api.project.Project; |
57 |
import org.netbeans.api.project.Project; |
57 |
import org.netbeans.api.project.SourceGroup; |
58 |
import org.netbeans.api.project.SourceGroup; |
Lines 69-75
Link Here
|
69 |
|
70 |
|
70 |
/** |
71 |
/** |
71 |
* An SPI for project's classpaths modification. |
72 |
* An SPI for project's classpaths modification. |
72 |
* A project can provide subclass of this class in its {@link org.netbeans.api.project.Project#getLookup lookup} to |
73 |
* A project can provide subclass of this class in its {@link Project#getLookup lookup} to |
73 |
* allow clients to add or remove new classpath elements (JAR, folder, dependent project, or library) to its |
74 |
* allow clients to add or remove new classpath elements (JAR, folder, dependent project, or library) to its |
74 |
* classpaths. |
75 |
* classpaths. |
75 |
* @since org.netbeans.modules.java.project/1 1.10 |
76 |
* @since org.netbeans.modules.java.project/1 1.10 |
Lines 103-112
Link Here
|
103 |
* Adds libraries into the project's classpath if the |
104 |
* Adds libraries into the project's classpath if the |
104 |
* libraries are not already included. |
105 |
* libraries are not already included. |
105 |
* @param libraries to be added |
106 |
* @param libraries to be added |
106 |
* @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA} |
107 |
* @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA} |
107 |
* identifying the compilation unit to change |
108 |
* identifying the compilation unit to change |
108 |
* @param type the type of the classpath the library should be added to, |
109 |
* @param type the type of the classpath the library should be added to, |
109 |
* eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE} |
110 |
* e.g. {@link ClassPath#COMPILE} |
110 |
* @return true in case the classpath was changed (at least one library was added to the classpath), |
111 |
* @return true in case the classpath was changed (at least one library was added to the classpath), |
111 |
* the value false is returned when all the libraries are already included on the classpath. |
112 |
* the value false is returned when all the libraries are already included on the classpath. |
112 |
* @exception IOException in case the project metadata cannot be changed |
113 |
* @exception IOException in case the project metadata cannot be changed |
Lines 120-129
Link Here
|
120 |
* Removes libraries from the project's classpath if the |
121 |
* Removes libraries from the project's classpath if the |
121 |
* libraries are included on it. |
122 |
* libraries are included on it. |
122 |
* @param libraries to be removed |
123 |
* @param libraries to be removed |
123 |
* @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA} |
124 |
* @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA} |
124 |
* identifying the compilation unit to change |
125 |
* identifying the compilation unit to change |
125 |
* @param type the type of the classpath the library should be removed from, |
126 |
* @param type the type of the classpath the library should be removed from, |
126 |
* eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE} |
127 |
* e.g. {@link ClassPath#COMPILE} |
127 |
* @return true in case the classpath was changed, (at least one library was removed from the classpath), |
128 |
* @return true in case the classpath was changed, (at least one library was removed from the classpath), |
128 |
* the value false is returned when none of the libraries was included on the classpath. |
129 |
* the value false is returned when none of the libraries was included on the classpath. |
129 |
* @exception IOException in case the project metadata cannot be changed |
130 |
* @exception IOException in case the project metadata cannot be changed |
Lines 136-145
Link Here
|
136 |
* Adds archive files or folders into the project's classpath if the |
137 |
* Adds archive files or folders into the project's classpath if the |
137 |
* entries are not already there. |
138 |
* entries are not already there. |
138 |
* @param classPathRoots roots to be added, each root has to be either a root of an archive or a folder |
139 |
* @param classPathRoots roots to be added, each root has to be either a root of an archive or a folder |
139 |
* @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA} |
140 |
* @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA} |
140 |
* identifying the compilation unit to change |
141 |
* identifying the compilation unit to change |
141 |
* @param type the type of the classpath the root should be added to, |
142 |
* @param type the type of the classpath the root should be added to, |
142 |
* eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE} |
143 |
* e.g. {@link ClassPath#COMPILE} |
143 |
* @return true in case the classpath was changed, (at least one classpath root was added to the classpath), |
144 |
* @return true in case the classpath was changed, (at least one classpath root was added to the classpath), |
144 |
* the value false is returned when all the classpath roots are already included on the classpath. |
145 |
* the value false is returned when all the classpath roots are already included on the classpath. |
145 |
* @exception IOException in case the project metadata cannot be changed |
146 |
* @exception IOException in case the project metadata cannot be changed |
Lines 156-165
Link Here
|
156 |
* {@link #addRoots(URL[], SourceGroup, String)}. It throws UnsupportedOperationException |
157 |
* {@link #addRoots(URL[], SourceGroup, String)}. It throws UnsupportedOperationException |
157 |
* if URIs are not absolute. |
158 |
* if URIs are not absolute. |
158 |
* @param classPathRoots roots to be added, each root has to be either a root of an archive or a folder; URI can be relative |
159 |
* @param classPathRoots roots to be added, each root has to be either a root of an archive or a folder; URI can be relative |
159 |
* @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA} |
160 |
* @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA} |
160 |
* identifying the compilation unit to change |
161 |
* identifying the compilation unit to change |
161 |
* @param type the type of the classpath the root should be added to, |
162 |
* @param type the type of the classpath the root should be added to, |
162 |
* eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE} |
163 |
* e.g. {@link ClassPath#COMPILE} |
163 |
* @return true in case the classpath was changed, (at least one classpath root was added to the classpath), |
164 |
* @return true in case the classpath was changed, (at least one classpath root was added to the classpath), |
164 |
* the value false is returned when all the classpath roots are already included on the classpath. |
165 |
* the value false is returned when all the classpath roots are already included on the classpath. |
165 |
* @exception IOException in case the project metadata cannot be changed |
166 |
* @exception IOException in case the project metadata cannot be changed |
Lines 206-215
Link Here
|
206 |
* Removes archive files or folders from the project's classpath if the |
207 |
* Removes archive files or folders from the project's classpath if the |
207 |
* entries are included on it. |
208 |
* entries are included on it. |
208 |
* @param classPathRoots roots to be removed, each root has to be either a root of an archive or a folder |
209 |
* @param classPathRoots roots to be removed, each root has to be either a root of an archive or a folder |
209 |
* @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA} |
210 |
* @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA} |
210 |
* identifying the compilation unit to change |
211 |
* identifying the compilation unit to change |
211 |
* @param type the type of the classpath the root should be removed from, |
212 |
* @param type the type of the classpath the root should be removed from, |
212 |
* eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE} |
213 |
* e.g. {@link ClassPath#COMPILE} |
213 |
* @return true in case the classpath was changed, (at least one classpath root was removed from the classpath), |
214 |
* @return true in case the classpath was changed, (at least one classpath root was removed from the classpath), |
214 |
* the value false is returned when none of the classpath roots was included on the classpath. |
215 |
* the value false is returned when none of the classpath roots was included on the classpath. |
215 |
* @exception IOException in case the project metadata cannot be changed |
216 |
* @exception IOException in case the project metadata cannot be changed |
Lines 226-235
Link Here
|
226 |
* {@link #removeRoots(URL[], SourceGroup, String)}. It throws UnsupportedOperationException |
227 |
* {@link #removeRoots(URL[], SourceGroup, String)}. It throws UnsupportedOperationException |
227 |
* if URIs are not absolute. |
228 |
* if URIs are not absolute. |
228 |
* @param classPathRoots roots to be removed, each root has to be either a root of an archive or a folder; URI can be relative |
229 |
* @param classPathRoots roots to be removed, each root has to be either a root of an archive or a folder; URI can be relative |
229 |
* @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA} |
230 |
* @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA} |
230 |
* identifying the compilation unit to change |
231 |
* identifying the compilation unit to change |
231 |
* @param type the type of the classpath the root should be removed from, |
232 |
* @param type the type of the classpath the root should be removed from, |
232 |
* eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE} |
233 |
* e.g. {@link ClassPath#COMPILE} |
233 |
* @return true in case the classpath was changed, (at least one classpath root was removed from the classpath), |
234 |
* @return true in case the classpath was changed, (at least one classpath root was removed from the classpath), |
234 |
* the value false is returned when none of the classpath roots was included on the classpath. |
235 |
* the value false is returned when none of the classpath roots was included on the classpath. |
235 |
* @exception IOException in case the project metadata cannot be changed |
236 |
* @exception IOException in case the project metadata cannot be changed |
Lines 247-256
Link Here
|
247 |
* @param artifactElements the URIs of the build output, the artifactElements has to have the same length |
248 |
* @param artifactElements the URIs of the build output, the artifactElements has to have the same length |
248 |
* as artifacts. |
249 |
* as artifacts. |
249 |
* (must be owned by the artifact and be relative to it) |
250 |
* (must be owned by the artifact and be relative to it) |
250 |
* @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA} |
251 |
* @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA} |
251 |
* identifying the compilation unit to change |
252 |
* identifying the compilation unit to change |
252 |
* @param type the type of the classpath the artifact should be added to, |
253 |
* @param type the type of the classpath the artifact should be added to, |
253 |
* eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE} |
254 |
* e.g. {@link ClassPath#COMPILE} |
254 |
* @return true in case the classpath was changed, (at least one artifact was added to the classpath), |
255 |
* @return true in case the classpath was changed, (at least one artifact was added to the classpath), |
255 |
* the value false is returned when all the artifacts are already included on the classpath. |
256 |
* the value false is returned when all the artifacts are already included on the classpath. |
256 |
* @exception IOException in case the project metadata cannot be changed |
257 |
* @exception IOException in case the project metadata cannot be changed |
Lines 266-275
Link Here
|
266 |
* @param artifactElements the URIs of the build output, the artifactElements has to have the same length |
267 |
* @param artifactElements the URIs of the build output, the artifactElements has to have the same length |
267 |
* as artifacts. |
268 |
* as artifacts. |
268 |
* (must be owned by the artifact and be relative to it) |
269 |
* (must be owned by the artifact and be relative to it) |
269 |
* @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA} |
270 |
* @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA} |
270 |
* identifying the compilation unit to change |
271 |
* identifying the compilation unit to change |
271 |
* @param type the type of the classpath the artifact should be removed from, |
272 |
* @param type the type of the classpath the artifact should be removed from, |
272 |
* eg {@link org.netbeans.api.java.classpath.ClassPath.COMPILE} |
273 |
* e.g. {@link ClassPath#COMPILE} |
273 |
* @return true in case the classpath was changed, (at least one artifact was removed from the classpath), |
274 |
* @return true in case the classpath was changed, (at least one artifact was removed from the classpath), |
274 |
* the value false is returned when none of the artifacts was included on the classpath. |
275 |
* the value false is returned when none of the artifacts was included on the classpath. |
275 |
* @exception IOException in case the project metadata cannot be changed |
276 |
* @exception IOException in case the project metadata cannot be changed |
Lines 285-294
Link Here
|
285 |
* Other project types can override the behaviour. |
286 |
* Other project types can override the behaviour. |
286 |
* @param projects to be added |
287 |
* @param projects to be added |
287 |
* (must be owned by the artifact and be relative to it) |
288 |
* (must be owned by the artifact and be relative to it) |
288 |
* @param sourceGroup of type {@link org.netbeans.api.java.project.JavaProjectConstants#SOURCES_TYPE_JAVA} |
289 |
* @param sourceGroup of type {@link JavaProjectConstants#SOURCES_TYPE_JAVA} |
289 |
* identifying the compilation unit to change |
290 |
* identifying the compilation unit to change |
290 |
* @param type the type of the classpath the artifact should be added to, |
291 |
* @param type the type of the classpath the artifact should be added to, |
291 |
* eg {@link org.netbeans.api.java.classpath.ClassPath#COMPILE} |
292 |
* e.g. {@link ClassPath#COMPILE} |
292 |
* @return true in case the classpath was changed, (at least one artifact was added to the classpath), |
293 |
* @return true in case the classpath was changed, (at least one artifact was added to the classpath), |
293 |
* the value false is returned when all the artifacts are already included on the classpath. |
294 |
* the value false is returned when all the artifacts are already included on the classpath. |
294 |
* @exception IOException in case the project metadata cannot be changed |
295 |
* @exception IOException in case the project metadata cannot be changed |
Lines 296-302
Link Here
|
296 |
* adding of an artifact to the classpath of the given type. |
297 |
* adding of an artifact to the classpath of the given type. |
297 |
* @since org.netbeans.modules.java.project/1 1.24 |
298 |
* @since org.netbeans.modules.java.project/1 1.24 |
298 |
*/ |
299 |
*/ |
299 |
protected boolean addProjects(Project[] projects, SourceGroup sg, String classPathType) throws IOException, UnsupportedOperationException { |
300 |
protected boolean addProjects(Project[] projects, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException { |
300 |
List<AntArtifact> ants = new ArrayList<AntArtifact>(); |
301 |
List<AntArtifact> ants = new ArrayList<AntArtifact>(); |
301 |
List<URI> antUris = new ArrayList<URI>(); |
302 |
List<URI> antUris = new ArrayList<URI>(); |
302 |
for (Project prj : projects) { |
303 |
for (Project prj : projects) { |
Lines 306-312
Link Here
|
306 |
antUris.add(aa.getArtifactLocations()[0]); |
307 |
antUris.add(aa.getArtifactLocations()[0]); |
307 |
} |
308 |
} |
308 |
} |
309 |
} |
309 |
return addAntArtifacts(ants.toArray(new AntArtifact[0]), antUris.toArray(new URI[0]), sg, classPathType); |
310 |
return addAntArtifacts(ants.toArray(new AntArtifact[0]), antUris.toArray(new URI[0]), sourceGroup, type); |
310 |
} |
311 |
} |
311 |
|
312 |
|
312 |
/** |
313 |
/** |