Creating outputs without the standard library

I’m building some utility libraries for use within our projects with haxe as the source, and targeting a few different platforms - java, javascript, and c++ primarily. It’s been working quite well, but I’m starting to run into a few issues with the packaging of the libraries that I’m trying to find a solution for.

As an example, say that I have a utility library in Haxe for parameter validation, which targets Java and generates a jar file. I also have a database library written in haxe, which references the validation library, targets Java, and generates a jar file. So from these two projects, both the jar files include the compiled standard library and the validation library. So when I build a java program that happens to use both of these libraries, the standard and validation libraries are included on the classpath twice. This can lead to issues if for example the validation library is updated to a new version but the database library is not recompiled - you end up with two versions of the same code on the classpath, which can lead to issues.

What I was considering, at least for the java case, is as a post processing step stripping out any code from the jar file that is not part of the source of the project being compiled: so the validation library will only include the validation classes, the database library will only include the database classes, etc. Then I can create a jar file that contains the standard library compiled for java, and include all three jar’s on the classpath. That should provide all the necessary compiled code at runtime, but obviously wouldn’t work for all targets (e.g. javascript could be an issue to post process). Another thing that I was considering is just trying to build all of my utility libraries that come from haxe source into a single library, but that doesn’t fit as well with our project structure.

Is there something else that I’m missing that could solve this issue? I think at its heart what I’m looking for is a way to filter the outputted code so that it only includes code compiled from the current project.

Being in the same situation some time ago, I did not find a nice solution to remove default entry point (main func) which may provide a duplicate symbol exception,
but Haxe has initialization macros for something like you want:

So you can try to play with it a bit.

That does look promising - thanks for the pointer!

GitHub - paulfitz/daff: align and compare tables,
may be helpful