Skip to content

Commit

Permalink
bump ng version and add junit support
Browse files Browse the repository at this point in the history
  • Loading branch information
Minecraftschurli committed Nov 7, 2024
1 parent 5982b53 commit 0fd5de9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
14 changes: 7 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ plugins {
kotlin("plugin.serialization") version "1.9.22"
}

group = "com.github.minecraftschurlimods"
version = "1.15"
base.archivesName = "HelperPlugin"

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))

repositories {
mavenCentral()
gradlePluginPortal()
maven { url = uri("https://maven.neoforged.net/releases") }
}

group = "com.github.minecraftschurlimods"
version = "1.14"
base.archivesName = "HelperPlugin"

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))

dependencies {
implementation("com.akuleshov7:ktoml-core:0.5.1")
implementation("net.neoforged.gradle:userdev:[7.0.142,)")
implementation("net.neoforged.gradle:userdev:[7.0.167,)")
}

gradlePlugin {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import net.neoforged.gradle.dsl.common.runs.run.Run
import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
Expand All @@ -22,7 +21,6 @@ import org.gradle.api.tasks.bundling.Jar
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.jvm.toolchain.JvmVendorSpec
import org.gradle.kotlin.dsl.*
import org.gradle.language.base.plugins.LifecycleBasePlugin
import java.net.URI
import javax.inject.Inject

Expand Down Expand Up @@ -265,21 +263,21 @@ open class HelperExtension @Inject constructor(private val project: Project) {
maybeCreate("client")
maybeCreate("server").apply {
singleInstance()
programArgument("--nogui")
arguments.add("--nogui")
}
}
}

fun withDataGenRuns(cfg: Action<Run> = Action<Run>{}) {
project.runs.maybeCreate("data").apply {
singleInstance()
programArguments.add("--mod")
programArguments.add(projectId)
programArguments.add("--all")
programArguments.add("--output")
programArguments.add(generatedResourcesDir.map { it.asFile.absolutePath })
programArguments.add("--existing")
programArguments.add(project.layout.projectDirectory.dir("src/main/resources/").asFile.absolutePath)
arguments.add("--mod")
arguments.add(projectId)
arguments.add("--all")
arguments.add("--output")
arguments.add(generatedResourcesDir.map { it.asFile.absolutePath })
arguments.add("--existing")
arguments.add(project.layout.projectDirectory.dir("src/main/resources/").asFile.absolutePath)
cfg.execute(this)
}
project.sourceSets.main {
Expand All @@ -300,4 +298,15 @@ open class HelperExtension @Inject constructor(private val project: Project) {
cfg.execute(this)
}
}

fun withUnitTestRuns(cfg: Action<Run> = Action<Run>{}) {
project.runs.maybeCreate("junit").apply {
singleInstance()
jvmArgument("-ea")
cfg.execute(this)
}
project.tasks.test.configure {
useJUnitPlatform()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.gradle.api.publish.PublishingExtension
import org.gradle.api.tasks.*
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.api.tasks.testing.Test
import org.gradle.jvm.component.internal.JvmSoftwareComponentInternal
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.the
Expand Down Expand Up @@ -53,6 +54,7 @@ val TaskContainer.jar: TaskProvider<Jar> get() = named<Jar>("jar")
val TaskContainer.apiJar: TaskProvider<Jar> get() = named<Jar>("apiJar")
val TaskContainer.sourcesJar: TaskProvider<Jar> get() = named<Jar>("sourcesJar")
val TaskContainer.javadocJar: TaskProvider<Jar> get() = named<Jar>("javadocJar")
val TaskContainer.test: TaskProvider<Test> get() = named<Test>("test")

operator fun JavaPluginExtension.invoke(action: Action<JavaPluginExtension>) = action.execute(this)
operator fun PublishingExtension.invoke(action: Action<PublishingExtension>) = action.execute(this)
Expand Down

0 comments on commit 0fd5de9

Please sign in to comment.