# Usage of subdirectories to store multiple packages in a single repo

**URL:** <https://discourse.julialang.org/t/usage-of-subdirectories-to-store-multiple-packages-in-a-single-repo/55534>\
**Category:** Tooling\
**Created:** [February 18, 2021, 10:37am UTC](https://discourse.julialang.org/t/usage-of-subdirectories-to-store-multiple-packages-in-a-single-repo/55534 "2021-02-18T10:37:30Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [February 18, 2021, 10:58am UTC](https://discourse.julialang.org/t/usage-of-subdirectories-to-store-multiple-packages-in-a-single-repo/55534/2 "2021-02-18T10:58:39Z")

</div>

Many/most of these questions can probably be answerd by this: _Packages in subdirectories are just regular packages. They just happen to live in the same git repo._

* * *

> [@Gregstrq](#):
>
> How are the subdirectories supposed to be organized? Must each of the subdirectories have the normal package structure with Project.toml, Manifest.toml, ./src, ./test, ./docs etc.?

Yes they need to be packages on their own with `Project.toml`, `src/Package.jl` entrypoint etc. Probably this structure makes the most sense:

```shell
$ tree .
.
├── PackageA
│ ├── Project.toml
│ └── src
│ └── PackageA.jl
└── PackageB
    ├── Project.toml
    └── src
        └── PackageB.jl

4 directories, 4 files

```

or perhaps

```shell
$ tree .
.
└── packages
    ├── PackageA
    │ ├── Project.toml
    │ └── src
    │ └── PackageA.jl
    └── PackageB
        ├── Project.toml
        └── src
            └── PackageB.jl

5 directories, 4 files

```

> [@Gregstrq](#):
>
> Is it possible to have shared docs or tests for the packages in subdirectories?

Not sure what you mean – they are standalone packages. On the repo-level if you want some common tests you can structure it like this maybe:

```shell
$ tree .
.
├── docs
│ └── common_docs.html
├── packages
│ ├── PackageA
│ │ ├── Project.toml
│ │ └── src
│ │ └── PackageA.jl
│ └── PackageB
│ ├── Project.toml
│ └── src
│ └── PackageB.jl
└── test
    └── common_tests.jl

7 directories, 6 files

```

(but Pkg.jl doesn’t understand it so you must organize it yourself).

> [@Gregstrq](#):
>
> If the packages in subdirectories depend on each other, how imports should be organized?

Since they are standalone package the same mechanism as if they were different repos.

> [@Gregstrq](#):
>
> How does one register a subdirectory package?

Here is an example: [InlineTest: bump version 0.1.0 -\> 0.1.1 · JuliaTesting/ReTest.jl@57368e6 · GitHub](https://github.com/JuliaTesting/ReTest.jl/commit/57368e614851d80672c5c02f35dcde34dc249c4f#commitcomment-46846460)

> [@Gregstrq](#):
>
> How does one add a subdirectory package to an active environment?

If it is registered just like a normal package. If you add by URL you specify the subdirectory after `:`: `add url:/subdirpath`

> [@Gregstrq](#):
>
> Let’s say I want to split some core functionality of a package into a subdirectory: I have SomePackage and I want to split it into subdirectories SomePackageBase and SomePackage. **Is it possible to reregister SomePackage so that it points to a subdirectory now?**

Yes.

---

_[View the full topic](https://discourse.julialang.org/t/usage-of-subdirectories-to-store-multiple-packages-in-a-single-repo/55534)._
