gradle-grunt-plugin icon indicating copy to clipboard operation
gradle-grunt-plugin copied to clipboard

Set gradle project version from package.json

Open dougborg opened this issue 10 years ago • 3 comments

In my projects that use this plugin, I generally want Gradle project to have the same version as what is specified in the package.json file. Do you think this would be a good thing to make part of the plugin?

Here is what I currently put in the build.gradle of my Gradle/Grunt projects:

import groovy.json.JsonSlurper
def packageSlurper = new JsonSlurper()
def packageJson = packageSlurper.parse file('package.json')
version = packageJson.version

I am open to a number of ways of implementing this. It could be an option set in the build.gradle (usePackageJsonVersion=true?), or you could just make the packageJson object an extension property of the project, so you could just do the version=packageJson.version bit and have access to the package.json data for other things in the build.

I feel like this probably belongs in the gradle-grunt-plugin, but I could see arguments for making it part of the gradle-node-plugin too.

dougborg avatar Oct 13 '14 19:10 dougborg

Nice, just copied and pasted this to our project as well.

peterlai-roboops avatar Apr 15 '15 13:04 peterlai-roboops

Is this Impented yet?

ccoulton avatar Jul 31 '15 18:07 ccoulton

I would also like to see this implemented if possible, any eta?

Neil201 avatar Apr 06 '16 10:04 Neil201