# Version numbering for projects with multiple targets

**URL:** https://forum.crystal-lang.org/t/version-numbering-for-projects-with-multiple-targets/3873
**Category:** Help & Support
**Created:** [September 20, 2021, 9:15pm UTC](https://forum.crystal-lang.org/t/version-numbering-for-projects-with-multiple-targets/3873 "2021-09-20T21:15:52Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![hutou](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/hutou/32/1337_2.png) [@hutou](https://forum.crystal-lang.org/u/hutou)
#### Post date: [September 20, 2021, 9:15pm UTC](https://forum.crystal-lang.org/t/version-numbering-for-projects-with-multiple-targets/3873/1 "2021-09-20T21:15:52Z")

</div>

Hi,  
I’m working on a personal project which results in the writing of 3 applications, which share part of their source code.

In this project P, the structure of the files looks for example like this :  
Application A : Source files app\_a.cr, a1.cr, a2.cr, a3.cr, a4.cr, …  
Application B: Source files app\_b.cr, b1.cr, b2.cr, a1.cr, a3.cr, …  
Application C : Source files app\_c.cr, c1.cr, c2.cr, b1.cr, a4.cr, …

For the moment, I have organized the file tree in the following way:

```auto
project_p/
  src/
   app_a.cr
   app_b.cr
   app_c.cr
   app_a/
       a1.cr
       a2.cr
       a3.cr
       a4.cr
       ...
   app_b
       b1.cr
       b2.cr   
       ...
   app_c
       c1.cr
       c2.cr
       ...

```

and with the appropriate “require” in code and appropriate “targets” in the shard.yml file, everything is ok.

Except that I wonder about the question of how to manage the version numbering. Each of the 3 applications has logically its own numbering, but the shard.yml file can only contain one (the one of the project P, but not defined as not used!). I guess, however, that this can only become a problem if the project is published.

Nevertheless, I would be happy to know the most appropriate solution in this case. For example, would it be better to split the project into 3 subprojects, with symbolic links to the shared source files?

Or is there a better solution?

Thanks for your advice.

---

<div class="post-metadata">

### Author: ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)
#### Post date: [September 20, 2021, 9:27pm UTC](https://forum.crystal-lang.org/t/version-numbering-for-projects-with-multiple-targets/3873/2 "2021-09-20T21:27:23Z")

</div>

> [@hutou](#):
>
> For example, would it be better to split the project into 3 subprojects

Probably yea, then just install/version them as you would any shard. You can use private shards, so they do not need to be public either.

See also: [Multiple shards in a single git repo?](https://forum.crystal-lang.org/t/multiple-shards-in-a-single-git-repo/3862)

---

<div class="post-metadata">

### Author: ![hugopl](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/hugopl/32/970_2.png) [@hugopl](https://forum.crystal-lang.org/u/hugopl)
#### Post date: [September 21, 2021, 3:51am UTC](https://forum.crystal-lang.org/t/version-numbering-for-projects-with-multiple-targets/3873/3 "2021-09-21T03:51:11Z")

</div>

If the 3 apps are related and part of a big thing/package, you can consider the `shards.yml` version number being the version of the big thing/package, So for each app you could show both version numbers, the big thing/package version and the app version.

If there are 3 different not related things, better split in 3 repositories.

I wrote a macro 2 years ago that help you to keep in sync the version number in shards.yml with the `VERSION` constant people usually have in their programs:

> **[GitHub - hugopl/version\_from\_shard: A macro to declare the VERSION constant...](https://github.com/hugopl/version_from_shard)**
>
> A macro to declare the VERSION constant from the value found in shard.yml, so you don't need to write the same version number in multiple places. - GitHub - hugopl/version\_from\_shard: A macro t...

---

<div class="post-metadata">

### Author: ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)
#### Post date: [September 21, 2021, 9:12am UTC](https://forum.crystal-lang.org/t/version-numbering-for-projects-with-multiple-targets/3873/4 "2021-09-21T09:12:53Z")

</div>

There can only be one shard in a single git repository. Thus, if you want to distribute these applications as individual (sub-)projects with independent versioning, you have to put them in separate repositories.

Symbolic links for shared code can’t work if the applications are supposed to be installed via `shards`. You need to define all dependend code as dependencies. For example, besides the three application shards, you could have a fourth shard with shared code.

This obviously creates a lot of friction. Keeping dependencies in sync can become an effort.

Keeping all applications in a single repository creates less maintenance overhead. I’d recommend to keep it that way unless you _really_ need them to be independent shards.

It obviously depends on your specific use case. But is it actually that much important to have separate version numbers for each application? If these applications belong together as parts of a project, what’s the reason to separate them? There should be no harm in using a collective version number. It just makes live much easier.

You could of course use different internal version numbers for each application, independent of the metaproject’s version as suggested by @hugopl. That should work, but I’d question if it’s worth it. Again, it’s more effort (although less than maintaining separate repos) and I don’t see an immediate benefit.

---

<div class="post-metadata">

### Author: ![hutou](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/hutou/32/1337_2.png) [@hutou](https://forum.crystal-lang.org/u/hutou)
#### Post date: [September 21, 2021, 12:25pm UTC](https://forum.crystal-lang.org/t/version-numbering-for-projects-with-multiple-targets/3873/5 "2021-09-21T12:25:49Z")

</div>

Thank you all for your suggestions.  
After thinking about it, I agree with @straight-shoota and choose to make it simple: a unique version number for the 3 applications, with the use of @hugopl macro to facilitate the update in each application.
