Interface ProjectManager

All Superinterfaces:
Service
All Known Implementing Classes:
DefaultProjectManager

@Experimental public interface ProjectManager extends Service
Interface to manage the project during its lifecycle.
Since:
4.0.0
  • Method Details

    • getPath

      @Nonnull Optional<Path> getPath(Project project)
      Returns the path to the built project artifact file, if the project has been built.
      Returns:
      the path of the built project artifact
    • getAttachedArtifacts

      @Nonnull Collection<ProducedArtifact> getAttachedArtifacts(Project project)
      Returns an immutable collection of attached artifacts for given project.
    • getAllArtifacts

      Collection<ProducedArtifact> getAllArtifacts(Project project)
      Returns project's all artifacts as immutable collection. The list contains all artifacts, even the attached ones, if any. Hence, the list returned by this method depends on which lifecycle step of the build was it invoked. The head of returned list is result of Project.getArtifacts() method, so same applies here: the list can have minimum of one element. The maximum number of elements is in turn dependent on build configuration and lifecycle phase when this method was invoked (i.e. is javadoc jar built and attached, is sources jar built attached, are all the artifact signed, etc.).

      This method is shorthand for Project.getArtifacts() and getAttachedArtifacts(Project) methods.

      See Also:
    • attachArtifact

      default void attachArtifact(@Nonnull Session session, @Nonnull Project project, @Nonnull Path path)
      Attaches an artifact to the project using the given file path. The artifact type will be determined from the file extension.
      Parameters:
      session - the current build session
      project - the project to attach the artifact to
      path - the path to the artifact file
      Throws:
      IllegalArgumentException - if the session, project or path is null
    • attachArtifact

      default void attachArtifact(@Nonnull Session session, @Nonnull Project project, @Nonnull String type, @Nonnull Path path)
      Attaches an artifact to the project with an explicitly specified type.
      Parameters:
      session - the current build session
      project - the project to attach the artifact to
      type - the type of the artifact (e.g., "jar", "war", "sources")
      path - the path to the artifact file
      Throws:
      IllegalArgumentException - if the session, project, type or path is null
      See Also:
    • attachArtifact

      void attachArtifact(@Nonnull Project project, @Nonnull ProducedArtifact artifact, @Nonnull Path path)
      Attaches a produced artifact to the project at the specified path. This is the base method that the other attachArtifact methods delegate to.
      Parameters:
      project - the project to attach the artifact to
      artifact - the produced artifact to attach
      path - the path to the artifact file
      Throws:
      IllegalArgumentException - if the project, artifact or path is null
    • getCompileSourceRoots

      @Nonnull List<Path> getCompileSourceRoots(@Nonnull Project project, @Nonnull ProjectScope scope)
      Obtain an immutable list of compile source roots for the given project and scope. Paths are absolute.
      Parameters:
      project - the project
      scope - the scope, i.e. usually main or test
      Returns:
      the list of compile source roots
    • addCompileSourceRoot

      void addCompileSourceRoot(@Nonnull Project project, @Nonnull ProjectScope scope, @Nonnull Path sourceRoot)
      Add a compilation source root to the given project for the given scope. The path will be transformed into an absolute path and added to the list for the given scope, if not already present.
      Parameters:
      project - the project
      scope - the scope, i.e. usually main or test
      sourceRoot - the new source root
    • getResources

      List<Resource> getResources(@Nonnull Project project, @Nonnull ProjectScope scope)
      Get the list of resources for the given project and scope
      Parameters:
      project - the project
      scope - the scope, i.e. usually main or test
      Returns:
      the list of resources
    • addResource

      void addResource(@Nonnull Project project, @Nonnull ProjectScope scope, @Nonnull Resource resource)
      Add a resource set to the given project for the given scope.
      Parameters:
      project - the project
      scope - the scope, i.e. usually main or test
      resource - the resource set to add
    • getRemoteProjectRepositories

      @Nonnull List<RemoteRepository> getRemoteProjectRepositories(@Nonnull Project project)
      Returns an immutable list of project remote repositories (directly specified or inherited).
      Parameters:
      project - the project
    • getRemotePluginRepositories

      @Nonnull List<RemoteRepository> getRemotePluginRepositories(@Nonnull Project project)
      Returns an immutable list of project remote plugin repositories (directly specified or inherited).
      Parameters:
      project - the project
    • getProperties

      @Nonnull Map<String,String> getProperties(@Nonnull Project project)
      Returns an immutable map of the project properties.
      See Also:
    • setProperty

      void setProperty(@Nonnull Project project, @Nonnull String key, @Nullable String value)
      Set a given project property.
      Parameters:
      project - the project to modify
      key - they property's key
      value - the value or null to unset the property
    • getExecutionProject

      @Nonnull Optional<Project> getExecutionProject(@Nonnull Project project)