forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathide.gradle
120 lines (108 loc) · 3.37 KB
/
ide.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
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
import org.opensearch.gradle.info.BuildParams
import org.jetbrains.gradle.ext.Remote
import org.jetbrains.gradle.ext.JUnit
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:0.7"
}
}
allprojects {
apply plugin: 'idea'
tasks.named('idea').configure {
doFirst { throw new GradleException("Use of the 'idea' task has been deprecated. For details on importing into IntelliJ see CONTRIBUTING.md.") }
}
}
// Applying this stuff, particularly the idea-ext plugin, has a cost so avoid it unless we're running in the IDE
if (System.getProperty('idea.active') == 'true') {
apply plugin: org.jetbrains.gradle.ext.IdeaExtPlugin
tasks.register('configureIdeaGradleJvm') {
group = 'ide'
description = 'Configures the appropriate JVM for Gradle'
doLast {
modifyXml('.idea/gradle.xml') { xml ->
def gradleSettings = xml.component.find { it.'@name' == 'GradleSettings' }.option[0].GradleProjectSettings
// Remove configured JVM option to force IntelliJ to use the project JDK for Gradle
gradleSettings.option.findAll { it.'@name' == 'gradleJvm' }.each { it.parent().remove(it) }
}
}
}
idea {
project {
vcs = 'Git'
jdkName = BuildParams.minimumCompilerVersion.majorVersion
settings {
delegateActions {
delegateBuildRunToGradle = false
testRunner = 'choose_per_test'
}
taskTriggers {
afterSync tasks.named('configureIdeaGradleJvm')
}
codeStyle {
java {
classCountToUseImportOnDemand = 999
}
}
encodings {
encoding = 'UTF-8'
}
compiler {
parallelCompilation = true
processHeapSize = 2048
addNotNullAssertions = false
javac {
generateDeprecationWarnings = false
preferTargetJDKCompiler = false
}
}
runConfigurations {
defaults(JUnit) {
vmParameters = '-ea -Djava.locale.providers=SPI,COMPAT'
}
}
copyright {
useDefault = 'Apache'
profiles {
Apache {
keyword = 'SPDX-License-Identifier: Apache-2.0'
notice = '''\
SPDX-License-Identifier: Apache-2.0
The OpenSearch Contributors require contributions made to
this file be licensed under the Apache-2.0 license or a
compatible open source license.'''.stripIndent()
}
}
}
}
}
}
}
/**
* Parses a given XML file, applies a set of changes, and writes those changes back to the original file.
*
* @param path Path to existing XML file
* @param action Action to perform on parsed XML document
*/
void modifyXml(Object path, Action<? super Node> action) {
File xmlFile = project.file(path)
Node xml = new XmlParser().parse(xmlFile)
action.execute(xml)
xmlFile.withPrintWriter { writer ->
new XmlNodePrinter(writer).print(xml)
}
}