-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
185 lines (152 loc) · 4.83 KB
/
build.gradle.kts
File metadata and controls
185 lines (152 loc) · 4.83 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
plugins {
groovy
id("java-library")
id("maven-publish")
id("signing")
id("com.github.ben-manes.versions") version ("0.41.0")
id("io.github.gradle-nexus.publish-plugin") version ("1.1.0")
}
val projectGroupId: String by project
val projectVersion: String by project
group = projectGroupId
version = projectVersion
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
fun getBuildProperty(property: String): String {
val prop: String? = project.findProperty(property) as String?
if(prop != null) {
return prop
}
val env: String? = System.getenv(property)
if (env != null) {
return env
}
return "n/a"
}
fun getBuildSignKey(property: String): String {
val prop: String? = project.findProperty(property) as String?
if(prop != null) {
return prop
}
val env: String? = System.getenv(property)
if (env != null) {
return env.replace("\\n", "\n")
}
return "n/a"
}
fun isReleaseVersion(): Boolean {
return !(project.version.toString().endsWith("SNAPSHOT"))
}
ext {
set("publishUser", getBuildProperty("PUBLISH_USER"))
set("publishKey", getBuildProperty("PUBLISH_KEY"))
set("signKey", getBuildSignKey("SIGN_KEY"))
set("signPwd", getBuildProperty("SIGN_PWD"))
}
repositories {
mavenCentral()
maven {
setUrl("https://oss.sonatype.org/content/repositories/snapshots")
mavenContent {
snapshotsOnly()
}
}
}
dependencies {
compileOnly("io.openapiprocessor:openapi-processor-api:2021.1")
implementation(platform("com.fasterxml.jackson:jackson-bom:2.13.1"))
implementation(platform("org.codehaus.groovy:groovy-bom:3.0.9"))
implementation("org.codehaus.groovy:groovy")
implementation("org.codehaus.groovy:groovy-nio")
implementation("com.fasterxml.jackson.core:jackson-databind")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
implementation("io.github.java-diff-utils:java-diff-utils:4.11")
implementation("com.google.jimfs:jimfs:1.2") {
exclude("com.google.guava")
}
}
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val javadocJar by tasks.registering(Jar::class) {
dependsOn("javadoc")
archiveClassifier.set("javadoc")
from(tasks.javadoc.get().destinationDir)
}
artifacts {
archives(sourcesJar)
archives(javadocJar)
}
//apply(from = "${rootProject.rootDir}/gradle/publishing.gradle.kts")
val projectTitle: String by project
val projectDesc: String by project
val projectUrl: String by project
val projectGithubRepo: String by project
// does not work on oss.sonatype.org
tasks.withType<GenerateModuleMetadata>().configureEach {
enabled = false
}
publishing {
publications {
create<MavenPublication>("OpenApiProcessor") {
from(components["java"])
artifact(sourcesJar.get())
artifact(javadocJar.get())
groupId = project.group.toString()
artifactId = project.name
version = project.version.toString()
pom {
name.set(projectTitle)
description.set(projectDesc)
url.set(projectUrl)
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("hauner")
name.set("Martin Hauner")
}
}
scm {
url.set("https://github.com/${projectGithubRepo}")
}
}
}
}
repositories {
maven {
val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = uri(if (isReleaseVersion()) releasesRepoUrl else snapshotsRepoUrl)
credentials {
username = project.extra["publishUser"].toString()
password = project.extra["publishKey"].toString()
}
}
}
}
//tasks.withType<Sign>().configureEach {
// onlyIf { isReleaseVersion() }
//}
signing {
useInMemoryPgpKeys(
project.extra["signKey"].toString(),
project.extra["signPwd"].toString())
sign(publishing.publications["OpenApiProcessor"])
}
nexusPublishing {
repositories {
sonatype {
username.set(project.extra["publishUser"].toString())
password.set(project.extra["publishKey"].toString())
}
}
}