PR: MPCHANGELOG-86
Support time period in MKS changelog parser. git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@397602 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -83,6 +83,11 @@
|
||||
</contributor>
|
||||
<contributor>
|
||||
<name>Christoph Jerolimov</name>
|
||||
<email>c.jerolimov@tarent.de</email>
|
||||
<organization>tarent GmbH, Germany</organization>
|
||||
<roles>
|
||||
<role>Java Developer</role>
|
||||
</roles>
|
||||
</contributor>
|
||||
</contributors>
|
||||
<developers>
|
||||
|
||||
@@ -85,8 +85,74 @@ public class MksChangeLogParser implements ChangeLogParser
|
||||
/** current changelog file */
|
||||
private ChangeLogFile changeLogFile;
|
||||
|
||||
/** date filter, only entries after this date match */
|
||||
private Date filterDateStart;
|
||||
|
||||
/** date filter, only entries before this date match */
|
||||
private Date filterDateEnd;
|
||||
|
||||
public void init( ChangeLog changeLog )
|
||||
{
|
||||
if (changeLog.getType().equals("range"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( ( changeLog.getRange() != null )
|
||||
&& ( changeLog.getRange().length() != 0 ) )
|
||||
{
|
||||
long range = Integer.parseInt(changeLog.getRange());
|
||||
filterDateStart = new Date(System.currentTimeMillis()
|
||||
- ( range * ( 24 * 60 * 60 * 1000 ) ) );
|
||||
filterDateEnd = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NumberFormatException("no range");
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
filterDateStart = null;
|
||||
filterDateEnd = null;
|
||||
}
|
||||
}
|
||||
else if (changeLog.getType().equals("date"))
|
||||
{
|
||||
if ( ( changeLog.getMarkerStart() != null )
|
||||
&& ( changeLog.getMarkerStart().length() != 0 ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
filterDateStart = new SimpleDateFormat("y-M-d").
|
||||
parse(changeLog.getMarkerStart());
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
filterDateStart = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( changeLog.getMarkerEnd() != null )
|
||||
&& ( changeLog.getMarkerEnd().length() != 0 ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
filterDateEnd = new SimpleDateFormat("y-M-d").
|
||||
parse(changeLog.getMarkerEnd());
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
filterDateEnd = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (changeLog.getType().equals("tag"))
|
||||
{
|
||||
// MKS filter for 'tag' is not impl yet.
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanup()
|
||||
@@ -269,6 +335,13 @@ public class MksChangeLogParser implements ChangeLogParser
|
||||
return;
|
||||
}
|
||||
|
||||
// do not add if entry doesn't match date range.
|
||||
if ( (filterDateStart != null && changeLogEntry.getDate().before(filterDateStart)) ||
|
||||
(filterDateEnd != null && changeLogEntry.getDate().after(filterDateEnd)) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String key =
|
||||
ENTRY_KEY_TIMESTAMP_FORMAT.format( changeLogEntry.getDate() )
|
||||
+ changeLogEntry.getAuthor() + changeLogEntry.getComment();
|
||||
|
||||
@@ -54,3 +54,19 @@ revision 1.1
|
||||
date: Jan 16, 2006 - 16:02 PM; author: AUTHOR; state: InWork; lines: +0 -0
|
||||
Initial revision
|
||||
===============================================================================
|
||||
member name: myproject/oldfile; working file: /myproject/oldfile
|
||||
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 14, 2006 - 11:02 PM; author: AUTHOR; state: InWork; lines: +0 -0
|
||||
Initial revision
|
||||
===============================================================================
|
||||
|
||||
@@ -20,12 +20,14 @@ package org.apache.maven.mkslib;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.maven.changelog.ChangeLog;
|
||||
import org.apache.maven.changelog.ChangeLogEntry;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -38,6 +40,9 @@ import java.util.Locale;
|
||||
*/
|
||||
public class MksChangeLogParserTest extends TestCase
|
||||
{
|
||||
/** the {link ChangeLog} used for testing */
|
||||
private ChangeLog changeLog;
|
||||
|
||||
/** the {@link MksChangeLogParser} used for testing */
|
||||
private MksChangeLogParser instance;
|
||||
|
||||
@@ -59,14 +64,25 @@ public class MksChangeLogParserTest extends TestCase
|
||||
*/
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
// We force the english locale
|
||||
// We force the german locale
|
||||
// because the test file uses it.
|
||||
Locale.setDefault(Locale.ENGLISH);
|
||||
Locale.setDefault(Locale.GERMAN);
|
||||
String baseDir = System.getProperty( "basedir" );
|
||||
if (baseDir == null)
|
||||
baseDir = "/home/christoph/workspace/changelog";
|
||||
|
||||
assertNotNull( "The system property basedir was not defined.", baseDir );
|
||||
testFile = baseDir + "/src/test-resources/mkslib/mkslog.txt";
|
||||
|
||||
System.out.println(new Date());
|
||||
|
||||
changeLog = new ChangeLog();
|
||||
changeLog.setType("date");
|
||||
changeLog.setMarkerStart("2006-01-15");
|
||||
changeLog.setMarkerEnd("2006-01-31");
|
||||
|
||||
instance = new MksChangeLogParser();
|
||||
instance.init( changeLog );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
</properties>
|
||||
<body>
|
||||
<release version="1.10" date="In SVN">
|
||||
<action dev="ltheussl" type="add" issue="MPCHANGELOG-86" due-to="Christoph Jerolimov">Support time period in MKS changelog parser.</action>
|
||||
<action dev="aheritier" type="update" issue="MAVEN-1753">Upgrade to Xerces 2.8.0. Replace the deprecated xmlParserAPIs by xml-apis 1.3.03. Add the xml-resolver dependency for xerces.</action>
|
||||
<action dev="aheritier" type="update">Upgrade to Junit 3.8.2.</action>
|
||||
</release>
|
||||
|
||||
Reference in New Issue
Block a user