I'm new with Gradle projects and I have one question. I've searched in Internet but I couldn't find what I need or maybe I couldn't know how to search it. First I'm going to tell you my case. I have a Gradle project and I would like to execute several automated tests, in the future with jenkins, but now I want to try on Eclipse. I have the oracle jdbc driver in /lib directory, and this is my build.gradle
apply plugin: 'java'
// In this section you declare where to find the dependencies of your project
repositories {
jcenter()
//mavenCentral()
}
// In this section you declare the dependencies for your production and test code
dependencies {
compile 'org.slf4j:slf4j-api:1.7.21'
compile 'org.seleniumhq.selenium:selenium-java:2.+'
compile 'org.testng:testng:6.+'
//compile 'com.oracle:ojdbc14:10.2.0.4.0'
//testCompile 'net.sourceforge.jexcelapi:jxl:2.6.12'
testCompile 'info.cukes:cucumber-core:1.+'
testCompile 'info.cukes:cucumber-java:1.+'
testCompile 'info.cukes:cucumber-junit:1.+'
testCompile 'junit:junit:4.12'
}
repositories {
flatDir(dir: 'libs')//, name: 'Local libs'
}
dependencies {
compile name: 'ojdbc7'
}
I'd like to use this jdbc driver in one class but I don't know how to use it. When I tried with Maven I used this way "import oracle.jdbc.driver.OracleDriver;" but I guess this is not valid for Gradle project. Can you help me, please? Thanks in advance
The JDBC Thin driver is a pure Java, Type IV driver that can be used in applications and applets. It is platform-independent and does not require any additional Oracle software on the client-side. The JDBC Thin driver communicates with the server using SQL*Net to access Oracle Database.
You can try reusing your local Maven repository for Gradle:
ojdbc7.jar
from Oracle siteInstall the jar into your local Maven repository:
mvn install:install-file -Dfile=ojdbc7.jar -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.1 -Dpackaging=jar
Check that you have the jar installed into your ~/.m2/
local Maven repository
Enable your local Maven repository in your build.gradle
file:
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile ("com.oracle:ojdbc7:12.1.0.1")
}
Now you should have the jar enabled for compilation in your project
You can simply add a jar as dependency, like so:
compile files('libs/ojdbc7.jar')
And there is no need to add a flatDir repository in that case. Read about it in the official user guide
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With