-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
163 lines (141 loc) · 4.46 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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import java.io.ByteArrayOutputStream
import java.io.FileOutputStream
import java.util.Properties
plugins {
kotlin("jvm") version "1.6.20"
application
`maven-publish`
}
val properties = "$buildDir/properties"
object Versions {
// Language
const val kotlin = "1.6.20"
const val kotlinLanguage = "1.6"
const val kotlinApi = "1.6"
const val jvmTarget = "1.8"
// Deps
const val guava = "31.1-jre"
const val jansi = "2.4.0"
const val jline = "3.21.0"
const val junit5 = "5.9.3"
const val picoCli = "4.7.0"
const val partiql = "0.14.9"
}
object Deps {
const val jansi = "org.fusesource.jansi:jansi:${Versions.jansi}"
const val jline = "org.jline:jline:${Versions.jline}"
const val junitParams = "org.junit.jupiter:junit-jupiter-params:${Versions.junit5}"
const val kotlinTest = "org.jetbrains.kotlin:kotlin-test:${Versions.kotlin}"
const val kotlinTestJunit = "org.jetbrains.kotlin:kotlin-test-junit5:${Versions.kotlin}"
const val picoCli = "info.picocli:picocli:${Versions.picoCli}"
const val partiql = "org.partiql:partiql-lang-kotlin:${Versions.partiql}"
}
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
api(Deps.partiql)
implementation(Deps.jansi)
implementation(Deps.jline)
implementation(Deps.picoCli)
// Test
testImplementation(Deps.kotlinTest)
testImplementation(Deps.kotlinTestJunit)
testImplementation(Deps.junitParams)
}
java {
sourceCompatibility = JavaVersion.toVersion(Versions.jvmTarget)
targetCompatibility = JavaVersion.toVersion(Versions.jvmTarget)
withJavadocJar()
withSourcesJar()
}
tasks.compileKotlin {
kotlinOptions.jvmTarget = Versions.jvmTarget
kotlinOptions.apiVersion = Versions.kotlinApi
kotlinOptions.languageVersion = Versions.kotlinLanguage
kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
}
tasks.compileTestKotlin {
kotlinOptions.jvmTarget = Versions.jvmTarget
kotlinOptions.apiVersion = Versions.kotlinApi
kotlinOptions.languageVersion = Versions.kotlinLanguage
kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
}
tasks.test {
useJUnitPlatform()
testLogging {
events.add(TestLogEvent.FAILED)
exceptionFormat = TestExceptionFormat.FULL
}
}
kotlin {
explicitApi = null
}
sourceSets {
main {
output.dir(properties)
}
}
application {
applicationName = "scribe"
mainClass.set("org.partiql.scribe.shell.Main")
}
tasks.register<GradleBuild>("install") {
tasks = listOf("assembleDist", "distZip", "installDist")
}
tasks.processResources {
dependsOn(tasks.findByName("generateProperties"))
}
tasks.create("generateProperties") {
val propertiesFile = file("$properties/scribe.properties")
val commit = ByteArrayOutputStream().apply {
exec {
commandLine = listOf("git", "rev-parse", "--short", "HEAD")
standardOutput = this@apply
}
}
// write properties
propertiesFile.parentFile.mkdirs()
val properties = Properties()
properties.setProperty("version", version.toString())
properties.setProperty("commit", commit.toString().trim())
properties.store(FileOutputStream(propertiesFile), null)
}
publishing {
repositories {
maven {
url = uri(layout.buildDirectory.dir("import"))
}
}
publications {
create<MavenPublication>("main") {
artifactId = "scribe"
from(components["java"])
pom {
name = "PartiQL Scribe"
description = "The PartiQL Scribe query transpiler framework."
url = "https://partiql.org"
packaging = "jar"
groupId = "org.partiql"
version = "0.1"
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
name.set("PartiQL Team")
email.set("[email protected]")
organization.set("PartiQL")
organizationUrl.set("https://github.com/partiql")
}
}
}
}
}
}