researchgate / gradle-release

gradle-release is a plugin for providing a Maven-like release process for projects using Gradle
MIT License
863 stars 223 forks source link

Version from custom file not applied to project #294

Open pun-ky opened 5 years ago

pun-ky commented 5 years ago

Hi!

release {
    versionPropertyFile = "version.properties"
    afterEvaluate {
        buildTasks = listOf(":aem:assembly:full:build")
    }
}

afterEvaluate {
    throw GradleException("${project.version}")
}

ends with

* What went wrong:
A problem occurred configuring root project 'example'.
> unspecified

however if I put version to gradle.properties file and

release {
    //versionPropertyFile = "version.properties"
    afterEvaluate {
        buildTasks = listOf(":aem:assembly:full:build")
    }
}

then the version is set correctly. why customizing versionPropertyFile property is not affecting version applied to project?

second thing, I need to wrap setting buildTasks into afterEvaluate to avoid

 Task with name ':aem:assembly:full:build' not found in root project 'example'.

yes it is pointing to subproject intentionally. should that be also supported without a need of wrapping into afterEvaluate ?

Hillkorn commented 5 years ago

How do you read the version.properties in gradle? I think it's now parsed by default. You configured the release plugin with the file to use but it is not configuring the project for you. The gradle.properties is always parsed by gradle and the project.version is set. If you move the version out into another properties file you have to parse it and set the project.version on your own. The configuration of release {} is only there to tell the release plugin where and what must be changed to update the version.

pun-ky commented 5 years ago

Ok. I know that however I was suspecting that you might want to handle that case. It is not trivial that one change / customizing properties file affects version not set to projects.

Hillkorn commented 5 years ago

The release plugin can handle the version to be somewhere else but like I said it's just gradle that needs to know too. The problem here is that you still expect the project.version to be set but this is a gradle internal thing and if you want to have custom like that you need to do a bit more like loading that properties file in your build.gradle. See this https://stackoverflow.com/a/37101792/1372349 how to load them easily You can then do project.version = props.getProperty("version") in your build gradle. I would do this at the very beginning that it is set as early as possible.

pun-ky commented 5 years ago

apply from properties file is not available when using kotlin dsl. I will ask gradle team about that missing feature available in groovy dsl. Yep I can load it by myself but it will not look so good...

pun-ky commented 5 years ago

how about second question

release { afterEvaluate { buildTasks = listOf(":aem:assembly:full:build") } }

plugin could internally do afterEvaluate ... so that release plugin DSL will look more nice in case of referencing subproject task