-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
165 lines (132 loc) · 5.06 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
This file is part of Octetoscope.
Copyright (C) 2013-2016 Octetoscope contributors (see /AUTHORS.txt)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import org.apache.tools.ant.DirectoryScanner
import org.apache.tools.ant.filters.FixCrLfFilter
apply plugin: 'base'
def getVersionInfo() {
def versionFile = file('version.gradle')
if (versionFile.exists()) {
def versionInfo = new VersionInfo(extraCommits: 0, commitHash: '0' * 40, dirty: false)
apply from: versionFile, to: versionInfo
if (versionInfo.releaseVersion == null)
throw new InvalidUserDataException('version.gradle provided, but doesn\'t set releaseVersion')
return versionInfo
} else {
return BuildUtils.getVersionInfo(project, 'release-')
}
}
version = getVersionInfo()
ext {
def scalaMajorVersion = '2.11'
deps = [
scalaLibrary: "org.scala-lang:scala-library:$scalaMajorVersion.8",
scalaTest: "org.scalatest:scalatest_$scalaMajorVersion:2.2.6",
icu: 'com.ibm.icu:icu4j:57.1',
arm: "com.jsuereth:scala-arm_$scalaMajorVersion:1.4",
]
}
subprojects {
apply plugin: 'scala'
repositories {
mavenCentral()
}
dependencies {
compile deps.scalaLibrary
testCompile deps.scalaTest
}
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
test << {
ant.taskdef(name: 'scalatest', classname: 'org.scalatest.tools.ScalaTestAntTask', classpath: classpath.asPath)
ant.scalatest(runpath: testClassesDir, haltonfailure: 'true', fork: 'false') {
reporter(type: 'stderr')
}
}
}
task installLauncher(type: Jar) {
from project(':application').sourceSets.main.output
archiveName 'octetoscope.jar'
destinationDir new File(buildDir, 'install/bin')
manifest {
attributes('Class-Path':
"${-> project(':application').configurations.runtime.collect{'../lib/' + it.name}.join(' ')}")
attributes('Main-Class': 'ru.corrigendum.octetoscope.application.Octetoscope')
}
}
task installLibs(type: Sync) {
from project(':application').configurations.runtime
into new File(buildDir, 'install/lib')
}
task install(dependsOn: [installLauncher, installLibs])
// Using CRLFs as line endings in distributions, since that's the lowest common denominator.
def exportEOL = FixCrLfFilter.CrLf.newInstance('crlf')
// Gradle uses Ant's default excludes list when finding files to copy, which includes things
// like .gitattributes and .gitignore, which we don't want to exclude when building the source
// distribution. And we don't know for sure what else it might exclude, so it's best to empty it
// entirely. It shouldn't matter at all for our other copy-like tasks, since we never copy from
// directories that might have something ignorable in them.
// See also <https://issues.gradle.org/browse/GRADLE-1883>.
DirectoryScanner.defaultExcludes.each { DirectoryScanner.removeDefaultExclude(it) }
task distBinary(type: Zip) {
classifier 'bin'
into "$baseName-$version-$classifier"
dirMode 0755
fileMode 0644
from(installLauncher.outputs) {
into 'bin'
fileMode 0755
}
from(installLibs.outputs) {
into 'lib'
}
from(['AUTHORS.txt', 'COPYING.txt', 'README.txt']) {
filter(FixCrLfFilter, eol: exportEOL)
}
}
task generateVersionGradle(type: GenerateFileTask) {
text = """\
releaseVersion = '$version.releaseVersion'
extraCommits = $version.extraCommits
commitHash = '$version.commitHash'
dirty = $version.dirty
""".stripIndent()
outputPath = new File(buildDir, 'generated/version.gradle')
}
task configureDistSource << {
// This is in a separate task in order to defer the exported file enumeration until execution
// time. This means we won't have to perform it when we run tasks unrelated to distSource.
BuildUtils.getExportedFiles(rootProject).each { f ->
// If we're building _from_ a source distribution, there's a version.gradle
// in our work directory. We don't want to include that, or we'll end up with
// two version.gradle files in the archive.
if (f.path == 'version.gradle') return
distSource.from(f.path) {
into RelativePath.parse(true, f.path).parent.pathString
if (f.executable) fileMode 0755
if (f.containsNativeText) filter(FixCrLfFilter, eol: exportEOL)
}
}
}
task distSource(type: Zip, dependsOn: configureDistSource) {
classifier 'src'
into "$baseName-$version-$classifier"
dirMode 0755
fileMode 0644
from(generateVersionGradle.outputs) {
filter(FixCrLfFilter, eol: exportEOL)
}
}
task dist(dependsOn: [distBinary, distSource])
defaultTasks 'build', 'install'