diff --git a/build.gradle.kts b/build.gradle.kts index 8b1c43b..1cf73b6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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 { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23..9355b41 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/src/main/kotlin/com/github/minecraftschurlimods/helperplugin/HelperExtension.kt b/src/main/kotlin/com/github/minecraftschurlimods/helperplugin/HelperExtension.kt index 32aa70d..4757f78 100644 --- a/src/main/kotlin/com/github/minecraftschurlimods/helperplugin/HelperExtension.kt +++ b/src/main/kotlin/com/github/minecraftschurlimods/helperplugin/HelperExtension.kt @@ -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 @@ -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 @@ -273,13 +271,13 @@ open class HelperExtension @Inject constructor(private val project: Project) { fun withDataGenRuns(cfg: Action = Action{}) { 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 { @@ -300,4 +298,15 @@ open class HelperExtension @Inject constructor(private val project: Project) { cfg.execute(this) } } + + fun withUnitTestRuns(cfg: Action = Action{}) { + project.runs.maybeCreate("junit").apply { + singleInstance() + jvmArgument("-ea") + cfg.execute(this) + } + project.tasks.test.configure { + useJUnitPlatform() + } + } } diff --git a/src/main/kotlin/com/github/minecraftschurlimods/helperplugin/Util.kt b/src/main/kotlin/com/github/minecraftschurlimods/helperplugin/Util.kt index 2b24689..3a7af20 100644 --- a/src/main/kotlin/com/github/minecraftschurlimods/helperplugin/Util.kt +++ b/src/main/kotlin/com/github/minecraftschurlimods/helperplugin/Util.kt @@ -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 @@ -53,6 +54,7 @@ val TaskContainer.jar: TaskProvider get() = named("jar") val TaskContainer.apiJar: TaskProvider get() = named("apiJar") val TaskContainer.sourcesJar: TaskProvider get() = named("sourcesJar") val TaskContainer.javadocJar: TaskProvider get() = named("javadocJar") +val TaskContainer.test: TaskProvider get() = named("test") operator fun JavaPluginExtension.invoke(action: Action) = action.execute(this) operator fun PublishingExtension.invoke(action: Action) = action.execute(this)