-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
141 lines (114 loc) · 3.33 KB
/
build.gradle.kts
File metadata and controls
141 lines (114 loc) · 3.33 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
/*
* Copyright 2022 Daarkii & contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.7.10" //kotlin
id ("com.github.johnrengelman.shadow") version "7.0.0" //build the jar
id("java-library") //need for publishing
`maven-publish` //need for publishing
id("org.jetbrains.dokka") version "1.7.10" //need for javadoc building
}
group = "me.daarkii"
version = "1.0.3"
repositories {
mavenCentral()
}
apply {
plugin("org.jetbrains.kotlin.jvm")
plugin("com.github.johnrengelman.shadow")
plugin("maven-publish")
plugin("org.jetbrains.dokka")
}
dependencies {
//mysql
api("com.zaxxer", "HikariCP", "3.4.5")
//mongoDB
api("org.mongodb", "mongo-java-driver", "3.12.10")
//needed to create javaDocs
dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.7.10")
}
/**
* Build settings
*/
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
tasks.withType<ShadowJar> {
archiveFileName.set("database-adapter-$version.jar")
exclude("*.pom")
exclude("**/*.kotlin_metadata")
exclude("**/*.kotlin_module")
exclude("**/*.kotlin_builtins")
}
val shadowJar: ShadowJar by tasks
val javadoc: Javadoc by tasks
val jar: Jar by tasks
val build: Task by tasks
val clean: Task by tasks
val sourcesForRelease = task<Copy>("sourcesForRelease") {
from("src/main/kotlin")
into("build/filteredSrc")
includeEmptyDirs = false
}
val sourcesJar = task<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(sourcesForRelease.destinationDir)
dependsOn(sourcesForRelease)
}
//Create javadocs
val dokkaHtml by tasks.getting(org.jetbrains.dokka.gradle.DokkaTask::class)
val javadocJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
dependsOn(dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaHtml.outputDirectory)
}
//build all files (normal, javadoc, source)
build.apply {
dependsOn(jar)
dependsOn(javadocJar)
dependsOn(sourcesJar)
dependsOn(shadowJar)
jar.mustRunAfter(clean)
shadowJar.mustRunAfter(sourcesJar)
}
/**
* Publish settings
*/
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
}
}
repositories {
maven {
name = "nexus"
url = if(version.toString().contains("SNAPSHOT"))
uri("https://repo.aysu.tv/repository/snapshots/")
else
uri("https://repo.aysu.tv/repository/releases/")
credentials {
username = System.getenv("NEXUS_USERNAME")
password = System.getenv("NEXUS_PASSWORD")
}
}
}
}