Multiple Pubspec.yaml

208 views
Skip to first unread message

Rat Jo

unread,
Sep 13, 2014, 8:42:01 PM9/13/14
to mi...@dartlang.org
Hi,

Is it possible to have multiple pubspec in the same project?

I'm trying to have this structure:

pubspec.yaml (server)
main.dart (server)
 -> public
 ---> index.html
 ---> index.dart
 ---> pubspec.yaml (client)

The editor doesn't seem to like. I'm trying to have different library for my server code and my client.

Jo

Günter Zöchbauer

unread,
Sep 14, 2014, 3:15:45 AM9/14/14
to mi...@dartlang.org
Just make different packages.
A pubspec.yaml is not for libraries it is for packages.
A package can have many libraries.
You can import packages which are not published to pub.dartlang.org with a path dependency.

pubspec.yaml in client and server

dependencies:
  my_shared_package:
    path: ../my_shared_package

Rat Jo

unread,
Sep 17, 2014, 5:58:58 PM9/17/14
to mi...@dartlang.org
Sorry, I was talking about package..

I want to have mysql package only for the server code and all other package (bootstrap, dquery, google_maps, intl, mime, rikolu, ...)

Günter Zöchbauer

unread,
Sep 18, 2014, 3:00:14 AM9/18/14
to mi...@dartlang.org
There were bugs related to this code layout but I thought they are all fixed.
What looks weird is your public directory.
You have index.html, index.dart and pubspec.yaml in the same directory.
index.html and index.dart need to be in the web subdirectory of your package.

-> public
---> pubspec.yaml
---> web
-----> index.html
-----> index.dart


I would discourage using such a layout anyway.
Make all packages related to one application on the same directory level

myapp
--> client
----> pubspec.yaml
----> web
------> index.html
------> index.dart
----> lib
------> other files

--> server
----> pubspec.yaml
----> bin
------> main.dart
----> lib
------> other files

--> shared
----> pubspec.yaml
----> lib
------> other files

The only disadvantage you have from this layout is that DartEditor doesn't show the entire code in one folder.
If this is what bothers you you can use workspaces in DartEditor.
To use workspaces you need to add a command line argument

DartEditor -data myworkspaces/my_cool_app

If you have other reasons please share so we can discuss how to avoid them.
Reply all
Reply to author
Forward
0 new messages