Struggling to import a package from relative subpath

98 views
Skip to first unread message

Víctor R. Escobar

unread,
Sep 20, 2015, 12:46:33 PM9/20/15
to Haxe
Hello everybody,

I am learning Haxe by implementing small examples, and today I decided to refactor a little bit one of the examples I did and separate one class in a whole different package to reuse it later, and then import it in the original project. I can't import it or complete a single compilation since I separated them, I am not sure why because the error message is not much descriptive :(

Here is the project path which imports the code:

~/projects/elm2openfl/Events/mouse/stamps

~/projects/elm2openfl/Events/mouse/stamps

$ tree

.

├── Makefile

├── Source

│   └── Main.hx

├── assets

│   └── openfl.svg

├── project.xml

└── stamps.iml



project.xml contains a line with: <include path="../../../Elm/Graphics/project.xml" />
Main.hx contains: import elm.graphics.Collage.Ngon;


And here is the package I wanted to abstract which is matching the mentioned relative path:

~/projects/elm2openfl/Elm/Graphics

$ tree

.

├── Graphics.iml

├── project.xml

└── src

    └── Collage.hx



Collage.hx declares: package elm.graphics;
And project.xml:
<?xml version="1.0" encoding="utf-8"?>
<project>
<meta title="Elm Graphics" package="elm.graphics.Collage" version="1.0.0" company="Company Name" />
<app main="Collage" path="Export" file="Graphics" />
<source path="src" />
<haxelib name="openfl" />
</project>


When I am in the path for stamps and I try to compile, that's everything I get:

$ haxelib run lime test project.xml neko -j16

--macro:1: character 0 : Invalid package : <empty> should be elm.graphics


I tried several renames of the folder also in case "Collage" may not be appropriate with capital C or perhaps by removing the class declared into the module but it made no change. Does anyone have an idea about how to declare properly a package and include it from my filesystem into another project?

Thank you so much in advance!

P.S. The setup is haxelib standard (non modified libraries or paths) everything is updated from the current week.info

Víctor R. Escobar

unread,
Sep 20, 2015, 4:03:41 PM9/20/15
to Haxe
Hello again,

I couldn't stop trying about it and re-read the documentation plus forums, so I found the reason of the problem was the package name must match the actual path from the project.xml of the *.hx file which declares the package. For some reason for me it was not too much obvious and I wasted quite some time there...


Now that everything compiles, I can import elm.graphics.Collage in my project (which is what I wanted) and the directory layout looks like the next:

├── Elm
├── ...
── graphics
  └── Collage.hx //  Includes the class Ngon which I mentioned previously
├── Events
└── mouse
.......
├── stamps
├── Makefile

├── Source
└── Main.hx
├── assets
└── openfl.svg
├── project.xml
└── ...
....


In case someone took the time to read it, thank you anyway.
Reply all
Reply to author
Forward
0 new messages