fix: 尝试修复构建环境配置错误

This commit is contained in:
叁玖领域 2026-05-12 20:39:30 +08:00
parent db7fe0b8f0
commit 51c9cff999
3 changed files with 31 additions and 54 deletions

View File

@ -41,26 +41,18 @@ clean {
def loaderAttribute = Attribute.of('io.github.mcgradleconventions.loader', String) def loaderAttribute = Attribute.of('io.github.mcgradleconventions.loader', String)
['apiElements', 'runtimeElements', 'sourcesElements', 'javadocElements'].each { variant -> ['apiElements', 'runtimeElements', 'sourcesElements', 'javadocElements'].each { variant ->
try { configurations.named("$variant") {
configurations.named(variant) {
if (!it.isLocked()) {
attributes { attributes {
attribute(loaderAttribute, 'common') attribute(loaderAttribute, 'common')
} }
} }
}
} catch (Exception ignored) {}
} }
sourceSets.configureEach { sourceSets.configureEach {
[it.compileClasspathConfigurationName, it.runtimeClasspathConfigurationName].each { variant -> [it.compileClasspathConfigurationName, it.runtimeClasspathConfigurationName].each { variant->
try { configurations.named("$variant") {
configurations.named(variant) {
if (!it.isLocked()) {
attributes { attributes {
attribute(loaderAttribute, 'common') attribute(loaderAttribute, 'common')
} }
} }
} }
} catch (Exception ignored) {}
}
} }

View File

@ -136,26 +136,18 @@ loom {
def loaderAttribute = Attribute.of('io.github.mcgradleconventions.loader', String) def loaderAttribute = Attribute.of('io.github.mcgradleconventions.loader', String)
['apiElements', 'runtimeElements', 'sourcesElements', 'javadocElements', 'includeInternal', 'modCompileClasspath'].each { variant -> ['apiElements', 'runtimeElements', 'sourcesElements', 'javadocElements', 'includeInternal', 'modCompileClasspath'].each { variant ->
try { configurations.named("$variant") {
configurations.named(variant) {
if (!it.isLocked()) {
attributes { attributes {
attribute(loaderAttribute, 'fabric') attribute(loaderAttribute, 'fabric')
} }
} }
}
} catch (Exception ignored) {}
} }
sourceSets.configureEach { sourceSets.configureEach {
[it.compileClasspathConfigurationName, it.runtimeClasspathConfigurationName].each { variant -> [it.compileClasspathConfigurationName, it.runtimeClasspathConfigurationName].each { variant->
try { configurations.named("$variant") {
configurations.named(variant) {
if (!it.isLocked()) {
attributes { attributes {
attribute(loaderAttribute, 'fabric') attribute(loaderAttribute, 'fabric')
} }
} }
} }
} catch (Exception ignored) {}
}
} }

View File

@ -31,7 +31,7 @@ neoForge {
) )
} }
data { data {
data() clientData()
// DataGen can be run by - "./gradlew :neoforge:runData" in Terminal. // DataGen can be run by - "./gradlew :neoforge:runData" in Terminal.
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
@ -108,28 +108,21 @@ tasks.named('build') {
sourceSets.main.resources.srcDir project(':common').file('src/generated/resources') sourceSets.main.resources.srcDir project(':common').file('src/generated/resources')
// Implement mcgradleconventions loader attribute
def loaderAttribute = Attribute.of('io.github.mcgradleconventions.loader', String) def loaderAttribute = Attribute.of('io.github.mcgradleconventions.loader', String)
['apiElements', 'runtimeElements', 'sourcesElements', 'javadocElements'].each { variant -> ['apiElements', 'runtimeElements', 'sourcesElements', 'javadocElements'].each { variant ->
try { configurations.named("$variant") {
configurations.named(variant) {
if (!it.isLocked()) {
attributes { attributes {
attribute(loaderAttribute, 'neoforge') attribute(loaderAttribute, 'neoforge')
} }
} }
}
} catch (Exception ignored) {}
} }
sourceSets.configureEach { sourceSets.configureEach {
[it.compileClasspathConfigurationName, it.runtimeClasspathConfigurationName, it.getTaskName(null, 'jarJar')].each { variant -> [it.compileClasspathConfigurationName, it.runtimeClasspathConfigurationName, it.getTaskName(null, 'jarJar')].each { variant ->
try { configurations.named("$variant") {
configurations.named(variant) {
if (!it.isLocked()) {
attributes { attributes {
attribute(loaderAttribute, 'neoforge') attribute(loaderAttribute, 'neoforge')
} }
} }
} }
} catch (Exception ignored) {}
}
} }