From 76550f85e5ba1975ae020413ed9004b65052b0b2 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Wed, 28 Feb 2024 15:16:13 -0800 Subject: [PATCH 01/16] Improve embedded upgrade process --- README.md | 5 +++++ build.gradle | 2 +- .../groovy/org/labkey/gradle/task/ModuleDistribution.groovy | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6c7d27b3..46f6204a 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,11 @@ on how to do that, including how to develop and test locally and the versioning _Note: 1.28.0 and later require Gradle 7_ +### 2.5.0 +*Released*: TBD +(Earliest compatible LabKey version: 24.2) +* Include `application.properties` in embedded distributions + ### 2.4.0 *Released*: 27 February 2024 (Earliest compatible LabKey version: 24.2) diff --git a/build.gradle b/build.gradle index 30a30ed1..646396ff 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,7 @@ dependencies { } group 'org.labkey.build' -project.version = "2.4.0-SNAPSHOT" +project.version = "2.5.0-embeddedUpgrade-SNAPSHOT" gradlePlugin { plugins { diff --git a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy index c7d9b53f..daefeb5c 100644 --- a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy +++ b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy @@ -417,6 +417,10 @@ class ModuleDistribution extends DefaultTask zipfileset(dir: "${BuildUtils.getBuildDirPath(project)}/") { include(name: "labkeywebapp/**") } + zipfileset(dir: "${BuildUtils.getBuildDirPath(project)}/", + prefix: "${DistributionExtension.DIST_FILE_DIR}") { + include(name: "VERSION") + } } project.copy { From 0b0f982c10cec8257cd4c4fd6bb3beb943f9bbbe Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Wed, 28 Feb 2024 16:57:38 -0800 Subject: [PATCH 02/16] Update ignored files --- .gitignore | 10 +++++++++- .idea/.gitignore | 8 -------- 2 files changed, 9 insertions(+), 9 deletions(-) delete mode 100644 .idea/.gitignore diff --git a/.gitignore b/.gitignore index 386153f9..5f94cbe2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,16 @@ .gradle build/ out/ +lib/ -.idea/dataSources.local.xml +# Unless specified, ignore all IDEA project files +.idea/ +!.idea/codeStyles/codeStyleConfig.xml +!.idea/inspectionProfiles/Project_Default.xml +!.idea/runConfigurations/Debug_plugins.xml +!.idea/compiler.xml +!.idea/misc.xml +!.idea/vcs.xml # Ignore zip files created by build src/main/resources/moduleTemplate.zip diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 5f1bdff7..00000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/workspace.xml -/shelf/ -$CACHE_FILE$ -$PRODUCT_WORKSPACE_FILE$ -gradle.xml -jarRepositories.xml -uiDesigner.xml From 631326565c0a421f2a6e512ebad51f75df68362b Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Wed, 28 Feb 2024 16:57:53 -0800 Subject: [PATCH 03/16] Remove version from executable server jar --- README.md | 1 + .../groovy/org/labkey/gradle/task/ModuleDistribution.groovy | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 46f6204a..ab08c630 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ _Note: 1.28.0 and later require Gradle 7_ *Released*: TBD (Earliest compatible LabKey version: 24.2) * Include `application.properties` in embedded distributions +* Remove version from executable server jar: `labkeyServer.jar` ### 2.4.0 *Released*: 27 February 2024 diff --git a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy index daefeb5c..d29dab91 100644 --- a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy +++ b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy @@ -232,7 +232,7 @@ class ModuleDistribution extends DefaultTask private String getEmbeddedTomcatJarPath() { - return BuildUtils.getBuildDirFile(project, "labkeyServer-${project.version}.jar").path + return BuildUtils.getBuildDirFile(project, "labkeyServer.jar").path } private String getTarArchivePath() From eb25257eab12dadb727f857c9662200e564eb493 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Thu, 29 Feb 2024 13:13:06 -0800 Subject: [PATCH 04/16] New task property to create embedded distributions --- README.md | 1 + .../gradle/task/ModuleDistribution.groovy | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ab08c630..0bf3a8d7 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ _Note: 1.28.0 and later require Gradle 7_ (Earliest compatible LabKey version: 24.2) * Include `application.properties` in embedded distributions * Remove version from executable server jar: `labkeyServer.jar` +* New task property to create embedded distributions ### 2.4.0 *Released*: 27 February 2024 diff --git a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy index d29dab91..de993671 100644 --- a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy +++ b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy @@ -38,7 +38,9 @@ class ModuleDistribution extends DefaultTask @Optional @Input Boolean includeTarGZArchive = false @Optional @Input - String embeddedArchiveType = null + Boolean includeEmbeddedArchive = false // New way to include embedded distribution, tar.gz only + @Optional @Input + String embeddedArchiveType = "" @Optional @Input Boolean makeDistribution = true // set to false for just an archive of modules @Optional @Input @@ -85,8 +87,20 @@ class ModuleDistribution extends DefaultTask } private boolean shouldBuildEmbeddedArchive(String extension = null) { - return (embeddedArchiveType != null && (extension == null || embeddedArchiveType.indexOf(extension) >= 0)) && - makeDistribution && BuildUtils.useEmbeddedTomcat(project) + boolean includeThisExtension = false + switch (extension) { + case DistributionExtension.TAR_ARCHIVE_EXTENSION: + includeThisExtension = includeEmbeddedArchive || embeddedArchiveType.contains(extension) + break; + case DistributionExtension.ZIP_ARCHIVE_EXTENSION: + includeThisExtension = embeddedArchiveType.contains(extension) + break; + case null: + includeThisExtension = includeEmbeddedArchive || !embeddedArchiveType.isEmpty() + } + return includeThisExtension + && makeDistribution + && BuildUtils.useEmbeddedTomcat(project) } @OutputFiles From 5208d38413d1eabe9eeac7aa4f73bf4062ab2fed Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Mon, 4 Mar 2024 14:08:30 -0800 Subject: [PATCH 05/16] Make `startTomcat` task work for embedded Tomcat on Windows --- README.md | 4 ++-- src/main/groovy/org/labkey/gradle/task/StartTomcat.groovy | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0bf3a8d7..4b8f9191 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ _Note: 1.28.0 and later require Gradle 7_ *Released*: TBD (Earliest compatible LabKey version: 24.2) * Include `application.properties` in embedded distributions -* Remove version from executable server jar: `labkeyServer.jar` -* New task property to create embedded distributions +* Remove version from executable server jar name: `labkeyServer.jar` +* Make `startTomcat` task work for embedded Tomcat on Windows ### 2.4.0 *Released*: 27 February 2024 diff --git a/src/main/groovy/org/labkey/gradle/task/StartTomcat.groovy b/src/main/groovy/org/labkey/gradle/task/StartTomcat.groovy index 171276aa..7fdd970a 100644 --- a/src/main/groovy/org/labkey/gradle/task/StartTomcat.groovy +++ b/src/main/groovy/org/labkey/gradle/task/StartTomcat.groovy @@ -52,7 +52,8 @@ class StartTomcat extends DefaultTask String javaHome = TeamCityExtension.getTeamCityProperty(project, "tomcatJavaHome", System.getenv("JAVA_HOME")) if (StringUtils.isEmpty(javaHome)) throw new GradleException("JAVA_HOME must be set in order to start your embedded tomcat server.") - File javaExec = new File(javaHome, "bin/java") + File javaBin = new File(javaHome, "bin") + File javaExec = new File(javaBin, SystemUtils.IS_OS_WINDOWS ? "java.exe" : "java") if (!javaExec.exists()) throw new GradleException("Invalid value for JAVA_HOME. Could not find java command in ${javaExec}") String[] commandParts = [javaExec.getAbsolutePath()] From 469e114626bea571ab5adcb947d58b4961e8db5d Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Mon, 4 Mar 2024 14:08:42 -0800 Subject: [PATCH 06/16] No new distribution property --- .../gradle/task/ModuleDistribution.groovy | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy index de993671..d29dab91 100644 --- a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy +++ b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy @@ -38,9 +38,7 @@ class ModuleDistribution extends DefaultTask @Optional @Input Boolean includeTarGZArchive = false @Optional @Input - Boolean includeEmbeddedArchive = false // New way to include embedded distribution, tar.gz only - @Optional @Input - String embeddedArchiveType = "" + String embeddedArchiveType = null @Optional @Input Boolean makeDistribution = true // set to false for just an archive of modules @Optional @Input @@ -87,20 +85,8 @@ class ModuleDistribution extends DefaultTask } private boolean shouldBuildEmbeddedArchive(String extension = null) { - boolean includeThisExtension = false - switch (extension) { - case DistributionExtension.TAR_ARCHIVE_EXTENSION: - includeThisExtension = includeEmbeddedArchive || embeddedArchiveType.contains(extension) - break; - case DistributionExtension.ZIP_ARCHIVE_EXTENSION: - includeThisExtension = embeddedArchiveType.contains(extension) - break; - case null: - includeThisExtension = includeEmbeddedArchive || !embeddedArchiveType.isEmpty() - } - return includeThisExtension - && makeDistribution - && BuildUtils.useEmbeddedTomcat(project) + return (embeddedArchiveType != null && (extension == null || embeddedArchiveType.indexOf(extension) >= 0)) && + makeDistribution && BuildUtils.useEmbeddedTomcat(project) } @OutputFiles From 0bee4dee19b15b34e39721823b9b0af4fa3f9df1 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Tue, 5 Mar 2024 10:36:23 -0800 Subject: [PATCH 07/16] Include application.properties in embedded distribution --- .../embedded/config/application.properties | 163 ++++++++++++++++++ .../embedded/manual-upgrade.sh | 2 - .../gradle/task/ModuleDistribution.groovy | 10 +- 3 files changed, 166 insertions(+), 9 deletions(-) create mode 100644 distributionResources/embedded/config/application.properties delete mode 100755 distributionResources/embedded/manual-upgrade.sh diff --git a/distributionResources/embedded/config/application.properties b/distributionResources/embedded/config/application.properties new file mode 100644 index 00000000..90e45d76 --- /dev/null +++ b/distributionResources/embedded/config/application.properties @@ -0,0 +1,163 @@ +server.port=8080 + +## To use ssl, update the properties below for your local installation + +#server.ssl.enabled=true +#server.ssl.enabled-protocols=TLSv1.3,TLSv1.2,TLSv1.1 +#server.ssl.protocol=TLS +#server.ssl.key-alias=tomcat +#server.ssl.key-store=@@keyStore@@ +#server.ssl.key-store-password=@@keyStorePassword@@ +## Typically either PKCS12 or JKS +#server.ssl.key-store-type=PKCS12 +#server.ssl.ciphers=HIGH:!ADH:!EXP:!SSLv2:!SSLv3:!MEDIUM:!LOW:!NULL:!aNULL + +## HTTP-only port for servers that need to handle both HTTPS (configure via server.port and server.ssl above) and HTTP +#context.httpPort=8080 + +## Database connections. All deployments need a labkeyDataSource as their primary database. Add additional external +## data sources by specifying the required properties (at least driverClassName, url, username, and password) +## with a prefix of context.resources.jdbc.. +context.resources.jdbc.labkeyDataSource.type=javax.sql.DataSource +context.resources.jdbc.labkeyDataSource.driverClassName=org.postgresql.Driver +context.resources.jdbc.labkeyDataSource.url=jdbc:postgresql://localhost/labkey +context.resources.jdbc.labkeyDataSource.username=@@jdbcUser@@ +context.resources.jdbc.labkeyDataSource.password=@@jdbcPassword@@ +context.resources.jdbc.labkeyDataSource.maxTotal=50 +context.resources.jdbc.labkeyDataSource.maxIdle=10 +context.resources.jdbc.labkeyDataSource.maxWaitMillis=120000 +context.resources.jdbc.labkeyDataSource.accessToUnderlyingConnectionAllowed=true +context.resources.jdbc.labkeyDataSource.validationQuery=SELECT 1 +#context.resources.jdbc.labkeyDataSource.logQueries=true +#context.resources.jdbc.labkeyDataSource.displayName=Alternate Display Name + +#context.resources.jdbc.@@extraJdbcDataSource@@.driverClassName=@@extraJdbcDriverClassName@@ +#context.resources.jdbc.@@extraJdbcDataSource@@.url=@@extraJdbcUrl@@ +#context.resources.jdbc.@@extraJdbcDataSource@@.username=@@extraJdbcUsername@@ +#context.resources.jdbc.@@extraJdbcDataSource@@.password=@@extraJdbcPassword@@ + +context.encryptionKey=@@encryptionKey@@ + +## By default, we deploy to the root context path. However, some servers have historically used /labkey or even /cpas +#context.contextPath=/labkey + +## Using a legacy context path provides backwards compatibility with old deployments. A typical use case would be to +## deploy to the root context (the default) and configure /labkey as the legacy path. GETs will be redirected. +## All other methods (POSTs, PUTs, etc) will be handled server-side via a servlet forward. +#context.legacyContextPath=/labkey + +## Other webapps to be deployed, most commonly to deliver a set of static files. The context path to deploy into is the +## property name after the "context.additionalWebapps." prefix, and the value is the location of the webapp on disk +#context.additionalWebapps.firstContextPath=/my/webapp/path +#context.additionalWebapps.secondContextPath=/my/other/webapp/path + +#context.oldEncryptionKey= +#context.requiredModules= +#context.pipelineConfig=/path/to/pipeline/config/dir +#context.serverGUID= +#context.bypass2FA=true +#context.workDirLocation=/path/to/desired/workDir + +mail.smtpHost=@@smtpHost@@ +mail.smtpPort=@@smtpPort@@ +mail.smtpUser=@@smtpUser@@ +#mail.smtpFrom=@@smtpFrom@@ +#mail.smtpPassword=@@smtpPassword@@ +#mail.startTlsEnable=@@smtpStartTlsEnable@@ +#mail.smtpSocketFactoryClass=@@smtpSocketFactoryClass@@ +#mail.smtpAuth=@@smtpAuth@@ + +## Optional - JMS configuration for remote ActiveMQ message management for distributed pipeline jobs +## https://www.labkey.org/Documentation/wiki-page.view?name=jmsQueue +#context.resources.jms.ConnectionFactory.type=org.apache.activemq.ActiveMQConnectionFactory +#context.resources.jms.ConnectionFactory.factory=org.apache.activemq.jndi.JNDIReferenceFactory +#context.resources.jms.ConnectionFactory.description=JMS Connection Factory +## Use an in-process ActiveMQ queue +#context.resources.jms.ConnectionFactory.brokerURL=vm://localhost?broker.persistent=false&broker.useJmx=false +## Use an out-of-process ActiveMQ queue +#context.resources.jms.ConnectionFactory.brokerURL=tcp://localhost:61616 +#context.resources.jms.ConnectionFactory.brokerName=LocalActiveMQBroker + +## Optional - LDAP configuration for LDAP group/user synchronization +## https://www.labkey.org/Documentation/wiki-page.view?name=LDAP_sync +#context.resources.ldap.ConfigFactory.type=org.labkey.premium.ldap.LdapConnectionConfigFactory +#context.resources.ldap.ConfigFactory.factory=org.labkey.premium.ldap.LdapConnectionConfigFactory +#context.resources.ldap.ConfigFactory.host=myldap.mydomain.com +#context.resources.ldap.ConfigFactory.port=389 +#context.resources.ldap.ConfigFactory.principal=cn=read_user +#context.resources.ldap.ConfigFactory.credentials=read_user_password +#context.resources.ldap.ConfigFactory.useTls=false +#context.resources.ldap.ConfigFactory.useSsl=false +#context.resources.ldap.ConfigFactory.sslProtocol=SSLv3 + +## HTTP session timeout for users - defaults to 30 minutes +#server.servlet.session.timeout=30m + +## Enable shutdown endpoint. Allows server to be shutdown with a POST to 'localhost:8081/actuator/shutdown +#management.endpoint.shutdown.enabled=true +#management.endpoints.enabled-by-default=false +#management.endpoints.web.exposure.include=* +#management.server.port=8081 + +## Don't show the Spring banner on startup +spring.main.banner-mode=off +#logging.config=path/to/alternative/log4j2.xml + +## Optional - JMS configuration for remote ActiveMQ message management for distributed pipeline jobs +## https://www.labkey.org/Documentation/wiki-page.view?name=jmsQueue +#context.resources.jms.name=jms/ConnectionFactory +#context.resources.jms.type=org.apache.activemq.ActiveMQConnectionFactory +#context.resources.jms.factory=org.apache.activemq.jndi.JNDIReferenceFactory +#context.resources.jms.description=JMS Connection Factory +#context.resources.jms.brokerURL=vm://localhost?broker.persistent=false&broker.useJmx=false +#context.resources.jms.brokerName=LocalActiveMQBroker + +## Turn on JSON-formatted HTTP access logging to stdout. See issue 48565 +## https://tomcat.apache.org/tomcat-9.0-doc/config/valve.html#JSON_Access_Log_Valve +#jsonaccesslog.enabled=true + +## Optional configuration, modeled on the non-JSON Spring Boot properties +## https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#application-properties.server.server.tomcat.accesslog.buffered +#jsonaccesslog.pattern=%h %t %m %U %s %b %D %S "%{Referer}i" "%{User-Agent}i" %{LABKEY.username}s +#jsonaccesslog.condition-if=attributeName +#jsonaccesslog.condition-unless=attributeName + +## Define one or both of 'csp.report' and 'csp.enforce' to enable Content Security Policy (CSP) headers +## Do not use these examples for any production environment without understanding the meaning of each directive! + +## example usage 1 - very strict, disallows 'external' websites, disallows unsafe-inline, but only reports violations (does not enforce) + +#csp.report=\ +# default-src 'self';\ +# connect-src 'self' ${LABKEY.ALLOWED.CONNECTIONS} ;\ +# object-src 'none' ;\ +# style-src 'self' 'unsafe-inline' ;\ +# img-src 'self' data: ;\ +# font-src 'self' data: ;\ +# script-src 'unsafe-eval' 'strict-dynamic' 'nonce-${REQUEST.SCRIPT.NONCE}';\ +# base-uri 'self' ;\ +# upgrade-insecure-requests ;\ +# frame-ancestors 'self' ;\ +# report-uri https://www.labkey.org/admin-contentsecuritypolicyreport.api?${CSP.REPORT.PARAMS} ; + +## example usage 2 - less strict but enforces directives, (NOTE: unsafe-inline is still required for many modules) + +#csp.enforce=\ +# default-src 'self' https: ;\ +# connect-src 'self' https: ${LABKEY.ALLOWED.CONNECTIONS};\ +# object-src 'none' ;\ +# style-src 'self' https: 'unsafe-inline' ;\ +# img-src 'self' data: ;\ +# font-src 'self' data: ;\ +# script-src 'unsafe-inline' 'unsafe-eval' 'strict-dynamic' 'nonce-${REQUEST.SCRIPT.NONCE}';\ +# base-uri 'self' ;\ +# upgrade-insecure-requests ;\ +# frame-ancestors 'self' ;\ +# report-uri https://www.labkey.org/admin-contentsecuritypolicyreport.api?${CSP.REPORT.PARAMS} ; + + +## Enable tomcat access log +#server.tomcat.basedir=. +#server.tomcat.accesslog.enabled=true +#server.tomcat.accesslog.directory=logs +#server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %S %I "%{Referrer}i" "%{User-Agent}i" %{LABKEY.username}s diff --git a/distributionResources/embedded/manual-upgrade.sh b/distributionResources/embedded/manual-upgrade.sh deleted file mode 100755 index 39394225..00000000 --- a/distributionResources/embedded/manual-upgrade.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -# Placeholder script for upgrading LabKey with embedded Tomcat diff --git a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy index d29dab91..0d8d635f 100644 --- a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy +++ b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy @@ -462,10 +462,7 @@ class ModuleDistribution extends DefaultTask include(name: "VERSION") } - tarfileset(dir: BuildUtils.getBuildDirFile(project, "embedded"), prefix: archiveName) { - // include(name: "manual-upgrade.sh") - include(name: "README.txt") - } + tarfileset(dir: BuildUtils.getWebappConfigFile(project, "embedded"), prefix: archiveName) } } @@ -490,10 +487,9 @@ class ModuleDistribution extends DefaultTask include(name: "VERSION") } - zipfileset(dir: "${BuildUtils.getBuildDirPath(project)}/embedded/", + zipfileset(dir: "${BuildUtils.getWebappConfigFile(project, "embedded")}/", prefix: "${archiveName}") { - // include(name: "manual-upgrade.sh") - include(name: "README.txt") + exclude(name: "manual-upgrade.sh") } } } From bd1768a542fa9784d36096659b51debab80a5346 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Tue, 5 Mar 2024 11:45:12 -0800 Subject: [PATCH 08/16] Get file from server repository --- .../labkey/gradle/task/ModuleDistribution.groovy | 16 +++++++++++----- .../org/labkey/gradle/util/BuildUtils.groovy | 8 ++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy index 0d8d635f..57505515 100644 --- a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy +++ b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy @@ -462,7 +462,7 @@ class ModuleDistribution extends DefaultTask include(name: "VERSION") } - tarfileset(dir: BuildUtils.getWebappConfigFile(project, "embedded"), prefix: archiveName) + tarfileset(dir: BuildUtils.getBuildDirFile(project, "embedded"), prefix: archiveName) } } @@ -487,10 +487,7 @@ class ModuleDistribution extends DefaultTask include(name: "VERSION") } - zipfileset(dir: "${BuildUtils.getWebappConfigFile(project, "embedded")}/", - prefix: "${archiveName}") { - exclude(name: "manual-upgrade.sh") - } + zipfileset(dir: "${BuildUtils.getBuildDirPath(project)}/embedded/", prefix: "${archiveName}") } } @@ -505,6 +502,15 @@ class ModuleDistribution extends DefaultTask copy.into(project.layout.buildDirectory) copy.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE) }) + // Prefer files from 'server/configs/webapps' if they exist + if (BuildUtils.getWebappConfigDir(project) != null) { + project.copy({ CopySpec copy -> + copy.from(BuildUtils.getWebappConfigDir(project)) + copy.exclude "*.xml" + copy.into(project.layout.buildDirectory) + copy.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE) + }) + } // Allow distributions to include custom README File resources = project.file("resources") if (resources.isDirectory()) { diff --git a/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy b/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy index af8f6750..a2de2a08 100644 --- a/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy +++ b/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy @@ -884,6 +884,14 @@ class BuildUtils return ModuleDistribution.getDistributionResources(project).matching {include fileName}.singleFile } + static File getWebappConfigDir(Project project) + { + if (project.rootProject.file("server/configs/webapps/").exists()) + return project.rootProject.file("server/configs/webapps/") + else + return null + } + static boolean embeddedProjectExists(Project project) { return project.findProject(getEmbeddedProjectPath(project.gradle)) != null From 0c9112c94f2bbdc336b2dd29bf3a65913aa193d5 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Tue, 5 Mar 2024 13:47:11 -0800 Subject: [PATCH 09/16] Exclude upgrade script --- .../org/labkey/gradle/task/ModuleDistribution.groovy | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy index 57505515..d9c0b6d7 100644 --- a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy +++ b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy @@ -462,7 +462,9 @@ class ModuleDistribution extends DefaultTask include(name: "VERSION") } - tarfileset(dir: BuildUtils.getBuildDirFile(project, "embedded"), prefix: archiveName) + tarfileset(dir: BuildUtils.getBuildDirFile(project, "embedded"), prefix: archiveName) { + exclude(name: "manual-upgrade.sh") + } } } @@ -487,7 +489,9 @@ class ModuleDistribution extends DefaultTask include(name: "VERSION") } - zipfileset(dir: "${BuildUtils.getBuildDirPath(project)}/embedded/", prefix: "${archiveName}") + zipfileset(dir: "${BuildUtils.getBuildDirPath(project)}/embedded/", prefix: "${archiveName}") { + exclude(name: "manual-upgrade.sh") + } } } From c2efc51a81fd05aecd4b2f96375be2897795017c Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Wed, 6 Mar 2024 10:44:48 -0800 Subject: [PATCH 10/16] Fix embedded tar distribution --- .../groovy/org/labkey/gradle/task/ModuleDistribution.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy index d9c0b6d7..a4cecdb4 100644 --- a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy +++ b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy @@ -462,7 +462,7 @@ class ModuleDistribution extends DefaultTask include(name: "VERSION") } - tarfileset(dir: BuildUtils.getBuildDirFile(project, "embedded"), prefix: archiveName) { + tarfileset(dir: "${BuildUtils.getBuildDirPath(project)}/embedded", prefix: archiveName) { exclude(name: "manual-upgrade.sh") } } From 73d64fcf4772befbf0ca9b966219e2dd22c2a783 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Wed, 6 Mar 2024 10:45:54 -0800 Subject: [PATCH 11/16] Remove unnecessary exclusion --- .../org/labkey/gradle/task/ModuleDistribution.groovy | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy index a4cecdb4..1a196f2b 100644 --- a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy +++ b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy @@ -462,9 +462,7 @@ class ModuleDistribution extends DefaultTask include(name: "VERSION") } - tarfileset(dir: "${BuildUtils.getBuildDirPath(project)}/embedded", prefix: archiveName) { - exclude(name: "manual-upgrade.sh") - } + tarfileset(dir: "${BuildUtils.getBuildDirPath(project)}/embedded", prefix: archiveName) } } @@ -489,9 +487,7 @@ class ModuleDistribution extends DefaultTask include(name: "VERSION") } - zipfileset(dir: "${BuildUtils.getBuildDirPath(project)}/embedded/", prefix: "${archiveName}") { - exclude(name: "manual-upgrade.sh") - } + zipfileset(dir: "${BuildUtils.getBuildDirPath(project)}/embedded/", prefix: "${archiveName}") } } From bf186641478e9d99505de091b8367392539f9491 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Fri, 8 Mar 2024 16:56:51 -0800 Subject: [PATCH 12/16] Include TeamCity buildUrl in distributions --- .../groovy/org/labkey/gradle/task/ModuleDistribution.groovy | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy index 1a196f2b..2f9e0672 100644 --- a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy +++ b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy @@ -15,6 +15,7 @@ */ package org.labkey.gradle.task +import org.apache.commons.lang3.StringUtils import org.gradle.api.DefaultTask import org.gradle.api.GradleException import org.gradle.api.Project @@ -563,6 +564,8 @@ class ModuleDistribution extends DefaultTask private void writeVersionFile() { - Files.write(getVersionFile().toPath(), ((String) project.version).getBytes()) + // Include TeamCity buildUrl, if present. + def buildUrl = StringUtils.trimToEmpty(System.getenv("BUILD_URL")) + Files.write(getVersionFile().toPath(), "${project.version}\n${buildUrl}".trim().getBytes()) } } From c29768f8f7b90c8cc14d1a5741ec26f00e64ee8a Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Mon, 11 Mar 2024 11:15:45 -0700 Subject: [PATCH 13/16] Avoid errors for missing `distributionDir` property --- README.md | 1 + .../gradle/task/ModuleDistribution.groovy | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 173bd434..878ce725 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ _Note: 1.28.0 and later require Gradle 7_ * Include `application.properties` in embedded distributions * Remove version from executable server jar name: `labkeyServer.jar` * Make `startTomcat` task work for embedded Tomcat on Windows +* Avoid errors for missing `distributionDir` property ### 2.5.0 *Released*: 10 March 2024 diff --git a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy index 2f9e0672..5196fadd 100644 --- a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy +++ b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy @@ -55,8 +55,7 @@ class ModuleDistribution extends DefaultTask @Input boolean simpleDistribution = false // Set to true to exclude pipeline tools and remote pipeline libraries - @OutputDirectory - File distributionDir + private File distributionDir private final DistributionExtension distExtension private Project licensingProject @@ -78,10 +77,14 @@ class ModuleDistribution extends DefaultTask } @OutputDirectory - File getResolvedDistributionDir() + File getDistributionDir() { - if (distributionDir == null && subDirName != null) - distributionDir = project.file("${distExtension.dir}/${subDirName}") + if (distributionDir == null) { + var subDir = StringUtils.trimToNull(subDirName) + if (subDir == null) + subDir = project.name + distributionDir = project.file("${distExtension.dir}/${subDir}") + } return distributionDir } @@ -238,27 +241,27 @@ class ModuleDistribution extends DefaultTask private String getTarArchivePath() { - return "${getResolvedDistributionDir()}/${getArchiveName()}.${DistributionExtension.TAR_ARCHIVE_EXTENSION}" + return "${getDistributionDir()}/${getArchiveName()}.${DistributionExtension.TAR_ARCHIVE_EXTENSION}" } private String getEmbeddedTarArchivePath() { - return "${getResolvedDistributionDir()}/${getArchiveName()}${DistributionExtension.EMBEDDED_SUFFIX}.${DistributionExtension.TAR_ARCHIVE_EXTENSION}" + return "${getDistributionDir()}/${getArchiveName()}${DistributionExtension.EMBEDDED_SUFFIX}.${DistributionExtension.TAR_ARCHIVE_EXTENSION}" } private String getZipArchivePath() { - return "${getResolvedDistributionDir()}/${getArchiveName()}.${DistributionExtension.ZIP_ARCHIVE_EXTENSION}" + return "${getDistributionDir()}/${getArchiveName()}.${DistributionExtension.ZIP_ARCHIVE_EXTENSION}" } private String getEmbeddedZipArchivePath() { - return "${getResolvedDistributionDir()}/${getArchiveName()}${DistributionExtension.EMBEDDED_SUFFIX}.${DistributionExtension.ZIP_ARCHIVE_EXTENSION}" + return "${getDistributionDir()}/${getArchiveName()}${DistributionExtension.EMBEDDED_SUFFIX}.${DistributionExtension.ZIP_ARCHIVE_EXTENSION}" } private String getWarArchivePath() { - return "${getResolvedDistributionDir()}/${getArchiveName()}.war" + return "${getDistributionDir()}/${getArchiveName()}.war" } private File getWindowsUtilDir() From 6fc474bfadde09da54e47ec6b327bcd271ea0ba4 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Mon, 11 Mar 2024 12:38:05 -0700 Subject: [PATCH 14/16] Pull in fix --- src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy b/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy index e2549342..3a416be1 100644 --- a/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy +++ b/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy @@ -926,6 +926,9 @@ class BuildUtils */ static void updateRestartTriggerFile(Project project) { + if (!project.hasProperty('useLocalBuild') || "false" == project.property("useLocalBuild")) + return + OutputStreamWriter writer = null try { File triggerFile = project.rootProject.layout.buildDirectory.file("deploy/modules/${RESTART_FILE_NAME}").get().getAsFile() From ef8ce22a592876fbed4cea43756248f718394212 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Mon, 11 Mar 2024 15:15:11 -0700 Subject: [PATCH 15/16] Don't make special-purpose `BuildUtils` method --- .../org/labkey/gradle/task/ModuleDistribution.groovy | 6 +++--- src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy | 8 -------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy index 72a12da7..4b2f6839 100644 --- a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy +++ b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy @@ -16,7 +16,6 @@ package org.labkey.gradle.task import org.apache.commons.lang3.StringUtils - import org.gradle.api.DefaultTask import org.gradle.api.GradleException import org.gradle.api.Project @@ -508,9 +507,10 @@ class ModuleDistribution extends DefaultTask copy.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE) }) // Prefer files from 'server/configs/webapps' if they exist - if (BuildUtils.getWebappConfigDir(project) != null) { + File serverConfigDir = project.rootProject.file("server/configs/webapps/") + if (serverConfigDir.exists()) { project.copy({ CopySpec copy -> - copy.from(BuildUtils.getWebappConfigDir(project)) + copy.from(serverConfigDir) copy.exclude "*.xml" copy.into(project.layout.buildDirectory) copy.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE) diff --git a/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy b/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy index 3a416be1..625ecfb0 100644 --- a/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy +++ b/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy @@ -886,14 +886,6 @@ class BuildUtils return ModuleDistribution.getDistributionResources(project).matching {include fileName}.singleFile } - static File getWebappConfigDir(Project project) - { - if (project.rootProject.file("server/configs/webapps/").exists()) - return project.rootProject.file("server/configs/webapps/") - else - return null - } - static boolean embeddedProjectExists(Project project) { return project.findProject(getEmbeddedProjectPath(project.gradle)) != null From 78a0931bdad572a53ec9ce55c59bef736e89ceb6 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Mon, 11 Mar 2024 15:16:02 -0700 Subject: [PATCH 16/16] Prepare for merge --- README.md | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c2dfcb10..410e2adf 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ on how to do that, including how to develop and test locally and the versioning _Note: 1.28.0 and later require Gradle 7_ ### 2.6.0 -*Released*: TBD +*Released*: 11 March 2024 (Earliest compatible LabKey version: 24.2) * Include `application.properties` in embedded distributions * Remove version from executable server jar name: `labkeyServer.jar` diff --git a/build.gradle b/build.gradle index f536a8d5..62dc356d 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,7 @@ dependencies { } group 'org.labkey.build' -project.version = "2.6.0-embeddedUpgrade-SNAPSHOT" +project.version = "2.7.0-SNAPSHOT" gradlePlugin { plugins {