3

I am building multiple projects for a client and they tend to have common code that I've factored out into separate projects. I'm trying to use DUB to organize all of this, but so far I can't figure out how to add these common projects as dependencies without publishing them on a site like github and registering them in DUB's public registry. Publishing these things would either violate my contract or put uninteresting spam in the DUB registry (or both). Is there any way I can operate my own DUB registry on a private server, and have it graph all of the usual public projects plus a handful of private ones in LAN-accessible git repos?

This would save me from having to make a lot of git submodules. :)

Thanks.

chadjoan
  • 485
  • 3
  • 11

1 Answers1

2

You can self host a dub registry by using your own --hostname parameter on dub-registry and providing your own --registry parameter on dub.

Alternatively, you can just use your packages locally (or remotely, if packages are placed on network drive). Dub wiki page "Cookbook" explains how to work with packages that are not in registry: https://github.com/dlang/dub/wiki/Cookbook#working-with-submodules-or-packages-that-are-not-in-the-registry

Working with submodules or packages that are not in the registry

It is a common practice to either have a project as a git submodule of a master project, or to use an unregistered project as a dependency for development. In this setup, setting the project to depend on a project at a given path, rather than looking up the repository, can come handy. Here's an example of such a package:

{ "name": "dlang-org", "dependencies": { "libddoc": { "path": "./libddoc" }, "libdparse": { "path": "./libdparse" } } }

Another possibility is to add-local a package. This is particular useful during development, when you want to test a package with some libraries using that package.

dub add-local myrepo dub list

John Smith
  • 496
  • 1
  • 6
  • 20
  • I wasn't aware of that particular "dependencies" structure (I'm currently playing with "subPackages" and the "main:subproject" notation in "dependencies") and I wasn't aware of add-local either, so that is nice information. Unfortunately, it doesn't answer the question or solve the problem: I really would prefer a private registry because I am trying to avoid git submodules and other developers on the same LAN need access to the same list of packages. I suspect it gets me closer though: perhaps using add-local on a networked file share would do it. Is there a better way? – chadjoan Jun 21 '17 at 21:10
  • There is also git subtree - compared to git submodules, all sources are stored ... – greenify Jun 21 '17 at 21:46
  • 1
    Well you could try using `--registry` parameter on dub and hosting dub-registry using your own `--hostname` parameter, if you really need to. – John Smith Jun 21 '17 at 21:59
  • I didn't know about the dub-registry package! The next step would have been to look for the --registry option, so that's new too. Thanks! In my case, I just now got it working using "dub add-path ". No git submodules or subtree necessary (I was probably going to use subtree if dub couldn't do this). John, would you edit your answer to include those approaches ((1) add-path with network share and (2) dub-registry, --registry, --hostname)? I would feel right accepting the answer after that. – chadjoan Jun 21 '17 at 23:15
  • sure here you go – John Smith Jun 22 '17 at 16:22
  • Alright then. I also suggested/queued an edit to mention the networked file share trick. Hope that helps. – chadjoan Jun 23 '17 at 04:08