99 */
1010
1111import org.gradle.api.tasks.AbstractCopyTask
12- import org.gradle.api.tasks.Delete
1312import org.gradle.api.tasks.JavaExec
1413import org.gradle.api.tasks.SourceSet
14+ import org.gradle.api.tasks.bundling.Jar
1515import org.gradle.api.tasks.compile.JavaCompile
1616import org.gradle.api.tasks.testing.Test
1717import org.gradle.internal.jvm.Jvm
18+ import org.jetbrains.intellij.tasks.PublishTask
1819import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
1920import java.io.File
2021
@@ -31,7 +32,7 @@ plugins {
3132 id(" org.jetbrains.kotlin.jvm" ) version " 1.1.1"
3233 groovy
3334 idea
34- id(" org.jetbrains.intellij" ) version " 0.2.5 "
35+ id(" org.jetbrains.intellij" ) version " 0.2.7 "
3536 id(" net.minecrell.licenser" ) version " 0.3"
3637}
3738
@@ -44,18 +45,27 @@ val javaVersion: String by extra
4445val kotlinVersion: String by extra
4546val downloadIdeaSources: String by extra
4647
47- val clean: Delete by tasks
48+ // for publishing nightlies
49+ val repoUsername: String by extra
50+ val repoPassword: String by extra
51+ val repoChannel: String by extra
52+
53+ val compileKotlin by tasks
4854val processResources: AbstractCopyTask by tasks
55+ val test: Test by tasks
4956val runIde: JavaExec by tasks
50- val compileKotlin by tasks
57+ val publishPlugin : PublishTask by tasks
5158
5259configurations {
60+ " kotlin" ()
61+ " compileOnly" { extendsFrom(" kotlin" ()) }
62+ " testCompile" { extendsFrom(" kotlin" ()) }
63+
64+ " gradle-tooling-extension" { extendsFrom(" idea" ()) }
5365 " jflex" ()
5466 " jflex-skeleton" ()
5567 " grammar-kit" ()
56- " testLibs" {
57- isTransitive = false
58- }
68+ " testLibs" { isTransitive = false }
5969}
6070
6171repositories {
@@ -70,23 +80,34 @@ repositories {
7080 }
7181}
7282
73- dependencies {
74- compile(kotlinModule(" stdlib-jre8" )) {
75- // JetBrains annotations are already bundled with IntelliJ IDEA
76- exclude(group = " org.jetbrains" , module = " annotations" )
83+ java {
84+ setSourceCompatibility(javaVersion)
85+ setTargetCompatibility(javaVersion)
86+
87+ sourceSets {
88+ " gradle-tooling-extension" {
89+ configurations[compileOnlyConfigurationName].extendsFrom(configurations[" gradle-tooling-extension" ])
90+ }
7791 }
92+ }
93+
94+ val gradleToolingExtension = java().sourceSets[" gradle-tooling-extension" ]
95+ val gradleToolingExtensionJar = task<Jar >(gradleToolingExtension.jarTaskName) {
96+ from(gradleToolingExtension.output)
97+ classifier = " gradle-tooling-extension"
98+ }
99+
100+ dependencies {
101+ " kotlin" (kotlinModule(" runtime" )) { isTransitive = false }
102+ " kotlin" (kotlinModule(" stdlib" )) { isTransitive = false }
103+ compile(kotlinModule(" stdlib-jre7" )) { isTransitive = false }
104+ compile(kotlinModule(" stdlib-jre8" )) { isTransitive = false }
78105
79106 // Add tools.jar for the JDI API
80107 compile(files(Jvm .current().toolsJar))
81108
82- // Add an additional dependency on kotlin-runtime. It is essentially useless
83- // (since kotlin-runtime is a transitive dependency of kotlin-stdlib-jre8)
84- // but without kotlin-stdlib or kotlin-runtime on the classpath,
85- // gradle-intellij-plugin will add IntelliJ IDEA's Kotlin version to the
86- // dependencies which conflicts with our newer version.
87- compile(kotlinModule(" runtime" )) {
88- isTransitive = false
89- }
109+ compile(files(gradleToolingExtensionJar))
110+ " gradle-tooling-extension" (intellijPlugin(" gradle" ))
90111
91112 " jflex" (" org.jetbrains.idea:jflex:1.7.0-b7f882a" )
92113 " jflex-skeleton" (" org.jetbrains.idea:jflex:1.7.0-c1fdf11:idea@skeleton" )
@@ -98,7 +119,7 @@ dependencies {
98119
99120intellij {
100121 // IntelliJ IDEA dependency
101- version = ideaVersion
122+ version = " IC- $ ideaVersion"
102123 // Bundled plugin dependencies
103124 setPlugins(" maven" , " gradle" , " Groovy" ,
104125 // needed dependencies for unit tests
@@ -112,9 +133,14 @@ intellij {
112133 sandboxDirectory = project.rootDir.canonicalPath + " /.sandbox"
113134}
114135
115- java {
116- setSourceCompatibility(javaVersion)
117- setTargetCompatibility(javaVersion)
136+ publishPlugin {
137+ if (properties[" publish" ] != null ) {
138+ project.version = " ${project.version} -${properties[" buildNumber" ]} "
139+
140+ username(repoUsername)
141+ password(repoPassword)
142+ channels(repoChannel)
143+ }
118144}
119145
120146tasks.withType<JavaCompile > {
@@ -133,7 +159,7 @@ processResources {
133159 }
134160}
135161
136- tasks.withType< Test > {
162+ test {
137163 if (CI ) {
138164 systemProperty(" slowCI" , " true" )
139165 }
@@ -231,3 +257,9 @@ runIde {
231257
232258inline operator fun <T : Task > T.invoke (a : T .() -> Unit ): T = apply (a)
233259fun KotlinDependencyHandler.kotlinModule (module : String ) = kotlinModule(module, kotlinVersion) as String
260+ fun intellijPlugin (name : String ) = mapOf (
261+ " group" to " org.jetbrains.plugins" ,
262+ " name" to name,
263+ " version" to ideaVersion,
264+ " configuration" to " compile"
265+ )
0 commit comments