forked from mjedynak/builder-generator-idea-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
idea.gradle
42 lines (35 loc) · 1.45 KB
/
idea.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
// --- changes to idea plugin ---
idea {
module {
iml {
whenMerged { module ->
removeIdeaJdkDependencies(module)
}
withXml {
def module = it.asNode()
changeModuleType(module)
removeUnnecessaryComponent(module)
appendRequiredComponent(module)
changeComponentWithNewModuleRootManager(module)
}
}
}
}
// --- changes to idea plugin ---
def removeIdeaJdkDependencies(def module) {
module.dependencies.removeAll(module.dependencies.findAll {it.classes.url[0].contains(ideaInstallationPath)})
}
def changeModuleType(def module) {
module.@type = 'PLUGIN_MODULE'
}
def removeUnnecessaryComponent(def module) {
module.remove(module.component.find { it.@name == 'ModuleRootManager'})
}
def appendRequiredComponent(def module) {
module.appendNode('component', ['name': 'DevKit.ModuleBuildProperties', 'url': 'file://$MODULE_DIR$/META-INF/plugin.xml'])
}
def changeComponentWithNewModuleRootManager(def module) {
def componentWithNewModuleRootManager = module.component.find { it.@name == 'NewModuleRootManager'}
componentWithNewModuleRootManager.remove(componentWithNewModuleRootManager.orderEntry.find { it.@type == 'inheritedJdk'})
componentWithNewModuleRootManager.appendNode('orderEntry', ['type': 'jdk', 'jdkName': ideaJdk, 'jdkType': 'IDEA JDK'])
}