2021-04-09 15:28:18 -04:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2021-03-12 13:49:28 -05:00
|
|
|
import org.opensearch.gradle.info.BuildParams
|
2020-03-19 14:43:33 -04:00
|
|
|
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'
|
|
|
|
|
2020-07-31 07:09:04 -04:00
|
|
|
tasks.named('idea').configure {
|
2020-03-19 14:43:33 -04:00
|
|
|
doFirst { throw new GradleException("Use of the 'idea' task has been deprecated. For details on importing into IntelliJ see CONTRIBUTING.md.") }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-08 19:47:02 -04:00
|
|
|
// 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'
|
2020-03-19 14:43:33 -04:00
|
|
|
|
2020-04-08 19:47:02 -04:00
|
|
|
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) }
|
|
|
|
}
|
2020-03-19 14:43:33 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-08 19:47:02 -04:00
|
|
|
idea {
|
|
|
|
project {
|
|
|
|
vcs = 'Git'
|
2020-04-09 15:25:24 -04:00
|
|
|
jdkName = BuildParams.minimumCompilerVersion.majorVersion
|
2020-03-19 14:43:33 -04:00
|
|
|
|
2020-04-08 19:47:02 -04:00
|
|
|
settings {
|
|
|
|
delegateActions {
|
|
|
|
delegateBuildRunToGradle = false
|
|
|
|
testRunner = 'choose_per_test'
|
2020-03-19 14:43:33 -04:00
|
|
|
}
|
2020-04-08 19:47:02 -04:00
|
|
|
taskTriggers {
|
|
|
|
afterSync tasks.named('configureIdeaGradleJvm')
|
2020-03-19 14:43:33 -04:00
|
|
|
}
|
2020-04-08 19:47:02 -04:00
|
|
|
codeStyle {
|
|
|
|
java {
|
|
|
|
classCountToUseImportOnDemand = 999
|
|
|
|
}
|
2020-03-19 14:43:33 -04:00
|
|
|
}
|
2020-04-08 19:47:02 -04:00
|
|
|
encodings {
|
|
|
|
encoding = 'UTF-8'
|
2020-03-19 14:43:33 -04:00
|
|
|
}
|
2020-04-08 19:47:02 -04:00
|
|
|
compiler {
|
|
|
|
parallelCompilation = true
|
2020-07-28 15:39:51 -04:00
|
|
|
processHeapSize = 2048
|
|
|
|
addNotNullAssertions = false
|
2020-04-08 19:47:02 -04:00
|
|
|
javac {
|
|
|
|
generateDeprecationWarnings = false
|
2020-07-28 15:39:51 -04:00
|
|
|
preferTargetJDKCompiler = false
|
2020-04-08 19:47:02 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
runConfigurations {
|
|
|
|
defaults(JUnit) {
|
|
|
|
vmParameters = '-ea -Djava.locale.providers=SPI,COMPAT'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
copyright {
|
|
|
|
useDefault = 'Apache'
|
|
|
|
profiles {
|
|
|
|
Apache {
|
2021-04-09 14:49:56 -04:00
|
|
|
keyword = 'SPDX-License-Identifier: Apache-2.0'
|
2020-04-08 19:47:02 -04:00
|
|
|
notice = '''\
|
2021-04-09 14:49:56 -04:00
|
|
|
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()
|
2020-04-08 19:47:02 -04:00
|
|
|
}
|
2020-03-19 14:43:33 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
}
|
|
|
|
}
|