1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.github.maven_nar;
21
22 import java.io.File;
23 import java.util.List;
24
25 import org.apache.maven.artifact.Artifact;
26 import org.apache.maven.plugin.MojoExecutionException;
27 import org.apache.maven.plugin.MojoFailureException;
28 import org.apache.maven.plugins.annotations.LifecyclePhase;
29 import org.apache.maven.plugins.annotations.Mojo;
30 import org.apache.maven.plugins.annotations.Parameter;
31 import org.apache.maven.plugins.annotations.ResolutionScope;
32 import org.apache.maven.shared.artifact.filter.collection.ScopeFilter;
33
34
35
36
37
38
39
40
41 @Mojo(name = "nar-test-unpack", defaultPhase = LifecyclePhase.GENERATE_TEST_SOURCES, requiresProject = true,
42 requiresDependencyResolution = ResolutionScope.TEST)
43 public class NarTestUnpackMojo extends AbstractDependencyMojo {
44
45
46
47
48 @Parameter
49 private List tests;
50
51
52
53
54 @Override
55 protected ScopeFilter getArtifactScopeFilter() {
56 return new ScopeFilter( Artifact.SCOPE_TEST, null );
57 }
58
59 @Override
60 protected File getUnpackDirectory() {
61 return getTestUnpackDirectory() == null ? super.getUnpackDirectory() : getTestUnpackDirectory();
62 }
63
64 @Override
65 public final void narExecute() throws MojoExecutionException, MojoFailureException {
66 final List<AttachedNarArtifact> attachedNarArtifacts = getAttachedNarArtifacts(tests);
67 unpackAttachedNars(attachedNarArtifacts);
68 }
69 }