# Build script doesn't include libs at runtime, only at configuration time

**URL:** <https://discuss.gradle.org/t/build-script-doesnt-include-libs-at-runtime-only-at-configuration-time/1208>\
**Category:** Old Forum Archive\
**Created:** [June 24, 2014, 5:49pm UTC](https://discuss.gradle.org/t/build-script-doesnt-include-libs-at-runtime-only-at-configuration-time/1208 "2014-06-24T17:49:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![necromantiarian\_necr](https://avatars.discourse-cdn.com/v4/letter/n/67e7ee/32.png) [@necromantiarian\_necr](https://discuss.gradle.org/u/necromantiarian_necr)\
**Post date:** [June 24, 2014, 5:49pm UTC](https://discuss.gradle.org/t/build-script-doesnt-include-libs-at-runtime-only-at-configuration-time/1208/1 "2014-06-24T17:49:00Z")

</div>

gradle dont use classpath dependencies in runtime

when add dependencies to buildscript they can be used inside of tasks at compile time, but not when I ran the tasks at runtime

```gradle
buildscript {
    repositories {
        maven {
            url "https://company.com/content/groups/public"
        }
        mavenLocal()
    }
      dependencies {
        classpath 'net.sourceforge.jtds:jtds:1.2.4'
        classpath 'org.codehaus.groovy:groovy-all:2.1.2'
    }
  }
  import groovy.sql.Sql
task myTask << {
    Sql sql = Sql.newInstance('someUrl', 'someuser', 'somepass', 'jdbc:jtds:sqlserver://localhost/db')
}

```

the task passes stage 1, but when executed doesn’t find driver class

so that some scenarios like: 1) task which connects to db - doesnt find driver class (dependency is in classpath) 2) task with custom logj4 and log4j.properties doesn’t see appenders, cause log4j.properties is not in classpath

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [June 25, 2014, 11:07am UTC](https://discuss.gradle.org/t/build-script-doesnt-include-libs-at-runtime-only-at-configuration-time/1208/2 "2014-06-25T11:07:00Z")

</div>

The case above is a known problem with JDBC class loading and Groovy. One solution is to implement the task as a Java class (e.g. in ‘buildSrc/src/main/java’). For other workarounds, search the forums and/or Stack Overflow (this has been asked before).
