Open Source & Free  

TIP: Nest cn1libs Cross Dependencies

TIP: Nest cn1libs Cross Dependencies

Header Image

On occasion developers ask us for cn1lib dependencies, e.g. allowing one cn1lib to use functionality in another cn1lib. This isn’t something we rolled into the cn1lib infrastructure because we strongly believe in simplicity. Dependency management solutions become fragile once nesting sets in and often mask over-engineering which is really dangerous for a tool that depends on small footprint.

A cn1lib is really just an ant project that packages the results into a zip containing nested zips with the data relevant to all the platforms. To add another cn1lib lib to the classpath first you need to unzip that cn1lib.

The file from the cn1lib will include the classes you need to compile. Now we can just add that to our compile path by editing the build.xml file. We can change the javac statement to include that file:

<javac destdir="build/tmp"
    <src path="${src.dir}"/>

This will only solve a part of the problem, we also need to edit the classpath in the IDE settings if you are in NetBeans we can do this for both NetBeans and IntelliJ by editing the nbproject/ file:


Now the dependency will exist, notice you will need to have both your cn1lib and the dependent cn1lib installed in the project. That’s why our library extension tool supports the declaration of dependencies when you submit your library.

1 Comment

Leave a Reply