# Multi-project build: Create fileset with project and its dependencies

**URL:** <https://discuss.gradle.org/t/multi-project-build-create-fileset-with-project-and-its-dependencies/33444>\
**Category:** Help/Discuss\
**Created:** [October 8, 2019, 11:35am UTC](https://discuss.gradle.org/t/multi-project-build-create-fileset-with-project-and-its-dependencies/33444 "2019-10-08T11:35:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![grossjohann](https://avatars.discourse-cdn.com/v4/letter/g/898d66/32.png) [@grossjohann](https://discuss.gradle.org/u/grossjohann)\
**Post date:** [October 8, 2019, 11:35am UTC](https://discuss.gradle.org/t/multi-project-build-create-fileset-with-project-and-its-dependencies/33444/1 "2019-10-08T11:35:39Z")

</div>

We have got a web application with a common backend and an old UI and a new UI. Currently, it is possible to deploy either into a Tomcat, and the `WEB-INF/lib` directory contains the jar files required for the UI and the backend.

I would like to deploy two web apps into one Tomcat, one web app for each UI. These two web apps should share the backend classes. To avoid classloader issues, my understanding is that the backend jars should be in the Tomcat `shared/lib` directory, instead of inside each web app’s `WEB-INF/lib`.

(I’ll attach a backend “manager” instance to the servlet context for the new UI, and I’ll change the old UI to obtain that instance.)

We’ve got a multi-project build, one set of projects for the backend, another set for the old UI and yet a third set for the new UI.

What I’ve got so far is this: the cargo plugin defines a setting `sharedClasspath` (a `FileCollection`), and I’ve added my backend projects there and the corresponding jar files are copied to `shared/lib`. What is missing is that I also need to copy the dependencies of these jar files.

As an example, let this be a backend project:

```
project(':backend') {
    dependencies {
        implementation 'org.apache.commons:commons-lang3:3.1'
    }
}

```

So now I will need to copy `backend.jar` and `commons-lang.jar` (not the exact file names) to the Tomcat `shared/lib` directory. I’m able to include `backend.jar` as follows:

```
...
    sharedClasspath = layout.files(project(':backend').jar.archivePath)
...

```

But how do I get all dependencies of `:backend` and the artifact fully qualified file names for them?

`project(':backend').configurations.api.allArtifacts` seems to be empty. I also tried the configuration `implementation`. And `project(':backend').configurations.api.dependencies` seems to contain `Dependecy` objects which don’t tell me the artifact file name.

---

<div class="post-metadata">

**Author:** ![grossjohann](https://avatars.discourse-cdn.com/v4/letter/g/898d66/32.png) [@grossjohann](https://discuss.gradle.org/u/grossjohann)\
**Post date:** [October 9, 2019, 12:06pm UTC](https://discuss.gradle.org/t/multi-project-build-create-fileset-with-project-and-its-dependencies/33444/2 "2019-10-09T12:06:52Z")

</div>

I’ve now found out how to do it:

```
...
    sharedClasspath = layout.files(
        project(':backend').jar.archivePath,
        project(':backend').configurations.runtimeClasspath.resolvedConfiguration.files,
    )
...

```

It took me a while to figure out that `runtimeClasspath` was the right configuration, and I only found through another forum post that I can do `.resolvedConfiguration.files` to access the actual files.
