Hi channel! A small question: Basically, I am tryi...
# gradle
a
Hi channel! A small question: Basically, I am trying to transfer the next task from Gradle DSL:
Copy code
task copyDependencies(type: Copy) {
    from(configurations.compile + configurations.testCompile) {
        include '*.dll'
        include '*.dylib'
        include '*.so'
    }
    into 'build/libs'
}
It looks like:
Copy code
val copyDependencies by tasks.creating(Copy::class) {
    from(configurations.testCompile) {
        include("*.dll")
        include("*.dylib")
        include("*.so")
    }
    into("$buildDir/libs")
}
But i am not sure, which scope should I use instead of
configurations.testCompile
in order to really copy libraries in the
$buildDir/libs
folder. Currently I am not getting anything copied 😕
g
Your original snippet copies also compile configuration
This is exact copy of you Groovy task:
Copy code
tasks.create<Copy>("copyDependencies") {
    from(configurations["compile"] + configurations["testCompile"]) {
        include("*.dll")
        include("*.dylib")
        include("*.so")
    }
    into("$buildDir/libs")
}
also, probably better to use tasks.register to make it lazy (but the groovy snippet is eager)
configurations.testCompile
in Kotlin a bit different, because it’s lazy by default, so you cannot do
compile + testCompile
directly (probably make sense to create an issue about it to provide override for
plus
to combine 2 NamedDomainObjectProviders
Type safe (but eager) way would be
Copy code
configurations.compile.get() + configurations.testCompile.get()
a
Thank you! Tried both ways:
configurations.compile.get() + configurations.testCompile.get()
and
configurations["compile"] + configurations["testCompile"]
from some reason library didn’t ge copied still… Will have to investigate further
g
it’s exactly the same as your groovy
check path. You groovy has
build/libs
, but Kotlin
$buildDir/lib
a
the difference in projects also, groovy one is Micronaut, the Kotlin one is spring, maybe dependencies are somehow fetched in different folders \ ways :?
now my Kotlin DSL looks like this:
Copy code
val copyDependencies by tasks.creating(Copy::class) {
	from(configurations.compile.get() + configurations.testCompile.get()) {
		include("*.dll")
		include("*.dylib")
		include("*.so")
	}
	into("build/libs")
}
ok, i think i found issue
in the Kotlin DSL i am using:
testImplementation()
to fetch dependency
but in the copy task, i am referring
configurations.testCompile.get()
which does not really work…
changing to
testCompile()
in the
dependencies {}
helped, but its a bit hacky way, i would say 😞
g
why you don’t use
configurations.testImplementation
?
a
its prohibited:
Copy code
Could not determine the dependencies of task ':server:copyDependencies'.
> Resolving configuration 'testImplementation' directly is not allowed
but i found a solution:
from(configurations.testRuntimeClasspath.get())
now it works 🎉
thank you for help!
g
👍
from(configurations.testRuntimeClasspath)
should also work
a
yes, i wonder, why it does not need
get()
in this case )
g
because
from()
allows you to use Provider<FileCollection>
but there is no overrider for Provider<FileCollection> + Provider<FileCollection>, so
configurations.compile + configurations.testCompile
doesn’t work
I created a task on gradle issue tracker about this https://github.com/gradle/gradle/issues/9738
a
ah, okay, i see