Skip to content

Commit

Permalink
updated javalin and start to add neoforge
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticdrew committed Jun 16, 2024
1 parent a8806ce commit 8296c97
Show file tree
Hide file tree
Showing 10 changed files with 377 additions and 33 deletions.
27 changes: 16 additions & 11 deletions Common/src/main/kotlin/journeymap/service/webmap/Webmap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ object Webmap {
if (!dir.exists()) {
logger.info("1Attempting to copy web content to {}", File(Constants.JOURNEYMAP_DIR, "web"))
val created =
FileHandler.copyResources(dir, ResourceLocation(journeymap.Constants.MOD_ID, "web"), "", false)
FileHandler.copyResources(
dir,
ResourceLocation(journeymap.Constants.MOD_ID, "web"),
"",
false
)
logger.info("Web content copied successfully: {}", created)
}

Expand All @@ -69,16 +74,16 @@ object Webmap {
}.before { ctx ->
ctx.header("Access-Control-Allow-Origin", "*")
ctx.header("Cache-Control", "no-cache")
}.routes {
get("/waypoint/{id}/icon", ::iconGet)
get("/data/{type}", ::dataGet)
get("/logs", ::logGet)
get("/polygons", ::polygonsGet)
get("/resources", ::resourcesGet)
get("/skin/{uuid}", ::skinGet)
get("/status", ::statusGet)
get("/tiles/tile.png", ::tilesGet)
}.start(port)
}
get("/waypoint/{id}/icon", ::iconGet)
get("/data/{type}", ::dataGet)
get("/logs", ::logGet)
get("/polygons", ::polygonsGet)
get("/resources", ::resourcesGet)
get("/skin/{uuid}", ::skinGet)
get("/status", ::statusGet)
get("/tiles/tile.png", ::tilesGet)
app?.start(port)

} catch (e: Exception) {
logger.error("Failed to start server: $e")
Expand Down
4 changes: 2 additions & 2 deletions Fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2'
classpath("io.github.goooler.shadow:shadow-gradle-plugin:8.1.7")
classpath group: 'com.modrinth.minotaur', name: 'Minotaur', version: '2.+'
}
}
Expand All @@ -18,7 +18,7 @@ plugins {
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'io.github.juuxel.loom-quiltflower' version '1.8.0'
}
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'io.github.goooler.shadow'
apply plugin: "com.modrinth.minotaur"
apply plugin: "maven-publish"

Expand Down
7 changes: 3 additions & 4 deletions Forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ buildscript {

dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2'
classpath("io.github.goooler.shadow:shadow-gradle-plugin:8.1.7")
classpath 'gradle.plugin.com.matthewprenger:CurseGradle:1.4.0'
classpath 'org.parchmentmc:librarian:1.+'
classpath 'org.spongepowered:mixingradle:0.7.+'
Expand All @@ -30,7 +30,7 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'com.matthewprenger.cursegradle'
apply plugin: 'eclipse'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'io.github.goooler.shadow'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: "com.modrinth.minotaur"
Expand Down Expand Up @@ -64,8 +64,7 @@ dependencies {
//external libs shade
shade group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'
shade group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: '1.6.10'
shade group: 'io.javalin', name: 'javalin', version: '5.3.0'
shade group: 'io.github.earcut4j', name: 'earcut4j', version: '2.2.2'
shade group: 'io.javalin', name: 'javalin', version: '6.0.0'
shade group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.3'

compileOnly project(":Common")
Expand Down
295 changes: 295 additions & 0 deletions NeoForge/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,295 @@
buildscript {
repositories {
mavenCentral()

maven {
name = "forge"
url = "https://maven.minecraftforge.net"
}
maven {
url = 'https://maven.parchmentmc.org'
}
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
url = 'https://repo.spongepowered.org/maven'
}
}

dependencies {
classpath("io.github.goooler.shadow:shadow-gradle-plugin:8.1.7")
classpath group: 'com.modrinth.minotaur', name: 'Minotaur', version: '2.+'
}
}

plugins {
id "java-library"
id "idea"
id "net.neoforged.gradle.userdev" version "[7.0.142,)"
id 'net.darkhax.curseforgegradle' version '1.+'
}


apply plugin: 'io.github.goooler.shadow'
apply plugin: "com.modrinth.minotaur"
apply plugin: "maven-publish"

version = "${project.mod_version}+${project.minecraft_version}"
def modVersion = "${project.mod_version}"

group = project.group_id
archivesBaseName = project.base_name

configurations {
shade
}

configurations.all {
// Check for snapshots more frequently than Gradle's default of 1 day. 0 = every build.
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

dependencies {
implementation "net.neoforged:neoforge:${neoforge_version}"
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
implementation group: "info.journeymap", name: "journeymap-api-neoforge", version: "${project.journeymap_api_version}-${project.minecraft_version}-SNAPSHOT", changing: true
// implementation fg.deobf("curse.maven:journeymap-32274:${project.jourenymap_forge_version}")
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-inline:4.1.+'

shade group: 'info.journeymap', name: 'webmap-client', version: project.journeymap_webmap_version, changing: true

//external libs shade
shade group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'
shade group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: '1.6.10'
shade group: 'io.javalin', name: 'javalin', version: '6.0.0'
shade group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.3'

compileOnly project(":Common")
}

mixin {
add sourceSets.main, "journeymap-refmap.json"
}

runs {
configureEach {
systemProperty "mixin.debug.export", "true"
systemProperty "forge.logging.console.level", "info"
systemProperty "journeymap.map_testing", "true"

modSource project.sourceSets.main
}
client {
workingDirectory project.file("run/client")
}
server {
programArgument "--nogui"
workingDirectory project.file("run/server")
}
}

tasks.build.dependsOn shadowJar
jar.finalizedBy('shadowJar')

shadowJar {
archiveName = "${baseName}-${version}-forge.${extension}"
classifier = ''
configurations = [project.configurations.shade]
duplicatesStrategy = DuplicatesStrategy.INCLUDE
dependencies {
exclude("META-INF/maven/**")
exclude("META-INF/services/org.*")
exclude("META-INF/services/jakarta.*")
exclude(dependency("org.ow2.asm:.*:.*"))
}
minimize {
// API has utility classes that must be included
exclude(dependency("info.journeymap:.*:.*"))
exclude(dependency("org.slf4j:.*:.*"))
}

relocate "jakarta", "info.journeymap.shaded.jakarta"
relocate "javax.servlet", "info.journeymap.shaded.org.javax.servlet"
relocate "org.intellij", "info.journeymap.shaded.org.intellij"
relocate "org.jetbrains", "info.journeymap.shaded.org.jetbrains"
relocate "org.slf4j", "info.journeymap.shaded.org.slf4j"
relocate "org.eclipse", "info.journeymap.shaded.org.eclipse"

relocate "kotlin", "info.journeymap.shaded.kotlin.kotlin"
relocate "io.javalin", "info.journeymap.shaded.io.javalin"

exclude 'dummyThing'
exclude 'LICENSE.txt'
}

tasks.withType(JavaCompile) {
source(project(":Common").sourceSets.main.allSource)
options.encoding = "UTF-8"
}


// This block of code expands all the gradle properties in the specified resource targets.
// It copies them into the targets and expands all the defined properties.
def resourceTargets = ['META-INF/neoforge.mods.toml', 'pack.mcmeta', 'license.txt']
def intoTargets = ["$rootDir/out/production/resources/", "$rootDir/out/production/${project.name}.main/", "$rootDir/bin/main/"]
def replaceProperties = [
version : project.version,
modVersion : modVersion,
mcversion : project.minecraft_version,
date : getDate()
]

processResources() {
from project(":Common").sourceSets.main.resources
// duplicatesStrategy = DuplicatesStrategy.INCLUDE
// this will ensure that this task is redone when the versions change.
inputs.properties replaceProperties
filesMatching(resourceTargets) {
expand replaceProperties
}

intoTargets.each { target ->
if (file(target).exists()) {
copy {
from(sourceSets.main.resources) {
include resourceTargets
expand replaceProperties
}
into target
}
}
}
}

task processDocs(type: Copy) {
// update docs
from(file("../doc/")) {
include '*.html'
expand 'version': project.version,
'date': getDate(),
'mcversion': project.minecraft_version,
'loaderversion': project.forge_version,
'loadername': "Forge"
}
into 'build/doc'
}


clean.doFirst {
// Remove the Webpack bundled assets as part of the clean task
delete "$projectDir/src/main/resources/assets/journeymap/web/"
}

jar {
classifier = 'slim'
dependsOn 'processDocs'
manifest {
attributes([
"Specification-Title" : project.name,
"Specification-Vendor" : project.group_id,
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : "${version}",
"Implementation-Vendor" : project.group_id,
"Implementation-URL" : "http://journeymap.info",
"Implementation-Timestamp": getDate(),
"FMLAT" : "accesstransformer.cfg",
])
}
}


artifacts {
archives shadowJar
}

def getDate() {
def date = new Date()
def formattedDate = date.format(project.dateFormat)
return formattedDate
}

// Automated upload to CurseForge for the win!
if (!project.hasProperty("curseForgeApiKey")) {
ext.curseForgeApiKey = "notset"
}
if (!project.hasProperty("modrinthApiKey")) {
ext.modrinthApiKey = "notset"
}

curseforge {
project {
id = '793035'
apiKey = "${curseForgeApiKey}"
changelogType = 'html'
releaseType = release_type
addGameVersion project.minecraft_version
relations {
requiredDependency 'journeymap'
}

mainArtifact(shadowJar) {
displayName = "${archivesBaseName}-${version}-forge"
changelog = file('/build/doc/changelog.html')
}
}
}


tasks.modrinth.dependsOn(tasks.assemble)

modrinth {
token = "${modrinthApiKey}"
projectId = "YaZ1fUTg"
versionNumber = "${version}-forge"
versionName = "${archivesBaseName}-${version}-forge"
versionType = release_type
uploadFile = shadowJar
gameVersions = ["${project.minecraft_version}"]
loaders = ["forge"]
changelog = file('/build/doc/changelog.html').exists() ? file('/build/doc/changelog.html').text : null
dependencies {
required.project "journeymap"
}
}

// Ensure build is done prior to cursegradle tasks
project.afterEvaluate {
project.tasks.findAll { task ->
(task.name.startsWith('curseforge') || task.name.startsWith('modrinth'))
&& (task.name != 'curseforge' || task.name != 'modrinth')
}.each { projectTask ->
projectTask.dependsOn build
}
}
tasks.withType(PublishToMavenRepository) { task ->
task.dependsOn reobfShadowJar
}
tasks.named('assemble').configure { dependsOn 'shadowJar' }
jar.finalizedBy 'reobfJar'
shadowJar.finalizedBy 'reobfShadowJar'

publishing {
repositories {
maven {
name = "JourneyMap"
url = uri("https://jm.gserv.me/repository/maven-releases/")

credentials {
username = project.findProperty("journeymap.user") ?: System.getenv("JOURNEYMAP_WEB_USER")
password = project.findProperty("journeymap.password") ?: System.getenv("JOURNEYMAP_WEB_PASSWORD")
}
}
}

publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version "${project.version}-forge"
artifact shadowJar
}
}
}
1 change: 1 addition & 0 deletions NeoForge/src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public com.mojang.blaze3d.platform.NativeImage m_85064_(Ljava/nio/channels/WritableByteChannel;)Z #writeToChannel
Loading

0 comments on commit 8296c97

Please sign in to comment.