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