[java][highlight] IDEA-274531 errors shown incorrectly when a method name is the...
[idea/community.git] / build / dependencies / setupCidr.gradle
1 import org.gradle.internal.os.OperatingSystem
2 import java.util.concurrent.TimeUnit
3
4 final def IJ_DIR = project.file("../../..").canonicalFile
5 final def REPOSITORY = "https://repo.labs.intellij.net/clion"
6 final def SETUP_ALL_PLATFORMS = Boolean.getBoolean("intellij.cidr.setup.all.platforms")
7
8 final def CURRENT_PLATFORM = {
9   def os = OperatingSystem.current()
10
11   if (os.isWindows()) "win"
12   else if (os.isMacOsX()) "mac"
13   else "linux"
14 }()
15
16 final def PACKAGE_EXTENSIONS = [
17   win: "zip",
18   mac: "tar.gz",
19   linux: "tar.gz"
20 ]
21
22 task setupCidr
23
24 [
25   clang: [
26     version: "10.0.0.143e87",
27     platforms: [
28       win: [archs: ["x64"]],
29       linux: [archs: ["x64"]],
30       mac: [archs: ["x64"]]
31     ],
32     path: "CIDR/clion/bin/clang"
33   ],
34   lldb: [
35     version: "e0cccbacab5cf5ee621edddca1ea452353192e6b",
36     platforms: [
37       win: [
38         version: "b6614b3742bb3db928fa8d0ab589494c780afeb0",
39         archs: ["x64", "x86"]
40       ],
41       linux: [archs: ["x64"]],
42       mac: [archs: ["x64"]]
43     ],
44     path: "CIDR/cidr-debugger/bin/lldb"
45   ],
46   lldbfrontend: [
47     version: "4834ed19d738ada8f552d88e920b8aaf98ee5c92",
48     platforms: [
49       win: [archs: ["x64", "x86"]],
50       linux: [archs: ["x64"]],
51       mac: [archs: ["x64"]]
52     ],
53     path: "CIDR/cidr-debugger/bin/lldb"
54   ],
55   bridge: [
56     version: "51b0c22",
57     platforms: [
58       mac: [archs: ["x64"]]
59     ],
60     path: "CIDR-appcode/appcode/bin",
61     no_platform_subdir: true
62   ],
63   jbdevice: [
64     version: "810660",
65     platforms: [
66       "mac": [archs: ["x64"]]
67     ],
68     path: "CIDR-appcode/appcode/bin",
69     no_platform_subdir: true
70   ],
71   objchelper: [
72     version: "e9b1fe3",
73     platforms: [
74       "mac": [archs: ["x64"]],
75       "linux": [archs: ["x64"]]
76     ],
77     path: "CIDR-appcode/appcode/bin",
78     no_platform_subdir: true
79   ]
80 ].each { name, settings ->
81   settings.platforms.findAll {
82     SETUP_ALL_PLATFORMS || it.key == CURRENT_PLATFORM
83   }.each { platform, platformSettings ->
84     def version = platformSettings.containsKey("version") ?
85       platformSettings.version : settings.version
86
87     platformSettings.archs.each { arch ->
88       def taskSuffix = "${name.capitalize()}${platform.capitalize()}${arch.capitalize()}"
89       def packageExtension = PACKAGE_EXTENSIONS[platform]
90
91
92       def packageName = "${name}-${version}-${platform}-${arch}.${packageExtension}"
93       def downloadUrl = "${REPOSITORY}/${name}/${version}/${packageName}"
94
95       def unpackDir = "${IJ_DIR}/${settings.path}" +
96                       "${settings.no_platform_subdir ? '' : "/${platform}"}" +
97                       "${platformSettings.archs.size > 1 ? "/${arch}" : ''}"
98
99       def downloadTool = task("downloadCidr${taskSuffix}") {
100         def packageArchive = "${buildDir}/cidr/${packageName}"
101         outputs.file(packageArchive)
102
103         doLast {
104           download {
105             src downloadUrl
106             dest packageArchive
107             tempAndMove true
108             connectTimeout TimeUnit.SECONDS.toMillis(30).toInteger()
109             readTimeout TimeUnit.MINUTES.toMillis(5).toInteger()
110             retries 10
111           }
112         }
113       }
114
115       setupCidr.dependsOn(
116         tasks.create(
117           name: "setupCidr${taskSuffix}",
118           dependsOn: [downloadTool], type: Copy
119         ) {
120           def packageArchive = downloadTool.outputs.files.singleFile
121
122           inputs.files(packageArchive)
123           outputs.dir(unpackDir)
124
125           outputs.upToDateWhen {
126             !fileTree(unpackDir).isEmpty()
127           }
128
129           from {
130             if (packageExtension == "zip")
131               zipTree(packageArchive)
132             else if(packageExtension == "tar.gz")
133               tarTree(resources.gzip(packageArchive))
134           }
135           into unpackDir
136         }
137       )
138     }
139   }
140 }
141
142 task cleanSetupCidr() {
143   doLast {
144     setupCidr.dependsOn.each { setupToolTask ->
145       def downloadToolTask = setupToolTask.dependsOn.first()
146       delete setupToolTask.outputs.files.singleFile
147       delete downloadToolTask.outputs.files.singleFile
148     }
149   }
150 }