Can a project have a dependency on an artifact created in another project?

I have a multi-project build. In projectA there is a libProjectA.jar that is created, along with a separate artifact.

In projectB I have a dependency to projectA, but it doesn’t seem to be able to find the artifact.

I’ve already tried something like this:

  configurations { zipAssets }
  task generateZipAssets(type: Zip) { from fileTree(dir: assets_dir, include: '**/*') }
  artifacts { zipAssets generateZipAssetsTask }

  dependencies {
    compile project(':prjA')
    runtime project(path: ':prjA', configuration: 'zipAssets') }

However this type of dependency on the other project’s configuration zipAssets doesn’t appear to locate the Is there a way to make projectB aware of the artifact from projectA, without pushing to an external repository?

Are you sure it’s not working?

This appears to work for me:

subprojects { apply plugin: 'java' }

project('a') {
   configurations { zips }
   task zip(type: Zip) { from "." }
   artifacts { zips zip }

project('b') {
   dependencies {
     compile project(':a')
     runtime project(path: ':a', configuration: 'zips')

   task listDeps << { println configurations.runtime.files }

Which version of Gradle are you using?

I’m on 2.7, it looks like your’re doing the same thing that I am. :confounded:

So, you’re right it was working all along. I thought that the zip artifact would be on the classpath somewhere. But that isn’t the case. In my java code at runtime I need to be able to find the location of this file and obviously don’t want to hard code it in to the application.

How does Gradle make these artifacts available to the app at runtime?

And is it possible for a project, to add a configuration to another, as a dependency. Is there a notation to say “self” for the path ? Using the project’s name itself doesn’t work.

${project.path} works