1 | |
package org.apache.maven.plugin.assembly.mojos; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.artifact.Artifact; |
23 | |
import org.apache.maven.artifact.factory.ArtifactFactory; |
24 | |
import org.apache.maven.artifact.handler.ArtifactHandler; |
25 | |
import org.apache.maven.plugin.AbstractMojo; |
26 | |
import org.apache.maven.plugin.MojoExecutionException; |
27 | |
import org.apache.maven.plugin.MojoFailureException; |
28 | |
import org.apache.maven.project.MavenProject; |
29 | |
import org.apache.maven.project.MavenProjectHelper; |
30 | |
|
31 | |
import java.io.File; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | 0 | public class AttachComponentDescriptorMojo |
39 | |
extends AbstractMojo |
40 | |
{ |
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
private File componentDescriptor; |
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
private MavenProject project; |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
private ArtifactHandler handler; |
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
private MavenProjectHelper projectHelper; |
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
private ArtifactFactory factory; |
69 | |
|
70 | |
public void execute() |
71 | |
throws MojoExecutionException, MojoFailureException |
72 | |
{ |
73 | 0 | Artifact artifact = factory.createProjectArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion() ); |
74 | 0 | artifact.setFile( project.getFile() ); |
75 | |
|
76 | 0 | getLog().debug( "Replacing main project artifact with POM artifact: " + artifact.getId() ); |
77 | |
|
78 | 0 | project.setArtifact( artifact ); |
79 | |
|
80 | 0 | getLog().info( "Attaching assembly-component descriptor: " + componentDescriptor + " to the main project artifact under type: " + handler.getExtension() + " and classifier: " + handler.getClassifier() ); |
81 | |
|
82 | 0 | projectHelper.attachArtifact( project, handler.getExtension(), handler.getClassifier(), componentDescriptor ); |
83 | 0 | } |
84 | |
|
85 | |
} |