In this session, Markus will explain how to build OpenCms with Gradle from Source.
He will explain the benefits and advantages as well as the difficulties in building OpenCms with Gradle. Markus will show how to build and import OpenCms modules with Gradle. This includes creating an OpenCms module automatically from source out of the repository (Nexus).
Markus will also talk about:
- Continuous Developement with OpenCms
- Building an OpenCms .war file with external configuration
3. Agenda
● Goal: add dependency management to an
Ant build
● Introduction Gradle
● Tasks and dependencies
● Plugins
● Slowly migrating from Ant to Gradle
● Using Ant build in Gradle
● Intercepting Ant targets
5. Introduction Gradle
● What is Gradle?
● A build tool
● Declarative way to describe builds
● Dependency management
● Build scripts - Groovy DSL
● How to use Gradle?
● „You can use Gradle's Ant integration as a path
for migrating your build from Ant to Gradle.“
9. build.gradle – Plugins
● Plugins with predefined tasks
apply plugin: 'java'
sourceCompatibility = 1.5
Version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
}
}
● A lot of ready to use plugins: java, war, eclipse
11. Copy/Sync task
task syncCompileLibs(type: Copy) {
def compileLib = ant.properties['opencms.input.libs.compile']
println "Sync the configured libs for compiling from repo to " + compileLib
from configurations.compileLibs
into compileLib
}
12. Intercepting Ant target
gradle.addListener new CompileLifecycleListener()
class CompileLifecycleListener implements TaskExecutionListener {
@Override
void beforeExecute(Task task) {
if (task.name == 'compile') {
task.project.tasks.syncCompileLibs.execute()
}
}
@Override
void afterExecute(Task task, TaskState taskState) {
if (task.name == 'compile') {
println 'done'
}
}
}
13. Intercepting Ant target
gradle compile
:init
[ant:echo] Building OpenCms 8.0.4
[ant:echo]
[ant:echo] OpenCms input directory is: /home/daniel/develop/opencms8/opencms-core
[ant:echo] OpenCms output directory is: /home/daniel/develop/opencms8/BuildCms
[ant:echo] Java version detected: 1.6
[ant:echo] Java target version: 1.5
[ant:echo] Java home is: /home/daniel/opt/java
[ant:echo] Tomcat home is: ${tomcat.home}
:compile
Download http://repo1.maven.org/maven2/javax/validation/validation-api/...
14. Next steps
● Uploading the artifacts to repository
● Installing OpenCms-Modules via
CmsShell
● Migrating Ant targets