PR: MPCHANGELOG-80

Submitted by: Christoph Jerolimov
Add MKS SI support


git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@370578 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
ltheussl
2006-01-19 19:29:01 +00:00
parent 98c84de9a1
commit e424286e61
12 changed files with 576 additions and 7 deletions

View File

@@ -84,6 +84,9 @@
<contributor>
<name>David Jackman</name>
</contributor>
<contributor>
<name>Christoph Jerolimov</name>
</contributor>
</contributors>
<developers>
<developer>

View File

@@ -72,6 +72,7 @@ public class ChangeLog
FACTORIES.put( "starteam",
"org.apache.maven.starteamlib.StarteamChangeLogFactory" );
FACTORIES.put( "vss", "org.apache.maven.vsslib.VssChangeLogFactory" );
FACTORIES.put( "mks", "org.apache.maven.mkslib.MksChangeLogFactory" );
}
/** Used to specify whether to build the log from a range, absolute date, or tag. */

View File

@@ -0,0 +1,52 @@
package org.apache.maven.mkslib;
/* ====================================================================
* Copyright 2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
import org.apache.maven.changelog.ChangeLogFactory;
import org.apache.maven.changelog.ChangeLogGenerator;
import org.apache.maven.changelog.ChangeLogParser;
/**
* Provides mks ChangeLogGenerator and ChangeLogParser.
*
* @author <a href="mailto:c.jerolimov@tarent.de">Christoph Jerolimov</a>
* @version $Id$
*/
public class MksChangeLogFactory implements ChangeLogFactory
{
/**
* Create a MKS specific ChangeLogGenerator.
*
* @return a MKS specific ChangeLogGenerator.
*/
public ChangeLogGenerator createGenerator()
{
return new MksChangeLogGenerator();
}
/**
* Create a MKS specific ChangeLogParser.
*
* @return a MKS specific ChangeLogParser.
*/
public ChangeLogParser createParser()
{
return new MksChangeLogParser();
}
}

View File

@@ -0,0 +1,79 @@
package org.apache.maven.mkslib;
/* ====================================================================
* Copyright 2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
import java.util.Date;
import org.apache.maven.changelog.AbstractChangeLogGenerator;
import org.apache.maven.util.RepositoryUtils;
import org.apache.tools.ant.types.Commandline;
/**
* A log-generator for the mks commandline tool.
*
* It supports an input file with <code>
*
* @author <a href="mailto:c.jerolimov@tarent.de">Christoph Jerolimov</a>
* @version $Id$
*/
public class MksChangeLogGenerator extends AbstractChangeLogGenerator
{
/**
* @return the mks command line to be executed.
*/
protected Commandline getScmLogCommand()
{
String[] tokens =
RepositoryUtils.splitSCMConnection( getConnection() );
Commandline commandline = new Commandline();
commandline.setExecutable( tokens[2] );
for ( int i = 3; i < tokens.length; i++ )
{
commandline.createArgument().setValue( tokens[i] );
}
return commandline;
}
/**
* Construct the MKS command-line argument that is used to specify the
* appropriate date range. Currently always returns null.
*
* @param before The starting point.
* @param to The ending point.
* @return A string that can be used to specify a date to a scm system.
*/
protected String getScmDateArgument( Date before, Date to )
{
return null;
}
/**
* Currently always returns null.
* @see AbstractChangeLogGenerator#getScmTagArgument(String, String)
*/
protected String getScmTagArgument( String tagStart, String tagEnd )
{
return null;
}
}

View File

@@ -0,0 +1,286 @@
package org.apache.maven.mkslib;
/* ====================================================================
* Copyright 2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Map;
import java.util.TreeMap;
import org.apache.maven.changelog.ChangeLog;
import org.apache.maven.changelog.ChangeLogEntry;
import org.apache.maven.changelog.ChangeLogFile;
import org.apache.maven.changelog.ChangeLogParser;
/**
* This class parse mks log output.
*
* @author <a href="mailto:c.jerolimov@tarent.de">Christoph Jerolimov</a>
* @version $Id$
*/
public class MksChangeLogParser implements ChangeLogParser
{
/**
* This date/time formatter will be uses to parse a mks date.
*/
private static final SimpleDateFormat MKS_TIMESTAMP_FORMAT =
new SimpleDateFormat( "MMM d, yyyy - h:mm a" );
/**
* Custom date/time formatter. Rounds ChangeLogEntry times to the nearest
* minute.
*/
private static final SimpleDateFormat ENTRY_KEY_TIMESTAMP_FORMAT =
new SimpleDateFormat( "yyyyMMddHHmm" );
/** expecting file name */
private static final int GET_FILE_NAME = 1;
/** expecting file revision */
private static final int GET_FILE_REVISION = 2;
/** expecting entry revision */
private static final int WAITFOR_ENTRY_REVISION = 3;
/** expecting file revision */
private static final int GET_ENTRY_INFO = 4;
/** expecting file revision */
private static final int GET_ENTRY_COMMENT = 5;
/** rcs entries, in reverse (date, time, author, comment) order */
private Map entries = new TreeMap( Collections.reverseOrder() );
/** current status of the parser */
private int status = GET_FILE_NAME;
/** current changelog entry */
private ChangeLogEntry changeLogEntry;
/** current changelog file */
private ChangeLogFile changeLogFile;
public void init( ChangeLog changeLog )
{
}
public void cleanup()
{
}
public void setDateFormatInFile( String dateFormat )
{
}
public Collection parse( InputStream in )
throws IOException
{
try
{
BufferedReader reader =
new BufferedReader( new InputStreamReader( in ) );
String line;
while ( ( line = reader.readLine() ) != null )
{
if ( line.startsWith(
"========================================" ) )
{
status = GET_FILE_NAME;
}
switch ( status )
{
case GET_FILE_NAME :
addEntry();
processGetFileName( line );
break;
case GET_FILE_REVISION :
processGetFileRevision( line );
break;
case WAITFOR_ENTRY_REVISION :
processWaitForEntryRevision( line );
break;
case GET_ENTRY_INFO :
processGetEntryInfo( line );
break;
case GET_ENTRY_COMMENT :
processGetEntryComment( line );
break;
default :
// wait for next entry
break;
}
}
addEntry();
}
catch ( RuntimeException e )
{
e.printStackTrace();
throw e;
}
catch ( IOException e )
{
e.printStackTrace();
throw e;
}
return entries.values();
}
protected void processGetFileName( String line )
{
if ( line.startsWith( "member name: " ) )
{
String filename;
if ( line.indexOf( ";" ) == -1 )
{
filename = line.substring( 13 );
}
else
{
filename = line.substring( 13, line.indexOf( ";" ) );
}
changeLogFile = new ChangeLogFile( filename );
status = GET_FILE_REVISION;
}
}
protected void processGetFileRevision( String line )
{
if ( line.startsWith( "member:\t" ) )
{
changeLogFile.setRevision( line.substring( 8 ) );
status = WAITFOR_ENTRY_REVISION;
}
}
protected void processWaitForEntryRevision( String line )
{
if ( line.equals( "-----------------------" ) )
{
status = GET_ENTRY_INFO;
}
}
protected void processGetEntryInfo( String line )
{
if ( line.startsWith( "date: " ) )
{
changeLogEntry = new ChangeLogEntry();
int posAuthor = line.indexOf( "; author: " );
if ( posAuthor == -1 )
{
return;
}
int posState = line.indexOf( "; state: " );
if ( posState == -1 )
{
return;
}
try
{
Date date =
MKS_TIMESTAMP_FORMAT.parse( line.substring( 6, posAuthor ) );
String author = line.substring( posAuthor + 10, posState );
changeLogEntry.setDate( date );
changeLogEntry.setAuthor( author );
status = GET_ENTRY_COMMENT;
}
catch ( ParseException e )
{
throw new IllegalArgumentException(
"I don't understand this date: "
+ line.substring( 6, posAuthor ) );
}
}
}
protected void processGetEntryComment( String line )
{
if ( line.equals( "-----------------------" ) )
{
addEntry();
status = GET_ENTRY_INFO;
return;
}
changeLogEntry.setComment( changeLogEntry.getComment() + line + "\n" );
}
protected void addEntry()
{
if ( ( changeLogEntry == null ) || ( changeLogFile == null ) )
{
return;
}
// do not add if entry is not populated
if ( ( changeLogEntry.getAuthor() == null )
|| ( changeLogEntry.getDate() == null ) )
{
return;
}
String key =
ENTRY_KEY_TIMESTAMP_FORMAT.format( changeLogEntry.getDate() )
+ changeLogEntry.getAuthor() + changeLogEntry.getComment();
if ( !entries.containsKey( key ) )
{
changeLogEntry.addFile( changeLogFile );
entries.put( key, changeLogEntry );
}
else
{
( (ChangeLogEntry) entries.get( key ) ).addFile( changeLogFile );
}
}
}

View File

@@ -0,0 +1,56 @@
member name: myproject/myfile; working file: /myproject/myfile
head: 1.1
member: 1.1
branch:
locks: ; strict
attributes:
file format: text
revision storage: reverse deltas
total revisions: 1; branches: 0; branch revisions: 0
description:
Initial Version
-----------------------
revision 1.1
date: Jan 16, 2006 - 16:02 PM; author: AUTHOR; state: InWork; lines: +0 -0
Initial revision
===============================================================================
member name: myproject/myfile2; working file: /myproject/myfile2
head: 1.1
member: 1.1
branch:
locks: ; strict
attributes:
file format: text
revision storage: reverse deltas
total revisions: 1; branches: 0; branch revisions: 0
description:
Initial Version
-----------------------
revision 1.1
date: Jan 16, 2006 - 16:02 PM; author: AUTHOR; state: InWork; lines: +0 -0
Initial revision
===============================================================================
member name: myproject/myfile3; working file: /myproject/myfile3
head: 1.3
member: 1.3
branch:
locks: ; strict
attributes:
file format: text
revision storage: reverse deltas
total revisions: 1; branches: 0; branch revisions: 0
description:
Initial Version
-----------------------
revision 1.3
date: Jan 16, 2006 - 16:14 PM; author: AUTHOR; state: InWork; lines: +0 -2
Revision 1.3
-----------------------
revision 1.2
date: Jan 16, 2006 - 16:11 PM; author: AUTHOR; state: InWork; lines: +2 -0
Revision 1.2
-----------------------
revision 1.1
date: Jan 16, 2006 - 16:02 PM; author: AUTHOR; state: InWork; lines: +0 -0
Initial revision
===============================================================================

View File

@@ -31,8 +31,6 @@ import junit.framework.TestCase;
public class CvsConnectionTest extends TestCase
{
/** the {@link CvsConnection} used for testing */
private CvsConnection instance;
/** test data */
private String testData = ":pserver:user@server:/home/cvs";
private String[] testTrueData = {

View File

@@ -0,0 +1,91 @@
package org.apache.maven.mkslib;
/* ====================================================================
* Copyright 2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
import junit.framework.TestCase;
import org.apache.maven.changelog.ChangeLogEntry;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
/**
* This class test the mks parser with an inputstream.
*
* @author dion (writes CvsChangeLogParserTest)
* @author <a href="mailto:c.jerolimov@tarent.de">Christoph Jerolimov</a>
* @version $Id$
*/
public class MksChangeLogParserTest extends TestCase
{
/** the {@link MksChangeLogParser} used for testing */
private MksChangeLogParser instance;
/** file with test results to check against */
private String testFile;
/**
* Create a test with the given name
* @param testName the name of the test
*/
public MksChangeLogParserTest( String testName )
{
super( testName );
}
/**
* Initialize per test data
* @throws Exception when there is an unexpected problem
*/
public void setUp() throws Exception
{
String baseDir = System.getProperty( "basedir" );
assertNotNull( "The system property basedir was not defined.", baseDir );
testFile = baseDir + "/src/test-resources/mkslib/mkslog.txt";
instance = new MksChangeLogParser();
}
/**
* Test the mks parser.
* @throws IOException when there is an unexpected problem
*/
public void testParser()
throws IOException
{
FileInputStream fis = new FileInputStream( testFile );
Collection entries = instance.parse( fis );
assertEquals( "Wrong number of entries returned", 3, entries.size() );
ChangeLogEntry entry = null;
for ( Iterator i = entries.iterator(); i.hasNext(); )
{
entry = (ChangeLogEntry) i.next();
assertEquals( "Wrong author parsed", "AUTHOR", entry.getAuthor() );
System.out.println( entry );
assertTrue( "ChangeLogEntry erroneously picked up",
entry.toString().indexOf( "ChangeLogEntry.java" ) == -1 );
}
}
}

View File

@@ -55,7 +55,7 @@ public class RepositoryTest
String con = "scm:cvs:local:/cvs/root";
try
{
String[] tokens = RepositoryUtils.splitSCMConnection(con);
RepositoryUtils.splitSCMConnection(con);
fail("Should throw an exception splitting " + con);
}
catch ( IllegalArgumentException expected )
@@ -69,7 +69,7 @@ public class RepositoryTest
String con = "scm:cvs:pserver:user@host:/cvs/root";
try
{
String[] tokens = RepositoryUtils.splitSCMConnection(con);
RepositoryUtils.splitSCMConnection(con);
fail("Should throw an exception splitting " + con);
}
catch ( IllegalArgumentException expected )
@@ -83,7 +83,7 @@ public class RepositoryTest
String con = "scm:cvs:local:foo:/cvs/root:module";
try
{
String[] tokens = RepositoryUtils.splitSCMConnection(con);
RepositoryUtils.splitSCMConnection(con);
fail("Should throw an exception splitting " + con);
}
catch ( IllegalArgumentException expected )

View File

@@ -25,6 +25,7 @@
</properties>
<body>
<release version="1.9-SNAPSHOT" date="in SVN">
<action dev="ltheussl" type="add" issue="MPCHANGELOG-80" due-to="Christoph Jerolimov">Add MKS SI support.</action>
<action dev="ltheussl" type="fix" issue="MPCHANGELOG-69">Changelog returns 0 entries on Windows with CVS (not CVSNT). New property <code>maven.changelog.quoteDate</code>.</action>
<action dev="ltheussl" type="fix" issue="MPCHANGELOG-74">Changelog plugin creates wrong links for Subversion repositories. New property <code>maven.changelog.svn.baseurl</code>.</action>
<action dev="aheritier" type="update" issue="MAVEN-1712">Update dependencies to match ones in maven 1.1 core and to unify them between plugins. The following dependencies are updated :

View File

@@ -30,9 +30,9 @@
<p>
This plugin produces a nicely formatted changelog report so
project team members can see at a glance what changes have
been made recently to the project. Currently, there are five
been made recently to the project. Currently, there are six
supported source control systems: CVS, Perforce, StarTeam, IBM
Rational ClearCase, Visual Source Safe and Subversion.
Rational ClearCase, Visual Source Safe, Subversion and MKS SI.
</p>
<p>
For more information on the functionality provided by this plugin,

View File

@@ -117,6 +117,8 @@
href="apidocs/org/apache/maven/starteamlib/StarteamChangeLogFactory.html">org.apache.maven.starteamlib.StarteamChangeLogFactory</a></li>
<li>Visual Source Safe: <a
href="apidocs/org/apache/maven/vsslib/VssChangeLogFactory.html">org.apache.maven.vsslib.VssChangeLogFactory</a></li>
<li>MKS Source Integrity: <a
href="apidocs/org/apache/maven/mkslib/MksChangeLogFactory.html">org.apache.maven.mkslib.MksChangeLogFactory</a></li>
</ul>
</td>
</tr>