如何动态添加新的部分到NamedDomainObjectContainer扩展?

时间:2016-03-09 07:51:30

标签: gradle

我想通过此插件动态添加json文件中的subversion存储库以结帐https://github.com/seu-as-code/seu-as-code.plugins/tree/master/seuac-svn-plugin

这是来自插件页面的示例

subversion {
    SeuAsCodePlugins {
        url 'https://github.com/seu-as-code/seu-as-code.plugins'
        directory file("$seuHome/codebase/seu-as-code.plugins/")
        username svnUsername
        password svnPassword
    }
}

这是我的实施

def svn_repositories = ['url1', 'url2']

svn_repositories.each { svn_url ->
    println("adding repository $svn_url ")
    subversion << {
        name = svn_url
        url = svn_url
        directory = file("$rootDir/$svn_url/")
        username = 'user'
        password = 'pass'

    }
}

但是我收到了这个错误 -

错误:没有方法签名:de.qaware.seu.as.code.plugins.svn.SvnPlugin $ _configureSvnTasks_closure1_closure2.doCall()适用于参数类型:(build_9zpeh26t5p1wvuzbyjmrvyck7 $ _run_closure2 $ _closure3)值:[build_9zpeh26t5p1wvuzbyjmrvyck7 $ _run_closure2 $ @ _closure3 49f44947] 可能的解决方案:doCall(de.qaware.seu.as.code.plugins.svn.SvnRepository),findAll(),findAll(),isCase(java.lang.Object),isCase(java.lang.Object)

任何想法如何动态地做到这一点?

1 个答案:

答案 0 :(得分:0)

我通过这种方式修复它:

def svn_repositories = ['url1', 'url2']

svn_repositories.each { svn_url ->
    println("adding repository $svn_url ")
    def svnRepository = new SvnRepository(svn_url)
    svnRepository.url = svn_url
    svnRepository.directory = file("$rootDir/$svn_url/")
    svnRepository.username = 'user'
    svnRepository.password = 'pass'
    subversion << svnRepository
}

但是想要使用更多&#39; groovy&#39;风格..