PR: MPCHANGES-7
fix version handling git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115032 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
1 parent
b4916b5b9d
commit
d9d79a4f0b
11 files changed
+535
-6
No files matched your search
@@ -28,7 +28,7 @@ import org.dom4j.io.*;
|
||||
/**
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*
|
||||
* @version $Id: ReleaseVersion.java,v 1.2 2004/03/02 15:37:56 evenisse Exp $
|
||||
* @version $Id: ReleaseVersion.java,v 1.3 2004/04/22 07:34:56 brett Exp $
|
||||
*/
|
||||
public class ReleaseVersion
|
||||
{
|
||||
@@ -39,7 +39,7 @@ public class ReleaseVersion
|
||||
releaseVersion( changesFile, currentVersion, version, dateFormat.format( new Date() ) );
|
||||
}
|
||||
|
||||
public static final void releaseVersion( File changesFile, String currentVersion, String version, String date )
|
||||
static final Document transformVersion( File changesFile, String currentVersion, String version, String date )
|
||||
throws DocumentException, FileNotFoundException, UnsupportedEncodingException, IOException
|
||||
{
|
||||
SAXReader r = new SAXReader();
|
||||
@@ -52,18 +52,38 @@ public class ReleaseVersion
|
||||
|
||||
for ( Iterator i = releases.elementIterator( "release" ); i.hasNext(); )
|
||||
{
|
||||
Element e = (Element) i.next();
|
||||
Element e = ( Element ) i.next();
|
||||
|
||||
Attribute v = e.attribute( "version" );
|
||||
|
||||
if ( v != null )
|
||||
{
|
||||
String text = v.getText();
|
||||
Attribute d = e.attribute( "date" );
|
||||
boolean updateRelease = false;
|
||||
if ( text.equals( currentVersion ) || text.equals( version ) )
|
||||
{
|
||||
updateRelease = true;
|
||||
}
|
||||
if ( updateRelease && d != null )
|
||||
{
|
||||
DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
|
||||
try
|
||||
{
|
||||
dateFormat.parse( d.getText() );
|
||||
// date is set correctly
|
||||
updateRelease = false;
|
||||
}
|
||||
catch ( ParseException ex )
|
||||
{
|
||||
// intentional
|
||||
}
|
||||
}
|
||||
|
||||
if ( updateRelease )
|
||||
{
|
||||
v.setText( version );
|
||||
|
||||
Attribute d = e.attribute( "date" );
|
||||
if ( d == null )
|
||||
{
|
||||
e.addAttribute( "date", date );
|
||||
@@ -72,10 +92,25 @@ public class ReleaseVersion
|
||||
{
|
||||
d.setText( date );
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// indicates no transform necessary
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final void releaseVersion( File changesFile, String currentVersion, String version, String date )
|
||||
throws DocumentException, FileNotFoundException, UnsupportedEncodingException, IOException
|
||||
{
|
||||
Document doc = transformVersion( changesFile, currentVersion, version, date );
|
||||
if ( doc == null )
|
||||
{
|
||||
// no transform necessary
|
||||
return;
|
||||
}
|
||||
|
||||
// Backup the original first.
|
||||
FileUtils.copyFile( changesFile, new File( changesFile + ".backup" ) );
|
||||
|
||||
@@ -91,3 +126,4 @@ public class ReleaseVersion
|
||||
writer.write( doc );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user