www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Import sources from parent project

reply Andrey <saasecondbox yandex.ru> writes:
Hi,
I have got this structure of my project:
 parentapp
     dub.json
     source
         common.d
     childapp1
         dub.json
         source
             app.d
             somefile.d
     childapp2
         dub.json
         source
             app.d
The "childapp1" and "childapp2" are standanole subprograms. I want to import file "common.d" in both "app.d". How to do it correctly? I tried to write "import common;" but got error: " Error: module `common` is in file 'common.d' which cannot be read". In "parentapp/dub.json" I also added these lines:
 "dependencies": {
     "parentapp:childapp1": "*",
     "parentapp:childapp2": "*"
 },
 "subPackages": [
     "./childapp1/",
     "./childapp2/"
 ]
Oct 19 2019
parent reply Andre Pany <andre s-e-a-p.de> writes:
On Saturday, 19 October 2019 at 18:00:12 UTC, Andrey wrote:
 Hi,
 I have got this structure of my project:
 parentapp
     dub.json
     source
         common.d
     childapp1
         dub.json
         source
             app.d
             somefile.d
     childapp2
         dub.json
         source
             app.d
The "childapp1" and "childapp2" are standanole subprograms. I want to import file "common.d" in both "app.d". How to do it correctly? I tried to write "import common;" but got error: " Error: module `common` is in file 'common.d' which cannot be read". In "parentapp/dub.json" I also added these lines:
 "dependencies": {
     "parentapp:childapp1": "*",
     "parentapp:childapp2": "*"
 },
 "subPackages": [
     "./childapp1/",
     "./childapp2/"
 ]
Hi, In dub.json of your child apps you need to add a dependency to parentapp. Kind regards Andre
Oct 19 2019
parent reply Andrey <saasecondbox yandex.ru> writes:
On Saturday, 19 October 2019 at 18:54:28 UTC, Andre Pany wrote:
 In dub.json of your child apps you need to add a dependency to 
 parentapp.
I added via "dependencies" parameter and after got this error: "Detected dependency cycle".
Oct 20 2019
parent Andre Pany <andre s-e-a-p.de> writes:
On Sunday, 20 October 2019 at 10:04:56 UTC, Andrey wrote:
 On Saturday, 19 October 2019 at 18:54:28 UTC, Andre Pany wrote:
 In dub.json of your child apps you need to add a dependency to 
 parentapp.
I added via "dependencies" parameter and after got this error: "Detected dependency cycle".
Does your main package needs access to the sub packages? If not, remove the dependencies section. If you need access move the common module into an own sub package. Kind regards Andre
Oct 20 2019