Skip to content

Commit

Permalink
Try publishing regular jars to maven (not full fat jars) for Forge an…
Browse files Browse the repository at this point in the history
…d NeoForge
  • Loading branch information
mezz committed Jun 14, 2024
1 parent 3000af0 commit e74e8e2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 67 deletions.
2 changes: 2 additions & 0 deletions Fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ publishing {

idea {
module {
isDownloadJavadoc = true
isDownloadSources = true
for (fileName in listOf("run", "out", "logs")) {
excludeDirs.add(file(fileName))
}
Expand Down
45 changes: 11 additions & 34 deletions Forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -142,40 +142,20 @@ minecraft {
}
}

tasks.withType<JavaCompile>().configureEach {
dependencyProjects.forEach {
source(it.sourceSets.main.get().allSource)
}
}

tasks.processResources {
dependencyProjects.forEach {
from(it.sourceSets.main.get().resources)
}
}

tasks.jar {
from(sourceSets.main.get().output)

duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

val sourcesJarTask = tasks.named<Jar>("sourcesJar") {
from(sourceSets.main.get().allJava)
for (p in dependencyProjects) {
from(p.sourceSets.main.get().allJava)
val sourcesJarTask = tasks.named<Jar>("sourcesJar")
val fatJarTask = tasks.create<Jar>("fatJar") {
dependencyProjects.forEach {
from(it.sourceSets.main.get().output)
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveClassifier.set("sources")
}

tasks.register<TaskPublishCurseForge>("publishCurseForge") {
dependsOn(tasks.jar)
dependsOn(fatJarTask)
dependsOn(":Changelog:makeChangelog")

apiToken = project.findProperty("curseforge_apikey") ?: "0"

val mainFile = upload(curseProjectId, tasks.jar.get().archiveFile)
val mainFile = upload(curseProjectId, fatJarTask.archiveFile)
mainFile.changelogType = CFG_Constants.CHANGELOG_HTML
mainFile.changelog = file("../Changelog/changelog.html")
mainFile.releaseType = CFG_Constants.RELEASE_TYPE_BETA
Expand All @@ -194,10 +174,10 @@ modrinth {
versionNumber.set("${project.version}")
versionName.set("${project.version} for Forge $minecraftVersion")
versionType.set("beta")
uploadFile.set(tasks.jar.get())
uploadFile.set(fatJarTask)
changelog.set(provider { file("../Changelog/changelog.md").readText() })
}
tasks.modrinth.get().dependsOn(tasks.jar)
tasks.modrinth.get().dependsOn(fatJarTask)
tasks.modrinth.get().dependsOn(":Changelog:makeMarkdownChangelog")

tasks.named<Test>("test") {
Expand All @@ -214,6 +194,7 @@ tasks.named<Test>("test") {
artifacts {
archives(tasks.jar.get())
archives(sourcesJarTask.get())
archives(fatJarTask)
}

publishing {
Expand Down Expand Up @@ -244,14 +225,10 @@ publishing {

idea {
module {
isDownloadJavadoc = true
isDownloadSources = true
for (fileName in listOf("run", "out", "logs")) {
excludeDirs.add(file(fileName))
}
}
}
// Required because FG, copied from the MDK
sourceSets.forEach {
val outputDir = layout.buildDirectory.file("sourcesSets/${it.name}").get().asFile
it.output.setResourcesDir(outputDir)
it.java.destinationDirectory.set(outputDir)
}
44 changes: 11 additions & 33 deletions NeoForge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,6 @@ dependencyProjects.forEach {
}
project.evaluationDependsOn(":Changelog")

val notNeoTask = { it: Task -> !it.name.startsWith("neo") }

tasks.withType<JavaCompile>().matching(notNeoTask).configureEach {
dependencyProjects.forEach {
source(it.sourceSets.main.get().allSource)
}
}

tasks.withType<ProcessResources>().matching(notNeoTask).configureEach {
dependencyProjects.forEach {
from(it.sourceSets.main.get().resources)
}
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(modJavaVersion))
Expand Down Expand Up @@ -134,31 +120,20 @@ runs {
}
}

tasks.jar {
from(sourceSets.main.get().output)
for (p in dependencyProjects) {
from(p.sourceSets.main.get().output)
}

duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

val sourcesJarTask = tasks.named<Jar>("sourcesJar") {
from(sourceSets.main.get().allJava)
for (p in dependencyProjects) {
from(p.sourceSets.main.get().allJava)
val sourcesJarTask = tasks.named<Jar>("sourcesJar")
val fatJarTask = tasks.create<Jar>("fatJar") {
dependencyProjects.forEach {
from(it.sourceSets.main.get().output)
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveClassifier.set("sources")
}

tasks.register<TaskPublishCurseForge>("publishCurseForge") {
dependsOn(tasks.jar)
dependsOn(fatJarTask)
dependsOn(":Changelog:makeChangelog")

apiToken = project.findProperty("curseforge_apikey") ?: "0"

val mainFile = upload(curseProjectId, tasks.jar.get().archiveFile)
val mainFile = upload(curseProjectId, fatJarTask.archiveFile)
mainFile.changelogType = CFG_Constants.CHANGELOG_HTML
mainFile.changelog = file("../Changelog/changelog.html")
mainFile.releaseType = CFG_Constants.RELEASE_TYPE_BETA
Expand All @@ -177,10 +152,10 @@ modrinth {
versionNumber.set("${project.version}")
versionName.set("${project.version} for NeoForge $minecraftVersion")
versionType.set("beta")
uploadFile.set(tasks.jar.get())
uploadFile.set(fatJarTask)
changelog.set(provider { file("../Changelog/changelog.md").readText() })
}
tasks.modrinth.get().dependsOn(tasks.jar)
tasks.modrinth.get().dependsOn(fatJarTask)
tasks.modrinth.get().dependsOn(":Changelog:makeMarkdownChangelog")

tasks.named<Test>("test") {
Expand All @@ -197,6 +172,7 @@ tasks.named<Test>("test") {
artifacts {
archives(tasks.jar.get())
archives(sourcesJarTask.get())
archives(fatJarTask)
}

publishing {
Expand Down Expand Up @@ -227,6 +203,8 @@ publishing {

idea {
module {
isDownloadJavadoc = true
isDownloadSources = true
for (fileName in listOf("run", "out", "logs")) {
excludeDirs.add(file(fileName))
}
Expand Down

0 comments on commit e74e8e2

Please sign in to comment.