Skip to content

Add BuildService to cache classloaders#39

Merged
martinbonnin merged 1 commit intomainfrom
build-service
Jun 10, 2025
Merged

Add BuildService to cache classloaders#39
martinbonnin merged 1 commit intomainfrom
build-service

Conversation

@martinbonnin
Copy link
Copy Markdown
Member

Fixes #27

This also splits the runtime in 2 parts:

  • wiring, can use Gradle APIs
  • task, always isolated

@martinbonnin martinbonnin force-pushed the build-service branch 4 times, most recently from bc9e2f4 to acbf496 Compare June 10, 2025 21:25
@martinbonnin martinbonnin merged commit 67e09a3 into main Jun 10, 2025
1 check passed
@martinbonnin martinbonnin deleted the build-service branch June 10, 2025 21:33
}
}

override fun close() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@Synchronized ?

Copy link
Copy Markdown
Member Author

@martinbonnin martinbonnin Jun 11, 2025

Choose a reason for hiding this comment

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

Doesn't hurt I guess but I would expect Gradle to serialize those calls.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It would be nice to have it for consistency: you protect the read/write, so it makes sense to protect the close as well

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've added it to #40

Comment on lines +30 to +40
val builder = StringBuilder(length)
var isCapitalized = false
forEach {
builder.append(if (!isCapitalized && it.isLetter()) {
isCapitalized = true
it.toString().uppercase()
} else {
it.toString()
})
}
return builder.toString()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Have you considered replaceFirstChar { it.upppercase() }?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This function comes from GraphQL-land where I wanted the underscores to be ignored: __foo --> __Foo. But you're right, in the general case, simple replaceFirstChar {} might be closer to what people would expect (and what Gradle is doing too?)

I made the change in #40. Let me know what you think.

@martinbonnin martinbonnin mentioned this pull request Jun 11, 2025
martinbonnin added a commit that referenced this pull request Jun 11, 2025
* use replaceFirstChar {}

* synchronized
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

Successfully merging this pull request may close these issues.

Use a BuildService to cache the classloader

2 participants