How to exclude folder from classpath with the HXML include macro? (SOLVED)

Hello guys,

I have a classpath folder structure that looks like this:

├── client
├── server
└── shared

And I’m trying to create a client.hxml, which only compiles classes in the client and shared folders.

# This I'm assuming is necessary so that packages can be located 
# with their full package names
-cp src

--macro include("", true, ["server*"], ["src"])

However building this, it would appear as if the ignore parameter of include() has no effect.
I tested it by making a class in client use a class from the server package, and the whole thing compiled without errors with the server class ending up in the output file. I do not want this to be possible.

Changing it to this:

--macro include("", true, [""], ["src/client", "src/shared"])

Gives an error similar to:

(unknown): Type not found SomeClassInClient

Which I’m assuming happens because it can no longer resolve package since its top-level is now the src/client folder?

So how should I go about doing this? Is there some better practice to achieve a similar project structure that I’m not following?

Some more information in case it’s relevant:

  • The target is lua.
  • There is no main, client is a library.

The signature of include is include (pack:String, rec:Bool = true, ?ignore:Array<String>, ?classPaths:Array<String>, strict:Bool = false):Void (see

So if you want to include all from the client and shared packages you can do:

--macro include("client")
--macro include("shared")

The calls adds to each other so it’s fine to have multiple of them.

Thank you for the suggestion. I tested it out and unfortunately it didn’t work.
As you can see in the following screenshot, both of the other packages ended up in the compiled output file, despite not being included in the hxml…

What I want is for the server folder to basically not exist when building client.hxml, referencing any of its classes should result in an error.

You use them so they have to be included.

In that case I’d do this

  - shared
  - client
  - server

And in your client.hxml

-cp src
-cp src-client
--macro include("client")

That way you won’t have access to the server package at all.

Ye the point of it was that I or the editor extension would be prevented from accidentally importing them and giving them as suggestions or putting them in the output.

I will do it the way you recommended, thank you :slight_smile: