make JSTL and postgres (optionally) runtime dependencies again

Fri, 30 Dec 2022 13:21:09 +0100

author
Mike Becker <universe@uap-core.de>
date
Fri, 30 Dec 2022 13:21:09 +0100
changeset 262
c357c4e69b9e
parent 261
1467d182cfe3
child 263
aa22103809cd

make JSTL and postgres (optionally) runtime dependencies again

INSTALL file | annotate | diff | comparison | revisions
build.gradle.kts file | annotate | diff | comparison | revisions
--- a/INSTALL	Thu Dec 29 15:12:25 2022 +0100
+++ b/INSTALL	Fri Dec 30 13:21:09 2022 +0100
@@ -26,10 +26,16 @@
 the lightpit_app user which has less privileges to create the data source and
 leave the lightpit_dbo user for the database operator.
 
-4. Deploy the WAR file of lightpit
+4. Build and Deploy the WAR file of lightpit
 
-This is the most straight forward step. Just deploy the WAR file as you usually
-do in your application server.
+Build the WAR file with gradle. If your application server already provides
+the necessary runtime libraries for JSTL and PostgreSQL, leave the variable
+libsAreProvided = true during the build. Otherwise, set this variable to false
+and the libraries will be included in the WAR file. But keep in mind that some
+servlet containers, like Tomcat, are not so happy about this when hot redeploy-
+ments are performed. If you experience ClassDefNotFound errors after a hot
+redeployment, you should either provide the libs in your container or always
+restart the entire container after a redeployment.
 
 5. Configuring a web server and authentication
 
--- a/build.gradle.kts	Thu Dec 29 15:12:25 2022 +0100
+++ b/build.gradle.kts	Fri Dec 30 13:21:09 2022 +0100
@@ -25,14 +25,18 @@
     from("src/main/resources")
 }
 
+val libsAreProvided = true
 kotlin {
     sourceSets {
         val main by getting {
             dependencies {
-                // change the following to compileOnly, if you already have them on your server
-                implementation("jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api:3.0.0")
-                implementation("org.glassfish.web:jakarta.servlet.jsp.jstl:3.0.1")
-                implementation("org.postgresql:postgresql:42.5.1")
+                arrayOf(
+                    "jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api:3.0.0",
+                    "org.glassfish.web:jakarta.servlet.jsp.jstl:3.0.1",
+                    "org.postgresql:postgresql:42.5.1"
+                ).forEach {
+                    if (libsAreProvided) compileOnly(it) else implementation(it)
+                }
                 compileOnly("jakarta.servlet:jakarta.servlet-api:6.0.0")
                 val flexmarkVersion = "0.64.0"
                 implementation("com.vladsch.flexmark:flexmark:${flexmarkVersion}")

mercurial