Developers who build LabKey Server from source will not be able to use the Ant build targets starting in 17.2 (July 2017). Instead, the Gradle build framework will be used. This topic is intended for developers who want to migrate their already existing LabKey Server development environment from Ant to Gradle. If you want to build a new development environment from scratch use the following topic instead: Set Up a Development Machine.

For the latest news on the migration to Gradle, see Gradle Developer Discussion Thread.

Summary

It is assumed in what follows that you have a standard LabKey SVN enlistment.  We use LABKEY_ROOT to refer to the directory into which you check out your enlistment (i.e., the parent of the server directory). (You may also have git modules checked out, but the first step will be to get a build using SVN modules going.)

General Setup

Complete the Gradle Config steps in the topic 'Set Up a Development Machine'.

Your First Gradle Commands

1. Clean out the ant build directories and files

ant clean

2. Execute a gradle command to show you the set of currently configured projects (modules).  You do not need to install gradle and should resist the urge to do so.  We use the gradle wrapper to make updating version numbers easier. The gradle wrapper script (either gradlew or gradlew.bat) is included in the SVN sync and is already in the <LABKEY_ROOT> directory. 

On the command line, type ./gradlew projects (or gradlew.bat projects)

3. Execute a gradle command to build and deploy the application

./gradlew :server:deployApp

This will take some time as it needs to pull down many resources to initialize the local caches.  Subsequent builds will be much faster.

Changing the Set of Projects

Gradle uses the <LABKEY_ROOT>/settings.gradle file to determine which projects (modules) are included in the build.  (This is an analog of the various .modules files used in the ant build.)  To include a different set of projects in your build, you will need to edit this file.  By default, only modules in the server/modules directory and the server/test and server/test/modules directories are included in the build.  See the file for examples of different ways to include different subsets of the modules.  

Ant-to-Gradle Command Line Mapping

The following table provides a mapping between the most popular (I assume) ant commands and their Gradle counterparts. Note that while a mapping is provided for the ‘ant clean’ and ‘ant rebuild’ commands to get you oriented, these commands should no longer be used automatically with each new day or each new sync from SVN.  Gradle handles checking for needed updates much better and so you do not need to proactively clean as often.

Ant Command

Gradle Command

Directory

ant build

gradlew deployApp

trunk or server

ant clean

gradlew cleanBuild

trunk or server

ant rebuild

gradlew cleanBuild deployApp

trunk or server

ant pick_pg

gradlew pickPg

trunk or server

ant pick_mssql

gradlew pickMSSQL

trunk or server

ant dist

gradlew distribution

trunk

ant wiki

gradlew :server:modules:wiki:deployModule

Any directory

ant wiki

gradlew deployModule

server/modules/wiki

ant test

gradlew :server:test:uiTest

Any directory

ant drt

gradlew :server:test:uiTest -Psuite=DRT

Any directory

ant production

gradlew deployApp -PdeployMode=prod

trunk or server

Tips

See Gradle Tips and Tricks.

Cleaning

See the topic Gradle Cleaning.

IntelliJ Setup

Follow these steps in order to make IntelliJ able to find all the source code and elements on the classpath as well as be able to run tests.

Troubleshooting

See the trouble shooting section in Set Up a Dev Machine.

Related Topics

discussion

Discussion

Search 

Pages 

previousnext
 
expand all collapse all