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

**URL:** <https://community.haxe.org/t/how-to-exclude-folder-from-classpath-with-the-hxml-include-macro-solved/2152>\
**Category:** Haxe\
**Tags:** hxml\
**Created:** [November 20, 2019, 10:52am UTC](https://community.haxe.org/t/how-to-exclude-folder-from-classpath-with-the-hxml-include-macro-solved/2152 "2019-11-20T10:52:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haath](https://community.haxe.org/user_avatar/community.haxe.org/haath/32/2174_2.png) [@Haath](https://community.haxe.org/u/Haath)\
**Post date:** [November 20, 2019, 10:52am UTC](https://community.haxe.org/t/how-to-exclude-folder-from-classpath-with-the-hxml-include-macro-solved/2152/1 "2019-11-20T10:52:48Z")

</div>

Hello guys,

I have a classpath folder structure that looks like this:

```haxe
src
├── client
├── server
└── shared

```

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

```haxe
# 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:

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

```

Gives an error similar to:

```haxe
(unknown): Type not found SomeClassInClient

```

Which I’m assuming happens because it can no longer resolve `package client.foo.bar` 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.

---

<div class="post-metadata">

**Author:** ![ibilon](https://community.haxe.org/user_avatar/community.haxe.org/ibilon/32/13_2.png) [@ibilon](https://community.haxe.org/u/ibilon)\
**Post date:** [November 20, 2019, 11:39am UTC](https://community.haxe.org/t/how-to-exclude-folder-from-classpath-with-the-hxml-include-macro-solved/2152/2 "2019-11-20T11:39:39Z")

</div>

The signature of include is `include (pack:String, rec:Bool = true, ?ignore:Array<String>, ?classPaths:Array<String>, strict:Bool = false):Void` (see [haxe.macro.Compiler - Haxe 4.2.1 API](https://api.haxe.org/haxe/macro/Compiler.html#include))

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

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

```

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

---

<div class="post-metadata">

**Author:** ![Haath](https://community.haxe.org/user_avatar/community.haxe.org/haath/32/2174_2.png) [@Haath](https://community.haxe.org/u/Haath)\
**Post date:** [November 20, 2019, 12:05pm UTC](https://community.haxe.org/t/how-to-exclude-folder-from-classpath-with-the-hxml-include-macro-solved/2152/3 "2019-11-20T12:05:04Z")

</div>

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…

 ![image](https://community.haxe.org/uploads/default/original/2X/0/0d3b5911fd1379a16f52a25288e1c70946b9daf0.png)

* * *

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.

---

<div class="post-metadata">

**Author:** ![ibilon](https://community.haxe.org/user_avatar/community.haxe.org/ibilon/32/13_2.png) [@ibilon](https://community.haxe.org/u/ibilon)\
**Post date:** [November 20, 2019, 12:09pm UTC](https://community.haxe.org/t/how-to-exclude-folder-from-classpath-with-the-hxml-include-macro-solved/2152/4 "2019-11-20T12:09:57Z")

</div>

You use them so they have to be included.

In that case I’d do this

```haxe
src
  - shared
src-client
  - client
src-server
  - server

```

And in your client.hxml

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

```

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

---

<div class="post-metadata">

**Author:** ![Haath](https://community.haxe.org/user_avatar/community.haxe.org/haath/32/2174_2.png) [@Haath](https://community.haxe.org/u/Haath)\
**Post date:** [November 20, 2019, 12:13pm UTC](https://community.haxe.org/t/how-to-exclude-folder-from-classpath-with-the-hxml-include-macro-solved/2152/5 "2019-11-20T12:13:21Z")

</div>

> [@ibilon](#):
>
> You use them so they have to be included.

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 🙂
