-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathbuild.gradle
127 lines (105 loc) · 4.28 KB
/
build.gradle
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
plugins {
id 'org.jetbrains.intellij' version '0.4.7'
id 'org.jetbrains.kotlin.jvm' version '1.3.21'
}
def pluginVersionSuffix = ideaVersionPrefix != '' ? '-' + ideaVersionPrefix : ''
group 'eu.long1.flutter'
version (pluginVersion + pluginVersionSuffix)
repositories {
mavenCentral()
}
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
implementation 'io.reactivex.rxjava2:rxjava:2.2.3'
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.3.10'
implementation 'org.yaml:snakeyaml:1.21'
}
// Read local.properties file.
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
patchPluginXml {
version (pluginVersion + pluginVersionSuffix)
}
// Publishing credentials to JetBrains.
publishPlugin {
// Preferred way to push plugins to JetBrains.
token = localProperties.getProperty('token')
// If you really must...
username = localProperties.getProperty('username')
password = localProperties.getProperty('password')
}
// IntelliJ base plugin configuration. The rest of the configuration is dynamic.
intellij {
pluginName 'Flutter i18n'
def requiredPlugins = ['yaml']
// Starting with 2019.2, JetBrains extracted the Java functionality into its own plugin
// so we have to check which plugins to load as build will fail when compiling for older IDE.
// See: https://blog.jetbrains.com/platform/2019/06/java-functionality-extracted-as-a-plugin/
if (ideaVersionPrefix != '' && ideaVersionPrefix.toInteger() >= 192) {
requiredPlugins.add('java')
}
plugins = requiredPlugins
}
// Load product matrix.
def productMatrixFile = 'product-matrix.json'
def jsonFile = new File(productMatrixFile)
if (jsonFile == null) {
// noinspection GroovyAssignabilityCheck
throw new GradleException("Unable to read $productMatrixFile, is it missing?")
}
// Fail if the product details file isn't found.
// noinspection UnnecessaryQualifiedReference
def productMatrix = new groovy.json.JsonSlurper().parseText(jsonFile.text)
if (productMatrix == null || !(productMatrix instanceof Map)) {
// noinspection GroovyAssignabilityCheck
throw new GradleException("Unable to read $productMatrixFile.")
}
// If an ideaVersionPrefix is provided, search for the first matched product and use that.
if (ideaVersionPrefix != '') {
def productMatrixKeys = productMatrix.keySet() as String[]
for (productMatrixKey in productMatrixKeys) {
if (productMatrixKey != null && productMatrixKey.startsWith("${ideaVersionPrefix}.")) {
ideaVersion = productMatrixKey
break
}
}
}
// Fail if requested version is unsupported.
if (!productMatrix.containsKey(ideaVersion)) {
// noinspection GroovyAssignabilityCheck
throw new GradleException("Requested IDEA version is unsupported: $ideaVersion")
}
// Determine which branch we're building for.
def productDetails = productMatrix[ideaVersion]
if (productDetails == null || !(productDetails instanceof Map)) {
// noinspection GroovyAssignabilityCheck
throw new GradleException("Product details for IDEA version $ideaVersion is missing or invalid.")
}
// Adjust plugin's output file name.
rootProject.setBuildDir("${rootProject.buildDir}/${productDetails.comments}")
System.out.println(
"\nBuilding plugin ${(pluginVersion + pluginVersionSuffix)} for IDEA " +
"version $ideaVersion (branch ${productDetails.comments})\n"
)
System.out.println("Since: ${productDetails.sinceBuild}")
System.out.println("Until: ${productDetails.untilBuild}")
System.out.println("Dart: ${productDetails.dartPluginVersion}")
System.out.println("Flutter: ${productDetails.flutterPluginVersion}\n")
System.out.println("Artifacts output directory: ${rootProject.buildDir}\n")
// Adjust plugin build settings.
intellij.version = ideaVersion
intellij.plugins += "Dart:${productDetails.dartPluginVersion}"
intellij.plugins += "io.flutter:${productDetails.flutterPluginVersion}"
patchPluginXml.sinceBuild = productDetails.sinceBuild
patchPluginXml.untilBuild = productDetails.untilBuild