2016-09-16 12:30:45 -04:00
|
|
|
description = 'Builds the Prelert Engine native binaries and Java classes'
|
|
|
|
|
2016-09-19 09:08:35 -04:00
|
|
|
import org.gradle.internal.os.OperatingSystem
|
2016-10-31 09:05:32 -04:00
|
|
|
import org.gradle.plugins.ide.eclipse.model.SourceFolder
|
2016-09-16 12:30:45 -04:00
|
|
|
|
2016-11-17 08:12:26 -05:00
|
|
|
boolean isLinux = OperatingSystem.current().isLinux()
|
|
|
|
boolean isMacOsX = OperatingSystem.current().isMacOsX()
|
|
|
|
boolean isWindows = OperatingSystem.current().isWindows()
|
|
|
|
|
|
|
|
project.ext.bash = isWindows ? "C:\\Program Files\\Git\\bin\\bash" : "/bin/bash"
|
|
|
|
project.ext.make = (isMacOsX || isWindows) ? "gnumake" : (isLinux ? "make" : "gmake")
|
2016-09-19 09:08:35 -04:00
|
|
|
project.ext.numCpus = Runtime.runtime.availableProcessors()
|
2016-09-16 12:30:45 -04:00
|
|
|
|
2016-11-17 08:12:26 -05:00
|
|
|
task cppClean(type: Exec) {
|
|
|
|
commandLine bash
|
|
|
|
args '-c', 'source cpp/set_env.sh && ' + make + ' clean'
|
|
|
|
}
|
|
|
|
|
|
|
|
task cppObjCompile(type: Exec) {
|
|
|
|
commandLine bash
|
|
|
|
args '-c', 'source cpp/set_env.sh && ' + make + ' -j' + numCpus + ' objcompile'
|
2016-09-16 12:30:45 -04:00
|
|
|
}
|
|
|
|
|
2016-11-17 08:12:26 -05:00
|
|
|
task cppMake(type: Exec) {
|
|
|
|
commandLine bash
|
|
|
|
args '-c', 'source cpp/set_env.sh && ' + make + ' -j' + numCpus
|
2016-09-16 12:30:45 -04:00
|
|
|
}
|
|
|
|
|
2016-11-17 08:12:26 -05:00
|
|
|
task cppTest(type: Exec) {
|
|
|
|
commandLine bash
|
|
|
|
args '-c', 'source cpp/set_env.sh && ' + make + ' -j' + numCpus + ' test'
|
2016-09-16 12:30:45 -04:00
|
|
|
}
|
|
|
|
|
2016-11-17 08:12:26 -05:00
|
|
|
task cppAll {
|
|
|
|
dependsOn 'cppObjCompile'
|
|
|
|
dependsOn 'cppMake'
|
|
|
|
dependsOn 'cppTest'
|
|
|
|
tasks.findByName('cppMake').mustRunAfter 'cppObjCompile'
|
|
|
|
tasks.findByName('cppTest').mustRunAfter 'cppMake'
|
2016-09-16 12:30:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
subprojects {
|
2016-11-07 04:27:22 -05:00
|
|
|
apply plugin: 'eclipse'
|
|
|
|
apply plugin: 'idea'
|
2016-09-16 12:30:45 -04:00
|
|
|
apply plugin: 'maven'
|
|
|
|
apply plugin: 'java'
|
2016-11-07 04:27:22 -05:00
|
|
|
|
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
if (System.getProperty("repos.mavenlocal") != null) {
|
|
|
|
// with -Drepos.mavenlocal=true we can force checking the local .m2 repo which is useful for building against
|
|
|
|
// elasticsearch snapshots
|
|
|
|
mavenLocal()
|
|
|
|
}
|
|
|
|
mavenCentral()
|
|
|
|
maven {
|
|
|
|
name 'sonatype-snapshots'
|
|
|
|
url "https://oss.sonatype.org/content/repositories/snapshots/"
|
|
|
|
}
|
|
|
|
jcenter()
|
|
|
|
}
|
|
|
|
}
|
2016-09-16 12:30:45 -04:00
|
|
|
|
2016-11-07 04:27:22 -05:00
|
|
|
group = 'org.elasticsearch.prelert'
|
2016-09-16 12:30:45 -04:00
|
|
|
|
|
|
|
repositories {
|
2016-11-07 04:27:22 -05:00
|
|
|
if (System.getProperty("repos.mavenlocal") != null) {
|
|
|
|
// with -Drepos.mavenlocal=true we can force checking the local .m2 repo which is useful for building against
|
|
|
|
// elasticsearch snapshots
|
|
|
|
mavenLocal()
|
|
|
|
}
|
|
|
|
mavenCentral()
|
|
|
|
maven {
|
|
|
|
name 'sonatype-snapshots'
|
|
|
|
url "https://oss.sonatype.org/content/repositories/snapshots/"
|
|
|
|
}
|
|
|
|
jcenter()
|
2016-09-16 12:30:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
configurations.all {
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
testCompile group: 'org.ini4j', name: 'ini4j', version:'0.5.2'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-31 09:05:32 -04:00
|
|
|
allprojects {
|
|
|
|
// injecting groovy property variables into all projects
|
|
|
|
project.ext {
|
|
|
|
// for ide hacks...
|
|
|
|
isEclipse = System.getProperty("eclipse.launcher") != null || gradle.startParameter.taskNames.contains('eclipse') || gradle.startParameter.taskNames.contains('cleanEclipse')
|
|
|
|
isIdea = System.getProperty("idea.active") != null || gradle.startParameter.taskNames.contains('idea') || gradle.startParameter.taskNames.contains('cleanIdea')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-17 08:12:26 -05:00
|
|
|
// intellij configuration
|
2016-10-31 09:05:32 -04:00
|
|
|
allprojects {
|
|
|
|
apply plugin: 'idea'
|
|
|
|
|
|
|
|
if (isIdea) {
|
|
|
|
project.buildDir = file('build-idea')
|
|
|
|
}
|
|
|
|
idea {
|
|
|
|
module {
|
|
|
|
inheritOutputDirs = false
|
|
|
|
outputDir = file('build-idea/classes/main')
|
|
|
|
testOutputDir = file('build-idea/classes/test')
|
|
|
|
|
|
|
|
// also ignore other possible build dirs
|
|
|
|
excludeDirs += file('build')
|
|
|
|
excludeDirs += file('build-eclipse')
|
|
|
|
|
|
|
|
iml {
|
|
|
|
// fix so that Gradle idea plugin properly generates support for resource folders
|
|
|
|
// see also https://issues.gradle.org/browse/GRADLE-2975
|
|
|
|
withXml {
|
|
|
|
it.asNode().component.content.sourceFolder.findAll { it.@url == 'file://$MODULE_DIR$/src/main/resources' }.each {
|
|
|
|
it.attributes().remove('isTestSource')
|
|
|
|
it.attributes().put('type', 'java-resource')
|
|
|
|
}
|
|
|
|
it.asNode().component.content.sourceFolder.findAll { it.@url == 'file://$MODULE_DIR$/src/test/resources' }.each {
|
|
|
|
it.attributes().remove('isTestSource')
|
|
|
|
it.attributes().put('type', 'java-test-resource')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure gradle idea was run before running anything in intellij (including import).
|
|
|
|
File ideaMarker = new File(projectDir, '.local-idea-is-configured')
|
|
|
|
tasks.idea.doLast {
|
|
|
|
ideaMarker.setText('', 'UTF-8')
|
|
|
|
}
|
|
|
|
if (System.getProperty('idea.active') != null && ideaMarker.exists() == false) {
|
|
|
|
throw new GradleException('You must run gradle idea from the root of elasticsearch before importing into IntelliJ')
|
|
|
|
}
|
|
|
|
|
|
|
|
// eclipse configuration
|
|
|
|
allprojects {
|
|
|
|
apply plugin: 'eclipse'
|
|
|
|
// Name all the non-root projects after their path so that paths get grouped together when imported into eclipse.
|
|
|
|
if (path != ':') {
|
|
|
|
eclipse.project.name = path
|
2016-11-17 08:12:26 -05:00
|
|
|
if (isWindows) {
|
2016-10-31 09:05:32 -04:00
|
|
|
eclipse.project.name = eclipse.project.name.replace(':', '_')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
plugins.withType(JavaBasePlugin) {
|
|
|
|
File eclipseBuild = project.file('build-eclipse')
|
|
|
|
eclipse.classpath.defaultOutputDir = eclipseBuild
|
|
|
|
if (isEclipse) {
|
|
|
|
// set this so generated dirs will be relative to eclipse build
|
|
|
|
project.buildDir = eclipseBuild
|
|
|
|
}
|
|
|
|
eclipse.classpath.file.whenMerged { classpath ->
|
|
|
|
// give each source folder a unique corresponding output folder
|
|
|
|
int i = 0;
|
|
|
|
classpath.entries.findAll { it instanceof SourceFolder }.each { folder ->
|
|
|
|
i++;
|
|
|
|
// this is *NOT* a path or a file.
|
|
|
|
folder.output = "build-eclipse/" + i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
task copyEclipseSettings(type: Copy) {
|
|
|
|
// TODO: "package this up" for external builds
|
|
|
|
from new File(project.rootDir, 'buildSrc/src/main/resources/eclipse.settings')
|
|
|
|
into '.settings'
|
|
|
|
}
|
|
|
|
// otherwise .settings is not nuked entirely
|
|
|
|
task wipeEclipseSettings(type: Delete) {
|
|
|
|
delete '.settings'
|
|
|
|
}
|
|
|
|
tasks.cleanEclipse.dependsOn(wipeEclipseSettings)
|
|
|
|
// otherwise the eclipse merging is *super confusing*
|
|
|
|
tasks.eclipse.dependsOn(cleanEclipse, copyEclipseSettings)
|
|
|
|
}
|
|
|
|
|