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

Consider introducing a lazy API to set repository URL for PublishToRepository task #22779

Open
Tracked by #24328 ...
mlopatkin opened this issue Nov 17, 2022 · 5 comments
Open
Tracked by #24328 ...
Labels
a:feature A new functionality in:publishing-plugins ivy-publish maven-publish
Milestone

Comments

@mlopatkin
Copy link
Member

mlopatkin commented Nov 17, 2022

Expected Behavior

It should be possible to set a URL of a repository in a configuration-cache compatible lazy manner.

Current Behavior

The existing Maven/IvyArtifactRepository.setUrl(Object) method is not lazy, the URL is eagerly evaluated when stored to the configuration cache.

Context

The lazy API will allow tweaking the publishing URL without invalidating the configuration cache, e.g. by wiring an environment variable provider.

There's also a more complex scenario, though it isn't obvious how widespread it is. The "publishing credentials" sample needs something to become fully configuration-cache compatible. The sample starts a bundled web server that works as a maven repository and then publishes libraries into the server. The URL of the server (the port part) may change between runs and can only be obtained after the server is started.

The current implementation starts the server in doFirst action and reconfigures the publishing repository. This isn't compatible with the configuration cache, because repository object is not restored from the cache fully.

A configuration cache-compatible implementation can be the following:

  1. The web server is implemented as a shared build service with a getUrl accessor/provider
  2. This URL provider is wired into the URL of publishing task repository with the new lazy API.
@gabrielittner
Copy link

We have one of the more complex scenarios in the vanniktech/gradle-maven-publish-plugin. We have a task that makes an API call to Sonatype OSS to create a staging repository to upload to. The repository url is then derived from that plus 2 other properties that are set through our extension. We currently use a provider for the url to make this possible.

This is the configuration code
https://github.com/vanniktech/gradle-maven-publish-plugin/blob/main/plugin/src/main/kotlin/com/vanniktech/maven/publish/MavenPublishBaseExtension.kt#L64-L71

@TWiStErRob
Copy link
Contributor

Gradle Nexus Publish Plugin would use this facility to support configuration cache. The value is set via provider already, but when Configuration Cache is enabled, the serialization eagerly resolves the provider too early before the task that would set the value executes.

See point 3) at gradle-nexus/publish-plugin#221 (comment)

@mlopatkin mlopatkin added this to the 9.0 RC1 milestone Jun 21, 2023
@mlopatkin mlopatkin added 👋 team-triage Issues that need to be triaged by a specific team and removed in:configuration-cache Configuration Caching @configuration-cache 👋 team-triage Issues that need to be triaged by a specific team labels Jul 18, 2023
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Feb 15, 2024
Publishing artifacts does not work with the configuration cache yet, see
[1].

[1]: gradle/gradle#22779

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Feb 15, 2024
Publishing artifacts does not work with the configuration cache yet, see
[1].

[1]: gradle/gradle#22779

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
@sschuberth

This comment was marked as resolved.

@mlopatkin
Copy link
Member Author

Nevermind, I have to use the --no-configuration-cache CLI option instead.

Either this or -Dorg.gradle.configuration-cache=false. -P sets the project property and is not suitable for most of the Gradle configuration.

@sschuberth
Copy link
Contributor

Either this or -Dorg.gradle.configuration-cache=false. -P sets the project property and is not suitable for most of the Gradle configuration.

I've never really understood the difference TBH. I thought that everything that can go to gradle.properties is also overridable via -P, and -D is to set Java system properties instead of Gradle properties.

Calvin-LL added a commit to Calvin-LL/AutoLinkText that referenced this issue Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature A new functionality in:publishing-plugins ivy-publish maven-publish
Projects
None yet
Development

No branches or pull requests

4 participants