Created
June 3, 2012 00:30
-
-
Save toddb/2860708 to your computer and use it in GitHub Desktop.
Gradle integration to SVN to generate CHANGELOG from svn log (integration via svnkit)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
task changeLog(type: ReleaseNotes){ | |
destFile file("CHANGELOG-DJANGO-SAMPLE") | |
url "http://django-page-cms.googlecode.com/svn/trunk/" | |
} | |
# gradle changeLog | |
Creates output (first entry only shown): | |
--------------------------------------------- | |
revision: 1 | |
author: null | |
date: Tue Nov 06 22:36:55 NZDT 2007 | |
log message: Initial directory structure. | |
changed paths: | |
A /trunk | |
A /tags | |
A /branches | |
--------------------------------------------- | |
*/ | |
buildscript { | |
repositories { | |
mavenCentral() | |
mavenRepo url:'http://maven.tmatesoft.com/content/repositories/releases' | |
} | |
dependencies { | |
classpath 'org.tmatesoft.svnkit:svnkit:1.3.8' | |
} | |
} | |
import java.util.Collection; | |
import java.util.Iterator; | |
import java.util.Set; | |
import org.tmatesoft.svn.core.SVNException; | |
import org.tmatesoft.svn.core.SVNLogEntry; | |
import org.tmatesoft.svn.core.SVNLogEntryPath; | |
import org.tmatesoft.svn.core.SVNURL; | |
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; | |
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; | |
import org.tmatesoft.svn.core.io.SVNRepository; | |
import org.tmatesoft.svn.core.io.SVNRepositoryFactory; | |
import org.tmatesoft.svn.core.wc.SVNWCUtil; | |
// Trying to work around a small defficiency in plug-in class | |
// resolution. | |
project.ext.ReleaseNotes = ReleaseNotes.class | |
class ReleaseNotes extends DefaultTask { | |
String url | |
File destFile | |
@Optional | |
String username | |
@Optional | |
String password | |
@Optional | |
long startRevision | |
@Optional | |
long endRevision | |
@TaskAction | |
def create() { | |
startRevision = startRevision != null ? startRevision : 0; | |
endRevision = endRevision != null ? endRevision : -1; //HEAD (the latest) revision | |
DAVRepositoryFactory.setup(); | |
println("Getting url: ${url}") | |
def repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url)); | |
def authManager = SVNWCUtil.createDefaultAuthenticationManager(username, password); | |
repository.setAuthenticationManager(authManager); | |
endRevision = repository.getLatestRevision(); | |
java.lang.String[] targetPaths; | |
java.util.Collection entries; | |
def logEntries = repository.log(targetPaths, entries, startRevision, endRevision, true, true); | |
destFile.withWriter { out -> | |
logEntries.each { logEntry -> | |
out.writeLine("---------------------------------------------"); | |
out.writeLine("revision: " + logEntry.getRevision()); | |
out.writeLine("author: " + logEntry.getAuthor()); | |
out.writeLine("date: " + logEntry.getDate()); | |
out.writeLine("log message: " + logEntry.getMessage()); | |
if ( logEntry.getChangedPaths().size() > 0 ){ | |
out.writeLine(""); | |
out.writeLine("changed paths:"); | |
logEntry.getChangedPaths().each { paths -> | |
paths.each { entryPath -> | |
out.writeLine( " " + entryPath.getValue() ) | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment