derteufelqwe
derteufelqwe

Reputation: 151

Can maven or gradle relocate dependencies on import?

I need a way for maven (or if maven doesn't work gradle) to relocate a dependency when importing it in the <dependencies> part of my pom.xml

Relocating the dependency when I build my jar doesn't work too well because intellij isn't able to debug the shaded code anymore.

I imagine something like this

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.10</version>
    <scope>provided</scope>
    <relocatedName>shaded.org.projectlombok</relocatedName>
</dependency>

Upvotes: 1

Views: 985

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35843

No, not possible in Maven.

You can shade a dependency with the Maven shade plugin (this is probably what you meant with "during build"), but you cannot generally shade it.

The only way I would see would be to build the third-party artifact from source with different project names or to do manipulation in the third-party jar itself and republish it to your (local) repository.

Upvotes: 2

Related Questions