forked from AmailP/robot-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
151 lines (128 loc) · 5.84 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
plugins {
id 'org.jetbrains.intellij' version '0.0.37'
id "de.undercouch.download" version '2.1.0'
}
repositories {
mavenCentral()
}
def runWithPython = System.getenv().getOrDefault("RUN_WITH_PYTHON", "true").toBoolean()
configurations {
ideaPlugins
if(runWithPython)
compile.extendsFrom(ideaPlugins)
}
apply plugin: 'scala'
apply plugin: 'org.jetbrains.intellij'
sourceCompatibility = JavaVersion.VERSION_1_8
// Following two assignments are necessary to let the scala plugin handle both java and scala compilation
sourceSets.main.java.srcDirs = []
sourceSets.test.java.srcDirs = []
// Python plugin is still necesessary to compile, even if not used at runtime
if(!runWithPython) {
sourceSets.main.compileClasspath += configurations.ideaPlugins
sourceSets.test.compileClasspath += configurations.ideaPlugins
}
sourceSets.main.scala.srcDir 'src/main/java'
sourceSets.main.scala.srcDir 'src/main/java-gen'
sourceSets.test.scala.srcDir 'src/test/java'
dependencies {
compile 'org.scala-lang:scala-library:2.11.7'
ideaPlugins fileTree("${projectDir}/lib/") {
include 'python*/lib/python*.jar'
}
testCompile 'org.scalatest:scalatest_2.11:2.2.5'
}
// Build number ranges: http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html
// Python CE plugin: https://plugins.jetbrains.com/plugin/7322-python-community-edition
// Python plugin: https://plugins.jetbrains.com/plugin/631-python
// Intellij repositories: https://www.jetbrains.com/intellij-repository/releases
// https://www.jetbrains.com/intellij-repository/snapshots
def pythonPluginForVersion = [
'IC-2017.3.2': 'https://plugins.jetbrains.com/plugin/download?updateId=41833',
'IC-2017.2.1': 'https://plugins.jetbrains.com/plugin/download?updateId=37356',
'IC-171.3780-EAP-CANDIDATE-SNAPSHOT': 'https://plugins.jetbrains.com/plugin/download?updateId=33293',
'IC-163.13906.18' : 'https://plugins.jetbrains.com/plugin/download?updateId=32326',
'IC-163.4396.1': 'https://plugins.jetbrains.com/plugin/download?pr=idea_ce&updateId=27090',
'IC-2016.1.1': 'https://plugins.jetbrains.com/plugin/download?pr=idea_ce&updateId=24604',
'IC-2016.1': 'https://plugins.jetbrains.com/plugin/download?pr=idea_ce&updateId=24604',
'IC-15.0.2': 'https://plugins.jetbrains.com/plugin/download?pr=idea_ce&updateId=22400',
'IC-14.1.6': 'https://plugins.jetbrains.com/plugin/download?pr=idea_ce&updateId=20879',
'IU-2017.3.2': 'https://plugins.jetbrains.com/plugin/download?updateId=41832',
'IU-171.3780-EAP-CANDIDATE-SNAPSHOT': 'https://plugins.jetbrains.com/plugin/download?updateId=33292',
'IU-2016.2.5': 'https://plugins.jetbrains.com/plugin/download?updateId=32327',
'IU-2016.1': 'https://plugins.jetbrains.com/plugin/download?pr=idea&updateId=24602',
'IU-15.0.2': 'https://plugins.jetbrains.com/plugin/download?pr=idea&updateId=22399'
]
intellij {
version = System.getenv().getOrDefault('IDEA_VERSION', 'IC-2017.3.2')
plugins = ['coverage', 'yaml'] // Dependent plugins are added for Python IU plugin
intellijFiles.addAll(configurations.ideaPlugins.files)
updateSinceUntilBuild = false
publish {
username 'AmailP'
pluginId '7415'
}
}
test {
exclude 'amailp/intellij/robot/testFramework'
if(!runWithPython) {
exclude 'amailp/intellij/robot/psi/reference/LibraryToDefinitionReferenceTest.class'
exclude 'amailp/intellij/robot/psi/reference/PythonKeywordToDefinitionReferenceTest.class'
}
}
import de.undercouch.gradle.tasks.download.Download
task downloadJFlex(type: Download) {
src 'https://bintray.com/jetbrains/intellij-third-party-dependencies/download_file?file_path=org%2Fjetbrains%2Fintellij%2Fdeps%2Fjflex%2Fjflex%2F1.7.0%2Fjflex-1.7.0.jar'
dest "${buildDir}/downloads/JFlex.jar"
onlyIfNewer true
overwrite false
}
task downloadSkeleton(dependsOn: downloadJFlex, type: Download) {
src 'https://github.com/JetBrains/intellij-community/raw/master/tools/lexer/idea-flex.skeleton'
dest "${buildDir}/downloads/idea-flex.skeleton"
onlyIfNewer true
overwrite false
}
task generateLexer(dependsOn: downloadSkeleton, type: JavaExec) {
main '-jar'
args """${buildDir}/downloads/JFlex.jar
|--nobak
|--skel
|${buildDir}/downloads/idea-flex.skeleton
|-d
|${projectDir}/src/main/java-gen/amailp/intellij/robot/lexer
|${projectDir}/src/main/resources/amailp/intellij/robot/lexer/Robot.flex""".stripMargin().split('\n').toList()
inputs.file "${projectDir}/src/main/resources/amailp/intellij/robot/lexer/Robot.flex"
outputs.dir "${projectDir}/src/main/java-gen/amailp/intellij/robot/lexer"
}
task downloadPython(type: Download) {
src pythonPluginForVersion["${intellij.type}-${intellij.version}"]
dest "${buildDir}/downloads/python.zip"
onlyIfNewer true
overwrite false
}
task unzipPython(dependsOn: downloadPython, type: Copy) {
from zipTree(downloadPython.dest)
into "${buildDir}/plugins/"
}
task copyPythonToSandbox(dependsOn: unzipPython, type: Copy) {
from "${buildDir}/plugins/python"
into "${intellij.sandboxDirectory}/plugins/python"
}
task copyPythonJarToLib(dependsOn: unzipPython, type: Copy) {
from ("${buildDir}/plugins") {
include 'python*/lib/python*.jar'
}
into "${projectDir}/lib"
}
compileScala.dependsOn(copyPythonJarToLib)
compileScala.dependsOn(generateLexer)
afterEvaluate {
if(runWithPython)
tasks.getByPath('prepareSandbox').dependsOn copyPythonToSandbox
tasks.getByPath('publishPlugin').doFirst {
def requiredVersion = JavaVersion.VERSION_1_8
if(JavaVersion.current() != requiredVersion)
throw new GradleException("The plugin should be published using JavaVersion $requiredVersion" )
}
}