Could not find method leftShift() for arguments on task of type org.gradle.api.DefaultTask

I’m trying to bump https://github.com/apache/fineract from a (very, I know) old Gradle 2.10 to current 5.2.1 in https://github.com/apache/fineract/compare/develop…vorburger:bump-gradle-wrapper for https://issues.apache.org/jira/browse/FINERACT-700 and it fails like this, after I’ve fixed a few other problems:

Build file '/home/vorburger/dev/Mifos/git/fineract/fineract-provider/build.gradle' line: 397
> Could not find method leftShift() for arguments [build_dihgpj995e9j6h72u3zxhswmc$_run_closure27@1a952200] on task ':createDB' of type org.gradle.api.DefaultTask.

that line 397 in https://github.com/apache/fineract/blob/develop/fineract-provider/build.gradle#397 is:

task createDB<<{
    description= "Creates the Database. Needs database name to be passed (like: -PdbName=someDBname)"
    sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' )
    sql.execute( 'create database '+"`$dbName`" )
}

Change to

task createDB {
   description= "Creates the Database. Needs database name to be passed (like: -PdbName=someDBname)"
   doLast {    
    sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' )
    sql.execute( 'create database '+"`$dbName`" )
   } 
}
2 Likes

<< was deprecated in 4.x and removed in 5.0. @Lancehas provided the correct solution.

2 Likes

yup, and it works; which is why I have accepted his answer!

PS: Hopefully this topic is useful to others searching this forum in the Future; I created it when I searched for this error, but noticed there was nothing on discuss.gradle.org about it yet.

Can you please elaborate what you do in that code with adding “doLast”

@1adarsh1 doLast adds an action to be executed. It’s a FIFO list of code blocks to do nearly anything you need.