Skip to content
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

How to set the stage for an included build when using composites. #197

Open
grumpheim opened this issue Jun 30, 2023 · 1 comment
Open

Comments

@grumpheim
Copy link

I am using Gradle composites to build a set of projects. Some, but not all, of the projects use the Reckon plugin. (Gradle 7.4.2, Reckon 0.16.0 )

This setup works very well for development. My issue arises when I try to use this approach to create a release version of one of the Reckon-enabled projects.

When working with the project on its own, generating a release is simple:
my_project_dir% gradle build -Preckon.stage=final

I would like to be able to do the same with the composite:

composite_dir% gradle :my_project:build -Preckon.stage=final

This doesn't produce a release. I reviewed the issues (#74) and it looks like this is intentional: The intended behavior is not clear. I understand and agree. But is there a (sane) way for me to get my use-case to work? Creating a release from one of the sub-projects seems like a valid use-case. I would like to get it to work without editing files, if possible. I think my ask can be summarized as:

"Given that at least one sub-project in a Gradle composite is Reckon-aware, how can I configure the build so that specific project is configured with reckon.stage=final?"

This would allow me to use composite builds in my CICD system.


I've tried some casual experiments just to see how/if reckon.scope was being propagated in the composite.

  • Setting reckon.stage=final in my global gradle.properties --> Ignored
  • Setting reckon.stage=final in the specific sub-projects gradle.properties -> Ignored (Standalone project complains that the version was evaluated before reckon was configured)

These failures led me to think I'm missing something basic, which is why I'm here :-)

@grumpheim
Copy link
Author

In the version of reckon that I'm using (0.16.0), the fix referenced above is implemented differently. The providers for stage and scope are modified with 'forUseAtConfigurationTime()'

This means that I can override this in my project:

`
reckon {
scopeFromProp()
stageFromProp('beta', 'rc', 'final')

// WARNING: Subtle and brittle
stage.set(project.getProviders().gradleProperty('reckon.stage'))
scope.set(project.getProviders().gradleProperty('reckon.scope'))
}
`

This has the effect of re-enabling the providers, even if we are in a composite.

This workaround is good enough for my narrow case (only one reckon-enabled project in a composite). But I don't consider it a real solution, especially since forUseAtConfigurationTime is deprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant