Have a look at the invoker:install, looks like it is doing the same thing.

Robert

Op Thu, 07 Nov 2013 23:02:08 +0100 schreef Karl Heinz Marbaise <[email protected]>:

Hi,
i'm currently trying to solve a problem, which i don't understand:

I have the following code:

     /**
      * The project currently being build.
      */
     @Component
     private MavenProject mavenProject;

     /**
      * The current Maven session.
      */
     @Component
     private MavenSession mavenSession;

     @Component
     private ArtifactResolver artifactResolver;

     @Component
     protected ArtifactRepositoryFactory artifactRepositoryFactory;

     @Component( role = ArtifactRepositoryLayout.class )
     private Map<String, ArtifactRepositoryLayout> repositoryLayouts;

     @Component
     private ArtifactInstaller artifactInstaller;

@Parameter( property = "localRepository", required = true, readonly = true )
     protected ArtifactRepository localRepository;

     public void execute()
         throws MojoExecutionException
     {
         ArtifactRepository targetRepository =
artifactRepositoryFactory.createDeploymentArtifactRepository( "local", getFolder().toURI().toString(),
     repositoryLayouts.get( "flat" ), false /* uniqueVersion */);

ProjectDependencyGraph projectDependencyGraph = mavenSession.getProjectDependencyGraph(); List<MavenProject> sortedProjects = projectDependencyGraph.getSortedProjects();

         for ( MavenProject sortedMavenProject : sortedProjects )
         {
             getLog().info( "---> " + sortedMavenProject.getId() );
             Artifact artifact = sortedMavenProject.getArtifact();
             try
             {
artifactInstaller.install( artifact.getFile(), artifact, targetRepository );
             }
             catch ( ArtifactInstallationException e )
             {
getLog().error( "Error during installation of artifacts", e );
             }
         }
     }

The problem i have is during the following code:

artifactInstaller.install( artifact.getFile(), artifact, targetRepository );

artifact.getFile() is null, cause the artifact is comming from the reactor. In this case i need to access the artifacts based on the sortedProjects list.

So the question is: How can i use an artifact which is within the reactor and how can i install (copy) this artifact to a particular location without the aboved described problem?

Apart from that is it possible to control if maven-metadata-local.xml is installed into that repository or not?

Thanks in advance.

Kind regards
Karl-Heinz Marbaise

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to