Skip to content

Commit bb866e4

Browse files
committed
Build shadow jar
1 parent 009856f commit bb866e4

1 file changed

Lines changed: 42 additions & 45 deletions

File tree

build.gradle

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
21
plugins {
32
id 'java-library'
43
id 'signing'
54
id 'idea'
65
id 'maven-publish'
76
id 'io.freefair.lombok' version '8.6'
7+
id 'com.github.johnrengelman.shadow' version '8.1.1'
88
}
99

10-
1110
repositories {
1211
mavenCentral()
1312
}
1413

15-
16-
group 'org.chronos-eaas'
17-
archivesBaseName = "chronos-agent"
18-
version '2.5.0-SNAPSHOT'
19-
20-
description = "Chronos Agent"
21-
14+
group = 'org.chronos-eaas'
15+
archivesBaseName = 'chronos-agent'
16+
version = '2.5.0-SNAPSHOT'
17+
description = 'Chronos Agent'
2218

2319
java {
2420
sourceCompatibility = JavaVersion.VERSION_11
@@ -27,7 +23,6 @@ java {
2723
withSourcesJar()
2824
}
2925

30-
3126
dependencies {
3227
implementation group: 'com.konghq', name: 'unirest-java-core', version: '4.4.4' // MIT
3328
implementation group: 'com.konghq', name: 'unirest-object-mappers-gson', version: '4.2.9' // MIT
@@ -41,54 +36,62 @@ dependencies {
4136
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.13' // MIT
4237
}
4338

44-
45-
tasks.withType(JavaCompile).configureEach {
39+
tasks.withType(JavaCompile) {
4640
options.encoding = 'UTF-8'
4741
}
4842

49-
5043
jar {
5144
manifest {
52-
attributes 'Manifest-Version': '1.0'
53-
attributes 'Copyright': 'The Chronos Project'
54-
attributes 'Group': project.group
55-
attributes 'Name': project.name
56-
attributes 'Version': project.version
45+
attributes(
46+
'Manifest-Version': '1.0',
47+
'Copyright': 'The Chronos Project',
48+
'Group': project.group,
49+
'Name': project.name,
50+
'Version': project.version
51+
)
5752
}
53+
dependsOn shadowJar
5854
}
5955

60-
/*shadowJar {
56+
shadowJar {
6157
archiveClassifier.set('shadow')
62-
}*/
63-
58+
manifest {
59+
attributes(
60+
'Manifest-Version': '1.0',
61+
'Copyright': 'The Chronos Project',
62+
'Group': project.group,
63+
'Name': project.name,
64+
'Version': project.version
65+
)
66+
}
67+
}
6468

6569
javadoc {
6670
failOnError = false
6771
}
6872

69-
7073
publishing {
7174
publications {
7275
mavenJava(MavenPublication) {
7376
from components.java
7477
pom {
75-
name = 'Chronos Agent'
76-
description = 'Reference implementation of a Chronos Agent.'
77-
url = 'https://chronos-eaas.org/'
78+
name.set('Chronos Agent')
79+
description.set('Reference implementation of a Chronos Agent.')
80+
url.set('https://chronos-eaas.org/')
7881
licenses {
7982
license {
80-
name = 'MIT License'
81-
url = 'https://opensource.org/licenses/MIT'
83+
name.set('MIT License')
84+
url.set('https://opensource.org/licenses/MIT')
8285
}
8386
}
8487
scm {
85-
url = 'https://github.com/Chronos-EaaS/Chronos-Agent/'
88+
url.set('https://github.com/Chronos-EaaS/Chronos-Agent/')
8689
}
8790
developers {
8891
developer {
89-
id = 'chronos'
90-
name = 'Chronos'
91-
email = 'mail@chronos-eaas.org'
92+
id.set('chronos')
93+
name.set('Chronos')
94+
email.set('mail@chronos-eaas.org')
9295
}
9396
}
9497
}
@@ -97,43 +100,37 @@ publishing {
97100
repositories {
98101
maven {
99102
name = "OSSRH"
100-
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
101-
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
102-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
103+
url = uri(version.endsWith('SNAPSHOT') ?
104+
"https://s01.oss.sonatype.org/content/repositories/snapshots/" :
105+
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
103106
credentials {
104107
username = System.getenv("MAVEN_USERNAME")
105108
password = System.getenv("MAVEN_PASSWORD")
106109
}
107110
}
108111
maven {
109112
name = "GitHubPackages"
110-
url = "https://maven.pkg.github.com/chronos-eaas/chronos-agent"
113+
url = uri("https://maven.pkg.github.com/chronos-eaas/chronos-agent")
111114
credentials {
112115
username = System.getenv("GITHUB_ACTOR")
113116
password = System.getenv("GITHUB_TOKEN")
114117
}
115118
}
116119
}
117120
}
118-
//task generatePom(group: 'publishing', dependsOn: "generatePomFileFor${project.name.capitalize()}Publication")
119-
120121

121122
signing {
122123
required { gradle.taskGraph.hasTask("publish") }
123-
def signingKey = findProperty("signingKey")
124-
def signingPassword = findProperty("signingPassword")
125-
useInMemoryPgpKeys(signingKey, signingPassword)
126-
sign publishing.publications.mavenJava
124+
useInMemoryPgpKeys(findProperty("signingKey"), findProperty("signingPassword"))
125+
sign(publishing.publications["mavenJava"])
127126
}
128127

129-
130128
idea {
131129
module {
132130
downloadJavadoc = true
133131
downloadSources = true
134-
135132
inheritOutputDirs = false
136-
outputDir = file("${project.buildDir}/classes/main")
137-
testOutputDir = file("${project.buildDir}/classes/test")
133+
outputDir = file("$buildDir/classes/main")
134+
testOutputDir = file("$buildDir/classes/test")
138135
}
139136
}

0 commit comments

Comments
 (0)