forked from EqualExperts/json-schema-validator
/
ide-support.gradle
41 lines (34 loc) · 1.39 KB
/
ide-support.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
allprojects {
apply plugin: 'idea'
}
//ideaModule.enabled = false
//ideaProject.subprojects.remove(project)
def versionControlMappings = [svn: "svn info", hg4idea: "hg status", Git: "git status"]
def projectVersionControlClosure = { provider ->
def vcs = versionControlMappings.find {
try {
it.value.execute(null, rootProject.projectDir).waitFor() == 0
} catch (Exception ignore) {
return false
}
}
if (vcs) {
def vcsConfig = provider.asNode().component.find { it.'@name' == 'VcsDirectoryMappings' }
vcsConfig.mapping[0].'@vcs' = vcs.key
}
}
def workspaceJunitClosure = { provider ->
def runManagerComponent = provider.asNode().component.find { it.'@name' == 'RunManager'}
def defaultJunitConfig = runManagerComponent.configuration.find {(it.'@default' == 'true') && (it.'@type' == 'JUnit')}
defaultJunitConfig.option.find {it.'@name' == 'WORKING_DIRECTORY'}.'@value' = '$MODULE_DIR$'
if (System.getenv('JAVA_OPTS')) {
defaultJunitConfig.option.find {it.'@name' == 'VM_PARAMETERS'}.'@value' = System.getenv('JAVA_OPTS')
}
}
if (gradle.gradleVersion.startsWith('0.9.')) {
ideaProject { withXml(projectVersionControlClosure) }
ideaWorkspace { withXml(workspaceJunitClosure) }
} else {
idea.project.ipr.withXml(projectVersionControlClosure)
idea.workspace.iws.withXml(workspaceJunitClosure)
}