@@ -18,6 +18,7 @@ plugins {
1818 id ' java'
1919 id ' java-library'
2020 id ' eclipse'
21+ id ' scala'
2122 id ' org.jetbrains.gradle.plugin.idea-ext' version ' 1.1.7'
2223 id ' com.gtnewhorizons.retrofuturagradle' version ' 1.3.+'
2324 id ' net.darkhax.curseforgegradle' version ' 1.0.+' apply false
@@ -74,22 +75,25 @@ propertyDefaultIfUnsetWithEnvVar("deploymentDebug", false, "DEPLOYMENT_DEBUG")
7475// Project property assertions
7576
7677final String javaSourceDir = ' src/main/java/'
77- // If Scala or Kotlin are supported, add those paths here
78+ final String scalaSourceDir = ' src/main/scala/'
79+ // If Kotlin is supported, add the path here
7880
7981final String modGroupPath = modGroup. toString(). replace(' .' as char , ' /' as char )
8082final String apiPackagePath = apiPackage. toString(). replace(' .' as char , ' /' as char )
8183
8284String targetPackageJava = javaSourceDir + modGroupPath
83- // If Scala or Kotlin are supported, add those paths here
85+ String targetPackageScala = scalaSourceDir + modGroupPath
86+ // If Kotlin is supported, add the path here
8487
85- if (! getFile(targetPackageJava). exists()) {
86- throw new GradleException (" Could not resolve \" modGroup\" ! Could not find " + targetPackageJava )
88+ if (! getFile(targetPackageJava). exists() && ! getFile(targetPackageScala) . exists() ) {
89+ throw new GradleException (" Could not resolve \" modGroup\" ! Could not find ${ targetPackageJava } or ${ targetPackageScala } " )
8790}
8891
8992if (apiPackage) {
9093 targetPackageJava = javaSourceDir + modGroupPath + ' /' + apiPackagePath
91- if (! getFile(targetPackageJava). exists()) {
92- throw new GradleException (" Could not resolve \" apiPackage\" ! Could not find " + targetPackageJava)
94+ targetPackageScala = scalaSourceDir + modGroupPath + ' /' + apiPackagePath
95+ if (! getFile(targetPackageJava). exists() && ! getFile(targetPackageScala). exists()) {
96+ throw new GradleException (" Could not resolve \" apiPackage\" ! Could not find ${ targetPackageJava} or ${ targetPackageScala} " )
9397 }
9498}
9599
@@ -110,15 +114,18 @@ if (usesMixins.toBoolean()) {
110114 }
111115 final String mixinPackagePath = mixinsPackage. toString(). replaceAll(' \\ .' , ' /' )
112116 targetPackageJava = javaSourceDir + modGroupPath + ' /' + mixinPackagePath
117+ targetPackageScala = scalaSourceDir + modGroupPath + ' /' + mixinPackagePath
113118 if (! getFile(targetPackageJava). exists()) {
114- throw new GradleException (" Could not resolve \" mixinsPackage\" ! Could not find " + targetPackageJava )
119+ throw new GradleException (" Could not resolve \" mixinsPackage\" ! Could not find ${ targetPackageJava } or ${ targetPackageScala } " )
115120 }
116121}
117122
118123if (coreModClass) {
119124 final String coreModPath = coreModClass. toString(). replaceAll(' \\ .' , ' /' )
120125 String targetFileJava = javaSourceDir + modGroupPath + ' /' + coreModPath + ' .java'
121- if (! getFile(targetFileJava). exists()) {
126+ String targetFileScala = scalaSourceDir + modGroupPath + ' /' + coreModPath + ' .scala'
127+ String targetFileScalaJava = scalaSourceDir + modGroupPath + ' /' + coreModPath + ' .java'
128+ if (! getFile(targetFileJava). exists() && ! getFile(targetFileScala). exists() && ! getFile(targetFileScalaJava). exists()) {
122129 throw new GradleException (" Could not resolve \" coreModClass\" ! Could not find " + targetFileJava)
123130 }
124131}
@@ -164,6 +171,10 @@ if (enableSpotless.toBoolean()) {
164171 // noinspection GroovyAssignabilityCheck
165172 eclipse(' 4.19.0' ). configFile(formatFile)
166173 }
174+ scala {
175+ target ' src/*/scala/**/*.scala'
176+ scalafmt(' 3.7.1' )
177+ }
167178 }
168179}
169180
@@ -208,6 +219,10 @@ tasks.withType(JavaCompile).configureEach {
208219 }
209220}
210221
222+ tasks. withType(ScalaCompile ). configureEach {
223+ options. encoding = ' UTF-8'
224+ }
225+
211226
212227// Configure Minecraft
213228
0 commit comments