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
|
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 {
|
gradlePlugin {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
package dev.architectury.plugin
|
package dev.architectury.plugin
|
||||||
|
|
||||||
import dev.architectury.plugin.loom.LoomInterface
|
import dev.architectury.plugin.loom.LoomInterface
|
||||||
|
import dev.architectury.plugin.utils.GradleSupport
|
||||||
import dev.architectury.transformer.Transformer
|
import dev.architectury.transformer.Transformer
|
||||||
import dev.architectury.transformer.input.OpenedFileAccess
|
import dev.architectury.transformer.input.OpenedFileAccess
|
||||||
import dev.architectury.transformer.shadowed.impl.com.google.common.hash.Hashing
|
import dev.architectury.transformer.shadowed.impl.com.google.common.hash.Hashing
|
||||||
@@ -57,7 +58,10 @@ open class ArchitectPluginExtension(val project: Project) {
|
|||||||
it.parentFile.mkdirs()
|
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 {
|
private val loom: LoomInterface by lazy {
|
||||||
LoomInterface.get(project)
|
LoomInterface.get(project)
|
||||||
}
|
}
|
||||||
@@ -136,7 +140,7 @@ open class ArchitectPluginExtension(val project: Project) {
|
|||||||
|
|
||||||
private fun getCompileClasspath(): Iterable<File> {
|
private fun getCompileClasspath(): Iterable<File> {
|
||||||
return project.configurations.findByName("architecturyTransformerClasspath")
|
return project.configurations.findByName("architecturyTransformerClasspath")
|
||||||
?: project.configurations.getByName("compileClasspath")
|
?: project.configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun transform(name: String, action: Action<Transform>) {
|
fun transform(name: String, action: Action<Transform>) {
|
||||||
@@ -151,7 +155,7 @@ open class ArchitectPluginExtension(val project: Project) {
|
|||||||
var plsAddInjectables = false
|
var plsAddInjectables = false
|
||||||
project.configurations.findByName("architecturyTransformerClasspath")
|
project.configurations.findByName("architecturyTransformerClasspath")
|
||||||
?: project.configurations.create("architecturyTransformerClasspath") {
|
?: project.configurations.create("architecturyTransformerClasspath") {
|
||||||
it.extendsFrom(project.configurations.getByName("compileClasspath"))
|
it.extendsFrom(project.configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME))
|
||||||
plsAddInjectables = true
|
plsAddInjectables = true
|
||||||
}
|
}
|
||||||
val architecturyJavaAgents = project.configurations.create("architecturyJavaAgents") {
|
val architecturyJavaAgents = project.configurations.create("architecturyJavaAgents") {
|
||||||
@@ -161,10 +165,22 @@ open class ArchitectPluginExtension(val project: Project) {
|
|||||||
transformedLoom = true
|
transformedLoom = true
|
||||||
|
|
||||||
with(project.dependencies) {
|
with(project.dependencies) {
|
||||||
add(
|
// We are trying to not leak to consumers that we are using architectury-transformer
|
||||||
JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME,
|
if (gradle8) {
|
||||||
"dev.architectury:architectury-transformer:$transformerVersion:runtime"
|
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(
|
add(
|
||||||
"architecturyJavaAgents",
|
"architecturyJavaAgents",
|
||||||
"dev.architectury:architectury-transformer:$transformerVersion:agent"
|
"dev.architectury:architectury-transformer:$transformerVersion:agent"
|
||||||
@@ -336,7 +352,7 @@ open class ArchitectPluginExtension(val project: Project) {
|
|||||||
|
|
||||||
with(project.dependencies) {
|
with(project.dependencies) {
|
||||||
add(
|
add(
|
||||||
JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME,
|
if (gradle8) JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME else JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME,
|
||||||
"dev.architectury:architectury-injectables:$injectablesVersion"
|
"dev.architectury:architectury-injectables:$injectablesVersion"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package dev.architectury.plugin.utils
|
|||||||
|
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.file.RegularFileProperty
|
import org.gradle.api.file.RegularFileProperty
|
||||||
|
import org.gradle.util.GradleVersion
|
||||||
|
|
||||||
object GradleSupport {
|
object GradleSupport {
|
||||||
fun getFileProperty(project: Project): RegularFileProperty {
|
fun getFileProperty(project: Project): RegularFileProperty {
|
||||||
@@ -29,4 +30,8 @@ object GradleSupport {
|
|||||||
method.isAccessible = true
|
method.isAccessible = true
|
||||||
return method.invoke(`object`) as RegularFileProperty
|
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