forked from cjbooms/fabrikt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
170 lines (149 loc) · 6.02 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.dokka.gradle.DokkaTask
plugins {
id("org.jetbrains.kotlin.jvm") version "1.4.0" // Apply the Kotlin JVM plugin to add support for Kotlin.
id("com.github.johnrengelman.shadow") version "4.0.1"
id("org.jetbrains.dokka") version "0.10.1"
id("com.palantir.git-version") version "0.12.3"
id("maven-publish")
id("signing")
`java-library` // For API and implementation separation.
}
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"
repositories {
jcenter()
}
dependencies {
val jacksonVersion = "2.9.8"
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("com.github.jknack:handlebars:4.1.0")
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.74")
implementation("com.reprezen.kaizen:openapi-parser:4.0.4") { exclude(group = "junit") }
implementation("com.reprezen.jsonoverlay:jsonoverlay:4.0.3")
implementation("com.squareup:kotlinpoet:1.3.0") { exclude(module = "kotlin-stdlib-jre7") }
implementation("com.google.flogger:flogger:0.4")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.1.0")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.1.0")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.1.0")
testImplementation("org.assertj:assertj-core:3.14.0")
// Below dependencies are solely present so code examples in the test resources dir compile
testImplementation("javax.validation:validation-api:2.0.1.Final")
testImplementation("org.springframework:spring-webmvc:5.1.9.RELEASE")
testImplementation("com.squareup.okhttp3:okhttp:4.9.1")
testImplementation("com.pinterest.ktlint:ktlint-core:0.41.0")
testImplementation("com.pinterest:ktlint:0.41.0")
}
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 by getting(DokkaTask::class) {
outputFormat = "html"
outputDirectory = "$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")
main = "com.cjbooms.fabrikt.cli.CodeGen"
args = listOf("--help")
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
}
}
withType<Test> {
useJUnitPlatform()
}
}
publishing {
repositories {
maven {
name = "OSSRH"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2")
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_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"])
}