简体   繁体   中英

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM