Disabling pages, layout and parts from lib

Enonic version: 6.7.1
OS: Mac and Linux

So we have started modularizing our code into libraries.
Now comes the problem that a lib sometimes comes with more than you want.

So lets say a library L contains parts X, Y and Z.

  • App A needs part X and Y, but not Z.
  • App B needs Y and Z, but not X.
  • App C needs Z and X, but not Y.

I would like some way either buildtime to not package the unwanted parts into the jar file.

Or runtime, so that you could in Application disable some parts.

Sounds like you need to split things into three libraries, x, y and z.
Either way, I guess it would be nice to “leave out” selected elements of a library when including it, or at least from the final build.

@srs do you know any Gradle tricks for this?

You could easily create a project with multiple subprojects in Gradle. So, create 3 sub-projects: X, Y and Z and publish them to your local (or remote repository). Then the apps could grab what they need.

What about filtering out selected files from a lib during the build? Is that possible?

Yes, but I think it’s easier to have subprojects.

I know the answer right now is spend a lot of time on setting up a complicated build environment with a bunch of dependencies, etc.

It would be much easier if components could be disabled per site though :slight_smile:

Note: In addition to this there could be granulated permissions on components, so only some people are allowed to see or edit them.

We prefer keeping things as simple as possible at the moment - granularity in “who can use what parts”, disabling things in UI etc is going to complicate things exponentially, and will likely not happen in the forseable future. Some smart build-features to “ignore/skip” files from being included in the app is a much better solution imho.

How are subprojects solving the case that you want to skip one or more parts from a lib when building?

Does not solve it, but it’s better to split up in different subprojects (artifacts) and have the artifacts stable and not changing depending on the “build”-environment.

So, if you need libs, then you are thinking reusability. Then you will need to construct your libs so that the libs is the smallest pieces to build your application with.

My suggestion then is to create a lib for each X, Y and Z.