These are the various directories involved in the build process, listed in the order in which they are used in the build process:
Directory Type | Path (relative to <LABKEY_HOME>) | Added to by... | Removed from by... | Deleted by... |
---|---|---|---|---|
Source | server/modules/<module> | you | you | you |
Build | build | Any build step | Any cleaning step | cleanBuild |
Module build | build/modules/<module> | module | N/A | :server:modules:<module>:clean |
Staging | build/staging | :server:deployApp :server:modules:<module>:deployModule | :server:modules:<module>:undeployModule | :server:cleanStaging :server:cleanDeploy |
Deploy | build/deploy | :server:deployApp :server:modules:<module>:deployModule | :server:modules:<module>:undeployModule | :server:cleanDeploy |
Source code is built into jar files (and other types of files) in a module's build directory. The result is a .module file, which contains potentially several jar files as well as other resources used by the module. This .module file is copied from the module's build directory into the staging directory and from there into the deploy directory. This is all usually accomplished with the './gradlew deployApp' command. The 'deployApp' task also configures and copies the labkey.xml tomcat context file. This file points to the deploy directory as a context path for Tomcat. Changes in that directory will therefore be noticed by Tomcat and cause it to reload the application.
A few important targets:
Gradle Targetooooooooooooooooooooooooooooooooo | Description |
---|---|
gradlew tasks | Lists all of the available tasks in the current project. |
gradlew pickPg gradlew pickMSSQL | Specify the database server to use. The first time you build LabKey, you need to invoke one of these targets to configure your database settings. If you are running against PostgreSQL, invoke the pickPg target. If you are running against SQL Server, invoke the pickMSSQL target. These targets copy the settings specified in the pg.properties or mssql.properties file, which you previously modified, to the LabKey configuration file, labkey.xml. |
gradlew deployApp | Build the LabKey Server source for development purposes. This is a development-only build that skips many important steps needed for production environments, including GWT compilation for popular browsers, gzipping of scripts, production of Java & JavaScript API documentation, and copying of important resources to the deployment location. Builds produced by this target will not run in production mode. |
gradlew :server:modules:wiki:deployModule or server/modules/wiki>gradlew deployModule | For convenience, every module can be deployed separately. If your changes are restricted to a single module then building just that module is a faster option than a full build. Example, to build the wiki module: 'gradlew :server:modules:wiki:deployModule'. |
gradlew deployApp -PdeployMode=prod | Build the LabKey Server source for deployment to a production server. This build takes longer than 'gradlew deployApp' but results in artifacts that are suitable and optimized for production environments. |
gradlew cleanBuild | Delete all artifacts from previous builds. This should be used sparingly as it requires Gradle to start all over again and not capitalize on the work it's done before. |
gradlew startTomcat gradlew stopTomcat | Starts/stops the server in dev mode. |
gradlew projects | Lists the current modules included in the build. |
gradlew :server:test:uiTest | Open the test runner's graphical UI. |
gradlew :server:test:uiTest -Psuite=DRT | Run the basic automated test suite. |
Gradle targets can also be invoked from within IntelliJ via the "Gradle projects" panel, but this has not been widely tested.
To improve performance, the LabKey build is configured by default to use Gradle's parallel build feature. This is controlled by these properties in the <LABKEY_ROOT>/gradle.properties file:
org.gradle.parallel=true
org.gradle.workers.max=3
By changing these properties, you can turn off parallel builds or adjust the number of threads Gradle uses.
If Gradle warns that "JVM heap space is exhausted", add more memory as described in the topic Gradle Tips and Tricks.
If you want to build without completing all build tasks, such as without overwriting the labkey.xml file, you can use "-x" syntax to exclude a task. Find out specific tasks using:
gradlew tasks
As an example, to build without completing the "setup" tasks including regenerating labkey.xml, use:
gradlew deployApp -x setup