-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
114 lines (97 loc) · 3.72 KB
/
build.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
project.ext {
versions = [java: "1.7"]
scalaLangLevel = 'Scala 2.11.2'
}
buildscript {
dependencies {
classpath 'com.andrewkroh.gradle:gradle-protobuf-plugin:0.3.0'
classpath "com.github.nullstress:DependencyAnalysisPlugin:1.0.3"
}
repositories {
mavenCentral()
mavenLocal()
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
allprojects {
apply plugin: 'idea'
plugins.withType(ScalaPlugin).whenPluginAdded {
dependencies { compile "org.scala-lang:scala-library:2.11.2" }
tasks.withType(ScalaCompile) {
scalaCompileOptions.fork = true
scalaCompileOptions.forkOptions.jvmArgs = ['-XX:MaxPermSize=1024m']
scalaCompileOptions.useAnt = false
scalaCompileOptions.deprecation = true
scalaCompileOptions.unchecked = true
scalaCompileOptions.additionalParameters = ["-language:_"]
}
idea.module.iml.withXml { p -> addScalaLangLevelToIdea(p) }
}
idea.module.iml.generateTo = file("${rootDir}/idea")
idea.module {
excludeDirs += file("${projectDir}/target")
excludeDirs -= buildDir
buildDir.listFiles().findAll{it.name != 'generated'}.each{excludeDirs += it}
['java', 'scala', 'resources'].each { lang ->
def dir = file("${projectDir}/src/main/${lang}")
if (dir.exists()) {
sourceDirs += dir
}
['test', 'perf'].each { type ->
dir = file("${projectDir}/src/${type}/${lang}")
if (dir.exists()) {
testSourceDirs += dir
}
}
}
def protoDir = file("${projectDir}/src/main/proto")
if (protoDir.exists()) {
def genDir = file("${buildDir}/generated/java")
sourceDirs += genDir
idea.module.iml.withXml { p -> addProtobufFacet(p, genDir) }
}
}
repositories {
mavenCentral()
mavenLocal()
}
}
idea.project {
languageLevel = versions.java
outputFile = file("${rootDir}/idea/midonet.ipr")
}
idea.module {
inheritOutputDirs = false
outputDir = file("${rootDir}/idea/out/${project.name}")
testOutputDir = file("${rootDir}/idea/test/${project.name}")
}
def getOrAddComponent(iml, name) {
iml.asNode().component.find { it.@name == name } ?:
iml.asNode().appendNode('component', [name: name])
}
def addScalaLangLevelToIdea(iml) {
def facets = getOrAddComponent(iml, 'FacetManager')
def scala = facets.facet.find { it.@type == 'scala' } ?:
facets.appendNode('facet', [type: 'scala', name: 'Scala'])
def config = scala.configuration ? scala.configuration[0] :
scala.appendNode('configuration', [])
config.option.find { it.@name == 'languageLevel' } ?:
config.appendNode('option', ['name': 'languageLevel',
'value': scalaLangLevel])
}
def addProtobufFacet(iml, generatedDir) {
def facets = getOrAddComponent(iml, 'FacetManager')
def protobuf = facets.facet.find { it.@type == 'protobuf' } ?:
facets.appendNode('facet', [type: 'protobuf', name: 'Protobuf Facet'])
def config = protobuf.configuration ? protobuf.configuration[0] :
protobuf.appendNode('configuration', [])
config.option.find { it.@name == 'COMPILER_OUTPUT_SOURCE_DIRECTORY' } ?:
config.appendNode('option', ['name': 'COMPILER_OUTPUT_SOURCE_DIRECTORY',
'value': generatedDir])
}
task wrapper(type: Wrapper) {
description 'Generate wrapper, which is distributed as part of source to alleviate the need of installing gradle'
gradleVersion = '2.1'
}