Skip to content

Commit

Permalink
Improve Gradle tasks to rename and move directly (Thanks @DevMunky)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabber235 committed Jan 20, 2025
1 parent 16e7f3d commit 775c63a
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 51 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/build-and-publish-release-jars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,9 @@ jobs:
with:
name: Typewriter-Releases
path: |
engine/engine-paper/build/libs/Typewriter.jar
extensions/**/build/libs/*Extensions.jar
jars/engine/*.jar
jars/extensions/*.jar
retention-days: 1
- name: Reset Extensions Gradle Builds Build
uses: gradle/gradle-build-action@v2
with:
arguments: clean --scan
build-root-directory: ./extensions
# ----------------------------------------------------------------------------------------------------
- name: Publish Engine to Beta Maven Repository
uses: gradle/gradle-build-action@v2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-development-jars-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Test Extensions
uses: gradle/gradle-build-action@v2
with:
arguments: test clean --scan
arguments: test --scan
build-root-directory: ./extensions
# ----------------------------------------------------------------------------------------------------
- name: Publish Engine to Beta Maven Repository
Expand Down Expand Up @@ -64,8 +64,8 @@ jobs:
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
modrinth-featured: false
files: |
engine/engine-paper/build/libs/Typewriter.jar
extensions/**/build/libs/*Extension.jar
jars/engine/*.jar
jars/extensions/*.jar
name: "Typewriter v${{ steps.vars.outputs.version }} Build"
version: "${{ steps.vars.outputs.version }}"
version-type: "beta"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-engine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: Typewriter.jar
path: engine/engine-paper/build/libs/Typewriter.jar
path: jars/engine/*.jar
3 changes: 1 addition & 2 deletions .github/workflows/build-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ jobs:
- name: Upload Extension
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.extension }}.jar
path: extensions/${{ inputs.extension }}/build/libs/${{ inputs.extension }}.jar
path: jars/extensions/*.jar
4 changes: 2 additions & 2 deletions .github/workflows/test-building.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
with:
name: Typewriter-Alpha-Builds
path: |
engine/engine-paper/build/libs/Typewriter.jar
extensions/**/build/libs/*Extension.jar
jars/engine/*.jar
jars/extensions/*.jar
retention-days: 1
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,6 @@ code_generator/EntityHeightProperty.kt
code_generator/EntityWidthProperty.kt

# For the moment
/marketplace
/marketplace

jars/
23 changes: 7 additions & 16 deletions engine/engine-paper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,8 @@ task<ShadowJar>("buildAndMove") {
description = "Builds the jar and moves it to the server folder"
outputs.upToDateWhen { false }

// Move the jar from the build/libs folder to the server/plugins folder
doLast {
val jar = file("build/libs/%s-%s-all.jar".format(project.name, project.version))
val server = file("../../server/plugins/Typewriter.jar")
jar.copyTo(server, overwrite = true)
}
destinationDirectory = file("../../server/plugins")
archiveFileName = "Typewriter.${archiveExtension.get()}"
}

task("copyFlutterWebFiles") {
Expand All @@ -105,25 +101,20 @@ task("copyFlutterWebFiles") {
}
}

task("buildRelease") {
dependsOn("copyFlutterWebFiles", "shadowJar")
task<ShadowJar>("buildRelease") {
dependsOn("copyFlutterWebFiles")
group = "build"
description = "Builds the jar including the flutter web panel"

outputs.upToDateWhen { false }

archiveFileName = "Typewriter-${project.version}.${archiveExtension.get()}"
destinationDirectory = file("../../jars/engine")

doLast {
// Remove the flutter web folder
val flutterWebDest = file("src/main/resources/web")
flutterWebDest.deleteRecursively()

// Rename the jar to remove the version and -all
val jar = file("build/libs/%s-%s-all.jar".format(project.name, project.version))
if (!jar.exists()) {
throw IllegalStateException("Jar does not exist: ${jar.absolutePath}")
}
jar.renameTo(file("build/libs/Typewriter.jar".format(project.name)))
file("build/libs/%s-%s.jar".format(project.name, project.version)).delete()
}
}

Expand Down
25 changes: 6 additions & 19 deletions extensions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,21 @@ subprojects {
}

if (!project.name.startsWith("_")) {
tasks.register("buildAndMove") {
dependsOn("shadowJar")

task<ShadowJar>("buildAndMove") {
group = "build"
description = "Builds the jar and moves it to the server folder"
outputs.upToDateWhen { false }

// Move the jar from the build/libs folder to the server/plugins folder
doLast {
val jar = file("build/libs/%s-%s-all.jar".format(project.name, project.version))
val server =
file("../../server/plugins/Typewriter/extensions/%s.jar".format(project.name.capitalizeAsciiOnly()))
jar.copyTo(server, overwrite = true)
}
archiveFileName = "${project.name}.${archiveExtension.get()}"
destinationDirectory = file("../../server/plugins/Typewriter/extensions")
}

tasks.register("buildRelease") {
onlyIf { !project.name.startsWith("_") }
dependsOn("shadowJar")
task<ShadowJar>("buildRelease") {
group = "build"
description = "Builds the jar and renames it"

doLast {
// Rename the jar to remove the version and -all
val jar = file("build/libs/%s-%s-all.jar".format(project.name, project.version))
jar.renameTo(file("build/libs/%s.jar".format(project.name)))
file("build/libs/%s-%s.jar".format(project.name, project.version)).delete()
}
archiveFileName = "${project.name}.${archiveExtension.get()}"
destinationDirectory = file("../../jars/extensions")
}

tasks.register("releaseSourcesJar", Jar::class) {
Expand Down

0 comments on commit 775c63a

Please sign in to comment.