Class SourceGroupModifier

java.lang.Object
org.netbeans.api.project.SourceGroupModifier

public final class SourceGroupModifier extends Object
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
  • Method Details

    • createSourceGroup

      public static final SourceGroup createSourceGroup(Project project, String type, String hint)
      Creates a SourceGroup in the given Project 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 sources
      hint -
      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 of createSourceGroup(org.netbeans.api.project.Project, java.lang.String, java.lang.String) allows to select appropriate locations, if the newly created SourceGroup should work in association with some existing one.

      The source group will be created on location most similar to the provided original group. If projectParts 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 project
      original - the original SourceGroup, which the new one should be related to.
      type - type of sources
      hint - additional type hint
      projectParts - optional; abstract location within the project.
      Returns:
      the creaed SourceGroup or null
      Since:
      1.68
    • createSourceGroupFuture

      public static final SourceGroupModifier.Future createSourceGroupFuture(Project project, String type, String hint)
      Creates a SourceGroupModifier.Future object that is capable of lazily creating SourceGroup in the given Project 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 sources
      hint -
      Returns:
      Future instance that is capable of creating a SourceGroup or null