Gradle strikes again:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ext{ | |
dbun = "SCOTT" | |
dbpw = "oracle" | |
dbinst = "orcl" | |
} | |
task deployUnitTests << { | |
def sqlplusCmd = "sqlplus -s $dbun/$dbpw @../src/test/sql/run.sql".execute() | |
sqlplusCmd.in.eachLine { line -> println line } | |
} | |
task runUnitTests << { | |
def sqlplusCmd = "sqlplus -s $dbun/$dbpw @ut_run.sql".execute() | |
sqlplusCmd.in.eachLine { line -> println line } | |
} | |
task deployDBUpdate << { | |
def sqlplusCmd = "sqlplus -s $dbun/$dbpw @../src/main/sql/run.sql".execute() | |
sqlplusCmd.in.eachLine { line -> println line } | |
} |
Yes, it really was that easy!
The Oracle database
This post assumes that you have an Oracle database available. I used an Oracle 10g XE instance running on localhost to develop this post. XE is free to download and is sufficient for development purposes.
I had a SCOTT schema with the password "oracle" in the database and also installed the utPLSQL schema, which is a necessary step to following this example. To replicate what I done I recommend downloading the Oracle Developer Days VM.
NOTE: If you install the utPLSQL schema into an Oracle 10g XE database, make sure that you have granted access on UTL_FILE to public as explained here (remember to connect as sysdba when doing this otherwise it won’t work).
The structure I used for this example is:
.
|-build
|---build.gradle
|---ut_run.sql
|-src
|---main
|-----sql
|-------run.sql
|---test
|-----sql
|-------run.sql
2 comments:
Intersting, but does not exit from sqlplus shell I think ...
586 rows selected.
> Building 0% > :importDBTerminate batch job (Y/N)? Y
C:\apps\test_scripts>
Hi EstyPrem,
It was a long time ago when I posted this, but you are absolutely correct. I think at the time I cheated this and added the EXIT; to the script. Apologies for the misdirection, I will update.
In the meantime a colleague has started writing a plugin:
https://github.com/iwarapter/gradle-utplsql-plugin
Feel free to contribute, as always the more the merrier!!
Post a Comment