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

Fix some IP problems in the build #28929

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

asodja
Copy link
Member

@asodja asodja commented Apr 23, 2024

No description provided.

@asodja asodja added the a:investigation Issues requiring decision or investigation label Apr 23, 2024
@asodja
Copy link
Member Author

asodja commented Apr 23, 2024

@bot-gradle test this BD

@bot-gradle
Copy link
Collaborator

I've triggered the following builds for you. Click here to see all build failures.

@asodja
Copy link
Member Author

asodja commented Apr 23, 2024

@bot-gradle test AST

@bot-gradle
Copy link
Collaborator

I've triggered the following builds for you. Click here to see all build failures.

buildEnvironmentExtension.gitBranch = git("rev-parse", "--abbrev-ref", "HEAD")
buildEnvironmentExtension.repoRoot = layout.projectDirectory.parentOrRoot()
val buildLayout = layout
gradle.lifecycle.beforeProject {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Before git would be executed only twice per build, right? And now it's once per project?

Copy link
Member Author

@asodja asodja Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly it seems it's called 3-times in both cases during sync, at least when trying to do some println in the zip part I get for both:

> Configure project :
Executed 'git rev-parse --abbrev-ref HEAD' for ':'
Executed 'git rev-parse --abbrev-ref HEAD' for ':'
Executed 'git rev-parse --abbrev-ref HEAD' for ':'

So it looks like provider is evaulated anytime git() is called anyway, or that should not be the case?

If you have any ideas how to improve that, let me know.
We can also just merge improvement for gradle/shared-with-buildSrc/mirrors.settings.gradle.kts that is trivial and we leave this one for some other time when we'll have more tools.

Copy link
Member Author

@asodja asodja Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any thoughts if that solution could be a problem or not @gradle/bt-developer-productivity?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it looks like provider is evaulated anytime git() is called anyway, or that should not be the case?

This seems to be expected behavior. BiProvider's implementation did run the combiner function every time:

R combinedUnpackedValue = combiner.apply(leftValue.getWithoutSideEffect(), rightValue.getWithoutSideEffect());

That being said, it's still a bit inefficient to have the provider instance in every Project, even though it may not be a problem right now. Suppose somebody start using gitCommitId in every Project in the future, that would be executed hundreds of times.

Right now I don't have a very good idea for this, is it possible to store the information in the similar way as DevelocityConfiguration? I think there's only one instance stored in the build right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be possible to always execute git once in the settings plugin and then simply propagate the data to every project as a Kotlin data class or similar construct (until we have a proper solution via the Shared Data API):

captureBuildEnvironment().let { buildEnvironment ->
  gradle.lifecycle.beforeProject {
     extensions.add("buildEnvironment", buildEnvironment)
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10 min review a:investigation Issues requiring decision or investigation build-script-change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants