-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: add single source of truth for kotlin and agp versions #102
Conversation
kotlinVersion = kotlinVersion, | ||
agpVersion = agpVersion, | ||
// we don't need check properties for exist, we read it successfully in forma configuration | ||
kotlinVersion = properties["forma.kotlinVersion"]!!.toString(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's extract property names to constants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constants doest allowed, extracted val
plugins/build.gradle.kts
Outdated
} | ||
|
||
// TODO: actually error will not be displayed, find the way to fix it | ||
fun errorNoProperty(propertyName: String): Nothing = error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO not the best use of Nothing
here. Let's replace it with throw
and custom exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant is - there is no need to use Nothing(calling error
) throw Exception would be more obvious IMHO
plugins/build.gradle.kts
Outdated
file.inputStream().use { properties.load(it) } | ||
} catch (e: Throwable) { | ||
throw Exception( | ||
"Cannot read gradle.properties file from root project. " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message is too verbose. Could be one sentence.
Can't read ${file.absolutePath}
org.gradle.vfs.watch=true | ||
forma.kotlinVersion=1.5.10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a suggestion. Should we use separate file for forma configuration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now it doesn't metter, but if we find correct way to declare versions in single place using gradle api, we should not use custom solutions. Configuring plugins using gradle.properties looks like straight forward gradle way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having forma properties in the separate file(e.g forma.properties) will allow us to do automated refactorings(or generate file to new projects) more easily compare to file with all possible flags
plugins/build.gradle.kts
Outdated
) | ||
|
||
val kotlinVersion = properties["forma.kotlinVersion"] ?: errorNoProperty("forma.kotlinVersion") | ||
val agpVersion = properties["forma.agpVersion"] ?: errorNoProperty("forma.agpVersion") | ||
val kotlinVersion = properties[propertyKotlinVersion] ?: errorNoProperty(propertyKotlinVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see why you need Nothing here.
properties[propertyKotlinVersion] ?: errorNoProperty(propertyKotlinVersion)
could be extracted as a separate method, doing that you'll not need fun errorNoProperty
#101