1 package org.codehaus.mojo.webstart.dependency;
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.codehaus.mojo.webstart.dependency.task.JnlpDependencyTask;
24
25 import java.io.File;
26
27
28
29
30
31
32
33 public class JnlpDependencyRequest
34 {
35
36 private final JnlpDependencyConfig config;
37
38 private final JnlpDependencyTask[] tasks;
39
40 private final File originalFile;
41
42 private final File finalFile;
43
44 private final boolean uptodate;
45
46 public JnlpDependencyRequest( JnlpDependencyConfig config, JnlpDependencyTask... tasks )
47 {
48 this.config = config;
49 this.tasks = tasks;
50
51 originalFile = buildOriginalFile();
52 finalFile = buildFinalFile();
53
54 File incomingFile = getConfig().getArtifact().getFile();
55
56 long limitDate = incomingFile.lastModified();
57 uptodate = originalFile.exists() && originalFile.lastModified() > limitDate &&
58 finalFile.exists() && finalFile.lastModified() > limitDate;
59 }
60
61 public JnlpDependencyConfig getConfig()
62 {
63 return config;
64 }
65
66 public JnlpDependencyTask[] getTasks()
67 {
68 return tasks;
69 }
70
71 public File getOriginalFile()
72 {
73 return originalFile;
74 }
75
76 public boolean isUptodate()
77 {
78 return uptodate;
79 }
80
81 public File getFinalFile()
82 {
83 return finalFile;
84 }
85
86 private File buildOriginalFile()
87 {
88
89 File workingDirectory = config.getWorkingDirectory();
90
91 Artifact artifact = config.getArtifact();
92
93 String fileName = config.getDependencyFilenameStrategy().getDependencyFilename( artifact, false, false );
94
95 return new File( workingDirectory, fileName );
96 }
97
98 private File buildFinalFile()
99 {
100
101 File finalDirectory = config.getFinalDirectory();
102 String filename = config.getDependencyFilenameStrategy().getDependencyFilename( config.getArtifact(),
103 config.isOutputJarVersion(),
104 config.isUseUniqueVersions());
105 if ( config.isPack200() )
106 {
107 filename += ".pack";
108 }
109
110 if ( config.isGzip() )
111 {
112 filename += ".gz";
113 }
114
115 return new File( finalDirectory, filename );
116 }
117 }