-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
242 lines (196 loc) · 6.66 KB
/
build.gradle
File metadata and controls
242 lines (196 loc) · 6.66 KB
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/*
* MIT License
*
* Copyright (c) 2020 NUM Technology Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
* OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
//file:noinspection SpellCheckingInspection
buildscript {
ext {
lombokVersion = '1.18.22'
}
}
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
id 'idea'
id "org.sonarqube" version "3.0"
}
repositories {
mavenLocal()
mavenCentral()
}
javadoc {
options.encoding = 'UTF-8'
failOnError=false
}
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'antlr'
apply plugin: 'maven-publish'
apply plugin: 'application'
apply plugin: 'application'
apply plugin: 'jacoco'
mainClassName = "uk.modl.server.ModlServer"
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
group = "uk.modl"
applicationName = "java-interpreter"
archivesBaseName = "java-interpreter"
version = "1.0.0"
mainClassName = "uk.modl.interpreter.Interpret"
def isSnapshot = version.endsWith("SNAPSHOT")
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.12.3'
// Dependency and config for Lombok annotations
compile("org.projectlombok:lombok:${lombokVersion}")
annotationProcessor("org.projectlombok:lombok:${lombokVersion}")
testAnnotationProcessor("org.projectlombok:lombok:${lombokVersion}")
compile group: 'org.slf4j', name: 'log4j-over-slf4j', version: '1.7.29'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.17.1'
// https://mvnrepository.com/artifact/io.vavr/vavr
compile 'io.vavr:vavr:0.10.4'
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
classifier 'sources'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc
classifier 'javadoc'
}
artifacts {
archives jar
archives sourceJar
archives javadocJar
}
/***********
* MAVEN PUBLISHING
***********/
def fatJarFile = file("$buildDir/libs/interpreter-" + version + ".jar")
def fatJarArtifact = artifacts.add('archives', fatJarFile) {
builtBy('customFatJar')
}
publishing {
publications {
mavenJava(MavenPublication) {
customisePom(pom)
groupId = "uk.modl"
artifactId = 'java-interpreter'
from components.java
artifact(sourceJar) {
classifier = 'sources'
}
artifact(javadocJar) {
classifier = 'javadoc'
}
artifact(fatJarArtifact) {
classifier = 'exe'
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoUrl = "$buildDir/repos/snapshots"
url = isSnapshot ? snapshotsRepoUrl : releasesRepoUrl
if (!isSnapshot) {
def stUser
def stPwd
if (project.hasProperty('sonatypeUsername')) {
stUser = sonatypeUsername
} else {
stUser = "notdefined"
logger.warn("sonatypeUsername not defined. Please update your gradle config file")
}
if (project.hasProperty('sonatypePassword')) {
stPwd = sonatypePassword
} else {
stPwd = "notdefined"
logger.warn("sonatypePassword not defined. Please update your gradle config file")
}
credentials {
username stUser
password stPwd
}
}
}
}
}
signing {
required {
// signing is required if this is a release version and the artifacts are to be published
!isSnapshot && tasks.withType(PublishToMavenRepository).find {
gradle.taskGraph.hasTask it
}
}
sign publishing.publications
}
def customisePom(pom) {
pom.withXml {
def root = asNode()
// eliminate test-scoped dependencies (no need in maven central POMs)
root.dependencies.removeAll { dep ->
dep.scope == "test"
}
// add all items necessary for maven central publication
root.children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name 'java-interpreter'
description 'Java interpreter for MODL language'
url 'https://github.com/MODLanguage/java-interpreter'
licenses {
license {
name 'MIT license'
url 'https://opensource.org/licenses/MIT'
distribution 'repo'
}
}
scm {
connection 'scm:git:git://MODLanguage/java-interpreter.git'
developerConnection 'scm:git:git://MODLanguage/java-interpreter.git'
url 'https://github.com/MODLanguage/java-interpreter'
}
developers {
developer {
id 'tony.walmsley@num.uk'
name 'Tony Walmsley'
email 'tony.walmsley@num.uk'
}
}
}
}
}
task customFatJar(type: Jar) {
manifest {
attributes 'Main-Class': 'Interpret'
}
baseName = 'interpreter'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
// ====== JACOCO TEST COVERAGE ======
jacocoTestReport {
reports {
xml.enabled true
}
}
test.finalizedBy jacocoTestReport