如何在gradle中编写脚本来更新svn项目

时间:2017-09-22 07:06:15

标签: gradle svnkit

我正在努力学习Gradle和 我尝试构建此代码,但它不起作用。 谁能告诉我它在哪里失败?

import org.tmatesoft.svn.core.wc2.*
import org.tmatesoft.svn.core.wc.*
import org.tmatesoft.svn.core.*

allprojects {
    repositories {
        jcenter { url "http://jcenter.bintray.com"}
        mavenCentral()
    }
    dependencies {
        classpath group: 'org.tmatesoft.svnkit', name: 'svnkit', version: '1.7.11'
    }
}

task svnCommitFile(){
    description = "Commits a single file to an SVN repository"
    doLast{
        if (!project.hasProperty("commitMsg")){
          ext.commitMsg = "None"
        }
        SvnOperationFactory svnOperationFactory = new SvnOperationFactory()
        def authentication = SVNWCUtil.createDefaultAuthenticationManager(svnUser, svnPassword)
        svnOperationFactory.setAuthenticationManager(authentication)
        try {
            SvnCommit commit = svnOperationFactory.createCommit()
            commit.setSingleTarget(SvnTarget.fromFile(new File(fileToCommit)))
            commit.setCommitMessage(commitMsg)
            SVNCommitInfo commitInfo = commit.run()
            println "Commit info: " + commitInfo
            println "Commit message: " + commitMsg
        } finally{
            svnOperationFactory.dispose()
        }
    }
}

0 个答案:

没有答案