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