1 package org.apache.maven.jelly.tags.maven;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.text.SimpleDateFormat;
22 import java.util.Date;
23 import java.util.TimeZone;
24
25 import org.apache.commons.jelly.MissingAttributeException;
26 import org.apache.commons.jelly.XMLOutput;
27 import org.apache.maven.jelly.tags.BaseTagSupport;
28 import org.apache.maven.project.Project;
29
30 /** Create snapshot signature for non-release JARs and distributions.
31 *
32 * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
33 * @version $Id: SnapshotSignature.java 517014 2007-03-11 21:15:50Z ltheussl $
34 */
35 public class SnapshotSignature
36 extends BaseTagSupport
37 {
38 /** Maven project */
39 private Project project;
40
41 /**
42 * Set the maven project object.
43 *
44 * @param project MavenSession project.
45 */
46 public void setProject( Project project )
47 {
48 this.project = project;
49 }
50
51 /**
52 * Get the maven project object.
53 *
54 * @return MavenSession project.
55 */
56 public Project getProject()
57 {
58 return project;
59 }
60
61 /**
62 * Process the tag. Create a variable in the current context of the format
63 * <code>${pom.artifactId}-yyyyMMdd.HHmmss</code>
64 *
65 * @param output used to send XML output to Jelly
66 * @throws MissingAttributeException if the project property is not set
67 */
68 public void doTag( XMLOutput output )
69 throws MissingAttributeException
70 {
71 checkAttribute( project, "project" );
72
73 Date now = new Date();
74 SimpleDateFormat formatter = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
75 formatter.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
76 String snapshotVersion = formatter.format( now );
77 String snapshotSignature = getProject().getArtifactId() + "-" + snapshotVersion;
78
79 context.setVariable( "snapshotSignature", snapshotSignature );
80
81
82
83
84 context.setVariable( "snapshotVersion", snapshotVersion );
85 }
86 }