Update build scripts to integrate frontend with backend.
This commit is contained in:
parent
5759d6c0dc
commit
25e8dc8e8e
|
|
@ -2,7 +2,6 @@ plugins {
|
||||||
java
|
java
|
||||||
id("org.springframework.boot") version "3.4.4"
|
id("org.springframework.boot") version "3.4.4"
|
||||||
id("io.spring.dependency-management") version "1.1.7"
|
id("io.spring.dependency-management") version "1.1.7"
|
||||||
// id("com.github.johnrengelman.shadow") version "8.1.1"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.alttd.altitudeweb"
|
group = "com.alttd.altitudeweb"
|
||||||
|
|
@ -27,6 +26,7 @@ repositories {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":open_api"))
|
implementation(project(":open_api"))
|
||||||
implementation(project(":database"))
|
implementation(project(":database"))
|
||||||
|
implementation(project(":frontend"))
|
||||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||||
annotationProcessor("org.projectlombok:lombok")
|
annotationProcessor("org.projectlombok:lombok")
|
||||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||||
|
|
@ -54,42 +54,13 @@ tasks.bootJar {
|
||||||
archiveClassifier.set("")
|
archiveClassifier.set("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.processResources {
|
||||||
|
dependsOn("includeFrontend")
|
||||||
|
}
|
||||||
|
|
||||||
//tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
|
tasks.register<Copy>("includeFrontend") {
|
||||||
// mergeServiceFiles()
|
description = "Copy the built frontend to the Spring Boot static resources directory"
|
||||||
// dependencies {
|
from("${project.rootDir}/frontend/dist")
|
||||||
// include(dependency("com.mysql:mysql-connector-j"))
|
into(layout.buildDirectory.dir("resources/main/static"))
|
||||||
// }
|
doNotTrackState("Cannot reliably track state in the static directory")
|
||||||
//}
|
}
|
||||||
|
|
||||||
//tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
|
|
||||||
// manifest {
|
|
||||||
// attributes["Main-Class"] = "com.alttd.altitudeweb.AltitudeWebApplication"
|
|
||||||
// }
|
|
||||||
// archiveBaseName.set("altitudeweb")
|
|
||||||
// archiveClassifier.set("")
|
|
||||||
// mergeServiceFiles()
|
|
||||||
//
|
|
||||||
// // Include everything
|
|
||||||
// from(sourceSets.main.get().output)
|
|
||||||
//
|
|
||||||
// // Include all project dependencies
|
|
||||||
// configurations = listOf(project.configurations.runtimeClasspath.get())
|
|
||||||
//
|
|
||||||
// // Ensure MySQL is included (even though it should be part of runtimeClasspath already)
|
|
||||||
// dependencies {
|
|
||||||
// include(dependency("com.mysql:mysql-connector-j"))
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Enable zip64 mode for large JARs
|
|
||||||
// isZip64 = true
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//// Make the shadowJar task the default jar task
|
|
||||||
//tasks.named("jar") {
|
|
||||||
// enabled = false
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//tasks.named("assemble") {
|
|
||||||
// dependsOn("shadowJar")
|
|
||||||
//}
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,58 @@
|
||||||
tasks.register<Exec>("npmInstall") {
|
import com.github.gradle.node.NodeExtension
|
||||||
commandLine("npm.cmd", "install")
|
import com.github.gradle.node.npm.task.NpmTask
|
||||||
// commandLine("npm", "install")
|
|
||||||
|
plugins {
|
||||||
|
id("com.github.node-gradle.node") version "7.1.0"
|
||||||
|
id("base") // This adds the standard Gradle lifecycle tasks like "build"
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register<Exec>("ngBuild") {
|
node {
|
||||||
dependsOn("npmInstall", "generateFrontendApi")
|
download.set(true)
|
||||||
// commandLine("npm", "run", "build")
|
version.set("22.14.0")
|
||||||
commandLine("npm.cmd", "run", "build")
|
npmVersion.set("10.9.2")
|
||||||
|
workDir.set(file("${project.projectDir}/node"))
|
||||||
|
npmWorkDir.set(file("${project.projectDir}/node"))
|
||||||
}
|
}
|
||||||
|
|
||||||
//dependencies {
|
// Clean the distribution directory
|
||||||
// implementation(project(":backend"))
|
tasks.register<Delete>("cleanDist") {
|
||||||
//}
|
description = "Clean the distribution directory"
|
||||||
|
delete("dist")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a task that will run npm build
|
||||||
|
tasks.register("npmBuild") {
|
||||||
|
description = "Run 'npm run build'"
|
||||||
|
group = "build"
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
// Use nodeCommand directly from the plugin
|
||||||
|
project.exec {
|
||||||
|
workingDir(project.projectDir)
|
||||||
|
|
||||||
|
// Use node's npm to ensure it works on all environments
|
||||||
|
val nodeDir = "${project.projectDir}/node"
|
||||||
|
val isWindows = System.getProperty("os.name").lowercase().contains("windows")
|
||||||
|
|
||||||
|
if (isWindows) {
|
||||||
|
val npmCmd = file(nodeDir).listFiles()?.find { it.name.startsWith("npm") && it.isDirectory }?.let {
|
||||||
|
"${it.absolutePath}/npm.cmd"
|
||||||
|
} ?: "$nodeDir/node_modules/npm/bin/npm.cmd"
|
||||||
|
|
||||||
|
commandLine(npmCmd, "run", "build")
|
||||||
|
} else {
|
||||||
|
val npmExecutable = file(nodeDir).listFiles()?.find { it.name.startsWith("npm") && it.isDirectory }?.let {
|
||||||
|
"${it.absolutePath}/npm"
|
||||||
|
} ?: "$nodeDir/node_modules/npm/bin/npm"
|
||||||
|
|
||||||
|
commandLine(npmExecutable, "run", "build")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependsOn("npmInstall")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named("assemble") {
|
||||||
|
dependsOn("npmBuild")
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user