class override (same full class name)

following up with https://lwpro2.dev/2021/12/28/maven-nested-modules/ and https://lwpro2.dev/2021/12/14/microservies-in-monorepo/, there are times where a class defined upstream (either third party or shared library internally) should be overriden.

The trick is to keep the class name exact with the same package name. when maven shaded the class, it would pick up the class from the closest level.

For example, if module ACore has a class names org.wordpress.util.DomainMapper, a class with the exact same name org.wordpress.util.DomainMapper could be created in A1 module to override the provided functionality.

when build module A with -amd, it would generated a A2 jar, which contains the compiled class binary from ACore. while the generated A1 jar, would contain the override class created in A1 module.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s