Issue #3 resolved

src/*/resources not visible to clojureTest task

Meikel Brandmeyer
created an issue

Moved from the old repository on behalf of Howard Lewis Ship.

Resources in src/main/resources and src/test/resources are not on the classpath when the clojureTest task is executing. My workaround:

clojureTest {
    testRoots.srcDir "src/main/resources"
    testRoots.srcDir "src/test/resources"
}

Comments (3)

  1. Meikel Brandmeyer reporter

    This is not a “workaround”, but the “solution”. There is no reason why hard wiring the resources on the classpath should be always a good idea.

    Maybe you need to generate some files? Then you would need the outputs of processResources on the classpath. But that cannot be hard wired neither since you might want to generate some resource files based on the compilation results?

    Just like the order of Java and Clojure compilation cannot be defined up front.

    Your solution is Good Enough™. You could go further and use the following to make it even more stable:

    clojureTest {
        classpath files(
            srcSets.main.resources.srcDirs,
            srcSets.test.resources.srcDirs
        )
    }
    

    This would not hardwire the resources location as long as the location is defined before this code in the build file.

    Unfortunately it won't pick up later changes. You would need a closure for that to defer the evaluation.

    clojureTest {
        classpath {
            files(
              srcSets.main.resources.srcDirs,
              srcSets.test.resources.srcDirs
            )
        }
    }
    

    However this is not implemented at the moment.

  2. Log in to comment