The libertyCreate task is used to create a named Liberty server instance.
libertyCreate depends on installLiberty.
libertyCreate is finalized by installFeature.
Server configuration parameters were added to the server extension for flexible configuration. Running libertyCreate will update the configuration files if the server already exists.
These examples show you different ways to configure servers in your scripts:
- Configure using
configDirectory. This is useful when you need to copy multiple files such asserver.xml,bootstrap.properties, and included configuration files. Alternatively, you can place your configuration files in the default location forconfigDirectorywhich issrc/main/liberty/config.
apply plugin: 'liberty'
liberty {
server {
configDirectory = file('src/resources/config')
}
}- Configure with inline properties. The
bootstrap.propertiesandjvm.optionsfiles are created with this content.
apply plugin: 'liberty'
liberty {
server {
bootstrapProperties = ['default.http.port':'9080', 'default.https.port':'9443']
jvmOptions = ['-Xms128m', '-Xmx512m']
}
}- Configure with user defined files. For this specific configuration file copy, the file is renamed to the expected name in the target.
apply plugin: 'liberty'
liberty {
server {
serverXmlFile = file('src/resources/config/server-test1.xml')
bootstrapPropertiesFile = file('src/resources/config/bootstrap.test.properties')
jvmOptionsFile = file('src/resources/config/jvm.test.options')
serverEnvFile = file('src/resources/config/server.test.env')
}
}- Override configuration specified above with an
extblock inbuild.gradle, with agradle.propertiesfile or with project properties specified on the command line. The following server extension properties can be overridden.
- bootstrapProperties
- defaultVar
- env
- jvmOptions
- var
Those backed by a Properties object can be overridden as a whole or by specifying individual properties. The jvmOptions can only be overridden as a whole.
Examples of using build.gradle file:
ext {
liberty.server.env."another.serverenv.var" = "anotherValue"
liberty.server.defaultVar.someDefaultVar = 'someDefaultValue'
liberty.server.var.someVar = 'someValue'
liberty.server.var."my.custom.var" = 'myCustomValue'
liberty.server.bootstrapProperties."default.http.port" = '9083'
liberty.server.jvmOptions=['-Xms128m','-Xmx2048m']
}Examples of using gradle.properties file:
liberty.server.env."another.serverenv.var"=anotherValue
liberty.server.defaultVar.someDefaultVar=someDefaultValue
liberty.server.var={"someVar"\:"someValue","my.custom.var"\:"myCustomValue"}
liberty.server.bootstrapProperties."default.http.port"=9083
liberty.server.jvmOptions={"-Xms128m","-Xmx2048m"}Examples of using the command line:
gradle build -Pliberty.server.bootstrapProperties."default.http.port"=9083
gradle build -Pliberty.server.jvmOptions={"-Xms128m","-Xmx2048m"}