forked from martoe/gradle-svntools-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSvnUpdate.groovy
32 lines (27 loc) · 1.15 KB
/
SvnUpdate.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package at.bxm.gradleplugins.svntools.tasks
import at.bxm.gradleplugins.svntools.internal.SvnBaseTask
import org.gradle.api.InvalidUserDataException
import org.gradle.api.PathValidation
import org.gradle.api.tasks.TaskAction
import org.tmatesoft.svn.core.SVNDepth
import org.tmatesoft.svn.core.SVNException
import static at.bxm.gradleplugins.svntools.internal.SvnSupport.revisionFrom
class SvnUpdate extends SvnBaseTask {
/** Local workspace that should be updated (default: {@code project.projectDir}) */
def workspaceDir
/** The target revision number (optional, defaults to HEAD) */
Long revision
@TaskAction
def run() {
def rev = revisionFrom(revision)
def dir = workspaceDir ? project.file(workspaceDir, PathValidation.DIRECTORY) : project.projectDir
try {
def targetRev = createSvnClientManager().updateClient.doUpdate(dir, rev, SVNDepth.INFINITY, false, false)
if (targetRev < 0) {
throw new InvalidUserDataException("workspaceDir $dir.absolutePath is no SVN workspace")
}
} catch (SVNException e) {
throw new InvalidUserDataException("svn-update failed for $dir.absolutePath\n" + e.message, e)
}
}
}