forked from aerogear-attic/aerogear-mobile-intellij-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
118 lines (93 loc) · 2.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
plugins {
id 'org.jetbrains.intellij' version '0.2.17'
}
group 'org.aerogear'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
ideaSdk
bundle // dependencies bundled with the plugin
}
dependencies {
ideaSdk fileTree(dir: 'lib/sdk/', include: ['*/lib/*.jar'])
testCompile group: 'junit', name: 'junit', version: '4.12'
}
def IDEA_SDK_URL = 'https://download-cf.jetbrains.com/idea/ideaIC-2017.3.3.tar.gz'
def IDEA_SDK_NAME = 'IntelliJ IDEA Community Edition IC-173.4301.25'
test {
// Avoid parallel execution, since the IntelliJ boilerplate is not up to that
maxParallelForks = 1
}
task downloadIdeaSdk(type: Download) {
sourceUrl = IDEA_SDK_URL
target = file('lib/idea-sdk.tar.gz')
}
task extractIdeaSdk(type: Copy, dependsOn: [downloadIdeaSdk]) {
def zipFile = file('lib/idea-sdk.tar.gz')
def outputDir = file("lib/sdk")
from tarTree(resources.gzip(zipFile))
into outputDir
}
task dist(type: Zip, dependsOn: [jar, test]) {
from configurations.bundle
from jar.archivePath
rename { f -> "lib/${f}" }
into project.name
baseName project.name
}
compileJava.dependsOn extractIdeaSdk
apply plugin: 'idea'
idea {
project {
languageLevel = '1.8'
jdkName = IDEA_SDK_NAME
ipr {
withXml {
it.node.find { node ->
node.@name == 'ProjectRootManager'
}.'@project-jdk-type' = 'IDEA JDK'
logger.warn "=" * 71
logger.warn " Configured IDEA JDK '${jdkName}'."
logger.warn " Make sure you have it configured IntelliJ before opening the project!"
logger.warn "=" * 71
}
}
}
module {
scopes.COMPILE.minus = [ configurations.ideaSdk ]
iml {
beforeMerged { module ->
module.dependencies.clear()
}
withXml {
it.node.@type = 'PLUGIN_MODULE'
// <component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/src/main/resources/META-INF/plugin.xml" />
def cmp = it.node.appendNode('component')
cmp.@name = 'DevKit.ModuleBuildProperties'
cmp.@url = 'file://$MODULE_DIR$/src/main/resources/META-INF/plugin.xml'
}
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '3.0'
}
// ========= Custom tasks ========= //
class Download extends DefaultTask {
@Input
String sourceUrl
@OutputFile
File target
@TaskAction
void download() {
if (!target.parentFile.exists()) {
target.parentFile.mkdirs()
}
logger.lifecycle "Downloading ${sourceUrl}, this might take a minute..."
ant.get(src: sourceUrl, dest: target, skipexisting: 'true')
}
}