mirror of
https://github.com/architectury/architectury-plugin.git
synced 2026-03-27 19:57:00 -05:00
Properly support Loom 1.1 & Gradle 8
This commit is contained in:
@@ -116,7 +116,7 @@ jar {
|
||||
attributes 'Implementation-Version': project.version
|
||||
}
|
||||
|
||||
from sourceSets.loom06.output + sourceSets.loom09.output + sourceSets.loom010Legacy.output + sourceSets.loom010.output + sourceSets.loom011.output
|
||||
from sourceSets.loom06.output + sourceSets.loom09.output + sourceSets.loom010Legacy.output + sourceSets.loom010.output + sourceSets.loom011.output + sourceSets.loom11.output
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package dev.architectury.plugin
|
||||
|
||||
import dev.architectury.plugin.loom.LoomInterface
|
||||
import dev.architectury.plugin.utils.GradleSupport
|
||||
import dev.architectury.transformer.Transformer
|
||||
import dev.architectury.transformer.input.OpenedFileAccess
|
||||
import dev.architectury.transformer.shadowed.impl.com.google.common.hash.Hashing
|
||||
@@ -57,7 +58,10 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
it.parentFile.mkdirs()
|
||||
}
|
||||
}
|
||||
|
||||
private val gradle8: Boolean by lazy {
|
||||
// We use compileOnly on Gradle 8+, I am not sure of the consequences of using compileOnly on Gradle 7
|
||||
GradleSupport.isGradle8(project)
|
||||
}
|
||||
private val loom: LoomInterface by lazy {
|
||||
LoomInterface.get(project)
|
||||
}
|
||||
@@ -136,7 +140,7 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
|
||||
private fun getCompileClasspath(): Iterable<File> {
|
||||
return project.configurations.findByName("architecturyTransformerClasspath")
|
||||
?: project.configurations.getByName("compileClasspath")
|
||||
?: project.configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME)
|
||||
}
|
||||
|
||||
fun transform(name: String, action: Action<Transform>) {
|
||||
@@ -151,7 +155,7 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
var plsAddInjectables = false
|
||||
project.configurations.findByName("architecturyTransformerClasspath")
|
||||
?: project.configurations.create("architecturyTransformerClasspath") {
|
||||
it.extendsFrom(project.configurations.getByName("compileClasspath"))
|
||||
it.extendsFrom(project.configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME))
|
||||
plsAddInjectables = true
|
||||
}
|
||||
val architecturyJavaAgents = project.configurations.create("architecturyJavaAgents") {
|
||||
@@ -161,10 +165,22 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
transformedLoom = true
|
||||
|
||||
with(project.dependencies) {
|
||||
// We are trying to not leak to consumers that we are using architectury-transformer
|
||||
if (gradle8) {
|
||||
val customRuntimeClasspath = project.configurations.findByName("architecturyTransformerRuntimeClasspath")
|
||||
?: project.configurations.create("architecturyTransformerRuntimeClasspath") {
|
||||
project.configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(it)
|
||||
}
|
||||
add(
|
||||
customRuntimeClasspath.name,
|
||||
"dev.architectury:architectury-transformer:$transformerVersion:runtime"
|
||||
)
|
||||
} else {
|
||||
add(
|
||||
JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME,
|
||||
"dev.architectury:architectury-transformer:$transformerVersion:runtime"
|
||||
)
|
||||
}
|
||||
add(
|
||||
"architecturyJavaAgents",
|
||||
"dev.architectury:architectury-transformer:$transformerVersion:agent"
|
||||
@@ -336,7 +352,7 @@ open class ArchitectPluginExtension(val project: Project) {
|
||||
|
||||
with(project.dependencies) {
|
||||
add(
|
||||
JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME,
|
||||
if (gradle8) JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME else JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME,
|
||||
"dev.architectury:architectury-injectables:$injectablesVersion"
|
||||
)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package dev.architectury.plugin.utils
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.util.GradleVersion
|
||||
|
||||
object GradleSupport {
|
||||
fun getFileProperty(project: Project): RegularFileProperty {
|
||||
@@ -29,4 +30,8 @@ object GradleSupport {
|
||||
method.isAccessible = true
|
||||
return method.invoke(`object`) as RegularFileProperty
|
||||
}
|
||||
|
||||
fun isGradle8(project: Project): Boolean {
|
||||
return GradleVersion.current().baseVersion >= GradleVersion.version("8.0")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user