1 | |
package org.apache.maven.plugin.dependency.utils.markers; |
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.plugin.dependency.fromConfiguration.ArtifactItem; |
23 | |
import org.codehaus.plexus.util.StringUtils; |
24 | |
|
25 | |
import java.io.File; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
public class UnpackFileMarkerHandler |
32 | |
extends DefaultFileMarkerHandler |
33 | |
{ |
34 | |
protected ArtifactItem artifactItem; |
35 | |
|
36 | |
public UnpackFileMarkerHandler( File markerFilesDirectory ) |
37 | |
{ |
38 | 101 | super( markerFilesDirectory ); |
39 | 101 | } |
40 | |
|
41 | |
public UnpackFileMarkerHandler( ArtifactItem artifactItem, File markerFilesDirectory ) |
42 | |
{ |
43 | 101 | this( markerFilesDirectory ); |
44 | 101 | setArtifactItem( artifactItem ); |
45 | 101 | } |
46 | |
|
47 | |
protected File getMarkerFile() |
48 | |
{ |
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | 141 | File markerFile = null; |
56 | 141 | if ( this.artifactItem == null || ( StringUtils.isEmpty( this.artifactItem.getIncludes() ) |
57 | |
&& StringUtils.isEmpty( this.artifactItem.getExcludes() ) ) ) |
58 | |
{ |
59 | 96 | markerFile = super.getMarkerFile(); |
60 | |
} |
61 | |
else |
62 | |
{ |
63 | 45 | int includeExcludeHash = 0; |
64 | |
|
65 | 45 | if ( StringUtils.isNotEmpty( this.artifactItem.getIncludes() ) ) |
66 | |
{ |
67 | 33 | includeExcludeHash += this.artifactItem.getIncludes().hashCode(); |
68 | |
} |
69 | |
|
70 | 45 | if ( StringUtils.isNotEmpty( this.artifactItem.getExcludes() ) ) |
71 | |
{ |
72 | 19 | includeExcludeHash += this.artifactItem.getExcludes().hashCode(); |
73 | |
} |
74 | |
|
75 | 45 | markerFile = |
76 | |
new File( this.markerFilesDirectory, this.artifact.getId().replace( ':', '-' ) + includeExcludeHash ); |
77 | |
} |
78 | |
|
79 | 141 | return markerFile; |
80 | |
} |
81 | |
|
82 | |
public void setArtifactItem( ArtifactItem artifactItem ) |
83 | |
{ |
84 | 103 | this.artifactItem = artifactItem; |
85 | |
|
86 | 103 | if ( this.artifactItem != null ) |
87 | |
{ |
88 | 101 | setArtifact( this.artifactItem.getArtifact() ); |
89 | |
} |
90 | 103 | } |
91 | |
|
92 | |
public ArtifactItem getArtifactItem() |
93 | |
{ |
94 | 2 | return this.artifactItem; |
95 | |
} |
96 | |
} |