mirror of
https://github.com/architectury/architectury-plugin.git
synced 2026-03-28 04:07:01 -05:00
Merge pull request #9 from architectury/feature/use_gradle_build
Tell IDEA to delegate through Gradle
This commit is contained in:
@@ -30,6 +30,7 @@ repositories {
|
||||
maven { url "https://maven.fabricmc.net/" }
|
||||
maven { url "https://files.minecraftforge.net/maven/" }
|
||||
maven { url "https://dl.bintray.com/shedaniel/cloth/" }
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
apply plugin: 'java-gradle-plugin'
|
||||
@@ -42,6 +43,7 @@ dependencies {
|
||||
implementation gradleApi()
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72"
|
||||
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.72"
|
||||
implementation "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:0.10"
|
||||
implementation "me.shedaniel:forgified-fabric-loom:$loom_version"
|
||||
runtime "me.shedaniel:forgified-fabric-loom:$loom_version"
|
||||
implementation "net.fabricmc:tiny-remapper:0.3.0.70"
|
||||
@@ -71,6 +73,7 @@ jar {
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
freeCompilerArgs = ['-Xjvm-default=compatibility']
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
kotlin.code.style=official
|
||||
loom_version=0.6.33
|
||||
loom_version=0.6.54
|
||||
base_version=2.0
|
||||
@@ -4,6 +4,9 @@ import me.shedaniel.architect.plugin.transformers.*
|
||||
import net.fabricmc.loom.util.LoggerFilter
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.ExtensionAware
|
||||
import org.gradle.plugins.ide.idea.model.IdeaModel
|
||||
import org.jetbrains.gradle.ext.ActionDelegationConfig
|
||||
import java.net.URI
|
||||
|
||||
class ArchitectPlugin : Plugin<Project> {
|
||||
@@ -23,10 +26,21 @@ class ArchitectPlugin : Plugin<Project> {
|
||||
mapOf(
|
||||
"plugin" to "java",
|
||||
"plugin" to "eclipse",
|
||||
"plugin" to "idea"
|
||||
"plugin" to "idea",
|
||||
"plugin" to "org.jetbrains.gradle.plugin.idea-ext"
|
||||
)
|
||||
)
|
||||
|
||||
project.afterEvaluate {
|
||||
val ideaModel = project.extensions.getByName("idea") as IdeaModel
|
||||
val idea = ideaModel.project as? ExtensionAware
|
||||
val settings = idea?.extensions?.getByName("settings") as? ExtensionAware
|
||||
(settings?.extensions?.getByName("delegateActions") as? ActionDelegationConfig)?.apply {
|
||||
delegateBuildRunToGradle = true
|
||||
testRunner = ActionDelegationConfig.TestRunner.GRADLE
|
||||
}
|
||||
}
|
||||
|
||||
project.extensions.create("architectury", ArchitectPluginExtension::class.java, project)
|
||||
|
||||
project.tasks.register("transformProductionFabric", TransformingTask::class.java) {
|
||||
|
||||
@@ -21,7 +21,7 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
fun platformSetupLoomIde() {
|
||||
val loomExtension = project.extensions.getByType(LoomGradleExtension::class.java)
|
||||
loomExtension.autoGenIDERuns = true
|
||||
loomExtension.addTaskBeforeRun("\$PROJECT_DIR\$/${project.name}:build")
|
||||
loomExtension.addTaskBeforeRun("\$PROJECT_DIR\$/${project.name}:classes")
|
||||
}
|
||||
|
||||
fun common(forgeEnabled: Boolean) {
|
||||
@@ -67,6 +67,8 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
it.outputs.upToDateWhen { false }
|
||||
} as TransformingTask
|
||||
|
||||
transformProductionFabricTask.dependsOn(transformDevelopmentFabricTask)
|
||||
|
||||
val remapJarTask = project.tasks.getByName("remapJar") {
|
||||
it as RemapJarTask
|
||||
|
||||
@@ -103,6 +105,8 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
it.outputs.upToDateWhen { false }
|
||||
} as TransformingTask
|
||||
|
||||
transformProductionForgeTask.dependsOn(transformDevelopmentForgeTask)
|
||||
|
||||
transformProductionForgeTask.archiveFile.get().asFile.takeUnless { it.exists() }?.createEmptyJar()
|
||||
transformDevelopmentForgeTask.archiveFile.get().asFile.takeUnless { it.exists() }?.createEmptyJar()
|
||||
|
||||
|
||||
@@ -3,9 +3,13 @@ package me.shedaniel.architect.plugin
|
||||
import me.shedaniel.architect.plugin.utils.GradleSupport
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import java.io.File
|
||||
import java.io.ObjectOutputStream
|
||||
import java.io.Serializable
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.StandardCopyOption
|
||||
@@ -16,7 +20,10 @@ import kotlin.time.ExperimentalTime
|
||||
import kotlin.time.nanoseconds
|
||||
|
||||
open class TransformingTask : Jar() {
|
||||
@InputFile
|
||||
val input: RegularFileProperty = GradleSupport.getFileProperty(project)
|
||||
|
||||
@Input
|
||||
val transformers = mutableListOf<Transformer>()
|
||||
|
||||
@ExperimentalTime
|
||||
@@ -103,6 +110,12 @@ fun Project.projectUniqueIdentifier(): String {
|
||||
return "architectury_inject_${name}_$id".filter { Character.isJavaIdentifierPart(it) }
|
||||
}
|
||||
|
||||
typealias Transformer = (project: Project, input: Path, output: Path) -> Unit
|
||||
interface Transformer : Serializable {
|
||||
operator fun invoke(project: Project, input: Path, output: Path)
|
||||
|
||||
@JvmDefault
|
||||
fun writeObject(s: ObjectOutputStream) {
|
||||
}
|
||||
}
|
||||
|
||||
object TransformerStepSkipped : Throwable()
|
||||
Reference in New Issue
Block a user