Class DefaultProjectInstaller

java.lang.Object
org.apache.maven.shared.transfer.project.install.internal.DefaultProjectInstaller
All Implemented Interfaces:
ProjectInstaller

@Component(role=ProjectInstaller.class) class DefaultProjectInstaller extends Object implements ProjectInstaller
This will install a whole project into the appropriate repository.
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • installer

      @Requirement private ArtifactInstaller installer
    • repositoryManager

      @Requirement private RepositoryManager repositoryManager
  • Constructor Details

    • DefaultProjectInstaller

      DefaultProjectInstaller()
  • Method Details

    • install

      public void install(org.apache.maven.project.ProjectBuildingRequest buildingRequest, ProjectInstallerRequest installerRequest) throws IOException, ArtifactInstallerException, NoFileAssignedException, IllegalArgumentException
      This will install a single project which may contain several artifacts. Those artifacts will be installed into the appropriate repository.
        @Parameter( defaultValue = "${session}", required = true, readonly = true )
        private MavenSession session;
        @Parameter( defaultValue = "${project}", required = true, readonly = true )
        private MavenProject project;
        ..
        @Component
        private ProjectInstaller installer;
        ...
        public void execute()
        {
          ProjectInstallerRequest pir =
            new ProjectInstallerRequest()
               .setProject( mavenProject );
       
          installer.install( session.getProjectBuildingRequest(), pir );
        }
       
      To set a different local repository than the current one in the Maven session, you can inject an instance of the RepositoryManager and set the path to the local repository, called localRepositoryPath, as such:
       @Component
       private RepositoryManager repositoryManager;
       
       buildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, localRepositoryPath );
       
      Specified by:
      install in interface ProjectInstaller
      Parameters:
      buildingRequest - ProjectBuildingRequest
      installerRequest - ProjectInstallerRequest
      Throws:
      IOException - In case of problems related to checksums.
      ArtifactInstallerException - In case of problems to install artifacts.
      NoFileAssignedException - If no file has been assigned to the project.
      IllegalArgumentException - in case of parameter projectBuildingRequest is null or parameter projectInstallerRequest is null.
    • validateParameters

      private void validateParameters(org.apache.maven.project.ProjectBuildingRequest buildingRequest, ProjectInstallerRequest installerRequest)
    • addMetaDataFilesForArtifact

      private void addMetaDataFilesForArtifact(org.apache.maven.project.ProjectBuildingRequest buildingRequest, org.apache.maven.artifact.Artifact artifact, Collection<File> targetMetadataFiles)
    • getLocalRepoFile

      private File getLocalRepoFile(org.apache.maven.project.ProjectBuildingRequest buildingRequest, org.apache.maven.artifact.metadata.ArtifactMetadata metadata)
      Gets the path of the specified artifact metadata within the local repository. Note that the returned path need not exist (yet).
      Parameters:
      buildingRequest - The project building request, must not be null.
      metadata - The artifact metadata whose local repo path should be determined, must not be null.
      Returns:
      The absolute path to the artifact metadata when installed, never null.