1
- import net.neoforged.moddevgradle.dsl.NeoForgeExtension as NfExtension
2
1
import org.gradle.api.Project
3
- import org.gradle.api.file.DuplicatesStrategy
4
2
import org.gradle.api.plugins.JavaPluginExtension
3
+ import org.gradle.api.tasks.compile.JavaCompile
5
4
import org.gradle.jvm.tasks.Jar
6
5
import org.gradle.kotlin.dsl.get
7
6
import org.gradle.kotlin.dsl.getByType
8
7
import org.gradle.kotlin.dsl.withType
8
+ import org.gradle.language.jvm.tasks.ProcessResources
9
+ import net.neoforged.moddevgradle.dsl.NeoForgeExtension as NfExtension
9
10
10
11
open class NeoForgeExtension (private val project : Project ) : BaseExtension(project) {
11
12
var modId: String? = null
12
13
13
14
fun neoForge () {
14
15
val sourceSets = project.extensions.getByType<JavaPluginExtension >().sourceSets
16
+ project.configurations[" commonJava" ].isCanBeResolved = true
17
+ project.configurations[" commonJava" ].isCanBeConsumed = modId == null
18
+ project.configurations[" commonResources" ].isCanBeResolved = true
19
+ project.configurations[" commonResources" ].isCanBeConsumed = modId == null
15
20
project.extensions.getByType<NfExtension >().apply {
16
21
version.set(neoForgeVersion)
17
22
addModdingDependenciesTo(sourceSets[" test" ])
@@ -37,10 +42,15 @@ open class NeoForgeExtension(private val project: Project) : BaseExtension(proje
37
42
}
38
43
}
39
44
sourceSets[" main" ].resources.srcDirs.add(project.file(" src/generated/resources" ))
45
+ project.tasks.withType<JavaCompile >().configureEach {
46
+ dependsOn(project.configurations[" commonJava" ])
47
+ source(project.configurations[" commonJava" ])
48
+ }
49
+ project.tasks.withType<ProcessResources >().configureEach {
50
+ dependsOn(project.configurations[" commonResources" ])
51
+ from(project.configurations[" commonResources" ])
52
+ }
40
53
project.tasks.withType<Jar >().configureEach {
41
- duplicatesStrategy = DuplicatesStrategy .EXCLUDE
42
- // These come in from the common API jars but should not end up in the neoforge jar
43
- exclude(" fabric.mod.json" )
44
54
from(" ../LICENSE.md" )
45
55
}
46
56
}
@@ -79,21 +89,4 @@ open class NeoForgeExtension(private val project: Project) : BaseExtension(proje
79
89
}
80
90
}
81
91
}
82
-
83
- fun compileWithProject (dependency : Project ) {
84
- project.evaluationDependsOn(" :" + dependency.name)
85
- project.dependencies.add(" compileOnly" , dependency)
86
- project.dependencies.add(" testCompileOnly" , dependency)
87
- val sourceSets = dependency.extensions.getByType<JavaPluginExtension >().sourceSets
88
- project.tasks.withType<Jar >().configureEach {
89
- from(sourceSets[" main" ].output)
90
- }
91
- project.extensions.getByType<NfExtension >().apply {
92
- mods {
93
- getByName(modId!! ) {
94
- modSourceSets.add(sourceSets[" main" ])
95
- }
96
- }
97
- }
98
- }
99
92
}
0 commit comments