Pergunta

I am writing 4 dart libraries A, B, C, and D and they are all early in development so I don't want to publish them on pub yet.

It is also the case that only A, B and C are public libraries which all depend on D which should be private to just those three libraries. How Do I manage a situation like this?

Can I use pub to install library D for A, B and C on my local development machine whilst it isn't published? and how do I publish A, B and C when they are complete without publishing D, seen as D is not particularly useful if it isn't being used by A, B or C?

I have read the getting started guide and package structure documentation but neither seemed to cover this type of situation, i.e. how to manage private libraries. There is also this SO question but the user didn't answer it after resolving her issue.

Foi útil?

Solução

By default, dependencies resolve to Pub but you can override that to import packages from URLs, git and local path.

For instance, the following is the syntax for importing a local package:

dependencies:
  transmogrify:
    path: /Users/me/transmogrify

See Pub Dependencies for more info.

As far as the other part of your question, I don't see how A, B, and C can logically be public packages and rely on a private package. I would publish all of the packages and just include in the description of D that is not meant as a standalone package and is only intended as a helper package for A, B, and C.

You could also publish A, B, and C to Pub and host D on github or a public URL and specify the relevant URL dependency in the pubspec for A, B, and C (see the above link for the proper syntax). This might make the differentiation between D and the other libraries a bit clearer, though in practice they will all still be publicly available packages.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top