Buildscript dependency

Add the ebean-gradle-plugin dependency to the buildscript section.

buildscript {
  repositories {
  dependencies {
    classpath "io.ebean:ebean-gradle-plugin:11.5.3"

Apply plugin

Add 'io.ebean' to the apply plugin section like:

apply plugin: 'io.ebean'

Add ebean section

Add a ebean section to control the debug level of the4) t enhancement. This is optional but generally a good idea.

ebean {
  debugLevel = 1

Test output

Gradle by default suppresses output logging. If we want to see SQL, DDL, Transaction logging etc we need to set testLogging.showStandardStreams = true in the test section like:

test {
  testLogging.showStandardStreams = true

Example project

Have a look at the Example Gradle Java for a full example - it's build.gradle.

Test output

Below is a example output from ./gradlew clean test. Specifically we can see:

  • The classes being enhanced (due to ebean debugLevel = 1)
  • The DDL, SQL and Transactions (controlled by logback-test.xml in this case)
$ ./gradlew clean test

> Task :compileJava
ebean-enhance> cls: org/example/domain/BaseDomain  msg: enhanced
ebean-enhance> cls: org/example/domain/Customer  msg: enhanced

> Task :test
enhancement prior to running tests

Gradle suite > Gradle test > org.example.domain.CustomerTest.saveAndFind STANDARD_OUT
14:48:49.900 [Test worker] INFO  io.ebean.internal.DefaultContainer - DatabasePlatform name:db platform:h2
14:48:50.063 [Test worker] TRACE io.ebean.TXN - txn[1001] Begin
14:48:50.064 [Test worker] INFO  io.ebean.DDL - Executing db-create-all.sql - 1 statements
14:48:50.064 [Test worker] DEBUG io.ebean.DDL - executing 1 of 1 create table customer ( id                            bigint auto_increment not...
14:48:50.076 [Test worker] DEBUG io.ebean.TXN - txn[1001] Commit
14:48:50.086 [Test worker] DEBUG io.ebean.SQL - txn[1002] insert into customer (name, start_date, comments, version) values (?,?,?,?); --bind(Hello Rob,2018-01-30,[LOB],1)
14:48:50.098 [Test worker] DEBUG io.ebean.SUM - txn[1002] Inserted [Customer] [1]
14:48:50.098 [Test worker] DEBUG io.ebean.TXN - txn[1002] Commit
14:48:50.122 [Test worker] DEBUG io.ebean.SQL - txn[1003] select,, t0.start_date, t0.version from customer t0 where = ?  ; --bind(1, )
14:48:50.124 [Test worker] DEBUG io.ebean.SUM - txn[1003] FindBean type[Customer] origin[D88YBi.A.A] exeMicros[3052] rows[1] bind[1, ]
14:48:50.129 [Test worker] DEBUG io.ebean.SQL - txn[1004] select,, t0.start_date, t0.version from customer t0 where is not null ; --bind()
14:48:50.130 [Test worker] DEBUG io.ebean.SUM - txn[1004] FindMany type[Customer] origin[D88YBm.A.A] exeMicros[0] rows[0] predicates[ is not null ] bind[]
hello Hello Rob
.. started on: 2018-01-30
14:48:50.136 [Test worker] DEBUG io.ebean.SQL - txn[1005] select,, t0.start_date, t0.version from customer t0 where like ?  and > ? ; --bind(BatOutOfHell%,1)
14:48:50.136 [Test worker] DEBUG io.ebean.SUM - txn[1005] FindMany type[Customer] origin[D88YBj.A.A] exeMicros[1619] rows[0] predicates[ like ?  and > ? ] bind[BatOutOfHell%,1]
bats:BeanList size[0] list[]


Edit Page