This message was deleted.
# community-support
s
This message was deleted.
a
https://docs.gradle.org/current/userguide/dependency_resolution.html#sec:programmatic_api try replacing
Copy code
from(swiftSources)
with
Copy code
from(swiftSources.map { it.incoming.files })
or, if
swiftSources
isn’t in a `Provider<>`:
Copy code
from(swiftSources.incoming.files)
c
Thanks for the suggestion, but unfortunately that did not help. Even if I comment out the consumer task and depenencies the issue occurs. Seems to be triggered at the producer side, when adding the artifact
a
ah I see, on the producer side, I missed that. You could try adding the outgoing files like this:
Copy code
swiftSources {
  outgoing {
    artifacts(tasks.updateDokkatooExamples.map { it.outputs.files })
  }
}
(something like that anyway, I might have the wrong syntax)
c
Trying this now (in producer):
Copy code
val generateSwiftSources = tasks.register("generateSwiftSources") {
    dependsOn("metadataCommonMainClasses")
    val fileTree = layout.buildDirectory.asFileTree.matching {
        include("**/*.swift")
    }
    outputs.files(fileTree)
}


val swiftSources by configurations.creating {
    isCanBeConsumed = true
    isCanBeResolved = false
    outgoing {
        artifacts {
            add("swiftSources", generateSwiftSources.map { it.outputs.files })
        }
    }
}
And getting:
Copy code
> Cannot convert the provided notation to a File or URI: task 'generateSwiftSources' output files.
     The following types/formats are supported:
       - A String or CharSequence path, for example 'src/main/java' or '/usr/include'.
       - A String or CharSequence URI, for example 'file:/usr/include'.
       - A File instance.
       - A Path instance.
       - A Directory instance.
       - A RegularFile instance.
       - A URI or URL instance.
       - A TextResource instance.
At least it is a different error πŸ™ƒ
πŸš€ 1
I decided to get rid of the filetree usage and use a Copy task to gather all files I want in a intermediate build dir: (producer)
Copy code
val copySwiftSources = tasks.register<Copy>("copySwiftSources") {
    dependsOn("metadataCommonMainClasses")
    from(layout.buildDirectory.dir("generated/ksp/metadata/commonMain/resources"))
    include("**/*.swift")
    into(layout.buildDirectory.dir("swift"))
}


val swiftSources by configurations.creating {
    isCanBeConsumed = true
    isCanBeResolved = false
}


artifacts {
    add("swiftSources", copySwiftSources)
}
This actually works fine for me πŸ™‚ Thanks for the help. Why the other approach did not work is still a mystery to me
a
ah good idea, yes a dedicated task definitely helps
btw you might want to use Sync instead of Copy. I always prefer using Sync because it will clear out any old files, so if a file is deleted from the source then Sync makes sure that will be deleted in the destination too
πŸ™Œ 1
☝️ 2