1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | < project > < modelVersion >4.0.0</ modelVersion > < groupId >org.fredy</ groupId > < artifactId >shaded</ artifactId > < version >0.0.1</ version > < properties > < maven.compiler.source >1.8</ maven.compiler.source > < maven.compiler.target >1.8</ maven.compiler.target > </ properties > < dependencies > < dependency > < groupId >org.fredy</ groupId > < artifactId >myjar</ artifactId > < version >0.0.1</ version > </ dependency > < dependency > < groupId >junit</ groupId > < artifactId >junit</ artifactId > < version >4.12</ version > </ dependency > </ dependencies > < build > < plugins > < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-shade-plugin</ artifactId > < version >3.0.0</ version > < configuration > < relocations > < relocation > < pattern >com.google.common</ pattern > < shadedPattern >org.fredy.com.google.common</ shadedPattern > </ relocation > </ relocations > </ configuration > < executions > < execution > < phase >package</ phase > < goals > < goal >shade</ goal > </ goals > < configuration > < filters > < filter > < artifact >*:*</ artifact > < excludes > < exclude >META-INF/*.SF</ exclude > < exclude >META-INF/*.DSA</ exclude > < exclude >META-INF/*.RSA</ exclude > </ excludes >1 </ filter > </ filters > < promoteTransitiveDependencies >true</ promoteTransitiveDependencies > < transformers > < transformer implementation = "org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> </ transformers > </ configuration > </ execution > </ executions > </ plugin > </ plugins > </ build > </ project > |
Thursday, April 6, 2017
How to Shade a JAR and Relocate Classes in Maven
The example below shows how to shade org.fredy.myjar and guava JARS and rename the Guava classes that contain com.google.guava to org.fredy.com.google.guava.
Subscribe to:
Posts (Atom)