-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathbuild.gradle.kts
196 lines (172 loc) · 7.37 KB
/
build.gradle.kts
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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.dokka.gradle.DokkaTask
plugins {
id("org.jetbrains.kotlin.jvm") version "2.0.20"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("org.jetbrains.dokka") version "1.8.10"
id("com.palantir.git-version") version "3.0.0"
id("maven-publish")
id("signing")
`java-library` // For API and implementation separation.
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
val executableName = "fabrikt"
group = "com.cjbooms"
val gitVersion: groovy.lang.Closure<*> by extra
version = gitVersion.call()
val projectUrl = "https://github.com/cjbooms/fabrikt"
val projectScmUrl = "scm:https://[email protected]/cjbooms/fabrikt.git"
val projectScmConUrl = "scm:https://[email protected]/cjbooms/fabrikt.git"
val projectScmDevUrl = "scm:git://github.com/cjbooms/fabrikt.git"
val projectIssueUrl = "https://github.com/cjbooms/fabrikt/issues"
val projectName = "Fabrikt"
val projectDesc = "Fabricates Kotlin code from OpenApi3 specifications"
val projectLicenseName = "Apache License 2.0"
val projectLicenseUrl = "https://opensource.org/licenses/Apache-2.0"
allprojects {
repositories {
mavenCentral()
}
}
val jacksonVersion by extra { "2.15.1" }
val junitVersion by extra { "5.9.2" }
val ktorVersion by extra { "3.0.1" }
val kotlinxSerializationVersion by extra { "1.7.3" }
val kotlinxDateTimeVersion by extra { "0.6.1" }
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("com.github.jknack:handlebars:4.3.1")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion")
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
implementation("com.fasterxml.jackson.core:jackson-core:$jacksonVersion")
implementation("com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:$jacksonVersion")
implementation("com.beust:jcommander:1.82")
implementation("com.reprezen.kaizen:openapi-parser:4.0.4") { exclude(group = "junit") }
implementation("com.reprezen.jsonoverlay:jsonoverlay:4.0.4")
implementation("com.squareup:kotlinpoet:1.14.2") { exclude(module = "kotlin-stdlib-jre7") }
implementation("com.google.flogger:flogger:0.7.4")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinxSerializationVersion")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:$kotlinxDateTimeVersion")
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitVersion")
testImplementation("org.assertj:assertj-core:3.24.2")
// Below dependencies are solely present so code examples in the test resources dir compile
testImplementation("javax.validation:validation-api:2.0.1.Final")
testImplementation("jakarta.validation:jakarta.validation-api:3.0.2")
testImplementation("org.springframework:spring-webmvc:6.0.9")
testImplementation("org.springframework.security:spring-security-web:6.1.0")
testImplementation("io.micronaut:micronaut-core:3.8.7")
testImplementation("io.micronaut:micronaut-http:3.8.7")
//testCompileOnly("io.micronaut.security:micronaut-security:3.8.7")
testImplementation("com.squareup.okhttp3:okhttp:4.10.0")
testImplementation("org.openapitools:jackson-databind-nullable:0.2.6")
testImplementation("io.ktor:ktor-server-core:$ktorVersion")
testImplementation("io.ktor:ktor-server-auth:$ktorVersion")
testImplementation(platform("com.pinterest.ktlint:ktlint-bom:0.49.0"))
testImplementation("com.pinterest:ktlint")
testImplementation("com.pinterest.ktlint:ktlint-core")
testImplementation("com.pinterest.ktlint:ktlint-rule-engine")
testImplementation("com.pinterest.ktlint:ktlint-ruleset-standard")
}
tasks {
val shadowJar by getting(ShadowJar::class) {
manifest {
attributes["Main-Class"] = "com.cjbooms.fabrikt.cli.CodeGen"
attributes["Implementation-Title"] = "fabrikt"
attributes["Implementation-Version"] = project.version
attributes["Built-JDK"] = System.getProperty("java.version")
attributes["Built-Gradle"] = gradle.gradleVersion
}
archiveBaseName.set(executableName)
archiveClassifier.set("")
}
val dokka = getByName<DokkaTask>("dokkaHtml") {
outputDirectory.set(file("$buildDir/dokka"))
}
create("sourcesJar", Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.getByName("main").allSource)
}
create("kotlinDocJar", Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles Kotlin docs with Dokka"
archiveClassifier.set("javadoc")
from(dokka)
dependsOn(dokka)
}
create("printCodeGenUsage", JavaExec::class) {
dependsOn(shadowJar)
classpath = project.files("./build/libs/$executableName-$version.jar")
mainClass.set("com.cjbooms.fabrikt.cli.CodeGen")
args = listOf("--help")
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
}
withType<Test> {
useJUnitPlatform()
jvmArgs = listOf("--add-opens=java.base/java.lang=ALL-UNNAMED", "--add-opens=java.base/java.util=ALL-UNNAMED")
}
}
publishing {
repositories {
maven {
name = "OSSRH"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2")
credentials {
username = System.getenv("OSSRH_USER_TOKEN_USERNAME")
password = System.getenv("OSSRH_USER_TOKEN_PASSWORD")
}
}
}
publications {
create<MavenPublication>("fabrikt") {
artifact(tasks["shadowJar"])
artifact(tasks["sourcesJar"])
artifact(tasks["kotlinDocJar"])
pom {
name.set(projectName)
description.set(projectDesc)
url.set(projectUrl)
inceptionYear.set("2020")
licenses {
license {
name.set(projectLicenseName)
url.set(projectLicenseUrl)
}
}
developers {
developer {
id.set("cjbooms")
name.set("Conor Gallagher")
email.set("[email protected]")
}
developer {
id.set("averabaq")
name.set("Alejandro Vera-Baquero")
email.set("[email protected]")
}
}
scm {
connection.set(projectScmConUrl)
developerConnection.set(projectScmDevUrl)
url.set(projectScmUrl)
}
}
}
}
}
signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications["fabrikt"])
}