Undetected Gradle test dependencies are ignored
See original GitHub issueGiven a Gradle project setup with subprojects:
a
b
, which depends ona.test
artefacts
The b-test.json
bloop file generated from bloopInstall
does not take the a.test
dependency into account (a-test
not a dependency and its output dir is not on the classpath). This means bloop test b
does not work, instead failing with
❯ bloop test b
Compiling b-test (1 Scala source)
[E] [E4] b/src/test/scala/com/beachape/BSpec.scala:9:3
[E] not found: value it
[E] L9: it("should lol") {
[E] ^
[E] [E3] b/src/test/scala/com/beachape/BSpec.scala:6:12
[E] not found: value yo
[E] L6: assert(yo == "yo")
[E] ^
[E] [E2] b/src/test/scala/com/beachape/BSpec.scala:5:3
[E] not found: value it
[E] L5: it("should yo") {
[E] ^
[E] [E1] b/src/test/scala/com/beachape/BSpec.scala:3:21
[E] not found: type ASpecLike
[E] L3: class BSpec extends ASpecLike {
[E] ^
[E] b/src/test/scala/com/beachape/BSpec.scala: L3 [E1], L5 [E2], L6 [E3], L9 [E4]
Compiled b-test (45ms)
[E] Failed to compile 'b-test'
I’ve put up a basic repro here with more details in the README https://github.com/lloydmeta/bloop-gradle-subprojects
I’ve looked at https://github.com/scalacenter/bloop/issues/800, https://github.com/scalacenter/bloop/issues/808, and https://github.com/scalacenter/bloop/issues/818, which seem to handle this, but it seems to be broken.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Multi-project test dependencies with gradle - Stack Overflow
To fix this problem you have to add a dependency on test source files next to dependency on compiled classes. // First dependency...
Read more >Gradle ignoring 'classifier' for 'tests' jar? - Old Forum
I am having problems with gradle ignoring my classifier: 'tests'. Here is the build script: apply ... How to express a testCompile dependency...
Read more >Authoring Tasks - Gradle User Manual
Task has no actions and some dependencies, but all of the dependencies are up-to-date, skipped or from cache. See also Lifecycle Tasks.
Read more >Gradle 7.6 Release Notes
The JVM test suite dependencies block now uses a strongly-typed API. ... For example, you can force tests to ignore up-to-date checks like...
Read more >Command-Line Interface - Gradle User Manual
When executed with --continue , Gradle executes every task in the build if all of the dependencies for that task completed without failure....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Looks like a bug in resolving to the correct sourceset - I’ll look to fix.
For now you should be able to add
testImplementation(project(":a"))
as a workaround.FYI - transitive project dependencies will never appear in the
dependencies
section, only theclasspath
sectionAnother attempt… I learnt about the
java-library
plugin that allows users to use theapi
dependency declaration to export transitive dependencies and thought I’d give that a shot (code at https://github.com/lloydmeta/bloop-gradle-subprojects/tree/two-projects-getByNamed-with-api)I’m not sure if it’s related to the same bug, but it revealed a possible hesienbug/race-condition whereby
b-test
sometimes getsa/build/classes
in its build path and sometimes getsa-test/build/classes
. Not 100% sure why either way:With `a-test/build/classes`
With `a/build/classes`