Skip to content

Commit f922aa2

Browse files
SNOW-1003783: Fix multi-release jar entries (#1621)
1 parent 455ba17 commit f922aa2

File tree

3 files changed

+78
-60
lines changed

3 files changed

+78
-60
lines changed

FIPS/pom.xml

+32-4
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,7 @@
567567
<exclude>META-INF/DEPENDENCIES</exclude>
568568
<exclude>META-INF/maven/**</exclude>
569569
<exclude>META-INF/services/com.fasterxml.*</exclude>
570-
<!-- jackson became a multi-release JAR since 2.15.x -->
571-
<!-- will need to exclude META-INF/versions/17 and META-INF/versions/19 until we move to newer Java versions -->
572-
<exclude>META-INF/versions/17/**</exclude>
573-
<exclude>META-INF/versions/19/**</exclude>
570+
<exclude>META-INF/versions/9/module-info.*</exclude>
574571
<exclude>META-INF/*.xml</exclude>
575572
<exclude>META-INF/*.SF</exclude>
576573
<exclude>META-INF/*.DSA</exclude>
@@ -618,6 +615,37 @@
618615
</execution>
619616
</executions>
620617
</plugin>
618+
<plugin>
619+
<!-- relocate the META-INF/versions files manually due to the maven bug -->
620+
<!-- https://issues.apache.org/jira/browse/MSHADE-406 -->
621+
<groupId>org.apache.maven.plugins</groupId>
622+
<artifactId>maven-antrun-plugin</artifactId>
623+
<executions>
624+
<execution>
625+
<id>repack</id>
626+
<goals>
627+
<goal>run</goal>
628+
</goals>
629+
<phase>package</phase>
630+
<configuration>
631+
<target>
632+
<unzip dest="${project.build.directory}/relocate" src="${project.build.directory}/${project.build.finalName}.jar"/>
633+
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
634+
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/17/${relocationBase}"/>
635+
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/19/${relocationBase}"/>
636+
<!-- com.fasterxml.* packages are relocated to ${relocationBase}.fasterxml.* -->
637+
<move file="${project.build.directory}/relocate/META-INF/versions/11/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
638+
<move file="${project.build.directory}/relocate/META-INF/versions/17/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/17/${relocationBase}"/>
639+
<move file="${project.build.directory}/relocate/META-INF/versions/19/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/19/${relocationBase}"/>
640+
<zip basedir="${project.build.directory}/relocate" destfile="${project.build.directory}/${project.build.finalName}.jar"/>
641+
<delete dir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
642+
<delete dir="${project.build.directory}/relocate/META-INF/versions/17/${relocationBase}"/>
643+
<delete dir="${project.build.directory}/relocate/META-INF/versions/19/${relocationBase}"/>
644+
</target>
645+
</configuration>
646+
</execution>
647+
</executions>
648+
</plugin>
621649
</plugins>
622650
</build>
623651
</profile>

ci/scripts/check_content.sh

+5
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ if jar tvf $DIR/../../target/snowflake-jdbc${package_modifier}.jar | awk '{prin
1212
echo "[ERROR] JDBC jar includes class not under the snowflake namespace"
1313
exit 1
1414
fi
15+
16+
if jar tvf $DIR/../../target/snowflake-jdbc${package_modifier}.jar | awk '{print $8}' | grep -E "^META-INF/versions/.*.class" | grep -v -E "^META-INF/versions/.*/(net|com)/snowflake"; then
17+
echo "[ERROR] JDBC jar includes multi release classes not under the snowflake namespace"
18+
exit 1
19+
fi

pom.xml

+41-56
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@
167167
<sortDependencyExclusions>groupId,artifactId</sortDependencyExclusions>
168168
<sortExecutions>true</sortExecutions>
169169
<sortModules>true</sortModules>
170-
<sortPlugins>groupId,artifactId</sortPlugins>
171170
<sortProperties>true</sortProperties>
172171
<verifyFail>stop</verifyFail>
173172
<verifyFailOn>strict</verifyFailOn>
@@ -609,33 +608,6 @@
609608
</execution>
610609
</executions>
611610
</plugin>
612-
<plugin>
613-
<!-- relocate the META-INF/versions files manually due to the maven bug -->
614-
<!-- https://issues.apache.org/jira/browse/MSHADE-406 -->
615-
<groupId>org.apache.maven.plugins</groupId>
616-
<artifactId>maven-antrun-plugin</artifactId>
617-
<executions>
618-
<execution>
619-
<id>repack</id>
620-
<goals>
621-
<goal>run</goal>
622-
</goals>
623-
<phase>package</phase>
624-
<configuration>
625-
<target>
626-
<unzip dest="${project.build.directory}/relocate" src="${project.build.directory}/${project.build.finalName}.jar"/>
627-
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/9/${relocationBase}"/>
628-
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
629-
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/15/${relocationBase}"/>
630-
<zip basedir="${project.build.directory}/relocate" destfile="${project.build.directory}/${project.build.finalName}.jar"/>
631-
<delete dir="${project.build.directory}/relocate/META-INF/versions/9/${relocationBase}"/>
632-
<delete dir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
633-
<delete dir="${project.build.directory}/relocate/META-INF/versions/15/${relocationBase}"/>
634-
</target>
635-
</configuration>
636-
</execution>
637-
</executions>
638-
</plugin>
639611
<plugin>
640612
<!-- google linkage checker doesn't work well with shaded jar, disable the check in this case for now -->
641613
<groupId>org.apache.maven.plugins</groupId>
@@ -697,7 +669,6 @@
697669
<exclude>META-INF/NOTICE*</exclude>
698670
<exclude>META-INF/DEPENDENCIES</exclude>
699671
<exclude>META-INF/maven/**</exclude>
700-
<exclude>META-INF/services/com.fasterxml.*</exclude>
701672
<exclude>META-INF/*.xml</exclude>
702673
<exclude>META-INF/*.SF</exclude>
703674
<exclude>META-INF/*.DSA</exclude>
@@ -781,33 +752,6 @@
781752
</activation>
782753
<build>
783754
<plugins>
784-
<plugin>
785-
<!-- relocate the META-INF/versions files manually due to the maven bug -->
786-
<!-- https://issues.apache.org/jira/browse/MSHADE-406 -->
787-
<groupId>org.apache.maven.plugins</groupId>
788-
<artifactId>maven-antrun-plugin</artifactId>
789-
<executions>
790-
<execution>
791-
<id>repack</id>
792-
<goals>
793-
<goal>run</goal>
794-
</goals>
795-
<phase>package</phase>
796-
<configuration>
797-
<target>
798-
<unzip dest="${project.build.directory}/relocate" src="${project.build.directory}/${project.build.finalName}.jar"/>
799-
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/9/${relocationBase}"/>
800-
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
801-
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/15/${relocationBase}"/>
802-
<zip basedir="${project.build.directory}/relocate" destfile="${project.build.directory}/${project.build.finalName}.jar"/>
803-
<delete dir="${project.build.directory}/relocate/META-INF/versions/9/${relocationBase}"/>
804-
<delete dir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
805-
<delete dir="${project.build.directory}/relocate/META-INF/versions/15/${relocationBase}"/>
806-
</target>
807-
</configuration>
808-
</execution>
809-
</executions>
810-
</plugin>
811755
<plugin>
812756
<!-- google linkage checker doesn't work well with shaded jar, disable the check in this case for now -->
813757
<groupId>org.apache.maven.plugins</groupId>
@@ -1010,6 +954,7 @@
1010954
<exclude>META-INF/DEPENDENCIES</exclude>
1011955
<exclude>META-INF/maven/**</exclude>
1012956
<exclude>META-INF/services/com.fasterxml.*</exclude>
957+
<exclude>META-INF/versions/9/module-info.*</exclude>
1013958
<exclude>META-INF/*.xml</exclude>
1014959
<exclude>META-INF/*.SF</exclude>
1015960
<exclude>META-INF/*.DSA</exclude>
@@ -1059,6 +1004,46 @@
10591004
</execution>
10601005
</executions>
10611006
</plugin>
1007+
<plugin>
1008+
<!-- relocate the META-INF/versions files manually due to the maven bug -->
1009+
<!-- https://issues.apache.org/jira/browse/MSHADE-406 -->
1010+
<groupId>org.apache.maven.plugins</groupId>
1011+
<artifactId>maven-antrun-plugin</artifactId>
1012+
<executions>
1013+
<execution>
1014+
<id>repack</id>
1015+
<goals>
1016+
<goal>run</goal>
1017+
</goals>
1018+
<phase>package</phase>
1019+
<configuration>
1020+
<target>
1021+
<unzip dest="${project.build.directory}/relocate" src="${project.build.directory}/${project.build.finalName}.jar"/>
1022+
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/9/${relocationBase}"/>
1023+
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
1024+
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/15/${relocationBase}"/>
1025+
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/17/${relocationBase}"/>
1026+
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/19/${relocationBase}"/>
1027+
<!-- org.bouncycastle.* packages are relocated to ${relocationBase}.org.bouncycastle.* -->
1028+
<move file="${project.build.directory}/relocate/META-INF/versions/9/org" todir="${project.build.directory}/relocate/META-INF/versions/9/${relocationBase}"/>
1029+
<move file="${project.build.directory}/relocate/META-INF/versions/11/org" todir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
1030+
<move file="${project.build.directory}/relocate/META-INF/versions/15/org" todir="${project.build.directory}/relocate/META-INF/versions/15/${relocationBase}"/>
1031+
<!-- com.fasterxml.* packages are relocated to ${relocationBase}.fasterxml.* -->
1032+
<move file="${project.build.directory}/relocate/META-INF/versions/11/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
1033+
<move file="${project.build.directory}/relocate/META-INF/versions/17/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/17/${relocationBase}"/>
1034+
<move file="${project.build.directory}/relocate/META-INF/versions/19/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/19/${relocationBase}"/>
1035+
<zip basedir="${project.build.directory}/relocate" destfile="${project.build.directory}/${project.build.finalName}.jar"/>
1036+
<delete dir="${project.build.directory}/relocate/META-INF/versions/9/${relocationBase}"/>
1037+
<delete dir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
1038+
<delete dir="${project.build.directory}/relocate/META-INF/versions/15/${relocationBase}"/>
1039+
<delete dir="${project.build.directory}/relocate/META-INF/versions/17/${relocationBase}"/>
1040+
<delete dir="${project.build.directory}/relocate/META-INF/versions/19/${relocationBase}"/>
1041+
</target>
1042+
</configuration>
1043+
</execution>
1044+
</executions>
1045+
</plugin>
1046+
10621047
<plugin>
10631048
<groupId>org.codehaus.mojo</groupId>
10641049
<artifactId>buildnumber-maven-plugin</artifactId>

0 commit comments

Comments
 (0)