6

This question has already been asked before, however the solution is still unknown... Kotlin DSL build scripts dependency updates

With the new implementation of kotlin-dsl. Now the imports looks like this.

implementation Koin.core
implementation Koin.android

and the buildSrc.

object Versions{
    const val koin = "2.0.1"
}

object Koin {
    val core = "org.koin:koin-core:${Versions.koin}"
    val android = "org.koin:koin-android:${Versions.koin}"
    val scope = "org.koin:koin-androidx-scope:${Versions.koin}"
    val viewModel = "org.koin:koin-androidx-viewmodel:${Versions.koin}"
    val extension = "org.koin:koin-androidx-ext:${Versions.koin}"
    val test = "org.koin:koin-test:${Versions.koin}"
}

in this case Koin is using a previous version, but i know that there's a new version https://github.com/InsertKoinIO/koin

anyone knows how to check if the dependencies has a newer version with kotlin-dsl?

Luis Cardoza Bird
  • 1,265
  • 4
  • 24
  • 43
  • Last time I used gradle-kotlin-dsl this option was missing. But You can use Gradle plugin that does exactly this instead, for example: https://github.com/ben-manes/gradle-versions-plugin – OMIsie11 Apr 18 '20 at 09:07
  • It's a link to a gradle plugin page - just install the plugin using the one line of code described on the page and run the gradle task described on the page. Honestly, the link really is enough – dnh Apr 18 '20 at 13:55

2 Answers2

6

I've tested this Gradle Dependencies Update Check Plugin on my Android/Kotlin DSL build (with a separate Versions class with versions definitions) and it works fine for me:

CheckDependencyUpdates Gradle Plugin

(I've also tested that it works with a traditional Groovy-DSL project)

To install the plugin (copied from linked page) add the following to your build.gradle.kts. Note that I've removed the version number from this as it will, unlike the page I've linked to, get out of date:

plugins {
  id("name.remal.check-dependency-updates")
}

To run the update check (copied from gradle tasks) run the following:

gradle checkDependencyUpdates

You will see an output section similar to the following:

New dependency version: com.android.tools.build:aapt2: 3.6.1-6040484 -> 3.6.3-6040484
New dependency version: com.android.tools.lint:lint-gradle: 26.6.1 -> 26.6.3
dnh
  • 527
  • 4
  • 15
  • I added this to my project but it is deprecated – Denny Jun 24 '21 at 18:24
  • 1
    @Denny Yes, they advise using pipeline-integrated checks such as Renovate or Dependabot, however the plugin still works correctly for those who appreciate the convenience of running checks locally – dnh Jun 25 '21 at 06:23
  • reading the web of the plugin it says is deprecated. so, no longer this answer the question (?) – Marlon López Jul 03 '21 at 17:52
  • The OP does not state whether they wanted to run the check locally or on a CI pipeline. Since the alternatives listed in the deprecation message are pipeline-only services, they are not viable solutions if developer wants to run dependency checks locally on a project. So this remains the answer for checking dependency checks locally (or on a pipeline not supported by the checking services) – dnh Jul 04 '21 at 09:13
0

I made this plugin. Dependency Updates Commenter. Just apply plugin and add annotation to the dependency properties and execute commentDependencyUpdates task. This is the example:

object Junit {
    const val junit = "junit:junit:4.12"
}
import io.github.zeroarst.dependencyupdatescommenter.CommentUpdates

object Junit {
    // Available versions:
    // 4.13-rc-2
    // 4.13-rc-1
    // 4.13-beta-3
    // 4.13-beta-2
    // 4.13-beta-1
    @CommentUpdates
    const val junit = "junit:junit:4.12"
}
Arst
  • 3,098
  • 1
  • 35
  • 42