I have a custom (exec) task that produces two tarballs (FWIW, they have two different artifactIds). I’m able to publish those two tarballs to a local maven repo, using code that looks essentially like this:
group "org.myorg"
version '1.2.3'
task myCustomTask(type: Exec) {
outputs.files("$buildDir/path/to")
commandLine("something that creates first.tar.gz and second.tar.gz")
}
publishing {
publications {
x(MavenPublications) {
artifactId 'foo'
classifier 'bin'
extension 'tar.gz'
from "$buildDir/path/to/first.tar.gz"
}
y(MavenPublications) {
artifactId 'bar'
classifier 'bin'
extension 'tar.gz'
from "$buildDir/path/to/second.tar.gz"
}
}
}
If I build the “gradle myCustomTask” target, I see the tarballs show up in my build directory, and then the “publishToMavenLocal” target publishes those files locally to “~/.m2/repository/org/myorg/foo/foo-1.2.3-bin.tar.gz” and “~/.m2/repository/org/myorg/bar/bar-1.2.3-bin.tar.gz”. However, there’s no dependency graph between the two, so if I try to publish on a clean repo, nothing gets built.
What’s the right way to tell Gradle that those publications have a dependency on “myCustomTask”?
Yes, I can publishToMavenLocal from a clean build and get both artifacts, but if I look in my build directory, I see that the myFooArtifact and myBarArtifact tasks have un-tarred and re-tarred the file (which I don’t want to happen, as this changes the MD5 hash of the artifact, and myCustomTask also produces a list of expected MD5 hashes which no longer match).
I think that the key part is something vaguely like this: