You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm-commits@maven.apache.org by ev...@apache.org on 2005/12/06 14:22:47 UTC
svn commit: r354423 -
/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java
Author: evenisse
Date: Tue Dec 6 05:22:43 2005
New Revision: 354423
URL: http://svn.apache.org/viewcvs?rev=354423&view=rev
Log:
PR: SCM-98
Submitted by: Dan Tran
Add scm:changelog goal.
This additional mojo dumps the contents of changelog command ( ChangeSet) to stdout. It is for testing changelog command only.
patch, manually tested with svn and starteam providers
Added:
maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java (with props)
Added: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java?rev=354423&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java (added)
+++ maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java Tue Dec 6 05:22:43 2005
@@ -0,0 +1,117 @@
+package org.apache.maven.scm.plugin;
+
+/*
+ * Copyright 2001-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.plugin.MojoExecutionException;
+import org.apache.maven.scm.ChangeSet;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
+import org.apache.maven.scm.provider.ScmProvider;
+import org.apache.maven.scm.repository.ScmRepository;
+
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Dump changelog contents to console. It is mainly used to test maven-scm-api's changelog command
+ * @goal changelog
+ * @aggregator
+ *
+ * @author <a href="dantran@gmail.com">Dan Tran</a>
+ * @version $Id:$
+ */
+public class ChangeLogMojo
+ extends AbstractScmMojo
+{
+
+ /**
+ * Start Date.
+ * @parameter expression="${startDate}"
+ */
+ private String startDate;
+
+ /**
+ * End Date
+ * @parameter expression="${endDate}"
+ */
+ private String endDate;
+
+ private SimpleDateFormat localFormat = new SimpleDateFormat();
+
+ public void execute()
+ throws MojoExecutionException
+ {
+
+ try
+ {
+ ScmRepository repository = getScmRepository();
+
+ ScmProvider provider = getScmManager().getProviderByRepository( repository );
+
+ ChangeLogScmResult result = provider.changeLog( repository,
+ getFileSet(),
+ this.parseDate( this.startDate ),
+ this.parseDate( this.endDate ),
+ 0,
+ null);
+ checkResult( result );
+
+ List changeLogs = result.getChangeLog();
+
+ for ( int i = 0; i < changeLogs.size(); ++i )
+ {
+ ChangeSet changeSet = (ChangeSet) changeLogs.get( i );
+ System.out.println( changeSet.toString() );
+ }
+
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Cannot run checkout command : ", e );
+ }
+ catch ( ScmException e )
+ {
+ throw new MojoExecutionException( "Cannot run checkout command : ", e );
+ }
+ }
+
+ /**
+ * Converts the localized date string pattern to date object.
+ * @return A date
+ */
+ private Date parseDate( String date )
+ throws MojoExecutionException
+ {
+ if ( date == null || date.trim().length() == 0 )
+ {
+ return null;
+ }
+
+ try
+ {
+ return localFormat.parse( date.toString() );
+ }
+ catch ( ParseException e )
+ {
+ throw new MojoExecutionException( "Please use this date pattern: " + localFormat.toLocalizedPattern().toString(), e);
+ }
+ }
+
+}
Propchange: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"