diff --git a/.gitignore b/.gitignore index 5f94cbe2..fd9d1fe3 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ lib/ # Ignore zip files created by build src/main/resources/moduleTemplate.zip -src/main/resources/distributionResources.zip # Ignore Gradle GUI config gradle-app.setting diff --git a/README.md b/README.md index 99917305..03a54b58 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,22 @@ on how to do that, including how to develop and test locally and the versioning ### TBD *Released*: TBD -(Earliest compatible LabKey version: 24.8) +(Earliest compatible LabKey version: 24.10) + +### 4.0.0 +*Released*: 5 September 2024 +(Earliest compatible LabKey version: 24.10) - Add `--add-opens` JVM arg for `java.nio` to `startTomcat` task. Required for Snowflake JDBC driver. - Update `distributions` task to build embedded Tomcat tar.gz archives only - Remove support for building zip, Tomcat standalone, and module archives - - Remove `makeDistribution` property and deprecate `embeddedArchiveType` property (currently ignored) + - Remove `makeDistribution` and `embeddedArchiveType` properties - Fix `subDirName` property's optional behavior; this property now correctly defaults to `project.name`. - - Change `extraFileIdentifier` property's default value to `project.name` as well + - Change `extraFileIdentifier` property's default value to `-project.name` +- Remove support for `useEmbeddedTomcat` property and remove all standalone handling +- Remove all `tomcat-lib` JAR file handling: `cleanTomcatLib`, `deployTomcatJars`, and `stageTomcatJars` tasks; + `tomcatJars` configuration +- Remove `labkey.xml` and `log4j2.xml` files and handling +- Remove `distributionResources` folder ### 3.0.1 *Released*: 18 July 2024 diff --git a/build.gradle b/build.gradle index 245667d4..b57f60ff 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,7 @@ dependencies { } group 'org.labkey.build' -project.version = "3.1.0-SNAPSHOT" +project.version = "4.1.0-SNAPSHOT" gradlePlugin { plugins { @@ -163,14 +163,6 @@ if (project.file("moduleTemplate").exists()) project.tasks.processResources.dependsOn(project.tasks.zipModuleTemplate) } -project.tasks.register("zipDistributionResources", Zip) { - Zip zip -> - zip.archiveFileName = "distributionResources.zip" - zip.from project.file("distributionResources") - zip.destinationDirectory.set(new File(project.projectDir, "src/main/resources")) -} -project.tasks.processResources.dependsOn(project.tasks.zipDistributionResources) - if (hasProperty('artifactory_user') && hasProperty('artifactory_password')) { publishing { diff --git a/distributionResources/README.txt b/distributionResources/README.txt deleted file mode 100644 index c3aa8701..00000000 --- a/distributionResources/README.txt +++ /dev/null @@ -1,7 +0,0 @@ -Thank you for downloading LabKey Server. For more information about... - -- Installing LabKey Server. See https://www.labkey.org/Documentation/wiki-page.view?name=config - -- Upgrading LabKey Server. See https://www.labkey.org/Documentation/wiki-page.view?name=upgrade - -- Using LabKey Server. See https://www.labkey.org/Documentation/project-begin.view \ No newline at end of file diff --git a/distributionResources/embedded/README.txt b/distributionResources/embedded/README.txt deleted file mode 100644 index 57e7aac2..00000000 --- a/distributionResources/embedded/README.txt +++ /dev/null @@ -1,7 +0,0 @@ -Thank you for downloading LabKey Server. For more information about... - -- Installing LabKey Server. See https://www.labkey.org/Documentation/wiki-page.view?name=embeddedConfig - -- Upgrading LabKey Server. See https://www.labkey.org/Documentation/wiki-page.view?name=embeddedUpgrade - -- Using LabKey Server. See https://www.labkey.org/Documentation/project-begin.view diff --git a/distributionResources/embedded/config/application.properties b/distributionResources/embedded/config/application.properties deleted file mode 100644 index 90e45d76..00000000 --- a/distributionResources/embedded/config/application.properties +++ /dev/null @@ -1,163 +0,0 @@ -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/labkey.xml b/distributionResources/labkey.xml deleted file mode 100644 index c34bca83..00000000 --- a/distributionResources/labkey.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/distributionResources/log4j2.xml b/distributionResources/log4j2.xml deleted file mode 100644 index 4f1039c9..00000000 --- a/distributionResources/log4j2.xml +++ /dev/null @@ -1,338 +0,0 @@ - - - - - - - - - - - - - - - %-5p %-24.24c{1} %d{ISO8601} %24.24t : %m%n - - - - - - - - - - - - - - - %m%n - - - - - - - - - - - - %m%n - - - - - - - - - - - - %-5p %-24.24c{1} %d{ISO8601} %24.24t : %m%n - - - - - - - - - - - %-5p %-24.24c{1} %d{ISO8601} %24.24t : %m%n - - - - - - - - - - %-5p %-24.24c{1} %d{ISO8601} %24.24t : %m%n - - - - - - - %d{yyyy-MM-dd HH:mm:ss}%m%n - - - - - - - - - - - %m%n - - - - - - - - - - - %-5p %-24.24c{1} %d{ISO8601} %24.24t : %m%n - - - - - - - - - - - %d{ISO8601} %m%n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/distributionResources/manual-upgrade.sh b/distributionResources/manual-upgrade.sh deleted file mode 100755 index d563796e..00000000 --- a/distributionResources/manual-upgrade.sh +++ /dev/null @@ -1,452 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2006-2018 LabKey Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -############################################################################################### -# LabKey Server Upgrade Script. -# This script can be used to upgrade an installed LabKey Server instance running -# on Linux, MacOSX or Solaris. The script assumes that you have installed the LabKey Server -# following the instructions at -# https://www.labkey.org/Documentation/wiki-page.view?name=manualInstall. -# -# If you have installed the LabKey Server using the Graphical Windows Installer, please use the -# latest version of Graphical Windows Installer to upgrade the LabKey Server -# -# If you have installed the LabKey Server using the Linux Installer (install-labkey.py), please -# use the Linux Installer upgrade script, upgrade-labkey.py, to upgrade the LabKey Server -# -# It is recommended that you perform an backup of your database and files before using this -# script to upgrade your server. -# -# Important Documentation -# - Documentation for using this script: -# https://www.labkey.org/Documentation/wiki-page.view?name=manualUpgradeScript -# - Documentation for performing a manual upgrade (ie not using this script): -# https://www.labkey.org/Documentation/wiki-page.view?name=manupgrade -# - LabKey Upgrade Support Policy: -# https://www.labkey.org/Documentation/wiki-page.view?name=upgradeSupportPolicy -# -################################################################################################# - - -print_usage() -{ - echo "Usage:" - echo " manual-upgrade.sh -l dir [-d dir] [-c dir] [-u tomcatuser] [--noPrompt] [--service|--systemctl|--catalina|--tomcat_lk|--skip_tomcat]" - echo "" - echo " -l dir: LABKEY_HOME directory to be upgraded. This directory contains the " - echo " the labkeywebapp, modules, pipeline-lib, etc directories for the existing " - echo " LabKey Server instance. (Required)" - echo "" - echo " -d dir: Upgrade distribution directory: contains labkeywebapp, lib, and this script." - echo " (default: `pwd`)" - echo "" - echo " -c dir: TOMCAT_HOME; root of LabKey Apache Tomcat installation." - echo " (default: $CATALINA_HOME)" - echo "" - echo " -u owner: the tomcat user account (default: `whoami`)" - echo "" - echo " --noPrompt: do not require the user to hit enter before proceeding with the install" - echo "" - echo " (Web server startup/shutdown method: select one of the following)" - echo "" - echo " --service: use /etc/init.d/tomcat (default)" - echo "" - echo " --systemctl: use /bin/systemctl" - echo "" - echo " --catalina: use TOMCAT_HOME/bin/shutdown.sh and TOMCAT_HOME/bin/startup.sh" - echo "" - echo " --tomcat_lk: for LabKey Internal Hosted Server Installed Only" - echo "" - echo " --skip_tomcat: the script will not attempt to start/stop tomcat. You must do this manually before/after running the script." - echo "" -} - -print_error() -{ - echo "" - echo " ERROR: The upgrade did not complete successfully. See the error message" - echo " above for more information " - echo "" - exit 1 - -} - -# -# Variables -# -service="true" -systemctl="false" -catalina="false" -tomcat_lk="false" -skip_tomcat="false" -noPrompt="false" -labkey_home="" -tomcat_home=$CATALINA_HOME -labkey_binary_distro_dir=$(pwd) -tomcat_user="-" -service_script="/etc/init.d/tomcat" -DATE=$(date +%Y-%m-%d\ %H:%M) -count=0 - -# -# Parse command line arguments -# -if [ -z "$1" ] -then - print_usage - exit -fi -while [ -n "$1" ] -do - case $1 - in - -c) - if [ -z $2 ] || [ "$(echo $2 | cut -c1)" = "-" ] - then - echo "Please specify a directory with the -c option. See the Usage text below" - echo "" - print_usage - exit - fi - tomcat_home=$2; - shift 2;; - -l) - if [ -z $2 ] || [ "$(echo $2 | cut -c1)" = "-" ] - then - echo "Please specify a directory with the -l option. See the Usage text below" - echo "" - print_usage - exit - fi - labkey_home=$2; - shift 2;; - -d) - if [ -z $2 ] || [ "$(echo $2 | cut -c1)" = "-" ] - then - echo "Please specify a directory with the -d option. See the Usage text below" - echo "" - print_usage - exit - fi - labkey_binary_distro_dir=$2; - shift 2;; - -u) - if [ -z $2 ] || [ "$(echo $2 | cut -c1)" = "-" ] - then - echo "Please specify the tomcat user with the -u option. See the Usage text below" - echo "" - print_usage - exit - fi - tomcat_user=$2; - shift 2;; - --service) - service="true"; - shift;; - --systemctl) - systemctl="true"; - service="false" - shift;; - --catalina) - catalina="true"; - service="false" - shift;; - --tomcat_lk) - tomcat_lk="true"; - service="false" - shift;; - --skip_tomcat) - skip_tomcat="true"; - service="false" - shift;; - --noPrompt) - noPrompt="true"; - shift;; - *) - echo "Option [$1] not one of [c, l, d, t, u, service, catalina, noPrompt]"; - print_usage - exit;; - esac -done - - -# -# More Variables -# -# strip trailing slashes off of paths for easier path contruction later: -labkey_home=`echo $labkey_home | sed 's;/$;;'` -tomcat_home=`echo $tomcat_home | sed 's;/$;;'` -labkey_binary_distro_dir=`echo $labkey_binary_distro_dir | sed 's;/$;;'` - - -# -# validate parameters -# -echo "" -echo "" -echo "------------- Starting the Upgrade at " `date` -echo "" - -echo "Verifying installation directories and upgrade files..." - -if [ -z $labkey_home ] || [ ! -d $labkey_home ] -then - echo "" - echo "LABKEY_HOME location, $labkey_home, is either invalid or not provided. Please specify correct path on the command line." - echo "" - print_usage - exit 1 -fi - -if [ -z $labkey_binary_distro_dir ] || [ ! -d $labkey_binary_distro_dir ] || [ ! -d "$labkey_binary_distro_dir/labkeywebapp" ] -then - echo "" - echo "The LabKey distribution location, $labkey_binary_distro_dir, was either invalid or not provided. Please specify correct path on the command line." - echo "" - print_usage - exit 1 -fi - -if [ -z $tomcat_home ] || [ ! -d $tomcat_home ] -then - echo "" - echo "TOMCAT_HOME location, $tomcat_home, is either invalid or not provided." - echo "Please specify the correct path on the command line, or set the CATALINA_HOME environment variable." - echo "" - print_usage - exit 1 -fi - -CATALINA_HOME=$tomcat_home -# export CATALINA_HOME - -echo "" -echo " Installation options have been verified" - -# -# Ask the administrator to backup the database. -# - -echo "" -echo " LabKey recommends performing a database backup before moving forward with the upgrade." -echo " - See https://www.labkey.org/Documentation/wiki-page.view?name=backupScenarios " -echo " for more information on how to perform a backup of your database." -echo "" -echo " Additionally, the upgrade process will replace the current contents of your deployment's" -echo " ./modules and ./labkeyWebapp directories. If you have added your own modules or content, " -echo " please migrate to using ./externalModules before proceeding." -echo " - See https://www.labkey.org/Documentation/wiki-page.view?name=moduleUpgrades" -echo "" - -if [ "$noPrompt" = "false" ] -then - echo " Press [Enter] to start the upgrade. " - read -p " " read_variable -fi - -# -# Stop the Tomcat server -# - -echo " Stopping the LabKey/Tomcat server..." -if [ "$service" = "true" ] -then - sudo $service_script stop -elif [ "$systemctl" = "true" ] -then - sudo /bin/systemctl stop tomcat.service -elif [ "$tomcat_lk" = "true" ] -then - sudo service tomcat_lk stop -elif [ "$catalina" = "true" ] -then - $tomcat_home/bin/shutdown.sh -elif [ "$skip_tomcat" = "true" ] -then - echo "skip_tomcat=true, so tomcat will not be shutdown" -fi - -# -# Check if Tomcat has successfully shutdown -# -PID=$(ps ax | grep bootstrap.jar | grep catalina) -if [ -n "$PID" ] -then - /bin/echo -n " Waiting for the Tomcat to shutdown..." - sleep 10 - while [ ${count} -le 15 ] - do - PID=$(ps ax | grep bootstrap.jar | grep catalina) - if [ -n "$PID" ] - then - /bin/echo -n "." - sleep 2 - count=`expr $count + 1` - else - echo "" - break - fi - done -fi - -if [ "$count" = "16" ] -then - echo "" - echo " The LabKey/Tomcat server did not respond to the stop request and is " - echo " still running. The upgrade will not proceed. " - echo "" - echo " Please see the Tomcat logs, in the directory $tomcat_home/logs, " - echo " for more information." - echo "" - exit -fi - -# -# Remove LabKey installed files in LABKEY_HOME -# -echo "" -echo " Remove the currently installed LabKey binaries from the $labkey_home directory" -rm -rf $labkey_home/modules -if [ $? != 0 ]; then print_error; fi # exit if the last command failed -rm -rf $labkey_home/labkeywebapp -if [ $? != 0 ]; then print_error; fi # exit if the last command failed -if [ -x $labkey_home/pipeline-lib ]; then - rm -rf $labkey_home/pipeline-lib - if [ $? != 0 ]; then print_error; fi # exit if the last command failed -fi - -# -# Install the new version of LabKey in LABKEY_HOME -# -echo "" -echo " Install the new version of LabKey into $labkey_home directory " -cd $labkey_binary_distro_dir - -# -# As of 16.2.1 sprint build, /bin directory no longer exists in the Linux/OSX distributions, #26103 & #26210 -# -# cp -f bin/* $labkey_home/bin -# if [ $? != 0 ]; then print_error; fi # exit if the last command failed - -cp -R modules $labkey_home -if [ $? != 0 ]; then print_error; fi # exit if the last command failed -cp -R labkeywebapp $labkey_home -if [ $? != 0 ]; then print_error; fi # exit if the last command failed -if [ -x pipeline-lib ]; then - cp -R pipeline-lib $labkey_home - if [ $? != 0 ]; then print_error; fi # exit if the last command failed -fi - -# -# Remove all existing LabKey JAR files from TOMCAT_HOME/lib directory, if found -# Throws warning if the forced delete fails. -# -removeTomcatJar() -{ - jar=$1 - file=$CATALINA_HOME/lib/$jar - if [ -f $file ] - then - echo "Deleting the $file file..." - rm -f $file; - retValue=$? - if [ $retValue -ne 0 ]; then - echo "FAILED" - deleteFailed=1 - fi - fi -} - -deleteFailed=0 -removeTomcatJar 'javax.activation.jar' -removeTomcatJar 'labkeyBootstrap.jar' -removeTomcatJar 'mysql.jar' -removeTomcatJar 'jtds.jar' -removeTomcatJar 'mail.jar' -removeTomcatJar 'postgresql.jar' - -if [ $deleteFailed -eq 1 ]; then - echo "Unable to delete one or more legacy jar files from $CATALINA_HOME/lib. You will need to remove these manually in order for the server to start cleanly." -fi - -# -# Copy the LabKey jar files (libraries) to the TOMCAT_HOME directory -# -echo "" -echo " Install the LabKey jar files(libraries) into $tomcat_home/lib directory " -cp -f tomcat-lib/*.jar $CATALINA_HOME/lib -if [ $? != 0 ]; then print_error; fi # exit if the last command failed - -# -# Ensure that the user running the tomcat server owns all the files -# -echo "" -echo " Setting owner for the newly installed files" -if [ $tomcat_user != "-" ]; then - chown -R $tomcat_user $labkey_home - chown -R $tomcat_user $tomcat_home/lib -fi - -# -# Start the LabKey/Tomcat Server -# -echo "" -echo " Starting Apache Tomcat..." -if [ $service = "true" ] -then - sudo $service_script start -elif [ $systemctl = "true" ] -then - sudo /bin/systemctl start tomcat.service -elif [ $tomcat_lk = "true" ] -then - sudo service tomcat_lk start -elif [ $catalina = "true" ] -then - $tomcat_home/bin/startup.sh -elif [ "$skip_tomcat" = "true" ] -then - echo "skip_tomcat=true, so tomcat will not be restarted" -fi - -# -# Write out upgrade log. -# The upgrade log is a record of all LabKey Server -# upgrades which occur on this server. The log will collect -# the date of the upgrade, LabKey Server version and other -# important information. -# -installLog=$labkey_home/labkey_installs.txt -hostname=`hostname -f` -if [ -z "$SUDO_USER" ] -then - user=$USER -else - user=$SUDO_USER -fi -distname=`basename $labkey_binary_distro_dir` -echo $DATE, $hostname, $user, $distname >> $installLog - - -echo "" -echo " The upgrade has completed successfully " -echo "" -echo " If the LabKey server does not start properly see the log files at " -echo " - Tomcat startup log: $tomcat_home/logs/catalina.out " -echo " - LabKey specific log: $tomcat_home/logs/labkey.log " -echo "" -echo " ------------- The upgrade has completed at " `date` -echo "" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e6441136..2c352119 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 09523c0e..9355b415 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index b740cf13..f5feea6d 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 25da30db..9d21a218 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## diff --git a/src/main/groovy/org/labkey/gradle/plugin/Distribution.groovy b/src/main/groovy/org/labkey/gradle/plugin/Distribution.groovy index 04139648..ad8d3475 100644 --- a/src/main/groovy/org/labkey/gradle/plugin/Distribution.groovy +++ b/src/main/groovy/org/labkey/gradle/plugin/Distribution.groovy @@ -237,7 +237,6 @@ class Distribution implements Plugin .orElse(project.name) } } - } diff --git a/src/main/groovy/org/labkey/gradle/plugin/LabKey.groovy b/src/main/groovy/org/labkey/gradle/plugin/LabKey.groovy index d5f0fcd7..93321044 100644 --- a/src/main/groovy/org/labkey/gradle/plugin/LabKey.groovy +++ b/src/main/groovy/org/labkey/gradle/plugin/LabKey.groovy @@ -69,10 +69,6 @@ class LabKey implements Plugin project.configurations { modules - // we don't want this to be transitive because we use this configuration to - // clean out the tomcat/lib directory when we do a cleanDeploy and the transitive - // dependencies include some of the jars that are native to tomcat. - tomcatJars { transitive = false } remotePipelineJars external { canBeConsumed = true @@ -85,7 +81,6 @@ class LabKey implements Plugin project.configurations.external.setDescription("External dependencies to be included in a module's lib directory") project.configurations.externalsNotTrans.setDescription("Direct external dependencies (not including transitive dependencies), for use in creating jars.txt file") project.configurations.modules.setDescription("Modules used in the current server deployment") - project.configurations.tomcatJars.setDescription("Dependencies to be copied into the tomcat/lib directory upon deployment") project.configurations.remotePipelineJars.setDescription("Dependencies required for running remote pipeline jobs") } diff --git a/src/main/groovy/org/labkey/gradle/plugin/ServerDeploy.groovy b/src/main/groovy/org/labkey/gradle/plugin/ServerDeploy.groovy index b1bbfc57..c5ab1001 100644 --- a/src/main/groovy/org/labkey/gradle/plugin/ServerDeploy.groovy +++ b/src/main/groovy/org/labkey/gradle/plugin/ServerDeploy.groovy @@ -27,7 +27,6 @@ import org.gradle.api.artifacts.Dependency import org.gradle.api.file.CopySpec import org.gradle.api.file.DeleteSpec import org.gradle.api.file.FileCollection -import org.gradle.api.file.FileTree import org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency import org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency import org.gradle.api.tasks.Delete @@ -47,9 +46,6 @@ import java.nio.file.Paths */ class ServerDeploy implements Plugin { - public static final List JDBC_JARS = ["jtds.jar", "mysql.jar", "postgresql.jar"] - public static final List TOMCAT_LIB_UNVERSIONED_JARS = JDBC_JARS + ["ant.jar", "mail.jar", "javax.activation.jar"] - private ServerDeployExtension serverDeploy @Override @@ -74,8 +70,7 @@ class ServerDeploy implements Plugin private void addTasks(Project project) { - project.tasks.register( - "deployApp", DeployApp) { + project.tasks.register("deployApp", DeployApp) { DeployApp task -> task.group = GroupNames.DEPLOY task.description = "Deploy the application locally into ${serverDeploy.dir}" @@ -125,20 +120,18 @@ class ServerDeploy implements Plugin if (!localModules.isEmpty()) { project.ant.copy( - overwrite: true, // overwrite existing files even if the destination files are newer - todir: staging.modulesDir, - preserveLastModified: true // this is important so we don't re-explode modules that have not changed + overwrite: true, // overwrite existing files even if the destination files are newer + todir: staging.modulesDir, + preserveLastModified: true // this is important so we don't re-explode modules that have not changed ) - { - localModules.addToAntBuilder(project.ant, "fileset", FileCollection.AntType.FileSet) - } + { + localModules.addToAntBuilder(project.ant, "fileset", FileCollection.AntType.FileSet) + } } - }) } project.tasks.named('stageModules').configure {dependsOn project.configurations.modules} - project.tasks.register("checkModuleVersions", CheckForVersionConflicts) { CheckForVersionConflicts task -> task.directory = new File(serverDeploy.modulesDir) @@ -154,10 +147,8 @@ class ServerDeploy implements Plugin }) } - project.tasks.named('stageModules').configure {dependsOn(project.tasks.checkModuleVersions)} - project.tasks.register("checkVersionConflicts") { Task task -> task.group = GroupNames.DEPLOY @@ -192,28 +183,25 @@ class ServerDeploy implements Plugin project.tasks.named('deployApp').configure {dependsOn(project.tasks.symlinkNode)} } - - project.tasks.register( - "stageRemotePipelineJars") { + project.tasks.register("stageRemotePipelineJars") { Task task -> task.group = GroupNames.DEPLOY task.description = "Copy files needed for using remote pipeline jobs into ${staging.pipelineLibDir}" - task.doLast( + task.doLast({ + if (!project.configurations.remotePipelineJars.getFiles().isEmpty()) { + project.ant.copy( + todir: staging.pipelineLibDir, + preserveLastModified: true + ) { - if (!project.configurations.remotePipelineJars.getFiles().isEmpty()) { - project.ant.copy( - todir: staging.pipelineLibDir, - preserveLastModified: true - ) - { - project.configurations.remotePipelineJars { Configuration collection -> - collection.addToAntBuilder(project.ant, "fileset", FileCollection.AntType.FileSet) - - } - } + project.configurations.remotePipelineJars + { + Configuration collection -> + collection.addToAntBuilder(project.ant, "fileset", FileCollection.AntType.FileSet) } } - ) + } + }) } project.tasks.named('stageRemotePipelineJars').configure {dependsOn project.configurations.remotePipelineJars} @@ -231,7 +219,7 @@ class ServerDeploy implements Plugin "setup", DoThenSetup) { DoThenSetup task -> task.group = GroupNames.DEPLOY - task.description = "Installs labkey.xml and application.properties (for embedded tomcat) into the tomcat configuration directory. Sets default database properties." + task.description = "Installs application.properties into the tomcat configuration directory. Sets default database properties." // stage the application first to try to avoid multiple Tomcat restarts task.mustRunAfter(project.tasks.stageApp) } @@ -272,41 +260,21 @@ class ServerDeploy implements Plugin } - String log4jFile = 'log4j2.xml' - project.tasks.register('configureLog4j', ConfigureLog4J) { - ConfigureLog4J task -> - task.fileName = log4jFile - task.group = GroupNames.DEPLOY - task.description = "Edit and copy ${log4jFile} file" - } - project.tasks.named('stageApp').configure {dependsOn(project.tasks.configureLog4j)} - project.tasks.register("stageDistribution", StageDistribution) { StageDistribution task -> task.group = GroupNames.DISTRIBUTION task.description = "Populate the staging directory using a LabKey distribution file from directory dist or directory specified with distDir property. Use property distType to specify zip or tar.gz (default)." } - if (BuildUtils.useEmbeddedTomcat(project)) - project.tasks.register("deployDistribution", DeployEmbeddedDistribution) { - DeployEmbeddedDistribution task -> - task.group = GroupNames.DISTRIBUTION - task.description = "Extract the executable jar from a distribution and put it and the included binaries in the appropriate deploy directory" - task.dependsOn(project.tasks.cleanEmbeddedDeploy, project.tasks.setup) - } - else - project.tasks.register("deployDistribution", DeployApp) { - DeployApp task -> - task.group = GroupNames.DISTRIBUTION - task.description = "Deploy a LabKey distribution file from directory dist or directory specified with distDir property. Use property distType to specify zip or tar.gz (default)." - task.dependsOn(project.tasks.stageDistribution, project.tasks.configureLog4j, project.tasks.setup) - task.doFirst {deployTomcatJars(task)} - } - + project.tasks.register("deployDistribution", DeployEmbeddedDistribution) { + DeployEmbeddedDistribution task -> + task.group = GroupNames.DISTRIBUTION + task.description = "Extract the executable jar from a distribution and put it and the included binaries in the appropriate deploy directory" + task.dependsOn(project.tasks.cleanEmbeddedDeploy, project.tasks.setup) + } // This may prevent multiple Tomcat restarts project.tasks.named('setup').configure {mustRunAfter(project.tasks.stageDistribution)} - project.tasks.named('configureLog4j').configure {mustRunAfter(project.tasks.stageDistribution)} project.tasks.register('undeployModules',UndeployModules) { UndeployModules task -> @@ -314,7 +282,6 @@ class ServerDeploy implements Plugin task.description = "Removes all module files and directories from the deploy and staging directories" } - project.tasks.register( 'cleanStaging',Delete) { Delete task -> @@ -337,16 +304,6 @@ class ServerDeploy implements Plugin } project.tasks.named('deployApp').configure {mustRunAfter(project.tasks.cleanDeploy)} - project.tasks.register("cleanTomcatLib") { - Task task -> - task.group = GroupNames.DEPLOY - task.description = "Remove the jar files deployed to the tomcat/lib directory" - task.doLast { - deleteTomcatLibs(project) - } - } - - project.tasks.register("cleanAndDeploy", DeployApp) { DeployApp task -> task.group = GroupNames.DEPLOY @@ -364,32 +321,6 @@ class ServerDeploy implements Plugin } project.tasks.named('deployApp').configure {mustRunAfter(project.tasks.cleanBuild)} - Project serverProject = BuildUtils.getServerProject(project) - if (serverProject != null) { - project.tasks.register('stageTomcatJars', DefaultTask) { - DefaultTask task -> - task.group = GroupNames.DEPLOY - task.description = "Copy runtime Tomcat dependencies to ${staging.tomcatLibDir}" - task.dependsOn(serverProject.configurations.tomcatJars) - task.doLast({ - stageTomcatJars(task) - }) - } - - project.tasks.register('deployTomcatJars', DefaultTask) { - DefaultTask task -> - task.group = GroupNames.DEPLOY - task.description = "Copying files from ${staging.tomcatLibDir} to \$CATALINA_HOME/lib" - task.dependsOn(serverProject.tasks.stageTomcatJars) - task.doLast({ - deployTomcatJars(task) - }) - } - - project.tasks.named('stageApp').configure {dependsOn(project.tasks.stageTomcatJars)} - project.tasks.named('deployApp').configure {dependsOn(project.tasks.deployTomcatJars)} - } - // TODO is this still useful? project.tasks.register( 'checkModuleTasks', DefaultTask) { @@ -410,112 +341,22 @@ class ServerDeploy implements Plugin }) if (projectsMissingTasks.length > 0) project.logger.quiet("Each of the following projects has a 'module.properties' file but no 'module' task. " + - "These modules will not be included in the deployed server. " + - "You should apply either the 'org.labkey.build.fileModule' or 'org.labkey.build.module' plugin in each project's 'build.gradle' file. " + - "See https://www.labkey.org/Documentation/wiki-page.view?name=gradleModules for more information.\n\t" + - "${projectsMissingTasks.join("\n\t")}") + "These modules will not be included in the deployed server. " + + "You should apply either the 'org.labkey.build.fileModule' or 'org.labkey.build.module' plugin in each project's 'build.gradle' file. " + + "See https://www.labkey.org/Documentation/wiki-page.view?name=gradleModules for more information.\n\t" + + "${projectsMissingTasks.join("\n\t")}") }) task.notCompatibleWithConfigurationCache("Needs to walk the project tree") } project.tasks.named('deployApp').configure {dependsOn(project.tasks.named("checkModuleTasks"))} project.tasks.named('checkModuleTasks').configure {mustRunAfter(project.tasks.stageApp)} // do this so the message appears at the bottom of the output - if (project.plugins.hasPlugin(Tomcat)) { - if (project.tomcat.hasCatalinaHome()) { - project.tasks.named("cleanBuild").configure { - it.dependsOn(project.tasks.stopTomcat) - } - project.tasks.named("cleanDeploy").configure { - it.dependsOn(project.tasks.stopTomcat) - } - } + project.tasks.named("cleanBuild").configure { + it.dependsOn(project.tasks.stopTomcat) } - } - - /** - * For consistency with a distribution deployment and the treatment of all other deployment artifacts, - * first copy the tomcat jars into the staging directory - * @param task - */ - private void stageTomcatJars(Task task) { - Project project = task.project - Project serverProject = BuildUtils.getServerProject(project) - // Remove the staging tomcatLib directory before copying into it to avoid duplicates. - project.delete project.staging.tomcatLibDir - - // We resolve the tomcatJars files outside of the ant copy because this seems to avoid - // an error we saw on TeamCity when running the pickMssql task on Windows when updating to Gradle 6.7 - // The error in the gradle log was: - // org.apache.tools.ant.BuildException: copy doesn't support the nested "exec" element. - // Theory is that when the files in the configuration have not been resolved, they get resolved - // inside the node being added to the ant task below and that is not supported. - FileTree tomcatJars = serverProject.configurations.tomcatJars.getAsFileTree() - - if (tomcatJars.size() == 1 && tomcatJars.getAt(0).getName().endsWith(".zip")) { - // Crack open zipped published tomcat libs - tomcatJars = project.zipTree(tomcatJars.singleFile) - } - task.logger.info("Copying to ${project.staging.tomcatLibDir}") - task.logger.info("tomcatFiles are ${tomcatJars.files}") - project.ant.copy( - todir: project.staging.tomcatLibDir, - preserveLastModified: true, - overwrite: true // Issue 33473: overwrite the existing jars to facilitate switching to older versions of labkey with older dependencies - ) - { - tomcatJars.addToAntBuilder(project.ant, "fileset", FileCollection.AntType.FileSet) - - // Put unversioned files into the tomcatLibDir. These files are meant to be copied into - // the tomcat/lib directory when deploying a build or a distribution. When version numbers change, - // you will end up with multiple versions of these jar files on the classpath, which will often - // result in problems of compatibility. Additionally, we want to maintain the (incorrect) names - // of the files that have been used with the Ant build process. - // - // We may employ CATALINA_BASE in order to separate our libraries from the ones that come with - // the tomcat distribution. This will require updating our instructions for installation by clients - // but would allow us to use artifacts with more self-documenting names. - chainedmapper() - { - flattenmapper() - // get rid of the version numbers on the jar files - // matches on: name-X.Y.Z-SNAPSHOT.jar, name-X.Y.Z_branch-SNAPSHOT.jar, name-X.Y.Z.jar - // - // N.B. Attempts to use BuildUtils.VERSIONED_ARTIFACT_NAME_PATTERN here fail for the javax.mail-X.Y.Z.jar file. - // The Ant regexpmapper chooses only javax as \\1, which is not what is wanted - regexpmapper(from: "^(.*?)(-\\d+(\\.\\d+)*(_.+)?(-SNAPSHOT)?)?\\.jar", to: "\\1.jar") - filtermapper() - { - replacestring(from: "mysql-connector-java", to: "mysql") - // the Ant build used mysql.jar - replacestring(from: "javax.mail", to: "mail") // the Ant build used mail.jar - replacestring(from: "jakarta.mail", to: "mail") - // the Ant build used mail.jar - replacestring(from: "jakarta.activation", to: "javax.activation") - // the Ant build used javax.activation.jar - } - } - } - } - - private void deployTomcatJars(Task task) { - Project project = task.project - if (BuildUtils.useEmbeddedTomcat(project)) { - task.logger.info("Not deploying tomcat jars for embedded deployment") - return + project.tasks.named("cleanDeploy").configure { + it.dependsOn(project.tasks.stopTomcat) } - - JDBC_JARS.each{String name -> new File("${project.tomcat.catalinaHome}/lib/${name}").delete()} - - // Then copy them into the tomcat/lib directory - task.logger.info("Copying files from ${project.staging.tomcatLibDir} to ${project.tomcat.catalinaHome}/lib") - project.ant.copy( - todir: "${project.tomcat.catalinaHome}/lib", - preserveLastModified: true, - overwrite: true - ) - { - fileset(dir: project.staging.tomcatLibDir) - } } private static linkBinaries(Project project, String packageMgr, String version, workDirectory) { @@ -558,29 +399,4 @@ class ServerDeploy implements Plugin project.logger.warn("No file found with prefix ${nodeDir.path}/${nodeFilePrefix}. Symbolic link in ${linkContainer.getPath()}/node not created.") } } - - private static void deleteTomcatLibs(Project project) - { - project.tomcat.validateCatalinaHome() - - Files.newDirectoryStream(Paths.get(project.tomcat.catalinaHome, "lib"), "${BuildUtils.BOOTSTRAP_JAR_BASE_NAME}*.jar").each { Path path -> - project.delete path.toString() - } - - project.configurations.tomcatJars.files.each {File jarFile -> - File libFile = new File("${project.tomcat.catalinaHome}/lib/${jarFile.getName()}") - if (libFile.exists()) - project.delete libFile.getAbsolutePath() - } - - // Get rid of (un-versioned) jars that were deployed - TOMCAT_LIB_UNVERSIONED_JARS.each{String name -> - File libFile = new File("${project.tomcat.catalinaHome}/lib/${name}") - if (libFile.exists()) - project.delete libFile.getAbsolutePath() - } - } } - - - diff --git a/src/main/groovy/org/labkey/gradle/plugin/TeamCity.groovy b/src/main/groovy/org/labkey/gradle/plugin/TeamCity.groovy index 1e4711c6..ad916dd3 100644 --- a/src/main/groovy/org/labkey/gradle/plugin/TeamCity.groovy +++ b/src/main/groovy/org/labkey/gradle/plugin/TeamCity.groovy @@ -66,11 +66,7 @@ class TeamCity extends Tomcat // from TeamCity's configuration when creating the UITestExtension on TeamCity super.apply(project) project.tomcat.assertionFlag = "-ea" - String truststoreFile = "${project.tomcat.catalinaHome}/localhost.truststore" - if (!project.file(truststoreFile).exists()) - { - truststoreFile = "${System.getProperty("user.home")}/localhost.truststore" - } + String truststoreFile = "${System.getProperty("user.home")}/localhost.truststore" if (project.file(truststoreFile).exists()) { project.tomcat.trustStore = "-Djavax.net.ssl.trustStore=${truststoreFile}" @@ -108,16 +104,11 @@ class TeamCity extends Tomcat task.group = GroupNames.TEST_SERVER task.description = "Removes log files from Tomcat and TeamCity" task.dependsOn project.tasks.cleanLogs - if (!BuildUtils.useEmbeddedTomcat(project)) { - // Not valid for embedded Tomcat - task.dependsOn project.tasks.cleanTemp - } task.doLast { project.delete "${project.projectDir}/${TEAMCITY_INFO_FILE}" } } - project.tasks.named("stopTomcat").configure { doLast { ensureShutdown(project) diff --git a/src/main/groovy/org/labkey/gradle/plugin/TestRunner.groovy b/src/main/groovy/org/labkey/gradle/plugin/TestRunner.groovy index 4e5b7a9e..61b9821c 100644 --- a/src/main/groovy/org/labkey/gradle/plugin/TestRunner.groovy +++ b/src/main/groovy/org/labkey/gradle/plugin/TestRunner.groovy @@ -17,8 +17,6 @@ package org.labkey.gradle.plugin import org.gradle.api.Project import org.gradle.api.Task -import org.gradle.api.tasks.TaskProvider -import org.gradle.api.tasks.bundling.Zip import org.labkey.gradle.plugin.extension.TeamCityExtension import org.labkey.gradle.task.RunTestSuite import org.labkey.gradle.util.BuildUtils @@ -35,8 +33,6 @@ class TestRunner extends UiTest addDataFileTasks(project) - addExtensionsTasks(project) - addTestSuiteTask(project) addAspectJ(project) @@ -164,36 +160,6 @@ class TestRunner extends UiTest } } - private static void addExtensionsTasks(Project project) - { - File extensionsDir = project.file("chromeextensions") - if (extensionsDir.exists()) - { - List extensionsZipTasks = new ArrayList<>() - extensionsDir.eachDir({ - File dir -> - - String extensionTaskName = "package" + dir.getName().capitalize() - project.tasks.register(extensionTaskName, Zip) { - Zip task -> - task.description = "Package the ${dir.getName()} chrome extension used for testing" - task.archiveBaseName.set(dir.getName()) - task.archiveExtension.set("zip") - task.from dir - task.destinationDirectory.set(project.layout.buildDirectory.dir("chromextensions")) - } - - extensionsZipTasks.add(project.tasks.named(extensionTaskName)) - }) - project.tasks.register("packageChromeExtensions") { - Task task -> - task.description = "Package all chrome extensions used for testing" - task.dependsOn (extensionsZipTasks) - } - - } - } - private void addTestSuiteTask(Project project) { project.logger.debug("TestRunner: addTestSuiteTask for ${project.path}") diff --git a/src/main/groovy/org/labkey/gradle/plugin/Tomcat.groovy b/src/main/groovy/org/labkey/gradle/plugin/Tomcat.groovy index 09a40565..f3eea330 100644 --- a/src/main/groovy/org/labkey/gradle/plugin/Tomcat.groovy +++ b/src/main/groovy/org/labkey/gradle/plugin/Tomcat.groovy @@ -16,7 +16,6 @@ package org.labkey.gradle.plugin -import org.gradle.api.DefaultTask import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.file.DeleteSpec @@ -26,7 +25,6 @@ import org.labkey.gradle.plugin.extension.TomcatExtension import org.labkey.gradle.plugin.extension.UiTestExtension import org.labkey.gradle.task.StartTomcat import org.labkey.gradle.task.StopTomcat -import org.labkey.gradle.util.BuildUtils import org.labkey.gradle.util.GroupNames /** @@ -50,60 +48,31 @@ class Tomcat implements Plugin tomcat.assertionFlag = Boolean.valueOf((String) testEx.getTestConfig("disableAssertions")) ? "-da" : "-ea" } tomcat.catalinaOpts = "-Dproject.root=${project.rootProject.projectDir.absolutePath}" - - addTasks(project, tomcat) + addTasks(project) } - - private static void addTasks(Project project, TomcatExtension tomcat) + private static void addTasks(Project project) { project.tasks.register("startTomcat", StartTomcat) { StartTomcat task -> task.group = GroupNames.WEB_APPLICATION - task.description = "Start the local or embedded (if property useEmbeddedTomcat is defined) Tomcat instance" + task.description = "Start the embedded Tomcat instance" } project.tasks.register( "stopTomcat", StopTomcat) { StopTomcat task -> task.group = GroupNames.WEB_APPLICATION - task.description = "Stop the local or embedded (if property useEmbeddedTomcat is defined) Tomcat instance" + task.description = "Stop the embedded Tomcat instance" } project.tasks.register("cleanLogs", Delete) { Delete task -> - var logDir = BuildUtils.useEmbeddedTomcat(project) - ? "${ServerDeployExtension.getEmbeddedServerDeployDirectory(project)}/logs" - : "${tomcat.catalinaHome}/logs" - + var logDir = "${ServerDeployExtension.getEmbeddedServerDeployDirectory(project)}/logs" task.group = GroupNames.WEB_APPLICATION task.description = "Delete logs from ${logDir}" - if (!BuildUtils.useEmbeddedTomcat(project)) { - task.doFirst {tomcat.validateCatalinaHome()} - } task.configure { DeleteSpec spec -> spec.delete project.fileTree(logDir) } } - - project.tasks.register("cleanTemp", DefaultTask) { - DefaultTask task -> - task.group = GroupNames.WEB_APPLICATION - task.description = "Delete temp files from ${tomcat.catalinaHome}" - task.doFirst {tomcat.validateCatalinaHome()} - task.doLast( { - // Note that we use the AntBuilder here because a fileTree in Gradle is a set of FILES only. - // Deleting a file tree will delete all the leaves of the directory structure, but none of the - // directories. - project.ant.delete(includeEmptyDirs: true, quiet: true) - { - fileset(dir: "${tomcat.catalinaHome}/temp") - { - include(name: "**/*") - } - } - new File("${tomcat.catalinaHome}", "temp").mkdirs() - }) - } - } } diff --git a/src/main/groovy/org/labkey/gradle/plugin/extension/StagingExtension.groovy b/src/main/groovy/org/labkey/gradle/plugin/extension/StagingExtension.groovy index 1f862df3..cf5f0a72 100644 --- a/src/main/groovy/org/labkey/gradle/plugin/extension/StagingExtension.groovy +++ b/src/main/groovy/org/labkey/gradle/plugin/extension/StagingExtension.groovy @@ -31,7 +31,6 @@ class StagingExtension String webInfDir String webappDir String modulesDir - String tomcatLibDir String pipelineLibDir void setDirectories(Project project) @@ -43,7 +42,6 @@ class StagingExtension webInfDir = "${buildDirPath}/${STAGING_WEBINF_DIR}" webappDir = "${buildDirPath}/${STAGING_WEBAPP_DIR}" modulesDir = "${buildDirPath}/${STAGING_MODULES_DIR}" - tomcatLibDir = "${dir}/tomcat-lib" // Note: Keep this path in sync with AdminController.getTomcatJars() pipelineLibDir = "${dir}/pipelineLib" } } diff --git a/src/main/groovy/org/labkey/gradle/plugin/extension/TeamCityExtension.groovy b/src/main/groovy/org/labkey/gradle/plugin/extension/TeamCityExtension.groovy index f2e34310..b7241f96 100644 --- a/src/main/groovy/org/labkey/gradle/plugin/extension/TeamCityExtension.groovy +++ b/src/main/groovy/org/labkey/gradle/plugin/extension/TeamCityExtension.groovy @@ -116,12 +116,7 @@ class TeamCityExtension } File startupPropertiesDir() { - File startupDir - if (BuildUtils.useEmbeddedTomcat(project)) { - startupDir = new File(new File(ServerDeployExtension.getEmbeddedServerDeployDirectory(project)), 'startup') - } else { - startupDir = new File(new File(ServerDeployExtension.getServerDeployDirectory(project)), 'startup') - } + File startupDir = new File(new File(ServerDeployExtension.getEmbeddedServerDeployDirectory(project)), 'startup') FileUtils.forceMkdir(startupDir) return startupDir } diff --git a/src/main/groovy/org/labkey/gradle/plugin/extension/TomcatExtension.groovy b/src/main/groovy/org/labkey/gradle/plugin/extension/TomcatExtension.groovy index 8bcfc0e2..c68398af 100644 --- a/src/main/groovy/org/labkey/gradle/plugin/extension/TomcatExtension.groovy +++ b/src/main/groovy/org/labkey/gradle/plugin/extension/TomcatExtension.groovy @@ -15,15 +15,12 @@ */ package org.labkey.gradle.plugin.extension -import org.gradle.api.GradleException import org.gradle.api.Project class TomcatExtension { private final Project project - String catalinaHome - String tomcatConfDir String assertionFlag = "-ea" // set to -da to disable assertions and -ea to enable assertions String maxMemory = "2G" boolean disableRecompileJsp = false @@ -36,79 +33,5 @@ class TomcatExtension TomcatExtension(Project project) { this.project = project - setCatalinaDirs(project) - } - - String getCatalinaHome() - { - return catalinaHome - } - - String getTomcatConfDir() - { - return tomcatConfDir - } - - void validateCatalinaHome() - { - String errorMsg = "" - if (catalinaHome == null || catalinaHome.isEmpty()) - { - errorMsg = "Tomcat home directory not set" - } - else if (!project.file(catalinaHome).exists()) - { - errorMsg = "Specified Tomcat home directory [${project.file(catalinaHome).getAbsolutePath()}] does not exist" - } - else if (!new File(project.file(catalinaHome), "conf/server.xml").exists()) - { - errorMsg = "Specified Tomcat home directory [${project.file(catalinaHome).getAbsolutePath()}] does not appear to be a tomcat installation" - } - if (!errorMsg.isEmpty()) - { - throw new GradleException("${errorMsg}. Please specify using the environment variable CATALINA_HOME. " + - "You may also set the value of the 'tomcat.home' system property using either " + - "systemProp.tomcat.home= in a gradle.properties file or " + - "-Dtomcat.home= on command line. Note that CATALINA_HOME is not, generally, " + - "visible from within IntelliJ IDEA") - } - } - - boolean hasCatalinaHome() - { - return catalinaHome != null && !catalinaHome.isEmpty() - } - - private void setCatalinaDirs(Project project) - { - if (System.getenv("CATALINA_HOME") != null) - { - this.catalinaHome = System.getenv("CATALINA_HOME") - } - else if (project.hasProperty("tomcatDir")) - { - this.catalinaHome = project.tomcatDir - } - else if (project.ext.hasProperty("tomcatDir")) - { - this.catalinaHome = project.ext.tomcatDir - } - else - { - this.catalinaHome = TeamCityExtension.getTeamCityProperty(project, "tomcat.home", null) - } - - if (project.ext.hasProperty("tomcatConfDir")) - { - this.tomcatConfDir = project.ext.tomcatConfDir - } - else if (this.catalinaHome != null) - { - this.tomcatConfDir = "${this.catalinaHome}/conf/Catalina/localhost" - } - else - { - this.tomcatConfDir = null - } } } diff --git a/src/main/groovy/org/labkey/gradle/task/Bootstrap.groovy b/src/main/groovy/org/labkey/gradle/task/Bootstrap.groovy index 5e57ddd9..b9d967f4 100644 --- a/src/main/groovy/org/labkey/gradle/task/Bootstrap.groovy +++ b/src/main/groovy/org/labkey/gradle/task/Bootstrap.groovy @@ -36,10 +36,4 @@ class Bootstrap extends DoThenSetup { databaseProperties = new DatabaseProperties(project, true) } - - @Override - boolean labkeyXmlUpToDate(String appDocBase) - { - return false - } } diff --git a/src/main/groovy/org/labkey/gradle/task/ConfigureLog4J.groovy b/src/main/groovy/org/labkey/gradle/task/ConfigureLog4J.groovy deleted file mode 100644 index 7daa5ba5..00000000 --- a/src/main/groovy/org/labkey/gradle/task/ConfigureLog4J.groovy +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2016-2018 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.gradle.task - -import org.gradle.api.DefaultTask -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputFile -import org.gradle.api.tasks.OutputFile -import org.gradle.api.tasks.TaskAction -import org.labkey.gradle.plugin.extension.LabKeyExtension -import org.labkey.gradle.util.BuildUtils - -/** - * Used to copy over the log4j.xml template file and replace the consoleAppender value - * as appropriate for the current deployMode. - */ -class ConfigureLog4J extends DefaultTask -{ - @Input - String fileName - - private File stagingDir = new File((String) project.staging.webappClassesDir) - private File deployDir = new File("${project.serverDeploy.webappDir}/WEB-INF/classes") - - @InputFile - File getLog4jXml() - { - return BuildUtils.getWebappConfigFile(project, fileName) - } - - @OutputFile - File getStagingFile() - { - return new File(stagingDir, fileName) - } - - @OutputFile - File getDeployFile() - { - return new File(deployDir, fileName) - } - - @TaskAction - void copyFile() - { - String consoleAppender = "" // this is the setting for production mode - if (LabKeyExtension.isDevMode(project)) - { - consoleAppender = '' - } - ant.copy( - todir: stagingDir, - overwrite: true, - ) - { - fileset(file: getLog4jXml()) - filterset(beginToken: "@@", endToken: "@@") - { - filter (token: "consoleAppender", - value: consoleAppender - ) - } - } - ant.copy( - todir: deployDir, - overwrite: true, - ) - { - fileset(file: getStagingFile()) - } - } -} diff --git a/src/main/groovy/org/labkey/gradle/task/DeployApp.groovy b/src/main/groovy/org/labkey/gradle/task/DeployApp.groovy index 7dde92ff..177a34aa 100644 --- a/src/main/groovy/org/labkey/gradle/task/DeployApp.groovy +++ b/src/main/groovy/org/labkey/gradle/task/DeployApp.groovy @@ -26,9 +26,6 @@ class DeployApp extends DeployAppBase @InputDirectory File stagingModulesDir = new File((String) project.staging.modulesDir) - @InputDirectory - File stagingWebappDir = new File((String) project.staging.webappDir) - @InputDirectory File stagingPipelineJarDir = new File((String) project.staging.pipelineLibDir) @@ -47,25 +44,12 @@ class DeployApp extends DeployAppBase @TaskAction void action() { - deployWebappDir() deployModules() deployPipelineJars() deployNlpEngine(deployBinDir) deployPlatformBinaries(deployBinDir) } - - private void deployWebappDir() - { - ant.copy( - todir: deployWebappDir, - preserveLastModified: true - ) - { - fileset(dir: stagingWebappDir) - } - } - private void deployModules() { ant.copy ( diff --git a/src/main/groovy/org/labkey/gradle/task/DoThenSetup.groovy b/src/main/groovy/org/labkey/gradle/task/DoThenSetup.groovy index 0827ae27..59a8ce45 100644 --- a/src/main/groovy/org/labkey/gradle/task/DoThenSetup.groovy +++ b/src/main/groovy/org/labkey/gradle/task/DoThenSetup.groovy @@ -16,7 +16,6 @@ package org.labkey.gradle.task import org.gradle.api.DefaultTask -import org.gradle.api.GradleException import org.gradle.api.Project import org.gradle.api.file.CopySpec import org.gradle.api.file.DuplicatesStrategy @@ -60,128 +59,66 @@ class DoThenSetup extends DefaultTask @TaskAction void setup() { doDatabaseTask() - boolean useEmbeddedTomcat = BuildUtils.useEmbeddedTomcat(project) - if (!useEmbeddedTomcat) - { - project.tomcat.validateCatalinaHome() - File tomcatConfDir = project.file(project.tomcat.tomcatConfDir) - if (tomcatConfDir.exists()) { - if (!tomcatConfDir.isDirectory()) - throw new GradleException("No such directory: ${tomcatConfDir.absolutePath}") - if (!tomcatConfDir.canWrite() || !tomcatConfDir.canRead()) - throw new GradleException("Directory ${tomcatConfDir.absolutePath} does not have proper permissions") - } else if (!canCreate(tomcatConfDir)) - throw new GradleException("Insufficient permissions to create ${tomcatConfDir.absolutePath}") - - String appDocBase = project.serverDeploy.webappDir.toString().split("[/\\\\]").join("${File.separator}") - - if (!labkeyXmlUpToDate(appDocBase)) { - Properties configProperties = databaseProperties.getConfigProperties() - configProperties.putAll(getExtraJdbcProperties()) - configProperties.setProperty("appDocBase", appDocBase) - boolean isNextLineComment = false - File labkeyXml = BuildUtils.getWebappConfigFile(project, "labkey.xml") - project.copy({ CopySpec copy -> - copy.from labkeyXml - copy.into project.rootProject.layout.buildDirectory - copy.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE) - copy.filter({ String line -> - if (project.ext.has('enableJms') && project.ext.enableJms) { - line = line.replace("", "") - return line - } - // If we want to automatically enable an LDAP Sync that is hardcoded in the labkey.xml - // for testing purposes, this will uncomment that stanza if the enableLdapSync - // property is defined. - if (project.hasProperty('enableLdapSync')) { - line = line.replace("", "") - return line - } - if (configProperties.containsKey("extraJdbcDataSource")) - { - line = line.replace("", "") - } - if (isNextLineComment || line.contains("") - return line // Don't apply replacements to comments - } - return PropertiesUtils.replaceProps(line, configProperties, true) - }) - }) - - project.copy({ CopySpec copy -> - copy.from project.rootProject.layout.buildDirectory - copy.into "${project.tomcat.tomcatConfDir}" - copy.include "labkey.xml" - copy.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE) - }) + if (!embeddedConfigUpToDate()) { + Properties configProperties = databaseProperties.getConfigProperties() + configProperties.putAll(getExtraJdbcProperties()) + // in .properties files, backward slashes are seen as escape characters, so all paths must use forward slashes, even on Windows + configProperties.setProperty("pathToServer", project.rootDir.getAbsolutePath().replaceAll("\\\\", "/")) + + configProperties.setProperty("serverPort", tcPropOrDefault(project, + TeamCityExtension::getLabKeyServerPort, + "serverPort", + project.hasProperty("useSsl") ? "8443" : "8080")) + + configProperties.setProperty("shutdownPort", tcPropOrDefault(project, + TeamCityExtension::getLabKeyServerShutdownPort, + "shutdownPort", + "8081")) + + if (project.hasProperty("useSsl")) { + configProperties.setProperty("keyStore", tcPropOrDefault(project, + TeamCityExtension::getLabKeyServerKeystore, + "keyStore", + "/opt/teamcity-agent/localhost.keystore")) + + configProperties.setProperty("keyStorePassword", tcPropOrDefault(project, + TeamCityExtension::getLabKeyServerKeystorePassword, + "keyStorePassword", + "changeit")) } - } - else { - if (!embeddedConfigUpToDate()) { - Properties configProperties = databaseProperties.getConfigProperties() - configProperties.putAll(getExtraJdbcProperties()) - // in .properties files, backward slashes are seen as escape characters, so all paths must use forward slashes, even on Windows - configProperties.setProperty("pathToServer", project.rootDir.getAbsolutePath().replaceAll("\\\\", "/")) - configProperties.setProperty("serverPort", tcPropOrDefault(project, - TeamCityExtension::getLabKeyServerPort, - "serverPort", - project.hasProperty("useSsl") ? "8443" : "8080")) - - configProperties.setProperty("shutdownPort", tcPropOrDefault(project, - TeamCityExtension::getLabKeyServerShutdownPort, - "shutdownPort", - "8081")) - - if (project.hasProperty("useSsl")) { - configProperties.setProperty("keyStore", tcPropOrDefault(project, - TeamCityExtension::getLabKeyServerKeystore, - "keyStore", - "/opt/teamcity-agent/localhost.keystore")) - - configProperties.setProperty("keyStorePassword", tcPropOrDefault(project, - TeamCityExtension::getLabKeyServerKeystorePassword, - "keyStorePassword", - "changeit")) - } - - String embeddedDir = BuildUtils.getEmbeddedConfigPath(project) - File configsDir = new File(BuildUtils.getConfigsProject(project).projectDir, "configs") - project.copy({ CopySpec copy -> - copy.from configsDir - copy.into embeddedDir - copy.include "application.properties" - copy.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE) - copy.filter({ String line -> - // Always uncomment properties prepended by '#setupTask#' - line = line.replace("#setupTask#", "") - if (project.hasProperty("useSsl")) { - line = line.replace("#server.ssl", "server.ssl") - } - if (project.hasProperty("useLocalBuild") && "false" != project.property("useLocalBuild")) { - // Enable properties that require 'useLocalBuild' (e.g. 'context.webAppLocation' and 'spring.devtools.restart.additional-paths') - line = line.replace("#useLocalBuild#", "") - } - else { - // Remove placeholder - line = line.replace("#useLocalBuild#", "#") - } - if (configProperties.containsKey("extraJdbcDataSource") && line.contains("=@@extraJdbc")) - { - line = line.replace("#context.", "context.") - } - if (line.startsWith("#")) { - return line // Don't apply replacements to comments - } - return PropertiesUtils.replaceProps(line, configProperties, false) - }) + String embeddedDir = BuildUtils.getEmbeddedConfigPath(project) + File configsDir = new File(BuildUtils.getConfigsProject(project).projectDir, "configs") + project.copy({ CopySpec copy -> + copy.from configsDir + copy.into embeddedDir + copy.include "application.properties" + copy.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE) + copy.filter({ String line -> + // Always uncomment properties prepended by '#setupTask#' + line = line.replace("#setupTask#", "") + if (project.hasProperty("useSsl")) { + line = line.replace("#server.ssl", "server.ssl") + } + if (project.hasProperty("useLocalBuild") && "false" != project.property("useLocalBuild")) { + // Enable properties that require 'useLocalBuild' (e.g. 'context.webAppLocation' and 'spring.devtools.restart.additional-paths') + line = line.replace("#useLocalBuild#", "") + } + else { + // Remove placeholder + line = line.replace("#useLocalBuild#", "#") + } + if (configProperties.containsKey("extraJdbcDataSource") && line.contains("=@@extraJdbc")) + { + line = line.replace("#context.", "context.") + } + if (line.startsWith("#")) { + return line // Don't apply replacements to comments + } + return PropertiesUtils.replaceProps(line, configProperties, false) }) - BuildUtils.updateRestartTriggerFile(project) - } + }) + BuildUtils.updateRestartTriggerFile(project) } } @@ -203,30 +140,6 @@ class DoThenSetup extends DefaultTask return extraJdbcProperties } - - // labkeyXml is up to date if it was created after the current config file was created - // and it has the current appDocBase - boolean labkeyXmlUpToDate(String appDocBase) - { - if (this.dbPropertiesChanged) - return false - - File dbPropFile = DatabaseProperties.getPickedConfigFile(project) - File tomcatLabkeyXml = new File("${project.tomcat.tomcatConfDir}", "labkey.xml") - if (!dbPropFile.exists() || !tomcatLabkeyXml.exists()) - return false - if (dbPropFile.lastModified() < tomcatLabkeyXml.lastModified()) - { - // make sure we haven't switch contexts - for (String line: tomcatLabkeyXml.readLines()) - { - if (line.contains("docBase=\"" + appDocBase + "\"")) - return true - } - } - return false - } - boolean embeddedConfigUpToDate() { if (this.dbPropertiesChanged) diff --git a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy index 2e0c6cfb..c67c0a58 100644 --- a/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy +++ b/src/main/groovy/org/labkey/gradle/task/ModuleDistribution.groovy @@ -21,23 +21,17 @@ import org.gradle.api.GradleException import org.gradle.api.Project import org.gradle.api.file.CopySpec import org.gradle.api.file.DuplicatesStrategy -import org.gradle.api.file.FileTree import org.gradle.api.provider.Property import org.gradle.api.tasks.* import org.labkey.gradle.plugin.ApplyLicenses import org.labkey.gradle.plugin.extension.DistributionExtension import org.labkey.gradle.plugin.extension.LabKeyExtension -import org.labkey.gradle.plugin.extension.StagingExtension import org.labkey.gradle.util.BuildUtils import java.nio.file.Files class ModuleDistribution extends DefaultTask { - // TODO: Remove this unused property - @Optional @Input - String embeddedArchiveType = null - @Optional @Input String extraFileIdentifier = null @Optional @Input @@ -205,16 +199,10 @@ class ModuleDistribution extends DefaultTask private makeEmbeddedTomcatJar() { - StagingExtension staging = project.getExtensions().getByType(StagingExtension.class) - File embeddedJarFile = project.configurations.embedded.singleFile String modulesZipFile = getDistributionZipPath() File serverJarFile = new File(getEmbeddedTomcatJarPath()) ant.zip(destFile: modulesZipFile) { - zipfileset(dir: staging.webappDir, - prefix: "labkeywebapp") { - exclude(name: "WEB-INF/classes/distribution") - } zipfileset(dir: getModulesDir(), prefix: "modules") { include(name: "*.module") @@ -275,13 +263,6 @@ class ModuleDistribution extends DefaultTask { writeDistributionFile() writeVersionFile() - FileTree zipFile = getDistributionResources(project) - project.copy({ CopySpec copy -> - copy.from(zipFile) - copy.exclude "*.xml" - copy.into(project.layout.buildDirectory) - copy.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE) - }) // Prefer files from 'server/configs/webapps' if they exist File serverConfigDir = project.rootProject.file("server/configs/webapps/") if (serverConfigDir.exists()) { @@ -312,19 +293,6 @@ class ModuleDistribution extends DefaultTask project.ant.fixcrlf (srcdir: BuildUtils.getBuildDirPath(project), includes: "manual-upgrade.sh", eol: "unix") } - static FileTree getDistributionResources(Project project) { - // This seems a very convoluted way to get to the zip file in the jar file. Using the classLoader did not - // work as expected, however. Following the example from here: - // https://discuss.gradle.org/t/gradle-plugin-copy-directory-tree-with-files-from-resources/12767/7 - FileTree jarTree = project.zipTree(ModuleDistribution.class.getProtectionDomain().getCodeSource().getLocation().toExternalForm()) - - def tree = project.zipTree( - jarTree.matching({ - include "distributionResources.zip" - }).singleFile) - return tree - } - private File getDistributionFile() { File distExtraDir = BuildUtils.getBuildDirFile(project, DistributionExtension.DIST_FILE_DIR) diff --git a/src/main/groovy/org/labkey/gradle/task/RunTestSuite.groovy b/src/main/groovy/org/labkey/gradle/task/RunTestSuite.groovy index fe81a79e..9d259663 100644 --- a/src/main/groovy/org/labkey/gradle/task/RunTestSuite.groovy +++ b/src/main/groovy/org/labkey/gradle/task/RunTestSuite.groovy @@ -16,13 +16,10 @@ package org.labkey.gradle.task import org.apache.commons.lang3.StringUtils -import org.gradle.api.file.CopySpec -import org.gradle.api.file.DuplicatesStrategy import org.gradle.api.tasks.Internal import org.labkey.gradle.plugin.TeamCity import org.labkey.gradle.plugin.extension.TeamCityExtension import org.labkey.gradle.util.DatabaseProperties -import org.labkey.gradle.util.TaskUtils /** * Class that sets our test/Runner.class as the junit test suite and configures a bunch of system properties for @@ -44,26 +41,10 @@ abstract class RunTestSuite extends RunUiTest dependsOn(project.tasks.writeSampleDataFile) dependsOn(project.tasks.ensurePassword) - if (project.findProject(":tools:Rpackages:install") != null) - dependsOn(project.project(':tools:Rpackages:install')) - if (!project.getPlugins().hasPlugin(TeamCity.class)) { - TaskUtils.addOptionalTaskDependency(project, this, 'packageChromeExtensions') - } if (project.getPlugins().hasPlugin(TeamCity.class)) { dependsOn(project.tasks.killChrome) - dependsOn(project.tasks.ensurePassword) - - if (project.tomcat.catalinaHome != null) - { - doLast( { - project.copy({ CopySpec copy -> - copy.from "${project.tomcat.catalinaHome}/logs" - copy.into project.layout.buildDirectory.file("logs/test/tomcat") - copy.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE) - }) - }) - } + dependsOn(project.tasks.killFirefox) } } @@ -80,7 +61,6 @@ abstract class RunTestSuite extends RunUiTest systemProperty "testRecentlyFailed", "${runRiskGroupTestsFirst.contains("recentlyFailed")}" } systemProperty "teamcity.buildType.id", project.teamcity['teamcity.buildType.id'] - systemProperty "tomcat.home", System.getenv("CATALINA_HOME") systemProperty "tomcat.port", project.teamcity["tomcat.port"] systemProperty "tomcat.debug", project.teamcity["tomcat.debug"] systemProperty "labkey.port", project.teamcity['tomcat.port'] diff --git a/src/main/groovy/org/labkey/gradle/task/RunUiTest.groovy b/src/main/groovy/org/labkey/gradle/task/RunUiTest.groovy index 84f35a86..2011fa55 100644 --- a/src/main/groovy/org/labkey/gradle/task/RunUiTest.groovy +++ b/src/main/groovy/org/labkey/gradle/task/RunUiTest.groovy @@ -88,11 +88,7 @@ abstract class RunUiTest extends Test systemProperty "labkey.root", project.rootProject.projectDir systemProperty "project.root", project.rootProject.projectDir systemProperty "user.home", System.getProperty('user.home') - // A handfull of tests require tomcat.home to be defined when running within IntelliJ - systemProperty "tomcat.home", project.tomcat.catalinaHome systemProperty "test.credentials.file", "${project.projectDir}/test.credentials.json" - if (BuildUtils.useEmbeddedTomcat(project)) - systemProperty BuildUtils.USE_EMBEDDED_TOMCAT, '' setTeamCityProperties() } diff --git a/src/main/groovy/org/labkey/gradle/task/StageDistribution.groovy b/src/main/groovy/org/labkey/gradle/task/StageDistribution.groovy index 5c90bcd6..09727ef7 100644 --- a/src/main/groovy/org/labkey/gradle/task/StageDistribution.groovy +++ b/src/main/groovy/org/labkey/gradle/task/StageDistribution.groovy @@ -38,10 +38,6 @@ class StageDistribution extends DefaultTask @OutputDirectory File pipelineJarStagingDir = new File((String) project.staging.pipelineLibDir) - @OutputDirectory - File tomcatJarStagingDir = new File((String) project.staging.tomcatLibDir) - - @TaskAction void action() { diff --git a/src/main/groovy/org/labkey/gradle/task/StartTomcat.groovy b/src/main/groovy/org/labkey/gradle/task/StartTomcat.groovy index 2745bea7..29e64dd4 100644 --- a/src/main/groovy/org/labkey/gradle/task/StartTomcat.groovy +++ b/src/main/groovy/org/labkey/gradle/task/StartTomcat.groovy @@ -43,14 +43,6 @@ class StartTomcat extends DefaultTask @TaskAction void action() - { - if (BuildUtils.useEmbeddedTomcat(project)) - startEmbeddedTomcat() - else - startLocalTomcat() - } - - private startEmbeddedTomcat() { File jarFile = BuildUtils.getExecutableServerJar(project) if (jarFile == null) @@ -89,72 +81,6 @@ class StartTomcat extends DefaultTask } } - private void startLocalTomcat() - { - project.tomcat.validateCatalinaHome() - - // we need to create the logs directory if it doesn't exist because Tomcat won't start without it, - // and, annoyingly, this is not seen as an error for this action. - if (!project.file("${project.tomcat.catalinaHome}/logs").exists()) - project.mkdir("${project.tomcat.catalinaHome}/logs") - if (SystemUtils.IS_OS_UNIX) - { - project.ant.chmod(dir: "${project.tomcat.catalinaHome}/bin", includes: "**/*.sh", perm: "ug+rx") - } - project.ant.exec( - spawn: true, - dir: SystemUtils.IS_OS_WINDOWS ? "${project.tomcat.catalinaHome}/bin" : project.tomcat.catalinaHome, - executable: SystemUtils.IS_OS_WINDOWS ? "cmd" : "bin/catalina.sh" - ) - { - env( - key: "PATH", - path: "${BuildUtils.getServerProject(project).serverDeploy.binDir}${File.pathSeparator}${System.getenv("PATH")}" - ) - - String catalinaOpts = getStartupOpts(project).join(" ").replaceAll("\\s+", " ") - - this.logger.debug("setting CATALINA_OPTS to ${catalinaOpts}") - env( - key: "CATALINA_OPTS", - value: catalinaOpts - ) - if (TeamCityExtension.isOnTeamCity(project)) - { - env( - key: "R_LIBS_USER", - value: System.getenv("R_LIBS_USER") != null ? System.getenv("R_LIBS_USER") : project.rootProject.file("sampledata/rlabkey") - ) - - def javaHome = TeamCityExtension.getTeamCityProperty(project, "tomcatJavaHome", System.getenv("JAVA_HOME")) - env ( - key: "JAVA_HOME", - value: javaHome - ) - env ( - key: "JRE_HOME", - value: javaHome - ) - } - - if (SystemUtils.IS_OS_WINDOWS) - { - env( - key: "CLOSE_WINDOW", - value: true - ) - arg(line: "/c start ") - arg(value: "'Tomcat Server'") - arg(value: "/B") - arg(value: "${project.tomcat.catalinaHome}/bin/catalina.bat") - } - arg(value: "start") - } - println("Waiting 5 seconds for tomcat to start...") - project.ant.sleep(seconds: 5) - println("Tomcat started.") - } - static List getStartupOpts(Project project) { List optsList = new ArrayList<>() diff --git a/src/main/groovy/org/labkey/gradle/task/StopTomcat.groovy b/src/main/groovy/org/labkey/gradle/task/StopTomcat.groovy index 369fb50a..75bbbc94 100644 --- a/src/main/groovy/org/labkey/gradle/task/StopTomcat.groovy +++ b/src/main/groovy/org/labkey/gradle/task/StopTomcat.groovy @@ -17,8 +17,6 @@ package org.labkey.gradle.task import org.gradle.api.DefaultTask import org.gradle.api.tasks.TaskAction -import org.gradle.process.JavaExecSpec -import org.labkey.gradle.util.BuildUtils import org.labkey.gradle.util.PropertiesUtils /** @@ -28,27 +26,6 @@ class StopTomcat extends DefaultTask { @TaskAction void action() - { - if (BuildUtils.useEmbeddedTomcat(project)) - stopEmbeddedTomcat() - else - stopLocalTomcat() - } - - void stopLocalTomcat() - { - project.tomcat.validateCatalinaHome() - project.javaexec( { - JavaExecSpec java -> - java.mainClass = "org.apache.catalina.startup.Bootstrap" - java.classpath { ["${project.tomcat.catalinaHome}/bin/bootstrap.jar", "${project.tomcat.catalinaHome}/bin/tomcat-juli.jar"] } - java.systemProperties["user.dir"] = project.tomcat.catalinaHome - java.args = ["stop"] - java.ignoreExitValue = true - }) - } - - void stopEmbeddedTomcat() { def applicationProperties = PropertiesUtils.getApplicationProperties(project) def port = applicationProperties.getProperty("management.server.port", applicationProperties.getProperty("server.port")) diff --git a/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy b/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy index cb0caf92..93f2cf82 100644 --- a/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy +++ b/src/main/groovy/org/labkey/gradle/util/BuildUtils.groovy @@ -30,7 +30,6 @@ import org.labkey.gradle.plugin.extension.LabKeyExtension import org.labkey.gradle.plugin.extension.ModuleExtension import org.labkey.gradle.plugin.extension.ServerDeployExtension import org.labkey.gradle.plugin.extension.TeamCityExtension -import org.labkey.gradle.task.ModuleDistribution import java.nio.charset.StandardCharsets import java.nio.file.Files @@ -45,7 +44,6 @@ import java.util.regex.Pattern class BuildUtils { public static final String BUILD_FROM_SOURCE_PROP = "buildFromSource" - public static final String USE_EMBEDDED_TOMCAT = "useEmbeddedTomcat" public static final String BUILD_CLIENT_LIBS_FROM_SOURCE_PROP = "buildClientLibsFromSource" public static final String SERVER_MODULES_DIR = "server/modules" public static final String PLATFORM_MODULES_DIR = "server/modules/platform" @@ -547,7 +545,7 @@ class BuildUtils 'tomcat-jsp-api', 'tomcat-util', 'tomcat-websocket-api', - 'tomcat7-websocket' + 'tomcat-websocket' ] static String getGitUrl(Project project) @@ -570,10 +568,7 @@ class BuildUtils static void addTomcatBuildDependencies(Project project, String configuration) { - List tomcatLibs = new ArrayList<>(TOMCAT_LIBS) // Don't modify list - if (!"${project.apacheTomcatVersion}".startsWith("7.")) - tomcatLibs.replaceAll({it.replace('tomcat7-', 'tomcat-')}) - for (String lib : tomcatLibs) + for (String lib : TOMCAT_LIBS) project.dependencies.add(configuration, "org.apache.tomcat:${lib}:${project.apacheTomcatVersion}") } @@ -870,36 +865,11 @@ class BuildUtils return jarFiles[0] } - static File getWebappConfigFile(Project project, String fileName) - { - if (project.rootProject.file("webapps/" + fileName).exists()) - return project.rootProject.fileTree("webapps/" + fileName).singleFile - else if (project.rootProject.file("server/configs/webapps/" + fileName).exists()) - return project.rootProject.fileTree("server/configs/webapps/" + fileName).singleFile - else - return ModuleDistribution.getDistributionResources(project).matching {include fileName}.singleFile - } - static boolean embeddedProjectExists(Project project) { return project.findProject(getEmbeddedProjectPath(project.gradle)) != null } - static boolean useEmbeddedTomcat(Project project) - { - _useEmbeddedTomcat(project) - } - - static boolean useEmbeddedTomcat(Settings settings) - { - _useEmbeddedTomcat(settings) - } - - private static boolean _useEmbeddedTomcat(Object o) - { - o.hasProperty(USE_EMBEDDED_TOMCAT) && o[USE_EMBEDDED_TOMCAT] != "false" - } - /** * Writes a file in the build/deploy/modules directory that can be used as a trigger file for restarting * SpringBoot. Without this, restarts may happen before the full application deployment is done, resulting