Skip to content

Commit

Permalink
Fix build.gradle.kts (#67)
Browse files Browse the repository at this point in the history
* Fix Exploits

* Fix build.gradle.kts
  • Loading branch information
IPECTER authored Dec 30, 2023
1 parent 68b9b26 commit 6343f61
Showing 1 changed file with 66 additions and 35 deletions.
101 changes: 66 additions & 35 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,53 @@ dependencies {
paperclip("io.papermc:paperclip:3.0.3")
}

subprojects {
allprojects {
apply(plugin = "java")
apply(plugin = "maven-publish")

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))

publishing {
repositories {
maven {
name = "githubPackage"
url = uri("https://maven.pkg.github.com/PlazmaMC/Plazma")

credentials {
username = System.getenv("GITHUB_USERNAME")
password = System.getenv("GITHUB_TOKEN")
}
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
publications.register<MavenPublication>("gpr") {
from(components["java"])
}
}
}
}

subprojects {
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.release.set(17)
}
apply(plugin = "java")

tasks.withType<Javadoc> {
options.encoding = Charsets.UTF_8.name()
}
tasks {
withType<JavaCompile>().configureEach {
options.compilerArgs.add("--add-modules=jdk.incubator.vector")
options.encoding = Charsets.UTF_8.name()
options.release.set(17)
}

tasks.withType<ProcessResources> {
filteringCharset = Charsets.UTF_8.name()
}
withType<Javadoc> {
options.encoding = Charsets.UTF_8.name()
}

tasks.withType<Test> {
minHeapSize = "2g"
maxHeapSize = "2g"
withType<ProcessResources> {
filteringCharset = Charsets.UTF_8.name()
}

withType<Test> {
minHeapSize = "2g"
maxHeapSize = "2g"
}
}

repositories {
Expand Down Expand Up @@ -83,28 +103,39 @@ paperweight {
}
}

val upstreamTask = tasks.register("updateUpstream") {
val tempDir = layout.cacheDir("updateUpstream");
val file = "gradle.properties";

doFirst {
val apiResponse = layout.cache.resolve("apiResponse.json");
download.get().download("https://api.github.com/repos/PaperMC/Paper/commits/master", apiResponse);
val latestCommit = gson.fromJson<paper.libs.com.google.gson.JsonObject>(apiResponse)["sha"].asString;
tasks {
generateDevelopmentBundle {
apiCoordinates.set("org.plazmamc.plazma:plazma-api")
mojangApiCoordinates.set("io.papermc.paper:paper-mojangapi")
libraryRepositories.addAll(
"https://repo.maven.apache.org/maven2/",
"https://papermc.io/repo/repository/maven-public/"
)
}

copy {
from(file)
into(tempDir)
filter { line: String ->
line.replace("paperCommit = .*".toRegex(), "paperCommit = $latestCommit")
register("updateUpstream") {
val tempDir = layout.cacheDir("updateUpstream");
val file = "gradle.properties";

doFirst {
val apiResponse = layout.cache.resolve("apiResponse.json");
download.get().download("https://api.github.com/repos/PaperMC/Paper/commits/master", apiResponse);
val latestCommit = gson.fromJson<paper.libs.com.google.gson.JsonObject>(apiResponse)["sha"].asString;

copy {
from(file)
into(tempDir)
filter { line: String ->
line.replace("paperCommit = .*".toRegex(), "paperCommit = $latestCommit")
}
}
}
}

doLast {
copy {
from(tempDir.file("gradle.properties"))
into(project.file(file).parent)
doLast {
copy {
from(tempDir.file("gradle.properties"))
into(project.file(file).parent)
}
}
}
}

0 comments on commit 6343f61

Please sign in to comment.