Class SourceGroupModifier
java.lang.Object
org.netbeans.api.project.SourceGroupModifier
SourceGroupModifier
provides ways of create specific folders (SourceGroup
root folders)
in case they don't exist, eg. cannot be retrieved from Sources
The project type supporting automated creation of SourceGroup
root folders needs to
provide SourceGroupModifierImplementation
in the project's lookup.- Since:
- org.netbeans.modules.projectapi 1.24
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
A wrapper class that is capable of lazily creating aSourceGroup
instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic final SourceGroup
createAssociatedSourceGroup
(Project project, SourceGroup original, String type, String hint, String... projectParts) Creates a source group associated to an existing one.static final SourceGroup
createSourceGroup
(Project project, String type, String hint) Creates aSourceGroup
in the givenProject
of the given type and hint.static final SourceGroupModifier.Future
createSourceGroupFuture
(Project project, String type, String hint) Creates aSourceGroupModifier.Future
object that is capable of lazily creatingSourceGroup
in the givenProject
of the given type and hint.
-
Method Details
-
createSourceGroup
Creates aSourceGroup
in the givenProject
of the given type and hint. Typically a type is a constant for java/groovy/ruby source roots and hint is a constant for main sources or test sources. Please consult specific APIs fro the supported types/hints. Eg.JavaProjectConstants
for java related project sources.- Parameters:
project
-type
- constant for type of sourceshint
-- Returns:
- the created SourceGroup or null
-
createAssociatedSourceGroup
public static final SourceGroup createAssociatedSourceGroup(Project project, SourceGroup original, String type, String hint, String... projectParts) Creates a source group associated to an existing one. In a project with multiple locations for sources or tests some of those locations can be more appropriate (or completely unrelated) to already existing specific sources. This variant ofcreateSourceGroup(org.netbeans.api.project.Project, java.lang.String, java.lang.String)
allows to select appropriate locations, if the newly createdSourceGroup
should work in association with some existing one.The source group will be created on location most similar to the provided
original
group. IfprojectParts
are specified, the most matching location will be selected.This feature is prototypically used in J2SE modular projects, where multiple locations exists for tests and sources, yet they are related by their owning module. Other project types may also partition project sources into logical groups, similar to modules.
Some (java) examples:
- to create a source folder in project module, use
relativeTo(modulesGroup, "moduleName").createSourceGroup(..)
- to create a specific module root in project module, use
relativeTo(modulesGroup, "moduleName", "path-to-modules").createSourceGroup(...)
- to create a test folder for a specific source location, use
relativeTo(sourceLocation).createSourceGroup(...)
- or, if there are more test locations to choose, you can use
relativeTo(sourceLocation, "test2").createSourceGroup(...)
.
- Parameters:
project
- the projectoriginal
- the original SourceGroup, which the new one should be related to.type
- type of sourceshint
- additional type hintprojectParts
- optional; abstract location within the project.- Returns:
- the creaed SourceGroup or
null
- Since:
- 1.68
- to create a source folder in project module, use
-
createSourceGroupFuture
public static final SourceGroupModifier.Future createSourceGroupFuture(Project project, String type, String hint) Creates aSourceGroupModifier.Future
object that is capable of lazily creatingSourceGroup
in the givenProject
of the given type and hint. Typically a type is a constant for java/groovy/ruby source roots and hint is a constant for main sources or test sources. Please consult specific APIs fro the supported types/hints. Eg.JavaProjectConstants
for java related project sources.- Parameters:
project
-type
- constant for type of sourceshint
-- Returns:
- Future instance that is capable of creating a SourceGroup or null
-