This message was deleted.
# dependency-management
s
This message was deleted.
1
c
this works when B has `api(lib)`but not with
implementation(lib)
Copy code
configurations.compileClasspath {
    resolutionStrategy {
        eachDependency {
            if (requested.group == "io.ktor") {
                throw RuntimeException("KTOR FOUND!")
            }
        }
    }
}
hum..I have to add in my case project B is a kotlin multiplatform project...and I don't see the dependency in the scan
t
With
implementation(lib)
in B, then the
compileClasspath
in A won't have
lib
in it (that's the point of
api
vs
implementation
). Maybe just check
runtimeClasspath
instead?
c
I tried runtime with the same luck
t
BTW, how about a dependency constraint with
version { rejectAll() }
? (wouldn't work for a groupId only, requires an artifactId too)
c
I can try, thanks!
no luck because it's not really there...I think it's an issue of kotlin MPP -> kotlin jvm
That works...
Copy code
configurations.default {
    resolutionStrategy {
        eachDependency {
            if (requested.group == "io.ktor") {
                throw RuntimeException("KTOR FOUND!")
            }
        }
    }
    resolve()
}
but I'm terrified
ok...you where right, runtimeClasspath is it, but I need to resolve it and
assemble
is not resolving it
t
Maybe using "resolution consistency" with
useRuntimeClasspathVersions()
would resolve it whenever the compile classpath needs to be resolved; but that kind of resolution consistency might not be what you want…
c
test task resolves it (and publishing tasks) so it's fine, I dropped the
resolve()
t
Alternatively, add your
project(B)
dependency in such a way that its
runtimeElements
variant is always used (rather than the
apiElements
variant)
c
I didn't get that... how?
right now it's simply:
Copy code
dependencies {
    implementation(project("B"))
t
Out of memory, something like:
Copy code
implementation(project("B")) {
    attributes {
        attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
    }
}
(no idea if that would actually work though!)
c
hehehe, I'll try to understand what it does.. I think the current solution is good enough, and the issue with the approach you suggested is that it needs to be applied to all dependencies. anyway, thanks a lot for helping!