Reputation: 56934
I just read Dart's suggested packagout layout spec and have a few questions regarding it:
lib
directory. But running pub get
or pub upgrade
will fetch those packages into a packages
directory. So which is it?!? Am I supposed to run pub get
, pull down packages into packages
, and then manually copy them over to lib
? That seems inefficient!lib
, but that internal packages (not a part of the API) should go in lib/src
. So if my project depends on some 3rd party package called transmogrify
, how do I known which transmogrify
packages are a part of the public API and should be placed in lib
, and which ones are "private" and should be placed in lib/src
? This seems tedious!main()
methods? Why/why not?packages/**
build/**
(produced by pub build
)pubspec.lock
Upvotes: 1
Views: 273
Reputation: 657871
1) you don't put 3rd party packages into a lib directory.
If you want to build a reusable library package you put the files building the library in the lib directory.
3rd party packages are just referenced in the dependencies
or dev_dependencies
section in the pubspec.yaml
file. The rest is maintained by pub
.
2) should be partly answered by 1). You put your public surface of your library package into lib. Library internals that should not be exposed as public API can/should go into a lib sub directory.
3) I think this depends how you specify a Dart app. A Dart package can certainly have several main functions. You can't have more entry pages in the web directory where each has a main.
You can have more Dart script files in bin, test, example where each can have a main.
You start an app by opening an entry page in the browser or running a script file with dart myscript.dart
so this clearly defines what gets called.
4)
pub *
)
I somehow have the impression that you are mixing up the concepts of libraries and packages. Just to clarify: You can have more than one library inside on package. You can (or have to) import individual libraries of a package individually if you want to use them.
Upvotes: 2
Reputation: 4013
Upvotes: 2