Skip to content

Commit

Permalink
优化构建文件 + 移出build文件夹
Browse files Browse the repository at this point in the history
  • Loading branch information
Xujiayao committed Jan 16, 2024
1 parent bc35a4e commit 2dd0b6c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: MC-Discord-Chat ${{ steps.get_short_commit_hash.outputs.short_sha }}
path: wrapper/build/libs/*.jar
path: build/*.jar
9 changes: 6 additions & 3 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ for (String version : versions) {
proj.buildFileName = "../../common.gradle"
}

include(":wrapper")
include(":active")
def active = project(":active")
active.name = "active"
active.projectDir = file("wrapper/active")

include(":compat")
def compat = project(":compat")
compat.projectDir = file("wrapper")
compat.buildFileName = "compat.gradle"
compat.name = "compat"
compat.projectDir = file("wrapper/compat")
10 changes: 9 additions & 1 deletion wrapper/build.gradle → wrapper/active/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ base {
archivesName = archives_base_name
}

sourceSets {
main.resources.srcDir "../src/main/resources"
}

dependencies {
minecraft("com.mojang:minecraft:${minecraft_version}")
mappings("net.fabricmc:yarn:${yarn_mappings}:v2")
Expand Down Expand Up @@ -40,7 +44,7 @@ dependencies {
}

def fabric_subprojects = parent.subprojects.findAll({
it.name != "wrapper" && !it.name.contains("compat")
it.name != "active" && !it.name.contains("compat")
})

remapJar {
Expand Down Expand Up @@ -92,4 +96,8 @@ processResources {
writer.flush()
writer.close()
}
}

clean {
delete file("../../build")
}
22 changes: 19 additions & 3 deletions wrapper/compat.gradle → wrapper/compat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ base {
archivesName = archives_base_name
}

sourceSets {
main.resources.srcDir "../src/main/resources"
}

dependencies {
minecraft("com.mojang:minecraft:${minecraft_version}")
mappings("net.fabricmc:yarn:${yarn_mappings}:v2")
Expand Down Expand Up @@ -43,8 +47,8 @@ def fabric_subprojects = parent.subprojects.findAll({
it.name.contains("compat_")
})

compileJava.dependsOn(":wrapper:jar")
processResources.dependsOn(":wrapper:jar")
compileJava.dependsOn(":active:jar")
processResources.dependsOn(":active:jar")

remapJar {
outputs.upToDateWhen { false }
Expand All @@ -53,7 +57,7 @@ remapJar {
fabric_subprojects.collect {
it.tasks.remapJar
}
":wrapper:remapJar"
":active:remapJar"
}

doFirst {
Expand All @@ -72,6 +76,18 @@ remapJar {
rename { "${it}_${archives_base_name}" }
}
from("build/tmp/versions")

doLast {
delete fileTree("../../build")
copy {
from "../active/build/libs"
into "../../build"
}
copy {
from "build/libs"
into "../../build"
}
}
}

processResources {
Expand Down

0 comments on commit 2dd0b6c

Please sign in to comment.