-
Notifications
You must be signed in to change notification settings - Fork 118
/
build.gradle
220 lines (182 loc) · 7.18 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'idea'
archivesBaseName = 'procyon'
ext.getProcyonVersion = { ->
final def fallbackVersion = "1.0-SNAPSHOT"
final def versionFilePath = rootDir.canonicalPath + "/Procyon.Core/src/main/java/com/strobel/Procyon.java"
final def versionFile = new File(versionFilePath)
if (versionFile.exists()) {
try {
final String fileContents = new File(versionFilePath).getText('UTF-8')
final def matcher = fileContents =~ /VERSION\s*=\s*"([^"]+)"/
if (matcher.find()) {
return matcher.group(1).trim()
}
}
catch (final Throwable ignored) {
}
}
logger.warn("WARNING: Could not resolve version from source; falling back to '$fallbackVersion'.")
return fallbackVersion
}
final def procyonVersion = getProcyonVersion()
allprojects {
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'maven'
buildDir = rootDir.canonicalPath + "/build/" + rootProject.relativePath(projectDir.canonicalPath)
version procyonVersion
group 'com.github.mstrobel'
sourceCompatibility = 1.7 // JDK version
repositories {
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.13.2'
}
}
//
// The root project is empty and doesn't need any tasks.
//
rootProject.tasks.each { it.enabled = false }
rootProject.tasks.withType(DefaultTask).each { it.enabled = true }
rootProject.uploadArchives.enabled = false
subprojects {
apply plugin: 'maven'
apply plugin: 'signing'
final boolean shouldSign = "true".equalsIgnoreCase(System.properties.getProperty("procyon.signing.enabled"))
archivesBaseName = "procyon-${(it.name as String).split('\\.')[1].toLowerCase()}"
jar {
metaInf {
from 'License.txt'
from 'README.md'
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
tasks.withType(Test) {
testLogging {
// set options for log level LIFECYCLE
events TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED
exceptionFormat TestExceptionFormat.FULL
showExceptions true
showCauses true
showStackTraces true
// set options for log level DEBUG and INFO
debug.with {
events TestLogEvent.STARTED,
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT
exceptionFormat TestExceptionFormat.FULL
}
info.events = debug.events
info.exceptionFormat = debug.exceptionFormat
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length() - 2
logger.lifecycle('\n' + '+' + ('-' * repeatLength) + '+' + '\n' + startItem + output + endItem + '\n' + '+' + ('-' * repeatLength) + '+')
}
}
}
}
if (project.name == "Procyon.Decompiler") {
artifacts {
archives jar
}
}
else {
javadoc {
options.encoding = 'UTF-8'
}
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
if (shouldSign) {
signing {
sign configurations.archives
}
}
uploadArchives {
repositories.mavenDeployer {
if (shouldSign) {
beforeDeployment { MavenDeployment deployment ->
signing.signPom(deployment)
}
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots") {
authentication(userName: project.properties.get("procyon.sonatype.username"),
password: project.properties.get("procyon.sonatype.password"))
}
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2") {
authentication(userName: project.properties.get("procyon.sonatype.username"),
password: project.properties.get("procyon.sonatype.password"))
}
pom {
groupId = project.group
version = project.version
artifactId = project.archivesBaseName
project {
name project.archivesBaseName
packaging 'jar'
description 'Procyon'
url 'https://github.com/mstrobel/procyon'
scm {
url 'https://github.com/mstrobel/procyon'
connection 'scm:git:https://github.com/mstrobel/procyon.git'
developerConnection 'scm:git:https://mstrobel@github.com/mstrobel/procyon.git'
}
issueManagement {
system 'github'
url 'https://github.com/mstrobel/procyon/issues'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'mstrobel'
name 'Mike Strobel'
roles {
role 'owner'
role 'packager'
role 'developer'
}
}
}
dependencies {
dependency {
groupId 'junit'
artifactId 'junit'
version '4.11'
scope 'test'
// optional = true
}
}
}
}
}
}
}
}