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

Create convenience APIs for artifact exchange between projects #32089

Open
liutikas opened this issue Jan 17, 2025 · 1 comment
Open

Create convenience APIs for artifact exchange between projects #32089

liutikas opened this issue Jan 17, 2025 · 1 comment
Labels
a:feature A new functionality in:dependency-declarations variant notation attributes capability substitution in:isolated-projects

Comments

@liutikas
Copy link
Contributor

Expected Behavior

API fan-fiction (no strong opinion on names/shape, just want something simple):

publisher project build.gradle.kts

val producingTask = tasks.register( ...
artifacts.publish(producingTask) {
  attributes {
    attribute( ...
  }
}

consumer project build.gradle.kts

val lazyFileCollection: FileCollection = artifacts.consume("configurationName") {
  attributes {
    attribute( ...
  }
}

dependencies {
  "configurationName"(project(":publishingProject"))
}

Current Behavior (optional)

It is non-trivial to set up artifact publishing for safe cross-project use and docs don't fully explain it end to end

Today, published project:

val producingTask = tasks.register( ...
configurations.create("artifactPublisher") {
    // Note, consumed and resolved are opposite of root project
    isCanBeResolved = false
    isCanBeConsumed = true
    attributes {
        attribute( ...
    }
}
artifacts.add("artifactPublisher", reportTask)

consumer project:

val artifactConsumer = configurations.create("configurationName") {
    isCanBeResolved = true
    isCanBeConsumed = false
    attributes {
        attribute(...
    }
}
// most people make a mistake of not going through artifactView and thus making this eager
val lazyFileCollection = artifactConsumer.incoming.artifactView { }.files

dependencies {
  "configurationName"(project(":publishingProject"))
}

Context

Reaching cross projects is bad, but currently a lot easier to do. project(":publishingProject").tasks.named("producing task").flatMap {} compared to all the code above.

This complexity means folks have to write guides how to do this (e.g. https://www.liutikas.net/2024/12/11/Together-In-Isolation.html) where it could be a lots simpler for a common case.

@liutikas liutikas added a:feature A new functionality to-triage labels Jan 17, 2025
@ov7a
Copy link
Member

ov7a commented Jan 21, 2025

This feature request is in the backlog of the relevant team and is prioritized by them.


Related:

@ov7a ov7a added in:dependency-declarations variant notation attributes capability substitution in:isolated-projects and removed to-triage labels Jan 21, 2025
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:dependency-declarations variant notation attributes capability substitution in:isolated-projects
Projects
None yet
Development

No branches or pull requests

2 participants