1
// Downloadable dependencies processing
6
url "https://plugins.gradle.org/m2/"
10
classpath "at.bxm.gradleplugins:gradle-svntools-plugin:2.2"
11
classpath "org.tmatesoft.svnkit:svnkit:1.10.1"
15
import at.bxm.gradleplugins.svntools.tasks.SvnExport
16
import at.bxm.gradleplugins.svntools.internal.SvnSupport
17
import at.bxm.gradleplugins.svntools.internal.SvnProxy
18
import at.bxm.gradleplugins.svntools.SvnToolsPluginExtension
19
import org.gradle.api.InvalidUserDataException
20
import org.tmatesoft.svn.core.SVNDepth
21
import org.tmatesoft.svn.core.SVNException
22
import org.tmatesoft.svn.core.SVNURL
23
import org.tmatesoft.svn.core.wc.SVNRevision
25
def fetchModule(String svnUrl, targetDir, Long revision) {
26
def svnClient = SvnSupport.createSvnClientManager(null, null, new SvnProxy())
27
def rev = SvnSupport.revisionFrom(revision)
30
repoUrl = SVNURL.parseURIEncoded(svnUrl)
31
} catch (SVNException e) {
32
throw new InvalidUserDataException("Invalid svnUrl value: $svnUrl", e)
35
throw new InvalidUserDataException("targetDir must be specified")
37
def dir = targetDir instanceof File ? targetDir : targetDir.toString() as File
39
if (!dir.isDirectory()) {
40
throw new InvalidUserDataException("targetDir $dir.absolutePath must be a directory")
43
throw new InvalidUserDataException("targetDir $dir.absolutePath must be an empty directory")
47
svnClient.updateClient.doExport(repoUrl, dir, SVNRevision.UNDEFINED, rev, null, true, SVNDepth.INFINITY)
48
} catch (SVNException e) {
49
throw new InvalidUserDataException("svn-export failed for $svnUrl\n" + e.message, e)
53
// - local maven repository module will be used if available
54
// - otherwise module will be download to deps directory
55
project.dependencies.ext.moduleDep = { depsName, packageName, moduleName ->
56
if (ext.has('depsRoot') && depsName == ext.depsRoot) {
57
return project(':modules:' + moduleName)
60
def depVersion = ext['deps' + depsName].version
61
def depGithubProfile = ext['deps' + depsName].githubProfile
62
def depGithubRepo = ext['deps' + depsName].githubRepo
64
def mavenModuleDir = repositories.mavenLocal().url.path + packageName.replace('.', '/') + '/' + moduleName + '/' + depVersion
65
if (new File(mavenModuleDir).isDirectory()) {
66
// Use maven package if available
67
return packageName + ':' + moduleName + ':' + depVersion
70
def depsDir = rootProject.buildDir.parent + '/deps/'
71
if (gradle.startParameter.taskNames == ['clean']) {
72
return project(':deps')
75
def depModuleDir = depsDir + moduleName
76
if (!new File(depModuleDir).isDirectory()) {
78
def githubModulePath = 'https://github.com/' + depGithubProfile + '/' + depGithubRepo + '/trunk/modules/' + moduleName
79
println 'Downloading ' + githubModulePath
81
fetchModule(githubModulePath, depModuleDir, null)
83
// Reports new module was downloaded -> need another sweep of dependency resolution
84
if (!new File(depsDir + ".downloaded").exists()) {
85
new File(depsDir + ".downloaded").createNewFile()
87
return project(':deps')
90
if (new File(depsDir + ".downloaded").exists()) {
91
return project(':deps')
94
return project(':deps:' + moduleName)
97
project.dependencies.ext.moduleDepPath = { depsName, moduleName ->
98
if (!ext.has('depsRoot') || depsName == ext.depsRoot) {
99
return ":modules:${moduleName}"
102
return ":deps:${moduleName}"