在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
dart里目前不清楚可不可以像Java一样指定一个classpath option(看了下dart --help好像--packages很像,但是可能是我path格式有问题,反正没成功),但是可以在dart项目根目录里添加 .dart_tool 目录,然后在里面添加 package_config.json 文件, 然后文件里写这样的配置即可实现将其他地方的库作为此项目的依赖库: { 即,这里用到了三个依赖库(注意,包括递归依赖); 不过它还可以进一步精简: { "configVersion": 2, "packages": [ { "name": "dart_console", "rootUri": "file:///home/silentdoer/.pub-cache/hosted/mirrors.tuna.tsinghua.edu.cn%2547dart-pub/dart_console-0.6.2", "packageUri": "lib/" }, { "name": "ffi", "rootUri": "file:///home/silentdoer/.pub-cache/hosted/mirrors.tuna.tsinghua.edu.cn%2547dart-pub/ffi-0.1.3", "packageUri": "lib/" }, { "name": "win32", "rootUri": "file:///home/silentdoer/.pub-cache/hosted/mirrors.tuna.tsinghua.edu.cn%2547dart-pub/win32-1.6.10", "packageUri": "lib/" } ] } 还能再简化: { "configVersion": 2, "packages": [ { "name": "dart_console", "rootUri": "/home/silentdoer/.pub-cache/hosted/mirrors.tuna.tsinghua.edu.cn%2547dart-pub/dart_console-0.6.2", "packageUri": "lib/" }, { "name": "ffi", "rootUri": "/home/silentdoer/.pub-cache/hosted/mirrors.tuna.tsinghua.edu.cn%2547dart-pub/ffi-0.1.3", "packageUri": "lib/" }, { "name": "win32", "rootUri": "/home/silentdoer/.pub-cache/hosted/mirrors.tuna.tsinghua.edu.cn%2547dart-pub/win32-1.6.10", "packageUri": "lib/" } ] } 而且,rootUri可以用相对路径,注意,它相对的是package_config.json文件的位置 { "configVersion": 2, "packages": [ { "name": "dart_console", "rootUri": "../../packages/dart_console-0.6.2", "packageUri": "lib/" }, { "name": "ffi", "rootUri": "/home/silentdoer/.pub-cache/hosted/mirrors.tuna.tsinghua.edu.cn%2547dart-pub/ffi-0.1.3", "packageUri": "lib/" }, { "name": "win32", "rootUri": "/home/silentdoer/.pub-cache/hosted/mirrors.tuna.tsinghua.edu.cn%2547dart-pub/win32-1.6.10", "packageUri": "lib/" } ] }
而,这里比如dart_console的目录结构(其实就是一个git项目)是这样的: analysis_options.yaml example LICENSE README.md 这里还可以简写成这样: { "configVersion": 2, "packages": [ { "name": "dart_console", "rootUri": "../../packages/dart_console-0.6.2/lib/" }, { "name": "ffi", "rootUri": "../../packages/ffi-0.1.3/lib" }, { "name": "win32", "rootUri": "../../packages/win32-1.6.10/lib" } ] }
|
请发表评论