OpenCms Days 2012 - Developing OpenCms with Gradle

979 views

Published on

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

Published in: Technology
  • Be the first to comment

OpenCms Days 2012 - Developing OpenCms with Gradle

  1. 1. Gradle –migratingfrom ant
  2. 2. OpenCms - GradleGradle – migrating from ant@author: Markus Daniel
  3. 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
  4. 4. GoalAdd dependency managementcapabilities to an existing Ant buildwithout changing anything at the Antbuild file.
  5. 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 Gradles Ant integration as a path for migrating your build from Ant to Gradle.“
  6. 6. build.gradle - Tasks ● Taskstask printConfigurations { configurations.runtimeLibs.each { File f -> println f} configurations.compileLibs.each { File f -> println f}}task copySomething(type: Copy) { from(/home/sources) into(buildDir)}
  7. 7. build.gradle - Repositories ● Repositoriesrepositories { mavenCentral() maven { url http://nexus.synyx.de/content/repositories/public-releases } maven { url http://nexus.synyx.de/content/repositories/public-thirdparty } ivy { url "http://repo.mycompany.com/repo" }}
  8. 8. build.gradle – Configurations ● Configurations & Dependenciesconfigurations { compileLibs runtimeLibs}dependencies { runtimeLibs javax.activation:activation:1.1.1 compileLibs javax.servlet.jsp:jsp-api:2.0, ant-contrib:ant-contrib:1.0b2, org.apache.ant:ant:1.7.0, javax.servlet:servlet-api:2.4}
  9. 9. build.gradle – Plugins ● Plugins with predefined tasksapply plugin: javasourceCompatibility = 1.5Version = 1.0jar { manifest { attributes Implementation-Title: Gradle Quickstart, Implementation-Version: version }} ● A lot of ready to use plugins: java, war, eclipse
  10. 10. Using Antbuild.gradle:ant.importBuild build.xmldef compileLib = ant.properties[opencms.input.libs.compile]build.xml: <property name="opencms.input.libs.compile" location="${basedir}/lib/compile" />
  11. 11. Copy/Sync tasktask 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. 12. Intercepting Ant targetgradle.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. 13. Intercepting Ant targetgradle 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}:compileDownload http://repo1.maven.org/maven2/javax/validation/validation-api/...
  14. 14. Next steps● Uploading the artifacts to repository● Installing OpenCms-Modules via CmsShell● Migrating Ant targets
  15. 15. synyx GmbH & Co.KGOpen Source Source:Solutions http://gradle.orgKarlstraße 6976137 Karlsruhe +49 721 203823-0 Questions? +49 721 203823-12 Ideas? info@synyx.de www.synyx.de blog.synyx.de

×