I’m currently migrating my project from Maven to Gradle. And one of my maven pom.xml has a plugins like follows:
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>org.objectweb</pattern>
<shadedPattern>blablabla.org.objectweb</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
And in my build.gradle, I wrote something like follows.
apply plugin: 'com.github.johnrengelman.plugin-shadow'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
}
}
shadowJar {
baseName = 'original-' + project.name
classifier = null
relocate 'org.objectweb', 'blablabla.org.objectweb'
}
The result is that it do generate a shadow .jar file. But after I compare this jar file with the one from Maven. I unjar them. They have different directory structure and several .class files are in different folders.
I’m not sure I did it correctly. Based on my understanding, I think they should generate the exactly some .jar. Could someone help me if I did something wrong here? Thank you.