Provided dependencies

70 views
Skip to first unread message

Matt Bossenbroek

unread,
Jan 17, 2014, 4:49:45 PM1/17/14
to cloju...@googlegroups.com
I'm trying to change a couple of my dependencies to be 'provided' dependencies, such that they're there for compilation and testing, but don't show up as transitive dependencies - they're expected to be present when this jar is used.

It seems to work fine for :compileClojure, but not for :clojureTest. When it loads the tests, it can't find the provided dependencies on the classpath.

Here's where our build framework sets up the provided configuration:

    configurations {

        provided {

            description = 'much like compile, but indicates you expect the JDK or a container to provide it. It is only available on the compilation classpath, and is not transitive.'

            transitive = true

            visible = true

        }

    }


    project.sourceSets {

        main.compileClasspath += project.configurations.provided

        main.runtimeClasspath -= project.configurations.provided

        test.compileClasspath += project.configurations.provided

        test.runtimeClasspath += project.configurations.provided

    }


And then these are the dependencies I'm trying to change to provided:

dependencies {

    compile 'org.clojure:clojure:1.5.1'

    compile 'org.clojure:data.json:0.2.2'

    compile 'clj-time:clj-time:0.5.0'

    compile 'instaparse:instaparse:1.2.14'

    compile 'com.taoensso:nippy:2.5.2'

    compile 'rhizome:rhizome:0.1.9'

    compile 'com.netflix.rxjava:rxjava-core:0.9.2'

    compile 'com.netflix.rxjava:rxjava-clojure:0.9.2'

    

    provided 'org.apache.pig:pig:0.11.1'

    provided 'org.apache.hadoop:hadoop-core:1.1.2'

// these are transitive dependencies that don't get picked up normally

    provided 'commons-logging:commons-logging:1.1.3'

    provided 'org.codehaus.jackson:jackson-core-asl:1.9.13'

}


Do you know what I'd need to change to get it to pick up those extra dependencies for :clojureTest? Is it using a different sourceSet?

This is the project I'm working on: https://github.com/Netflix/PigPen

Thanks,
Matt

Meikel Brandmeyer

unread,
Jan 20, 2014, 2:35:14 AM1/20/14
to cloju...@googlegroups.com
Bleh. That's a bug in the setting of the test classpath. I have to clean up the classpath settings. Please try the following as a workaround.

configurations {
    provided {
        description = 'much like compile, but indicates you expect the JDK or a container to provide it. It is only available on the compilation classpath, and is not transitive.'
        transitive = true // <- ??? The description states otherwise.
        visible = true
    }
}

sourceSets {
    main {
        compileClasspath += project.configurations.provided
        runtimeClasspath += project.configurations.provided
    }

    test {
        compileClasspath += project.configurations.provided
        runtimeClasspath += project.configurations.provided
    }
}

clojureTest {
    classpath = project.files(
        sourceSets.main.output,
        sourceSets.test.runtimeClasspath
    )
}


I'll fix this for the next release. https://bitbucket.org/clojuresque/base/issue/19/classpath-setting-for-clojuretest-is

Meikel

Meikel Brandmeyer

unread,
Jan 20, 2014, 2:36:44 AM1/20/14
to cloju...@googlegroups.com
Ah. You can skip the source set output. That's already contained in the default value.

clojureTest {
    classpath = sourceSets.test.runtimeClasspath
}


This should be sufficient.

Meikel

Matt Bossenbroek

unread,
Jan 23, 2014, 3:00:14 PM1/23/14
to cloju...@googlegroups.com
That worked great - thanks!

Thanks,
Matt
Reply all
Reply to author
Forward
0 new messages