When using maven-publish with non-Java artifacts in multi-project build, how does one declare cross-subproject dependencies?

We have a multi-project build with non-Java artifacts that we’re storing in a Maven repo (call the subprojects sub1/sub2/sub3). Each subproject produces two tarballs: one with runtime bin/lib files, and one with api header files for other projects to compile against. (Due to Maven’s limitations of one artifact per pom, we’re naming these artifactIds ‘subN’ and ‘subN-api’ for N in {1,2,3}).

allprojects {
  apply plugin: 'maven'
  apply plugin: 'maven-publish'
  group 'foo'
  version '1.2.3'
  repositories {
    mavenLocal()
    maven { url '...' }
  }
  configurations {
    runtime { transitive = true }
    compile
  }
}
subprojects {
  task makeArtifacts {
    ext.binFile = file("${buildDir}/bin.tgz")
    ext.apiFile = file("${buildDir}/api.tgz")
    inputs.files("${projectDir}/src", configurations.runtime, configurations.compile)
    outputs.files(binFile, apiFile)
    ...something that creates the bin/api files
  }
  publishing {
    repositories { ... }
    publications {
      runtime(MavenPublication) {
        artifact(makeArtifacts.ext.binFile) {
          builtBy makeArtifacts
        }
      }
      compile(MavenPublication) {
        artifact(makeArtifacts.ext.apiFile) {
          artifactId "${project.name}-api"
          builtBy makeArtifacts
        }
      }
    }
  }
}
project(':sub1' { }
project(':sub2') {
  dependencies {
    runtime "${group}:sub1:${version}"
    compile "${group}:sub1-api:${version}"
  }
}
project(':sub3') {
  dependencies {
    runtime "${group}:sub2:${version}"
    compile "${group}:sub2-api:${version}"
  }
}

I have two questions that may or may not be related:

(1) What’s the right way to tell gradle that the ‘runtime’ dependencies from sub2 can be satisfied locally by building the ‘runtime’ artifacts from sub1 without publishing? For example, if I do ‘gradle :sub2:makeArtifacts’, which depends on a sub1 artifact, I get:

Could not resolve all dependencies for configuration ':sub2:runtime'.
> Could not find foo:sub1:1.2.3.

If I publish all of the dependencies from the root project, using ‘gradle :publishToMavenLocal’, this works, but is there any shorthand to tell sub2 to use sub1’s artifacts without publishing? It smells wrong that my makeArtifacts task doesn’t have an explicit relationship with ‘assemble’ or ‘build’, but I’m not clear what that relationship should be or if that would fix the problem.

(2) What’s the best-practices way to make gradle recognize transitive dependencies when writing out a pom file? I was hoping that by marking the ‘runtime’ configuration transitive, any ‘runtime’ dependencies would get added to the pom file of the ‘runtime’ publication, but that didn’t happen. (Perhaps it happens in java with jar files, but I’m not using the java plugin and my artifacts happen to be tgz files.) I can hack my runtime publication:

runtime(MavenPublication) {
    artifact(makeArtifacts.ext.binFile) {
      builtBy makeArtifacts
    }
    pom.withXml {
      Node dependenciesNode = asNode().appendNode('dependencies');
      configurations.runtime.dependencies.each { Dependency dependency ->
        Node d = dependenciesNode.appendNode('dependency')
        d.appendNode('groupId', dependency.group)
        d.appendNode('artifactId', dependency.name)
        d.appendNode('version', dependency.version)
        d.appendNode('scope', 'runtime')
      }
    }
  }

I’ve verified that this establishes transitive dependencies by running ‘gradle sub3:dependencies’. But is there a better way to do this that doesn’t involve pom-hacking?

Thanks for reading this far!