Is there a way to clear the library/dependency cac...
# gradle
n
Is there a way to clear the library/dependency cache in Gradle? Been experimenting with publishing a Kotlin multi-platform library to Bintray, and have a simple Kotlin project to test the library. With the project the library API changes aren't coming through (eg code completion) after doing a Gradle refresh (via IntelliJ).
x
did you change the cache time?
n
No. How is the cache time changed?
x
here's the very java way of doing it
Copy code
project.getConfigurations().all( conf -> {
            conf.resolutionStrategy( rs -> rs.cacheChangingModulesFor( 1, TimeUnit.MINUTES ) );
        } );
in kotlin
Copy code
-
-configurations.all({
-    resolutionStrategy.cacheChangingModulesFor(1, TimeUnit.MINUTES)
-})
without the -'s
also make sure you're using 4.6+? there was a bug in earlier versions if you were using something like springs dep management plugin
n
Has no effect in the project.
m
That's for changing modules like SNAPSHOT
--refresh-dependencies
might work for you
n
Tried refreshing but it had no effect. ☹️
x
oh, reading your problem I assumed they were changing modules, because otherwise the version should have changed
so this is a released module? and its version didn't change? or its version did but just not updating fast enough?
how do you the dependency defined?
n
Since i'm experimenting with uploading a library the same version is always used every time a upload is made.
x
ah
you should use a snapshot version for that, IMHO, releases are meant to be incremented
just append -SNAPSHOT to your version
n
With the production version a standard versioning system would be used, which wouldn't have the issue, I hope 🍀.
x
I think there is also a way to tell gradle that a module is a changing module, but I don't recall the syntax
right
n
Bintray automatically rejects SNAPSHOT versions.
x
yuck
so yeah, your next option I believe is to tell gradle that it's a changing module
n
How is that done?
x
that's a good question
I'm 80% sure I saw it when I was learning gradle
but now I'm trying to find it
Copy code
implementation("com.xenoterracide.rpf:sec-dtos:0.1.0-SNAPSHOT") {
        module(setChanging(true))
    }
maybe?
something like htat
Copy code
implementation("com.xenoterracide.rpf:sec-dtos:0.1.0-SNAPSHOT") {
        module({ isChanging = true })
    }
also looks happy
and then you set the changing cache time like I showed you prieviously
though depending on what you're doing you may also want to consider making your libraries into a "composite" where you can simply use the output of one for the other locally (kind of like multi-module, but more separated)
n
The newer versions of the library are definitely uploaded to Bintray. Its just that Gradle doesn't check for a newer version of the library on Bintray once it has a copy in the cache.
Discovered how to manually remove the dependency so that Gradle downloads the newer (current) version. Manually remove the dependency directory from the global Gradle cache, and run the Gradle clean task for the project ( https://stackoverflow.com/a/39019437 ). On Linux the dependency is removed using the following path: /home/username/.gradle/caches/modules-2/files-2.1/group_id/name. Not a clean method but it does work simple smile .
Now if only Gradle had a function (accessible in a build script) that could be called for forcing a specific dependency to be downloaded again (force a partial cache refresh). 🤔
x
am I allowed ot suggest not using bintray?
using s3 for my private hosting, and way cheaper
actually... I switched to gradle in part because it was easier and cheaper to do s3 than having to worry about other overlypriced or high maintenance (buggy) software
n
Considering that the project is open source there is no cost with having it hosted on JCenter, and BinTray simple smile.