Skip to content

Commit 1737bb1

Browse files
committed
fix relative path of gradle plugin
1 parent aafd944 commit 1737bb1

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/main/kotlin/top/mcfpp/gradle/MCFPPGradlePlugin.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,29 @@ class MCFPPGradlePlugin: Plugin<Project> {
3838

3939
val config = project.extensions.create("mcfpp", ProjectConfig::class.java)
4040

41-
if(config.root == null) config.root = project.rootDir.toPath()
42-
if(config.sourcePath == null) config.sourcePath = Path(config.root!!.absolutePathString(), "src/main/mcfpp")
43-
if(config.targetPath == null) config.targetPath = project.layout.buildDirectory.get().dir("datapack").asFile.toPath()
44-
4541
// 自定义任务来调用MCFPP
4642
project.tasks.register("mcfppCompile") {
4743
it.group = "build"
4844
it.description = "Compile mcfpp files"
4945

5046
it.dependsOn("jar")
5147

48+
if(config.root == null) config.root = project.rootDir.toPath()
49+
50+
if(config.sourcePath == null) {
51+
config.sourcePath = Path(config.root!!.absolutePathString(), "src/main/mcfpp")
52+
}
53+
else if(config.sourcePath?.isAbsolute == false) {
54+
config.sourcePath = config.root!!.resolve(config.sourcePath!!)
55+
}
56+
57+
if(config.targetPath == null) {
58+
config.targetPath = project.layout.buildDirectory.get().dir("datapack").asFile.toPath()
59+
}
60+
else if(config.targetPath?.isAbsolute == false) {
61+
config.targetPath = config.root!!.resolve(config.targetPath!!)
62+
}
63+
5264
val jars = (project.tasks.named("jar").get() as org.gradle.api.tasks.bundling.Jar).destinationDirectory.get().files()
5365

5466
it.doLast {

0 commit comments

Comments
 (0)