public abstract class ProjectClassPathModifierImplementation extends Object
lookup
to
allow clients to add or remove new classpath elements (JAR, folder, dependent project, or library) to its
classpaths.Modifier | Constructor and Description |
---|---|
protected |
ProjectClassPathModifierImplementation() |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
addAntArtifacts(AntArtifact[] artifacts,
URI[] artifactElements,
SourceGroup sourceGroup,
String type)
Adds artifacts (e.g.
|
protected abstract boolean |
addLibraries(Library[] libraries,
SourceGroup sourceGroup,
String type)
Adds libraries into the project's classpath if the
libraries are not already included.
|
protected boolean |
addProjects(Project[] projects,
SourceGroup sourceGroup,
String type)
Adds projects as dependencies into project's classpath if the
artifacts are not already on it.
|
protected boolean |
addRoots(URI[] classPathRoots,
SourceGroup sourceGroup,
String type)
Adds archive files or folders into the project's classpath if the
entries are not already there.
|
protected abstract boolean |
addRoots(URL[] classPathRoots,
SourceGroup sourceGroup,
String type)
Adds archive files or folders into the project's classpath if the
entries are not already there.
|
protected static URI[] |
convertURLsToURIs(URL[] entry)
Converts array of URLs to array of URIs.
|
protected abstract String[] |
getExtensibleClassPathTypes(SourceGroup sourceGroup)
Returns the types of classpaths for given
SourceGroup which may be modified. |
protected abstract SourceGroup[] |
getExtensibleSourceGroups()
Returns the
SourceGroup s providing classpath(s)
which may be modified. |
protected String |
performSharabilityHeuristics(URI classpathRoot,
AntProjectHelper helper)
Takes a classpath root and tries to figure the best way to reference that file for that particular project.
|
protected abstract boolean |
removeAntArtifacts(AntArtifact[] artifacts,
URI[] artifactElements,
SourceGroup sourceGroup,
String type)
Removes artifacts (e.g.
|
protected abstract boolean |
removeLibraries(Library[] libraries,
SourceGroup sourceGroup,
String type)
Removes libraries from the project's classpath if the
libraries are included on it.
|
protected boolean |
removeRoots(URI[] classPathRoots,
SourceGroup sourceGroup,
String type)
Removes archive files or folders from the project's classpath if the
entries are included on it.
|
protected abstract boolean |
removeRoots(URL[] classPathRoots,
SourceGroup sourceGroup,
String type)
Removes archive files or folders from the project's classpath if the
entries are included on it.
|
protected ProjectClassPathModifierImplementation()
protected abstract SourceGroup[] getExtensibleSourceGroups()
SourceGroup
s providing classpath(s)
which may be modified.SourceGroup
, never returns nullprotected abstract String[] getExtensibleClassPathTypes(SourceGroup sourceGroup)
SourceGroup
which may be modified.sourceGroup
- for which the classpath types should be returnedprotected abstract boolean addLibraries(Library[] libraries, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException
libraries
- to be addedsourceGroup
- of type JavaProjectConstants.SOURCES_TYPE_JAVA
identifying the compilation unit to changetype
- the type of the classpath the library should be added to,
e.g. ClassPath.COMPILE
IOException
- in case the project metadata cannot be changedUnsupportedOperationException
- is thrown when the project does not support
adding of a library to the classpath of the given type.protected abstract boolean removeLibraries(Library[] libraries, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException
libraries
- to be removedsourceGroup
- of type JavaProjectConstants.SOURCES_TYPE_JAVA
identifying the compilation unit to changetype
- the type of the classpath the library should be removed from,
e.g. ClassPath.COMPILE
IOException
- in case the project metadata cannot be changedUnsupportedOperationException
- is thrown when the project does not support
removing of a library from the classpath of the given type.protected abstract boolean addRoots(URL[] classPathRoots, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException
classPathRoots
- roots to be added, each root has to be either a root of an archive or a foldersourceGroup
- of type JavaProjectConstants.SOURCES_TYPE_JAVA
identifying the compilation unit to changetype
- the type of the classpath the root should be added to,
e.g. ClassPath.COMPILE
IOException
- in case the project metadata cannot be changedUnsupportedOperationException
- is thrown when the project does not support
adding of a root to the classpath of the given type.protected boolean addRoots(URI[] classPathRoots, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException
This method is not abstract only for backward compatibility and therefore should be always
overrriden. Default implementation converts given URIs to URLs and calls
ProjectClassPathModifierImplementation.addRoots(URL[], SourceGroup, String)
. It throws UnsupportedOperationException
if URIs are not absolute.
classPathRoots
- roots to be added, each root has to be either a root of an archive or a folder; URI can be relativesourceGroup
- of type JavaProjectConstants.SOURCES_TYPE_JAVA
identifying the compilation unit to changetype
- the type of the classpath the root should be added to,
e.g. ClassPath.COMPILE
IOException
- in case the project metadata cannot be changedUnsupportedOperationException
- is thrown when the project does not support
adding of a root to the classpath of the given type.protected static URI[] convertURLsToURIs(URL[] entry)
entry
- list of URLs to convertprotected abstract boolean removeRoots(URL[] classPathRoots, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException
classPathRoots
- roots to be removed, each root has to be either a root of an archive or a foldersourceGroup
- of type JavaProjectConstants.SOURCES_TYPE_JAVA
identifying the compilation unit to changetype
- the type of the classpath the root should be removed from,
e.g. ClassPath.COMPILE
IOException
- in case the project metadata cannot be changedUnsupportedOperationException
- is thrown when the project does not support
removing of a root from the classpath of the given type.protected boolean removeRoots(URI[] classPathRoots, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException
This method is not abstract only for backward compatibility and therefore should be always
overrriden. Default implementation converts given URIs to URLs and calls
ProjectClassPathModifierImplementation.removeRoots(URL[], SourceGroup, String)
. It throws UnsupportedOperationException
if URIs are not absolute.
classPathRoots
- roots to be removed, each root has to be either a root of an archive or a folder; URI can be relativesourceGroup
- of type JavaProjectConstants.SOURCES_TYPE_JAVA
identifying the compilation unit to changetype
- the type of the classpath the root should be removed from,
e.g. ClassPath.COMPILE
IOException
- in case the project metadata cannot be changedUnsupportedOperationException
- is thrown when the project does not support
removing of a root from the classpath of the given type.protected abstract boolean addAntArtifacts(AntArtifact[] artifacts, URI[] artifactElements, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException
artifacts
- to be addedartifactElements
- the URIs of the build output, the artifactElements has to have the same length
as artifacts.
(must be owned by the artifact and be relative to it)sourceGroup
- of type JavaProjectConstants.SOURCES_TYPE_JAVA
identifying the compilation unit to changetype
- the type of the classpath the artifact should be added to,
e.g. ClassPath.COMPILE
IOException
- in case the project metadata cannot be changedUnsupportedOperationException
- is thrown when the project does not support
adding of an artifact to the classpath of the given type.protected abstract boolean removeAntArtifacts(AntArtifact[] artifacts, URI[] artifactElements, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException
artifacts
- to be addedartifactElements
- the URIs of the build output, the artifactElements has to have the same length
as artifacts.
(must be owned by the artifact and be relative to it)sourceGroup
- of type JavaProjectConstants.SOURCES_TYPE_JAVA
identifying the compilation unit to changetype
- the type of the classpath the artifact should be removed from,
e.g. ClassPath.COMPILE
IOException
- in case the project metadata cannot be changedUnsupportedOperationException
- is thrown when the project does not support
removing of an artifact from the classpath of the given type.protected boolean addProjects(Project[] projects, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException
ProjectClassPathModifierImplementation.addAntArtifacts(org.netbeans.api.project.ant.AntArtifact[], java.net.URI[], org.netbeans.api.project.SourceGroup, java.lang.String)
Other project types can override the behaviour.projects
- to be added
(must be owned by the artifact and be relative to it)sourceGroup
- of type JavaProjectConstants.SOURCES_TYPE_JAVA
identifying the compilation unit to changetype
- the type of the classpath the artifact should be added to,
e.g. ClassPath.COMPILE
IOException
- in case the project metadata cannot be changedUnsupportedOperationException
- is thrown when the project does not support
adding of an artifact to the classpath of the given type.protected final String performSharabilityHeuristics(URI classpathRoot, AntProjectHelper helper) throws URISyntaxException, IOException
classpathRoot
- passed in through the addRoots()
and removeRoots()
methodshelper
- URISyntaxException
IOException