forked from Illarion-eV/Illarion-Java
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
163 lines (144 loc) · 4.41 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
/*
* This file is part of the Illarion project.
*
* Copyright © 2015 - Illarion e.V.
*
* Illarion is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Illarion 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.
*/
apply plugin: 'idea'
task wrapper(type: Wrapper) {
gradleVersion = '2.7'
}
idea {
project {
languageLevel = '1.8'
}
}
allprojects {
if (project.hasProperty('targetRepo')) {
ext.mavenRepo = "file://$targetRepo"
} else {
ext.mavenRepo = "file://${project.buildDir}/repo"
}
task gitVersion { task ->
def gitVersion = 'unknown'
def branch = 'develop'
def File rootDir = project.rootDir
for (def gitCmd in ['git', 'git.cmd']) {
try {
def procBranch = "$gitCmd rev-parse --abbrev-ref HEAD".execute(null as List, rootDir)
procBranch.waitFor()
branch = procBranch.in.text.trim()
procBranch.destroy()
def procVersion = "$gitCmd describe --tags HEAD".execute(null as List, rootDir)
procVersion.waitFor()
gitVersion = procVersion.in.text.trim()
procVersion.destroy()
break
} catch (e) {
logger.error('Failed to get version from Git', e)
}
}
def String mainVersion
def indexOfSeparator = gitVersion.indexOf('-')
if (indexOfSeparator == -1) {
mainVersion = gitVersion
} else {
mainVersion = gitVersion.substring(0, indexOfSeparator)
}
if (branch == 'master') {
if (indexOfSeparator > -1) {
throw new RuntimeException("Can't build snapshot in master branch.")
}
} else {
mainVersion += '-SNAPSHOT'
}
task.project.version = mainVersion
task.project.ext.fullVersion = gitVersion
}
configurations.all {
resolutionStrategy {
cacheDynamicVersionsFor 10 * 60, 'seconds'
cacheChangingModulesFor 0, 'seconds'
}
}
repositories {
mavenCentral()
maven {
url 'http://illarion.org/media/java/maven'
}
maven {
url 'http://oss.sonatype.org/content/repositories/releases'
}
}
}
buildscript {
repositories {
mavenCentral()
maven {
url 'http://maven.ej-technologies.com/repository'
}
}
dependencies {
classpath group: 'net.sf.proguard', name: 'proguard-gradle', version: '5.1'
classpath group: 'de.undercouch', name: 'gradle-download-task', version: '2.0.0'
classpath group: 'com.install4j', name: 'gradle-plugin', version: '6.0.4'
}
}
subprojects {
group = 'org.illarion'
plugins.withType(JavaPlugin) {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
test {
useTestNG()
options {
listeners.clear()
listeners << 'org.testng.reporters.XMLReporter'
}
}
configurations {
provided
}
sourceSets {
main.compileClasspath += configurations.provided
test.compileClasspath += configurations.provided
test.runtimeClasspath += configurations.provided
}
dependencies {
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '2.0.3'
}
}
apply plugin: 'idea'
apply plugin: 'findbugs'
apply plugin: 'pmd'
findbugs {
ignoreFailures = true
effort = "max"
reportLevel = "high"
}
pmd {
ignoreFailures = true
targetJdk = '1.7'
ruleSetFiles = files(new File(rootDir, 'pmd.xml'))
ruleSets = []
}
idea {
module {
if (scopes.PROVIDED != null) {
scopes.PROVIDED.plus += configurations.provided
}
}
}
}