Index: xdocs/index.xml =================================================================== --- xdocs/index.xml (Revision 368355) +++ xdocs/index.xml (Arbeitskopie) @@ -30,9 +30,9 @@

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.

For more information on the functionality provided by this plugin, Index: xdocs/properties.xml =================================================================== --- xdocs/properties.xml (Revision 370212) +++ xdocs/properties.xml (Arbeitskopie) @@ -117,6 +117,8 @@ href="apidocs/org/apache/maven/starteamlib/StarteamChangeLogFactory.html">org.apache.maven.starteamlib.StarteamChangeLogFactory

  • Visual Source Safe: org.apache.maven.vsslib.VssChangeLogFactory
  • +
  • MKS Source Integrity: org.apache.maven.mkslib.MksChangeLogFactory
  • Index: project.xml =================================================================== --- project.xml (Revision 368355) +++ project.xml (Arbeitskopie) @@ -22,7 +22,7 @@ 3 maven-changelog-plugin Maven Changelog Plugin - 1.9-SNAPSHOT + 1.9-with-mks The Changelog plugin generates reports about recent changes to the SCM repository. Produce SCM changelog reports. http://maven.apache.org/maven-1.x/reference/plugins/changelog/ Index: src/test/org/apache/maven/mkslib/MksChangeLogParserTest.java =================================================================== --- src/test/org/apache/maven/mkslib/MksChangeLogParserTest.java (Revision 0) +++ src/test/org/apache/maven/mkslib/MksChangeLogParserTest.java (Revision 0) @@ -0,0 +1,66 @@ +package org.apache.maven.mkslib; + +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Collection; +import java.util.Iterator; + +import org.apache.maven.changelog.ChangeLogEntry; + +import junit.framework.TestCase; + +/** + * This class test the mks parser with an inputstream. + * + * @author dion (writes CvsChangeLogParserTest) + * @author Christoph Jerolimov + * @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. + */ + 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); + } + } +} Index: src/test/org/apache/maven/cvslib/CvsConnectionTest.java =================================================================== --- src/test/org/apache/maven/cvslib/CvsConnectionTest.java (Revision 368355) +++ src/test/org/apache/maven/cvslib/CvsConnectionTest.java (Arbeitskopie) @@ -31,8 +31,6 @@ 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 = { Index: src/test/org/apache/maven/util/RepositoryTest.java =================================================================== --- src/test/org/apache/maven/util/RepositoryTest.java (Revision 368355) +++ src/test/org/apache/maven/util/RepositoryTest.java (Arbeitskopie) @@ -55,7 +55,7 @@ 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 @@ 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 @@ 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 ) Index: src/main/org/apache/maven/mkslib/MksChangeLogParser.java =================================================================== --- src/main/org/apache/maven/mkslib/MksChangeLogParser.java (Revision 0) +++ src/main/org/apache/maven/mkslib/MksChangeLogParser.java (Revision 0) @@ -0,0 +1,246 @@ +package org.apache.maven.mkslib; + +/* ==================================================================== + * Copyright 2005 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 Christoph Jerolimov + * @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); + } + } +} Index: src/main/org/apache/maven/mkslib/MksChangeLogGenerator.java =================================================================== --- src/main/org/apache/maven/mkslib/MksChangeLogGenerator.java (Revision 0) +++ src/main/org/apache/maven/mkslib/MksChangeLogGenerator.java (Revision 0) @@ -0,0 +1,59 @@ +package org.apache.maven.mkslib; + +/* ==================================================================== + * Copyright 2005 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 + * + * @author Christoph Jerolimov + * @version $Id: $ + */ +public class MksChangeLogGenerator extends AbstractChangeLogGenerator +{ + 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; + } + + protected String getScmDateArgument(Date before, Date to) + { + return null; + } + + protected String getScmTagArgument(String tagStart, String tagEnd) + { + return null; + } +} Index: src/main/org/apache/maven/mkslib/MksChangeLogFactory.java =================================================================== --- src/main/org/apache/maven/mkslib/MksChangeLogFactory.java (Revision 0) +++ src/main/org/apache/maven/mkslib/MksChangeLogFactory.java (Revision 0) @@ -0,0 +1,41 @@ +package org.apache.maven.mkslib; + +/* ==================================================================== + * Copyright 2005 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 Christoph Jerolimov + * @version $Id: $ + */ +public class MksChangeLogFactory implements ChangeLogFactory +{ + public ChangeLogGenerator createGenerator() + { + return new MksChangeLogGenerator(); + } + + public ChangeLogParser createParser() + { + return new MksChangeLogParser(); + } +} Index: src/main/org/apache/maven/changelog/ChangeLog.java =================================================================== --- src/main/org/apache/maven/changelog/ChangeLog.java (Revision 370221) +++ src/main/org/apache/maven/changelog/ChangeLog.java (Arbeitskopie) @@ -72,6 +72,7 @@ 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. */ Index: src/test-resources/mkslib/mkslog.txt =================================================================== --- src/test-resources/mkslib/mkslog.txt (Revision 0) +++ src/test-resources/mkslib/mkslog.txt (Revision 0) @@ -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 +===============================================================================