|
1 | | -import org.jetbrains.intellij.tasks.PatchPluginXmlTask |
2 | 1 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
3 | 2 |
|
4 | | -plugins { |
5 | | - java |
6 | | - kotlin("jvm") version "1.4.30" |
7 | | - id("org.jetbrains.intellij") version "0.7.2" |
8 | | -} |
9 | | - |
10 | | -group = "ru.meanmail" |
11 | | -version = "${project.properties["version"]}-${project.properties["postfix"]}" |
| 3 | +fun config(name: String) = project.findProperty(name).toString() |
12 | 4 |
|
13 | 5 | repositories { |
14 | 6 | mavenCentral() |
15 | 7 | } |
16 | 8 |
|
17 | | -dependencies { |
18 | | - implementation(kotlin("stdlib-jdk8")) |
19 | | - testImplementation("junit:junit:4.13.2") |
20 | | -} |
21 | | - |
22 | | -configure<JavaPluginConvention> { |
23 | | - sourceCompatibility = JavaVersion.VERSION_1_8 |
24 | | -} |
25 | | - |
26 | | -tasks.withType<KotlinCompile> { |
27 | | - kotlinOptions.jvmTarget = "11" |
28 | | -} |
29 | | - |
30 | | -tasks.withType<Wrapper> { |
31 | | - distributionType = Wrapper.DistributionType.ALL |
32 | | - gradleVersion = project.properties["gradleVersion"].toString() |
| 9 | +plugins { |
| 10 | + java |
| 11 | + kotlin("jvm") version "1.5.10" |
| 12 | + id("org.jetbrains.intellij") version "1.3.0" |
33 | 13 | } |
34 | 14 |
|
35 | | -tasks.test { |
36 | | - useJUnit() |
| 15 | +group = config("group") |
| 16 | +version = "${config("version")}-${config("platformVersion")}" |
37 | 17 |
|
38 | | - maxHeapSize = "1G" |
| 18 | +dependencies { |
| 19 | + compileOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.10") |
| 20 | + testImplementation("junit:junit:4.13.2") |
39 | 21 | } |
40 | 22 |
|
41 | 23 | intellij { |
42 | | - pluginName = project.properties["pluginName"].toString() |
43 | | - version = if (project.properties["eap"].toString() == "true") { |
44 | | - "LATEST-EAP-SNAPSHOT" |
45 | | - } else { |
46 | | - project.properties["IdeVersion"].toString() |
47 | | - } |
48 | | - type = project.properties["ideType"].toString() |
49 | | - when (type) { |
50 | | - "PY" -> { |
51 | | - setPlugins("python") |
| 24 | + pluginName.set(config("pluginName")) |
| 25 | + version.set( |
| 26 | + if (config("platformVersion") == "eap") { |
| 27 | + "LATEST-EAP-SNAPSHOT" |
| 28 | + } else { |
| 29 | + config("platformVersion") |
52 | 30 | } |
53 | | - "PC" -> { |
54 | | - setPlugins("PythonCore") |
| 31 | + ) |
| 32 | + type.set(config("platformType")) |
| 33 | + |
| 34 | + val usePlugins = config("usePlugins").split(',') |
| 35 | + for (plugin in usePlugins) { |
| 36 | + if (plugin.isEmpty()) { |
| 37 | + continue |
55 | 38 | } |
56 | | - else -> { |
57 | | - setPlugins(project.properties["pythonPluginVersion"].toString()) |
| 39 | + val (name, version) = plugin.split(':') |
| 40 | + if (name == "python") { |
| 41 | + when (type.get()) { |
| 42 | + "PY" -> { |
| 43 | + plugins.add("python") |
| 44 | + } |
| 45 | + "PC" -> { |
| 46 | + plugins.add("PythonCore") |
| 47 | + } |
| 48 | + else -> { |
| 49 | + plugins.add("PythonCore:${version}") |
| 50 | + } |
| 51 | + } |
| 52 | + } else { |
| 53 | + plugins.add(plugin) |
58 | 54 | } |
59 | 55 | } |
60 | 56 | } |
@@ -88,11 +84,44 @@ fun readChangeNotes(pathname: String): String { |
88 | 84 | it.joinToString("<br>") |
89 | 85 | } + |
90 | 86 | "See the full change notes on the <a href='" + |
91 | | - project.properties["repository"] + |
92 | | - "/blob/master/ChangeNotes.md'>github</a>" |
| 87 | + config("repository") + |
| 88 | + "/blob/master/CHANGES.md'>github</a>" |
93 | 89 | } |
94 | 90 |
|
95 | | -tasks.withType<PatchPluginXmlTask> { |
96 | | - setPluginDescription(file("Description.html").readText()) |
97 | | - setChangeNotes(readChangeNotes("ChangeNotes.md")) |
| 91 | +tasks { |
| 92 | + config("jvmVersion").let { |
| 93 | + withType<JavaCompile> { |
| 94 | + sourceCompatibility = it |
| 95 | + targetCompatibility = it |
| 96 | + } |
| 97 | + withType<KotlinCompile> { |
| 98 | + kotlinOptions.jvmTarget = it |
| 99 | + } |
| 100 | + } |
| 101 | + |
| 102 | + wrapper { |
| 103 | + distributionType = Wrapper.DistributionType.ALL |
| 104 | + gradleVersion = config("gradleVersion") |
| 105 | + } |
| 106 | + |
| 107 | + test { |
| 108 | + useJUnit() |
| 109 | + |
| 110 | + maxHeapSize = "1G" |
| 111 | + } |
| 112 | + |
| 113 | + patchPluginXml { |
| 114 | + version.set(project.version.toString()) |
| 115 | + pluginDescription.set(file("description.html").readText()) |
| 116 | + changeNotes.set(readChangeNotes("CHANGES.md")) |
| 117 | + } |
| 118 | + |
| 119 | + publishPlugin { |
| 120 | + dependsOn("buildPlugin") |
| 121 | + token.set(System.getenv("PUBLISH_TOKEN")) |
| 122 | + channels.set(listOf(config("publishChannel"))) |
| 123 | + } |
| 124 | + buildSearchableOptions { |
| 125 | + enabled = false |
| 126 | + } |
98 | 127 | } |
0 commit comments