1 package org.apache.maven.starteamlib;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.io.IOException;
22
23 import java.util.Date;
24
25
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28
29
30 import org.apache.maven.changelog.AbstractChangeLogGenerator;
31
32
33 import org.apache.tools.ant.types.Commandline;
34
35
36 /**
37 * A Starteam implementation of the {@link org.apache.maven.changelog.ChangeLog}
38 * interface.
39 *
40 * @author <a href="mailto:evenisse@ifrance.com">Emmanuel Venisse</a>
41 * @version $Id: StarteamChangeLogGenerator.java 532339 2007-04-25 12:28:56Z ltheussl $
42 */
43 public class StarteamChangeLogGenerator extends AbstractChangeLogGenerator
44 {
45 /** Log */
46 private static final Log LOG =
47 LogFactory.getLog( StarteamChangeLogGenerator.class );
48
49 /**
50 * Constructs the appropriate command line to execute the starteam
51 * log command whose output is then later parsed.
52 *
53 * @return the starteam command line to be executed.
54 */
55 protected Commandline getScmLogCommand()
56 {
57 Commandline command = new Commandline();
58
59 command.setExecutable( "stcmd" );
60 command.createArgument().setValue( "hist" );
61 command.createArgument().setValue( "-x" );
62 command.createArgument().setValue( "-nologo" );
63 command.createArgument().setValue( "-is" );
64 command.createArgument().setValue( "-p" );
65
66 String repo = changeLogExecutor.getRepositoryConnection();
67
68 if ( "starteam".equals( repo.substring( 4, 12 ) ) )
69 {
70 repo = repo.substring( 13 );
71 command.createArgument().setValue( repo );
72 }
73
74 return command;
75 }
76
77 /**
78 * Construct the Starteam command-line argument that is used to specify
79 * the appropriate date range. This date option doesn't supported with
80 * Starteam
81 *
82 * @param before The starting point.
83 * @param to The ending point.
84 * @return An empty string
85 */
86 protected String getScmDateArgument( Date before, Date to )
87 {
88 return "";
89 }
90
91 /**
92 * @see AbstractChangeLogGenerator#getScmTagArgument(String, String)
93 */
94 protected String getScmTagArgument( String tagStart, String tagEnd )
95 {
96 throw new UnsupportedOperationException(
97 "This plugin currently does not support generating logs from tags with Starteam." );
98 }
99
100 /**
101 * Handle ChangeLogParser IOExceptions.
102 *
103 * @param ioe The IOException thrown.
104 * @throws IOException If the handler doesn't wish to handle the
105 * exception.
106 */
107 protected void handleParserException( IOException ioe )
108 throws IOException
109 {
110 if ( ( ioe.getMessage().indexOf( "CreateProcess" ) != -1 )
111 || ( ioe.getMessage().indexOf( "Starteam: not found" ) != -1 ) )
112 {
113
114 LOG.error(
115 "Unable to find Starteam executable. Changelog will be empty("
116 + ioe + ")" );
117 }
118 else
119 {
120 throw ioe;
121 }
122 }
123 }