Skip to content

Commit

Permalink
Move version definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Kotori316 committed Nov 18, 2023
1 parent 552d02b commit 960850e
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 265 deletions.
90 changes: 85 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tasks.named("wrapper", Wrapper.class) {
gradleVersion = "8.4"
}

version = "${project.scala3_version}-build-${project.build_number}"
version = "${libs.versions.scala3.get()}-build-${project.build_number}"

final boolean RELEASE_DEBUG = Boolean.parseBoolean(System.getenv("RELEASE_DEBUG") ?: "true")
githubRelease {
Expand All @@ -18,13 +18,13 @@ githubRelease {
targetCommitish.set(project.branch as String)
prerelease.set(project.version.toString().contains("SNAPSHOT"))
body.set("""\
For Minecraft ${project.minecraft_version}
For Minecraft ${libs.versions.minecraft.get()}
This mod provides language provider, "kotori_scala".
Scala3: ${project.scala3_version}
Scala: ${project.scala_version}
Cats: ${project.cats_version}
Scala3: ${libs.versions.scala3.get()}
Scala: ${libs.versions.scala2.get()}
Cats: ${libs.versions.cats.get()}
""".stripIndent())
releaseAssets = files(
releaseAssets = files(
Expand All @@ -38,3 +38,83 @@ githubRelease {
)
dryRun.set(RELEASE_DEBUG)
}

subprojects {
apply(plugin: "scala")

repositories {
mavenLocal()
maven {
name = "Azure-SLP"
url = uri("https://pkgs.dev.azure.com/Kotori316/minecraft/_packaging/mods/maven/v1")
content {
it.includeVersion("org.typelevel", "cats-core_3", libs.versions.cats.get())
it.includeVersion("org.typelevel", "cats-kernel_3", libs.versions.cats.get())
it.includeVersion("org.typelevel", "cats-free_3", libs.versions.cats.get())
}
}
}

test {
useJUnitPlatform()

testLogging {
events "skipped", "failed", "standardOut", "standardError"
exceptionFormat 'full'
}
}

tasks.register('data') {
doLast {
println("Java: ${System.getProperty('java.version')} JVM: ${System.getProperty('java.vm.version')}" +
"(${System.getProperty('java.vendor')}) Arch: ${System.getProperty('os.arch')}")
println("Scala: ${libs.versions.scala3.get()}}")
println("Build Number: $build_number, ${build_number.getClass()}")
println("Version: $version, ${version.getClass()}")
println("Minecraft: ${libs.versions.minecraft.get()}")
println("Forge: ${libs.versions.forge.get()}")
println("NeoForge: ${libs.versions.neoforge.get()}")
print(System.lineSeparator() * 2)
println("All Dependencies")
getProject().getConfigurations().forEach { con ->
if (!con.dependencies.isEmpty()) {
start_group(con.name)
for (Object o : con.dependencies) {
println(o)
}
end_group()
}
}
print(System.lineSeparator() * 2)
start_group("Dependencies to be included in pom")
getProject().getConfigurations().implementation.dependencies.each { Dependency dep ->
if (!dep.name.contains("junit")) {
printf("Group: %s, ArtifactId: %s, Version: %s%n", dep.group, dep.name, dep.version)
} else {
printf("JUNIT - Group: %s, ArtifactId: %s, Version: %s%n", dep.group, dep.name, dep.version)
}
}
end_group()
start_group("Publishing Information")
publishing.properties.each { Map.Entry<?, ?> entry ->
printf("%s -> %s (key: %s, value: %s)%n", entry.key, entry.value, entry.getKey().getClass(), entry.getValue().getClass())
}
end_group()
start_group("Repositories")
publishing.properties.get("repositories").getAsMap().each { Map.Entry<String, Object> e -> printf("%s=%s%n", e.key, e.value.getUrl()) }
end_group()
start_group("Changelog")
println(project.getChangelog() as String)
end_group()
}
}
}

static void start_group(String name) {
println("::group::${name}")
}

@SuppressWarnings('SpellCheckingInspection')
static void end_group() {
println("::endgroup::")
}
148 changes: 24 additions & 124 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
}

def build_number = String.valueOf(getProperty("build_number"))
version = "${project.scala3_version}-build-${build_number}"
version = "${libs.versions.scala3.get()}-build-${project.build_number}"
group = "com.kotori316" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "ScalableCatsForce"

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
jarJar.enable()

minecraft {
mappings channel: 'parchment', version: ((project.parchmentMapping + "-" + project.minecraft_version) as String)
mappings channel: 'parchment', version: ((libs.versions.parchment.get() + "-" + libs.versions.minecraft.get()) as String)
// copyIdeResources = true
runs {
client {
Expand Down Expand Up @@ -75,64 +74,24 @@ minecraft {
}
}

sourceSets {
main {
scala {
exclude "/com/kotori316/scala_lib/example/**"
}
java {
srcDir 'src/main/java'
}
}
}

repositories {
mavenLocal()
maven {
name = "Azure-SLP"
url = uri("https://pkgs.dev.azure.com/Kotori316/minecraft/_packaging/mods/maven/v1")
content {
it.includeVersion("org.typelevel", "cats-core_3", String.valueOf(project.cats_version))
it.includeVersion("org.typelevel", "cats-kernel_3", String.valueOf(project.cats_version))
it.includeVersion("org.typelevel", "cats-free_3", String.valueOf(project.cats_version))
}
}
}

dependencies {
String cats_version = getProperty("cats_version")

minecraft("net.minecraftforge:forge:" + project.forge_version)
// https://mvnrepository.com/artifact/org.scala-lang/scala-library
implementation(group: 'org.scala-lang', name: 'scala-library', version: project.scala_version)
implementation(group: "org.scala-lang", name: "scala3-library_3", version: project.scala3_version) { transitive = false }
// https://mvnrepository.com/artifact/org.typelevel/cats-core
implementation(group: 'org.typelevel', name: "cats-kernel_3", version: cats_version) { transitive = false }
implementation(group: 'org.typelevel', name: "cats-core_3", version: cats_version) { transitive = false }
implementation(group: 'org.typelevel', name: "cats-free_3", version: cats_version) { transitive = false }
minecraft("net.minecraftforge:forge:" + libs.versions.forge.get())
implementation(libs.scala2)
implementation(libs.scala3) { transitive = false }
implementation(libs.bundles.cats) { transitive = false }

// Jar in Jar
jarJar(group: 'org.scala-lang', name: 'scala-library', version: "[$project.scala_version, 3.0)") { transitive = false }
jarJar(group: 'org.scala-lang', name: 'scala3-library_3', version: "[3.0, $project.scala3_version]") { transitive = false }
jarJar(group: 'org.typelevel', name: "cats-core_3", version: "[2.0, $cats_version]") { transitive = false }
jarJar(group: 'org.typelevel', name: "cats-kernel_3", version: "[2.0, $cats_version]") { transitive = false }
jarJar(group: 'org.typelevel', name: "cats-free_3", version: "[2.0, $cats_version]") { transitive = false }
jarJar(group: 'org.scala-lang', name: 'scala-library', version: "[${libs.versions.scala2.get()}, 3.0)") { transitive = false }
jarJar(group: 'org.scala-lang', name: 'scala3-library_3', version: "[3.0, ${libs.versions.scala3.get()}]") { transitive = false }
jarJar(group: 'org.typelevel', name: "cats-core_3", version: "[2.0, ${libs.versions.cats.get()}]") { transitive = false }
jarJar(group: 'org.typelevel', name: "cats-kernel_3", version: "[2.0, ${libs.versions.cats.get()}]") { transitive = false }
jarJar(group: 'org.typelevel', name: "cats-free_3", version: "[2.0, ${libs.versions.cats.get()}]") { transitive = false }

// Test Dependencies.
testImplementation(group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: project.jupiterVersion)
testImplementation(group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: project.jupiterVersion)
testRuntimeOnly(group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: project.jupiterVersion)
testImplementation(group: 'org.junit.platform', name: 'junit-platform-launcher', version: project.jupiterPlatformVersion)

}

test {
useJUnitPlatform()

testLogging {
events "skipped", "failed", "standardOut", "standardError"
exceptionFormat 'full'
}
testImplementation(libs.jupiter.api)
testImplementation(libs.jupiter.params)
testRuntimeOnly(libs.jupiter.engine)
testImplementation(libs.jupiter.launcher)
}

jar {
Expand Down Expand Up @@ -200,7 +159,7 @@ curseforge {
project {
id = '320926'
changelogType = 'markdown'
changelog = project.getChangelog()
changelog = getChangelog()
releaseType = 'release'
addGameVersion("1.20.2")
addGameVersion("Forge")
Expand All @@ -227,13 +186,13 @@ modrinth {
]
gameVersions = ["1.20.2"]
loaders = ["forge"]
changelog = project.getChangelog()
changelog = getChangelog()
debugMode = RELEASE_DEBUG
}

publishing {
repositories {
if(!RELEASE_DEBUG) {
if (!RELEASE_DEBUG) {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/Kotori316/SLP")
Expand Down Expand Up @@ -266,7 +225,7 @@ publishing {

pom {
name = archivesBaseName
description = "Scala Loading library build with Minecraft ${project.minecraft_version} and Forge ${project.forge_version}"
description = "Scala Loading library build with Minecraft ${libs.versions.minecraft.get()} and Forge ${libs.versions.forge.get()}"
url = 'https://github.com/Kotori316/SLP'
packaging = "jar"
withXml {
Expand Down Expand Up @@ -330,78 +289,19 @@ tasks.withType(AbstractPublishToMaven).configureEach {

def getChangelog() {
String t = """\
For Minecraft ${project.minecraft_version}
For Minecraft ${libs.versions.minecraft.get()}
Built with forge ${project.forge_version}
Built with forge ${libs.versions.forge.get()}
This mod provides language provider, "kotori_scala".
Scala3: ${project.scala3_version}
Scala: ${project.scala_version}
Cats: ${project.cats_version}
Scala3: ${libs.versions.scala3.get()}
Scala: ${libs.versions.scala2.get()}
Cats: ${libs.versions.cats.get()}
""".stripIndent()
return t
}

// --------- Github Actions ----------

static void start_group(String name) {
println("::group::${name}")
}

@SuppressWarnings('SpellCheckingInspection')
static void end_group() {
println("::endgroup::")
}

tasks.register('data') {
doLast {
println("Java: ${System.getProperty('java.version')} JVM: ${System.getProperty('java.vm.version')}" +
"(${System.getProperty('java.vendor')}) Arch: ${System.getProperty('os.arch')}")
println("Scala: ${project.scala_version}, ${project.scala_version.getClass()}")
println("Build Number: $build_number, ${build_number.getClass()}")
println("Version: $version, ${version.getClass()}")
println("Scala Loading library build with Minecraft ${project.minecraft_version} and Forge ${project.forge_version}")
println("Forge: ${project.forge_version}")
println("Minecraft: ${project.minecraft_version}")
print(System.lineSeparator() * 2)
println("All Dependencies")
getProject().getConfigurations().forEach { con ->
if (!con.dependencies.isEmpty()) {
start_group(con.name)
for (Object o : con.dependencies) {
println(o)
}
end_group()
}
}
print(System.lineSeparator() * 2)
start_group("Dependencies to be included in pom")
getProject().getConfigurations().implementation.dependencies.each { Dependency dep ->
if (!dep.name.contains("junit")) {
printf("Group: %s, ArtifactId: %s, Version: %s%n", dep.group, dep.name, dep.version)
} else {
printf("JUNIT - Group: %s, ArtifactId: %s, Version: %s%n", dep.group, dep.name, dep.version)
}
}
end_group()
start_group("Publishing Information")
publishing.properties.each { Map.Entry<?, ?> entry ->
printf("%s -> %s (key: %s, value: %s)%n", entry.key, entry.value, entry.getKey().getClass(), entry.getValue().getClass())
}
end_group()
start_group("Repositories")
// publishing.properties.get("repositories").getClass().getMethods().each { println(it) }
// publishing.properties.get("repositories").getClass().getInterfaces().each { println(it) }
publishing.properties.get("repositories").getAsMap().each { Map.Entry<String, Object> e -> printf("%s=%s%n", e.key, e.value.getUrl()) }
// (publishing.properties.get("repositories") as Collection<Object>).toArray()[0].getClass().getMethods().each {println(it)}
end_group()
start_group("Changelog")
println(getChangelog())
end_group()
}
}

afterEvaluate {
rootProject.tasks.named("githubRelease").configure { it.dependsOn(":forge:assemble") }
}
15 changes: 0 additions & 15 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
scala_version=2.13.12
scala3_version=3.3.1
cats_version=2.10.0-kotori
build_number=2
minecraft_version=1.20.2
branch=1.20
# https://ldtteam.jfrog.io/ui/native/parchmentmc-public/org/parchmentmc/data/parchment-1.20.1/
# https://github.com/ParchmentMC/Parchment
parchmentMapping=1.20.2-2023.10.22
# https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
jupiterVersion=5.8.2
# https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher
jupiterPlatformVersion=1.8.2
# Forge
forge_version=1.20.2-48.0.39
# NeoForge
mod_id=scala-library-object
neo_version=20.2.56-beta
31 changes: 31 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[versions]
minecraft = "1.20.2"
forge = "1.20.2-48.0.39"
neoforge = "20.2.56-beta"
# https://ldtteam.jfrog.io/ui/native/parchmentmc-public/org/parchmentmc/data/parchment-1.20.2/
# https://github.com/ParchmentMC/Parchment
parchment="1.20.2-2023.10.22"
# https://mvnrepository.com/artifact/org.scala-lang/scala-library
scala2 = "2.13.12"
# https://mvnrepository.com/artifact/org.scala-lang/scala3-library
scala3 = "3.3.1"
cats = "2.10.0-kotori"
# https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
jupiter = "5.8.2"
# https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher
jupiter-platform = "1.8.2"

[libraries]
scala2 = { group = "org.scala-lang", name = "scala-library", version.ref = "scala2" }
scala3 = { group = "org.scala-lang", name = "scala3-library_3", version.ref = "scala3" }
cats-kernel = { group = "org.typelevel", name = "cats-kernel_3", version.ref = "cats" }
cats-core = { group = "org.typelevel", name = "cats-core_3", version.ref = "cats" }
cats-free = { group = "org.typelevel", name = "cats-free_3", version.ref = "cats" }
jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "jupiter" }
jupiter-params = { group = "org.junit.jupiter", name = "junit-jupiter-params", version.ref = "jupiter" }
jupiter-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "jupiter" }
jupiter-launcher = { group = "org.junit.platform", name = "junit-platform-launcher", version.ref = "jupiter-platform" }


[bundles]
cats = ["cats-kernel", "cats-core", "cats-free"]
Loading

0 comments on commit 960850e

Please sign in to comment.