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

Settings scripts and plugins should provide APIs to create RegularFile and Directory instances according to the settings layout #16506

Closed
eskatos opened this issue Mar 12, 2021 · 6 comments · Fixed by #26492
Assignees
Labels
a:feature A new functionality @configuration-cache in:configuration-model lazy api, domain object container
Milestone

Comments

@eskatos
Copy link
Member

eskatos commented Mar 12, 2021

Settings scripts and plugins can currently only access Settings.rootDir or Settings.settingsDir which return File instances. Several Gradle APIs require RegularFile or Directory instances and creating them from a File is currently not convenient.

This issue is about providing convenient APIs to Settings scripts and plugins to work with APIs that require RegularFile or Directory instances.

On example of such API is providers.fileContents(file) that expects a RegularFile.

This could be done in the same way it is currently done for Project scripts and plugins that have the ProjectLayout available.

Current Behavior

To use providers.fileContents(file) the convoluted following is currently required:

def regularFile = services.get(ObjectFactory).fileProperty().tap {
    set(new File(rootDir, "path/to/some.txt"))
}.get()
providers.fileContents(regularFile)

Note that it requires using the internal service lookup.

Expected Behavior

It should be convenient and only require public API instead, e.g.:

providers.fileContents(layout.rootDirectory.file("path/to/some.txt"))
@jjohannes jjohannes added in:configuration-model lazy api, domain object container and removed in:core DO NOT USE contributor labels Mar 30, 2021
@stale
Copy link

stale bot commented Apr 17, 2022

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added the stale label Apr 17, 2022
@cesar1000
Copy link

cesar1000 commented Apr 17, 2022

I think this issue is still relevant.

@stale stale bot removed the stale label Apr 17, 2022
@bamboo bamboo added 👋 team-triage Issues that need to be triaged by a specific team and removed 👋 team-triage Issues that need to be triaged by a specific team labels Jul 24, 2023
@jdochez
Copy link
Contributor

jdochez commented Aug 23, 2023

We need such an API to properly declare inputs to configuration cache from settings plugin.

@bamboo bamboo modified the milestones: 8.4 RC1, 8.5 RC1 Aug 23, 2023
abstratt added a commit that referenced this issue Sep 4, 2023
bot-gradle added a commit that referenced this issue Sep 15, 2023
@abstratt
Copy link
Member

abstratt commented Sep 18, 2023

@jdochez @cesar1000 Last night's nightly has new API under Settings to retrieve a Settings-based file system layout service (SettingsLayout):

https://docs.gradle.org/nightly/javadoc/org/gradle/api/initialization/Settings.html#getLayout--

(also injectable as a service)

PTAL and let us know if it covers your use cases.

abstratt added a commit that referenced this issue Sep 19, 2023
- also tweak javadoc for SettingsLayout

Issue: #16506
@abstratt
Copy link
Member

This is now implemented (to be released in 8.5).

@abstratt
Copy link
Member

The API is still WIP. Reopening.

@abstratt abstratt reopened this Sep 22, 2023
abstratt added a commit that referenced this issue Sep 22, 2023
...to open room for a new BuildLayout API type

Issue: #16506
abstratt added a commit that referenced this issue Sep 22, 2023
...to open room for a new BuildLayout API type

Issue: #16506
abstratt added a commit that referenced this issue Sep 22, 2023
...to open room for a new BuildLayout API type

Issue: #16506
abstratt added a commit that referenced this issue Sep 22, 2023
- remove FileSystemLayout

Issue: #16506
@abstratt abstratt linked a pull request Sep 22, 2023 that will close this issue
bot-gradle added a commit that referenced this issue Sep 23, 2023
...to open room for a new BuildLayout API type

Context (by @adammurdoch):
> Regarding #26227, I think we should rename SettingsLayout to BuildLayout. Settings isn’t really a thing that has a layout, it’s basically just a mutable view of the build. To me it doesn’t make sense to talk about a “settings layout”. It’s the build that has the layout.

Issue: #16506

### Reviewing cheatsheet

Before merging the PR, comments starting with
- ❌ ❓**must** be fixed
- 🤔 💅 **should** be fixed
- 💭 **may** be fixed
- 🎉 celebrate happy things

Co-authored-by: Rafael Chaves <rchaves@gradle.com>
bot-gradle added a commit that referenced this issue Sep 25, 2023
Rename SettingsLayout to BuildLayout

- also remove FileSystemLayout

Issue: #16506

### Reviewing cheatsheet

Before merging the PR, comments starting with
- ❌ ❓**must** be fixed
- 🤔 💅 **should** be fixed
- 💭 **may** be fixed
- 🎉 celebrate happy things

Co-authored-by: Rafael Chaves <rchaves@gradle.com>
bot-gradle added a commit that referenced this issue Sep 26, 2023
Rename SettingsLayout to BuildLayout

- also remove FileSystemLayout

Issue: #16506

### Reviewing cheatsheet

Before merging the PR, comments starting with
- ❌ ❓**must** be fixed
- 🤔 💅 **should** be fixed
- 💭 **may** be fixed
- 🎉 celebrate happy things

Co-authored-by: Rafael Chaves <rchaves@gradle.com>
abstratt added a commit that referenced this issue Oct 20, 2023
abstratt added a commit that referenced this issue Oct 20, 2023
abstratt added a commit that referenced this issue Oct 20, 2023
bot-gradle added a commit that referenced this issue Oct 20, 2023
Issue: #16506

Co-authored-by: Rafael Chaves <rchaves@gradle.com>
bot-gradle added a commit that referenced this issue Nov 28, 2023
…le services

Issue: #16506

Co-authored-by: Rafael Chaves <rchaves@gradle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature A new functionality @configuration-cache in:configuration-model lazy api, domain object container
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants