-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
144 lines (113 loc) · 3.67 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
plugins {
id "application"
}
ext {
slf4jVersion = "1.7.28"
lombokVersion = "1.18.16"
jvmVersion = JavaVersion.VERSION_13
}
description = "Protop CLI"
allprojects {
group = "io.protop"
version = "0.8.0"
apply plugin: "java"
repositories {
mavenLocal()
mavenCentral()
}
}
java {
sourceCompatibility = jvmVersion
targetCompatibility = jvmVersion
}
subprojects {
dependencies {
implementation "com.google.guava:guava:27.0.1-jre"
implementation "com.fasterxml.jackson.core:jackson-databind:2.9.9.3"
implementation "com.fasterxml.jackson.core:jackson-annotations:2.9.9"
implementation "javax.validation:validation-api:2.0.1.Final"
implementation "commons-io:commons-io:2.6"
implementation "ch.qos.logback:logback-classic:1.2.3"
implementation "io.reactivex.rxjava2:rxjava:2.2.17"
compileOnly "org.projectlombok:lombok:$lombokVersion"
compileOnly "javax.annotation:javax.annotation-api:1.3.2"
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
testImplementation "junit:junit:4.12"
}
tasks.withType(org.gradle.api.tasks.javadoc.Javadoc).all { enabled = false }
java {
sourceCompatibility = jvmVersion
targetCompatibility = jvmVersion
}
}
dependencies {
implementation project(":protop-cli")
}
def DIST_NAME = "protop-${project.version}"
def DIST_JAR_NAME = "protop.jar"
def MANIFEST_NAME = "MANIFEST.MF"
task distFatJar(type: Jar) {
description = 'Assembles a jar archive containing all dependencies.'
group = 'Distribution'
archiveFileName = DIST_JAR_NAME
manifest {
attributes (
'Protop-Version' : project.version,
'Built-By' : System.properties['user.name'],
'Build-Timestamp': new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
'Created-By' : "Gradle ${gradle.gradleVersion}",
'Build-Jdk' : "${System.properties['java.revision']}",
"Main-Class" : "io.protop.cli.ProtopCli"
)
}
from sourceSets.main.output
// Do the rest of this task as such because https://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
doFirst {
from configurations.runtimeClasspath.
findAll { it.name.endsWith('jar') }.
collect { zipTree(it) }
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}
tasks.register('executable') {
description = 'Assembles an executable from the fat jar.'
group = 'Build'
dependsOn distFatJar
final outputFile = file("${buildDir}/bin/protop")
inputs.files tasks.distFatJar.outputs.files.getSingleFile()
outputs.file outputFile
doFirst {
mkdir outputFile.getParent()
}
doLast {
outputFile.text = '#!/bin/bash\n'
outputFile.append('exec java -jar "$0" "$@"\n')
outputFile.append(inputs.files.first().readBytes())
outputFile.setExecutable(true)
}
}
plugins.withType(DistributionPlugin) {
distZip {
archiveFileName = "${DIST_NAME}.zip"
if (!project.hasProperty("dev")) {
include(DIST_JAR_NAME)
include(MANIFEST_NAME)
}
}
distTar {
compression = Compression.GZIP
archiveFileName = "${DIST_NAME}.tgz"
if (!project.hasProperty("dev")) {
include(DIST_JAR_NAME)
include(MANIFEST_NAME)
}
}
}
distributions {
main {
contents {
from distFatJar
}
}
}
mainClassName = "io.protop.cli.ProtopCli"