question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: How to get a Version string manually

See original GitHub issue

I would like to use refreshVersions to set the ktlint version in the ktlint-gradle-plugin:

ktlint {
    version.set("0.36.0") // "_" is not accepted here
    ...
}

Is there some refreshVersions mechanism to pull the Version and use it here or is it ok to use something like project.properties[...]

ktlint {
    val ktlintVersion = project.properties["com.pinterest:ktlint:_"]
    version.set("$ktlintVersion")
    ...
}

The problem with that is that refreshVersions Task removes that version every time it’s ran.

Would be nice to know how to handle the not so ordinary cases of dependencies!

Other than that, Greate Plugin!!! It really cleaned up our Project a lot!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

1reaction
LouisCADcommented, May 13, 2021

Hello, the version 0.10.0 added the versionFor function. I hope you like it!

1reaction
NikkyAIcommented, May 13, 2020

this is probably going to break but currently works:

import de.fayard.versions.internal.InternalRefreshVersionsApi
import de.fayard.versions.internal.getVersionProperties

@UseExperimental(InternalRefreshVersionsApi::class)
val versionsMap =  getVersionProperties()
versionsMap.forEach { (key, value) ->
    logger.lifecycle("$key : $value")
}

for this to work there needs to be some dependency on what you want to grab though… otherwise refreshDependencies task will wipe it maybe you can define a new configuration to gradle that does nothing

@miikeat for you that this code should do the trick:

import de.fayard.versions.internal.InternalRefreshVersionsApi
import de.fayard.versions.internal.getVersionProperties

configurations {
    create("fake")
}

dependencies {
  add("fake", "com.pinterest:ktlint:_")
}

@UseExperimental(InternalRefreshVersionsApi::class)
val versionsMap =  getVersionProperties()

logger.lifecycle("ktlint: ${versionsMap["version.com.pinterest..ktlint"]}")

PS for a nicer key (version.ktlint)… use this rule:

com.pinterest:ktlint
              ^^^^^^

could refreshVersions register a no-op configuration automatically?

could this be exposed via a extension ? then it would be possible to call refreshVersions.getVersion("version.jooq") for example

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to auto-generate a version string in git [duplicate]
This is done by using special placeholders (e.g. $Branch$) which are auto-replaced by the source control application. Is it possible to achieve ......
Read more >
Maintaining a version string in a project and using it ... - GitHub
Hi. I was looking into automating our release process with Actions and I am in a fix as to how I can best...
Read more >
How to manually determine version control metadata for Finder?
I have a Scripts folder where I keep Automator actions, Applescripts, and shell scripts. Automator scripts are automatically assigned a version ...
Read more >
How to compare two app version strings in Swift - Sarunw
Learn how to check your app version strings are higher or lower. ... You might try to do it manually with the help...
Read more >
ASK CLI Command Reference | Alexa Skills Kit
To get the version number of the ASK CLI that is installed on your computer, ... You can create a replay file manually...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found