Replacing the content of a SQL File

not-a-bug

(Mohan Rao) #1

Hello,

We have a requirement to create a database in MYSQL server using gradle. We have below two files.

  1. gradle.properties file : From where I will fetch the database name, below is the content of gradle.properties file.

CUSTOMERDBNAME=ALPHA
2. dbscript.sql file : Where I have the SQL statements to create database. Below is the content of SQL file.

CREATE SCHEMA IF NOT EXISTS customer_db_name DEFAULT CHARACTER SET utf8 COLLATE ‘utf8_general_ci’;

Requirement : We need replace the customer_db_name in SQL file with CUSTOMERDBNAME variable value and execute that SQL file to create the DB. Please help me in doing this.

Regards,
Mohan


(uklance) #2

You could use a Copy task along with filter(…) eg ReplaceTokens