2023-03-25 23:41:02 +00:00
|
|
|
/*
|
2023-05-11 06:31:04 +00:00
|
|
|
* Botendo
|
|
|
|
* Copyright (C) 2023 moonleay
|
2023-03-25 23:41:02 +00:00
|
|
|
*
|
2023-05-11 06:31:04 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2023-03-25 23:41:02 +00:00
|
|
|
*
|
2023-05-11 06:31:04 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2023-03-25 23:41:02 +00:00
|
|
|
*
|
2023-05-11 06:31:04 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2023-03-25 23:41:02 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
import org.jetbrains.gradle.ext.ProjectSettings
|
|
|
|
import org.jetbrains.gradle.ext.TaskTriggersConfig
|
|
|
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
|
|
|
|
|
|
plugins {
|
2023-05-04 21:20:52 +00:00
|
|
|
kotlin("jvm") version "1.8.21"
|
2023-03-25 23:41:02 +00:00
|
|
|
id("com.github.johnrengelman.shadow") version "7.1.2"
|
|
|
|
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.6"
|
|
|
|
`maven-publish`
|
|
|
|
}
|
|
|
|
|
2023-05-04 21:20:52 +00:00
|
|
|
//Botendo version 6
|
2023-03-25 23:41:02 +00:00
|
|
|
val ownerID = 372703841151614976L
|
2023-05-18 01:44:38 +00:00
|
|
|
group = "net.moonleay.botendo"
|
2023-03-25 23:41:02 +00:00
|
|
|
version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" }
|
|
|
|
?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" }
|
2023-12-13 17:03:41 +00:00
|
|
|
?: "6.5.3"
|
2023-03-28 21:34:10 +00:00
|
|
|
|
2023-12-13 15:47:26 +00:00
|
|
|
val kordext_ver = "1.7.1-SNAPSHOT"
|
|
|
|
val lavakord_ver = "6.0.0"
|
|
|
|
val coroutines_ver = "1.7.3"
|
|
|
|
val slf4j_ver = "2.0.9"
|
2023-03-25 23:41:02 +00:00
|
|
|
|
|
|
|
val mavenArtifact = "Botendo"
|
|
|
|
project.base.archivesName.set(mavenArtifact)
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
maven {
|
|
|
|
name = "Gitlab"
|
|
|
|
val projectId = System.getenv("CI_PROJECT_ID")
|
|
|
|
val apiV4 = System.getenv("CI_API_V4_URL")
|
|
|
|
url = uri("https://$apiV4/projects/$projectId/packages/maven")
|
|
|
|
authentication {
|
|
|
|
create("header", HttpHeaderAuthentication::class.java) {
|
|
|
|
if (System.getenv("CI_JOB_TOKEN") != null) {
|
|
|
|
credentials(HttpHeaderCredentials::class) {
|
|
|
|
name = "Job-Token"
|
|
|
|
value = System.getenv("CI_JOB_TOKEN")
|
|
|
|
}
|
2023-04-14 21:13:24 +00:00
|
|
|
} else if (project.hasProperty("myGitlabToken")) {
|
2023-03-25 23:41:02 +00:00
|
|
|
credentials(HttpHeaderCredentials::class) {
|
|
|
|
name = "Private-Token"
|
|
|
|
value = project.ext["myGitlabToken"] as String
|
|
|
|
}
|
2023-04-14 21:13:24 +00:00
|
|
|
} else {
|
|
|
|
credentials(HttpHeaderCredentials::class) {
|
|
|
|
name = "none"
|
|
|
|
value = ""
|
|
|
|
}
|
2023-03-25 23:41:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-12-13 13:39:01 +00:00
|
|
|
maven {
|
|
|
|
name = "sonatype"
|
|
|
|
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots")
|
|
|
|
}
|
|
|
|
maven {
|
|
|
|
name = "sonatype 2"
|
|
|
|
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
|
|
|
|
}
|
2023-03-25 23:41:02 +00:00
|
|
|
}
|
|
|
|
|
2023-04-14 11:03:28 +00:00
|
|
|
val shadow by configurations.getting
|
|
|
|
val implementation by configurations.getting
|
|
|
|
implementation.extendsFrom(shadow)
|
|
|
|
|
2023-03-25 23:41:02 +00:00
|
|
|
dependencies {
|
2023-05-04 21:20:52 +00:00
|
|
|
//Discord
|
2023-12-13 15:47:26 +00:00
|
|
|
shadow("com.kotlindiscord.kord.extensions:kord-extensions:$kordext_ver")
|
|
|
|
shadow("dev.schlaubi.lavakord:kord:$lavakord_ver")
|
2023-05-04 21:20:52 +00:00
|
|
|
|
|
|
|
//Util
|
2023-12-13 15:47:26 +00:00
|
|
|
shadow("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_ver")
|
2023-05-04 21:20:52 +00:00
|
|
|
|
|
|
|
//Logging
|
2023-12-13 15:47:26 +00:00
|
|
|
shadow("org.slf4j:slf4j-api:$slf4j_ver")
|
|
|
|
shadow("org.slf4j:slf4j-simple:$slf4j_ver")
|
2023-03-25 23:41:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val targetJavaVersion = 17
|
|
|
|
val templateSrc = project.rootDir.resolve("src/main/templates")
|
|
|
|
val templateDest = project.buildDir.resolve("generated/templates")
|
|
|
|
val templateProps = mapOf(
|
|
|
|
"version" to project.version as String,
|
|
|
|
"ownerID" to ownerID,
|
2023-12-13 15:47:26 +00:00
|
|
|
"kordversion" to kordext_ver,
|
|
|
|
"lavaversion" to lavakord_ver,
|
|
|
|
"coroutinesversion" to coroutines_ver
|
2023-03-25 23:41:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tasks {
|
|
|
|
create<Copy>("generateTemplates") {
|
|
|
|
filteringCharset = "UTF-8"
|
|
|
|
|
|
|
|
inputs.properties(templateProps)
|
|
|
|
from(templateSrc)
|
|
|
|
expand(templateProps)
|
|
|
|
into(templateDest)
|
|
|
|
}
|
|
|
|
|
|
|
|
withType<Jar> {
|
|
|
|
manifest {
|
2023-05-18 01:44:38 +00:00
|
|
|
attributes["Main-Class"] = "net.moonleay.botendo.MainKt"
|
2023-03-25 23:41:02 +00:00
|
|
|
}
|
|
|
|
// To add all of the dependencies
|
|
|
|
from(sourceSets.main.get().output)
|
|
|
|
|
|
|
|
dependsOn(configurations.runtimeClasspath)
|
|
|
|
from({
|
|
|
|
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
|
|
|
|
})
|
|
|
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
|
|
dependsOn("generateTemplates", "processResources")
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
|
2023-04-14 11:03:28 +00:00
|
|
|
configurations = listOf(shadow)
|
2023-03-25 23:41:02 +00:00
|
|
|
dependsOn("generateTemplates", "processResources")
|
|
|
|
}
|
|
|
|
|
|
|
|
withType<JavaCompile> {
|
|
|
|
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
|
|
|
// this fixes some edge cases with special characters not displaying correctly
|
|
|
|
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
|
|
|
// If Javadoc is generated, this must be specified in that task too.
|
|
|
|
options.encoding = "UTF-8"
|
|
|
|
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible) {
|
|
|
|
options.release.set(targetJavaVersion)
|
|
|
|
}
|
|
|
|
|
|
|
|
dependsOn("generateTemplates", "processResources")
|
|
|
|
}
|
|
|
|
|
|
|
|
withType<KotlinCompile> {
|
|
|
|
kotlinOptions.jvmTarget = targetJavaVersion.toString()
|
|
|
|
|
|
|
|
dependsOn("generateTemplates", "processResources")
|
|
|
|
}
|
|
|
|
|
|
|
|
withType<Jar> {
|
|
|
|
from("LICENSE") {
|
|
|
|
rename { "${it}_${project.base.archivesName.get()}" }
|
|
|
|
}
|
|
|
|
|
|
|
|
archiveBaseName.set(mavenArtifact)
|
|
|
|
|
|
|
|
dependsOn("generateTemplates", "processResources")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
java {
|
|
|
|
val javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
|
|
|
if (JavaVersion.current() < javaVersion) {
|
|
|
|
toolchain.languageVersion.set(JavaLanguageVersion.of(targetJavaVersion))
|
|
|
|
}
|
|
|
|
|
|
|
|
withSourcesJar()
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
main {
|
|
|
|
java {
|
|
|
|
srcDir(templateDest)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
create<MavenPublication>("mavenJava") {
|
|
|
|
version = project.version as String
|
|
|
|
artifactId = mavenArtifact
|
|
|
|
from(components["java"])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
if (System.getenv("CI_JOB_TOKEN") != null) {
|
|
|
|
maven {
|
|
|
|
name = "GitLab"
|
|
|
|
val projectId = System.getenv("CI_PROJECT_ID")
|
|
|
|
val apiV4 = System.getenv("CI_API_V4_URL")
|
|
|
|
url = uri("$apiV4/projects/$projectId/packages/maven")
|
|
|
|
authentication {
|
|
|
|
create("token", HttpHeaderAuthentication::class.java) {
|
|
|
|
credentials(HttpHeaderCredentials::class.java) {
|
|
|
|
name = "Job-Token"
|
|
|
|
value = System.getenv("CI_JOB_TOKEN")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rootProject.idea.project {
|
|
|
|
this as ExtensionAware
|
|
|
|
configure<ProjectSettings> {
|
|
|
|
this as ExtensionAware
|
|
|
|
configure<TaskTriggersConfig> {
|
|
|
|
afterSync(tasks["generateTemplates"], tasks["processResources"])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//rootProject.eclipse.synchronizationTasks("generateTemplates", "processResources")
|
|
|
|
//Fuck eclipse users amirite?
|