-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Provide parsed package.json
contents as (or in) extension
#232
Comments
This sounds like a good idea and should be fairly quick to implement, in the next version of the plugin I'll add a first version of this I imagine |
Having some common properties hard-coded and being able to access the rest dynamically sounds perfect. :-) |
Nice @deepy, two questions. |
3.3.0 was just released, so it should be possible to test right now.
All the |
Ah, I see, I missed that part.
This is the pattern I used, feel free to copy or adapt it: inline fun <reified T> cachedProvider(crossinline block: () -> T): Provider<T> =
objects
.property<T>()
.value(provider { block() })
.apply {
disallowChanges()
finalizeValueOnRead()
}
val theValue = cachedProvider {
costlyCalculateValue()
} |
And another detail, your implementation is not configuration cache safe. Update: the<PackageJsonExtension>()
.version
.zip(
providers.fileContents(layout.projectDirectory.file("package.json")).asBytes
) { version, _ -> version }
.get() and then it worked properly |
I'm going to check the issues and see what else should go into |
I didn't try yet, but the |
So, I retried with Gradle 8.1 where the configuration cache became officially stable. One thing that could be improved though is the name of the |
There's a configuration cache issue with ARM environments that needs to be solved so 4.0 will likely be only that issue + finishing up this one |
4.0.0 has been released |
It would be nice if the plugin would parse the
package.json
and provide its contents readily available for further usage either as separate extension,
or as field of the existing extension.
What I for example currently do is
The text was updated successfully, but these errors were encountered: