Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scala version, and buildscript #23

Open
wants to merge 12 commits into
base: scala3
Choose a base branch
from
Open
77 changes: 22 additions & 55 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
plugins {
id "java-library"
id "scala"
id "maven-publish"
id 'fabric-loom' version '0.10.30'
id "com.matthewprenger.cursegradle" version "1.4.0"
id 'java-library'
id 'scala'
id 'maven-publish'
id 'fabric-loom' version '1.5-SNAPSHOT'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = project.archives_base_name
group = project.maven_group

version = mod_version
def ENV = System.getenv()
version = version + "+scala." + project.scala_version + (ENV.GITHUB_ACTIONS ? "" : ".local")
version = mod_version + "+scala." + project.scala_version + (System.getenv('GITHUB_ACTIONS') ? "" : ".local")

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

include(api("org.scala-lang:scala3-library_3:${project.scala_version}"))
// Depended on by scala3
include(api("org.scala-lang:scala-library:2.13.6"))
// Scala Dependencies
implementation "org.scala-lang:scala3-library_3:${project.scala_version}"
Comment on lines +20 to +21

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it seems right? I don't think this is the correct nested-jar.

After I testing about it, I can't find any bundled jar in fabric-language-scala.

@modmuss50

Maybe correcting it into

modApi(include("org.scala-lang:scala3-library_3:${project.scala_version}"))

like fabric-language-kotlin will be ok?

image
image

implementation "org.scala-lang:scala-reflect:${project.scala_reflect_version}"
implementation "org.scala-lang.modules:scala-xml_3:${project.scala_xml_version}"// might be unnecessary but wtv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed or not? I dont see why it would be, why also add scala-reflect?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding scala reflect can add more complex coding practice when using scala. and the xml idk why i added that i think it was just late at night so i wasnt thinking.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks I have removed them. Its much easier to add them later if needed.

}

processResources {
Expand All @@ -39,49 +36,22 @@ java {
}

publishing {
publications {
maven(MavenPublication) {
publications {
maven(MavenPublication) {
from components.java
}
}
repositories {
repositories {
if (ENV.MAVEN_URL) {
maven {
url ENV.MAVEN_URL
credentials {
username ENV.MAVEN_USERNAME
password ENV.MAVEN_PASSWORD
}
}
}
repositories {
if (System.getenv('MAVEN_URL')) {
maven {
url System.getenv('MAVEN_URL')
credentials {
username System.getenv('MAVEN_USERNAME')
password System.getenv('MAVEN_PASSWORD')
}
}
}
}
}

curseforge {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill add this back.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh i didnt know fabric was on curseforge anymore

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its fine, I would have also removed this plugin as I have my own. Ill sort this out after merging.

if (ENV.CURSEFORGE_API_KEY) {
apiKey = ENV.CURSEFORGE_API_KEY
}

project {
id = '309275'
changelog = 'A changelog can be found at https://github.com/FabricMC/fabric-language-scala/commits/master'
releaseType = 'release'
addGameVersion '1.17.1'
addGameVersion '1.16.5'
addGameVersion '1.15.2'
addGameVersion '1.14.4'
addGameVersion "Fabric"

mainArtifact(file("${project.buildDir}/libs/${base.archivesBaseName}-${version}.jar")) {
displayName = "Fabric Language Scala $version"
}
}

options {
forgeGradleIntegration = false
}
}

// A task to ensure that the version being released has not already been released.
Expand All @@ -95,6 +65,3 @@ task checkVersion {
}
}
}

publish.mustRunAfter checkVersion
project.tasks.curseforge.mustRunAfter checkVersion
14 changes: 9 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.17.1
yarn_mappings=1.17.1+build.61
loader_version=0.11.7
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.7

# Mod Properties
mod_version=2.0.0
maven_group=net.fabricmc
archives_base_name=fabric-language-scala
description=Fabric language module for Scala
url=https://github.com/FabricMC/fabric-language-scala/
# Other
scala_version=3.0.2

# Scala
scala_version=3.4.0
scala_reflect_version=2.13.13
scala_xml_version=2.2.0
6 changes: 4 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-rc-1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@

package net.fabricmc.language.scala


import net.fabricmc.loader.api.{LanguageAdapter, ModContainer}

import scala.util.{Failure, Success, Try}

class ScalaLanguageAdapter extends LanguageAdapter {

override def create[T](modContainer: ModContainer, s: String, aClass: Class[T]): T = {
try {
Try {
val objectClass = Class.forName(s + "$")
val moduleField = objectClass.getField("MODULE$")
val instance = moduleField.get(null).asInstanceOf[T]
if (instance == null) throw new NullPointerException
instance
} catch {
case _: Exception =>
Option(instance).getOrElse(throw new NullPointerException)
} match {
case Success(instance) => instance
case Failure(_) =>
println(s"Unable to find ${aClass.getName}$$MODULE$$")
aClass.getConstructor().newInstance()
}
Expand Down
12 changes: 7 additions & 5 deletions src/test/scala/net/fabricmc/language/scala/TestMod.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import net.fabricmc.api.ModInitializer
import net.minecraft.block.Blocks

object TestMod extends ModInitializer {

override def onInitialize(): Unit = {
System.out.println("**********************")
System.out.println("Hello from Scala!")
System.out.println("Hello " + Blocks.DIRT)
System.out.println("**********************")
val message = """
|**********************
|Hello from Scala!
|Hello ${Blocks.DIRT}!
|**********************
|""".stripMargin
println(message)
}
modmuss50 marked this conversation as resolved.
Show resolved Hide resolved
}
Loading