diff --git a/LICENSE-HEADER b/LICENSE-HEADER
new file mode 100644
index 0000000..1a7c44d
--- /dev/null
+++ b/LICENSE-HEADER
@@ -0,0 +1,15 @@
+SimpleCoreAPI - Kotlin Project Library
+Copyright (C) 2024 Francisco SolĂs
+
+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.
+
+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.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index b699691..89b7bc0 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -7,24 +7,37 @@ import java.util.*
plugins {
`maven-publish`
- id("com.github.johnrengelman.shadow") version "8.1.1" // ShadowJar
- id("cl.franciscosolis.gradledotenv") version "1.0.1" // .env support
- kotlin("jvm") version "1.9.22" // Kotlin
- id("org.jetbrains.dokka") version "1.9.10" // Dokka (Kotlin Docs)
- id("cl.franciscosolis.sonatype-central-upload") version "1.0.2" // Sonatype Central Upload
+ id("com.github.johnrengelman.shadow") version "8.1.1" // ShadowJar
+ id("cl.franciscosolis.gradledotenv") version "1.0.1" // .env support
+ kotlin("jvm") version "1.9.22" // Kotlin
+ id("org.jetbrains.dokka") version "1.9.10" // Dokka (Kotlin Docs)
+ id("cl.franciscosolis.sonatype-central-upload") version "1.0.2" // Sonatype Central Upload
+ id("org.cadixdev.licenser") version "0.6.1" // License Header
+
}
-/*
- The project version can be:
- - environment variable VERSION or the manually added version
- - If the environment variable ENV is set to dev, the project
- version will have appended the git commit short hash + SNAPSHOT
-*/
-val projectVersion = (env["VERSION"] ?: "1.0.0") + (if (env["ENV"] == "dev") "-${env["GIT_COMMIT_SHORT_HASH"] ?: UUID.randomUUID().toString().replace("-", "").split("").shuffled().joinToString("").substring(0, 8)}" else "")
+/* Project Build ID is based on GIT_COMMIT_SHORT_HASH if any,
+ * otherwise we generate an UUIDv4 that will randomize its
+ * contents and get the first 8 characters.
+ */
+val projectBuildId = env["GIT_COMMIT_SHORT_HASH"] ?: UUID.randomUUID().toString().replace("-", "").split("").shuffled().joinToString("").substring(0, 8)
+
+/* Project Version will be the environment variable version (or the one specified by us) if it's production,
+ * otherwise it will be added '$projectBuildId'
+ * (no snapshot because maven central does not support it)
+ */
+val projectVersion = "${env["VERSION"] ?: "1.0.0"}${if (env["ENV"] != "prod") "-$projectBuildId" else ""}";
+/* Print out the current version */
println("This build version was '$projectVersion'")
-val repo = "https://github.com/TheProgramSrc/SimpleCoreAPI"
-val groupId = "cl.franciscosolis"
+val repo = "https://github.com/Im-Fran/SimpleCoreAPI"
+
+/*
+ * The groupId will be the package name in lowercase
+ * if the environment is not production, we will add the environment name
+ * (or 'dev' if it's not specified)
+ */
+val groupId = "cl.franciscosolis${if(env["ENV"] != "prod") ".${env["ENV"] ?: "dev"}" else ""}".lowercase()
group = groupId
version = projectVersion.replaceFirst("v", "").replace("/", "")
@@ -36,6 +49,7 @@ allprojects {
plugin("cl.franciscosolis.gradledotenv")
plugin("org.jetbrains.kotlin.jvm")
plugin("org.jetbrains.dokka")
+ plugin("org.cadixdev.licenser")
}
group = rootProject.group
@@ -70,13 +84,17 @@ subprojects {
named("dokkaHtmlPartial") {
outputDirectory = layout.buildDirectory.dir("dokka")
- val dokkaCache = file("${System.getProperty("user.home")}/.cache/dokka")
- if (!dokkaCache.exists()) {
- dokkaCache.mkdirs()
+ cacheRoot = file("${System.getProperty("user.home")}/.cache/dokka").apply {
+ if(!exists()) mkdirs()
}
- cacheRoot.set(dokkaCache)
}
}
+
+ license {
+ header(rootProject.file("LICENSE-HEADER"))
+ include("**/*.kt", "**/*.java")
+ newLine(true)
+ }
}
dependencies {
@@ -87,7 +105,7 @@ dependencies {
tasks {
named("shadowJar") {
manifest {
- attributes["Main-Class"] = "xyz.theprogramsrc.simplecoreapi.standalone.StandaloneLoaderKt"
+ attributes["Main-Class"] = "cl.franciscosolis.simplecoreapi.standalone.StandaloneLoaderKt"
}
mergeServiceFiles()
@@ -171,7 +189,7 @@ publishing {
if (env["GITHUB_ACTOR"] != null && env["GITHUB_TOKEN"] != null) {
maven {
name = "GithubPackages"
- url = uri("https://maven.pkg.github.com/TheProgramSrc/SimpleCoreAPI")
+ url = uri("https://maven.pkg.github.com/Im-Fran/SimpleCoreAPI")
credentials {
username = env["GITHUB_ACTOR"]
password = env["GITHUB_TOKEN"]
@@ -214,7 +232,7 @@ publishing {
}
scm {
- url = repo
+ url = "$repo${if(repo.endsWith(".git")) "" else ".git"}"
}
}
}