karelpeeters
09/25/2019, 11:25 AMmain
and test
but called local
. I want it to depend on both main
and test
. This is my build.gradle: https://pastebin.com/raw/5u89DqYP, building with gradle commandline seems to work so i think that's correct. I'm having some problems getting it to work in intelij though, when I change any code in eg. the main
module I start to get build errors like this:Mike
09/25/2019, 11:33 AMkarelpeeters
09/25/2019, 12:08 PMMike
09/25/2019, 12:15 PMkarelpeeters
09/25/2019, 12:29 PMMike
09/25/2019, 1:06 PMMike
09/25/2019, 1:13 PMtest
rather than explicitly adding both main
and test
to local. The example adds main, but that's because they explicitly DON'T want it to extend/know about test code.
The sourceSet defines the code dependencies, and the Configuration defines the dependency hierarchy. I don't think you need the configuration unless you want to be able to add dependencies only for local.
Cleaner build config. I'm not sure how new Gradle has to be for this to work, but I think it's been this way since late 4, and hopefully you're on 5.Mike
09/25/2019, 1:21 PMmain/java
, main/kotlin
and main/resources
approach? At least I think that's what happens when you set it to src/main
, isn't it?karelpeeters
09/25/2019, 1:28 PMMike
09/25/2019, 1:36 PM+= sourceSets.main.output
with += sourceSets.test.output
in the example.
Yes, of course. It can't find stdlib because I was wrong. The configurations
block is required. Have to tell Gradle what dependencies belong in localImplementation
. In your case, you again want to extend test, so instead of implementation
, you'd put testImplementation
and testRuntimeOnly
.
Functionally, this is basically what you had, but perhaps IntelliJ will import this correctly, and you won't have errors. And it's the approach currently recommended by Gradle, so may as well use it.
The one thing I don't like about Gradle. If you've been working with it awhile, there have been many different ways to define things. And if you're new, you're just as likely to find one of the 'old' ways as you are to find the 'new' way.
HTH. Good luck!