Skip to content

Commit 2e11f55

Browse files
committed
fix: resolving jersey 2.x and 3.x conflict for code dx scan task
1 parent 3115fd5 commit 2e11f55

6 files changed

Lines changed: 380 additions & 130 deletions

File tree

jersey-shaded/pom.xml

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
6+
<modelVersion>4.0.0</modelVersion>
7+
<groupId>com.codedx</groupId>
8+
<artifactId>jersey-shaded</artifactId>
9+
<version>2.0.1</version>
10+
<packaging>jar</packaging>
11+
<name>Jersey 3.x Shaded (relocated to com.codedx.shaded.*)</name>
12+
<description>
13+
Shades Jersey 3.x and HK2 into com.codedx.shaded.jersey.* and com.codedx.shaded.hk2.*
14+
so they do not conflict with Bamboo's parent-first org.glassfish.jersey.* packages.
15+
</description>
16+
17+
<properties>
18+
<jersey-version>3.1.11</jersey-version>
19+
<jakarta-annotation-version>2.1.1</jakarta-annotation-version>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
<maven.compiler.source>21</maven.compiler.source>
22+
<maven.compiler.target>21</maven.compiler.target>
23+
</properties>
24+
25+
<dependencies>
26+
<!-- Jersey client and its transitive deps -->
27+
<dependency>
28+
<groupId>org.glassfish.jersey.core</groupId>
29+
<artifactId>jersey-client</artifactId>
30+
<version>${jersey-version}</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.glassfish.jersey.inject</groupId>
34+
<artifactId>jersey-hk2</artifactId>
35+
<version>${jersey-version}</version>
36+
<exclusions>
37+
<exclusion>
38+
<groupId>jakarta.inject</groupId>
39+
<artifactId>jakarta.inject-api</artifactId>
40+
</exclusion>
41+
</exclusions>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.glassfish.jersey.media</groupId>
45+
<artifactId>jersey-media-multipart</artifactId>
46+
<version>${jersey-version}</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.glassfish.jersey.media</groupId>
50+
<artifactId>jersey-media-json-jackson</artifactId>
51+
<version>${jersey-version}</version>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.glassfish.jersey.connectors</groupId>
55+
<artifactId>jersey-apache-connector</artifactId>
56+
<version>${jersey-version}</version>
57+
<exclusions>
58+
<exclusion>
59+
<groupId>commons-codec</groupId>
60+
<artifactId>commons-codec</artifactId>
61+
</exclusion>
62+
<exclusion>
63+
<groupId>org.apache.httpcomponents</groupId>
64+
<artifactId>httpclient</artifactId>
65+
</exclusion>
66+
<exclusion>
67+
<groupId>org.apache.httpcomponents</groupId>
68+
<artifactId>httpcore</artifactId>
69+
</exclusion>
70+
</exclusions>
71+
</dependency>
72+
<!-- jakarta.ws.rs-api: NOT relocated — keep original package name.
73+
Excluded from shading so the plugin module can embed it separately. -->
74+
<dependency>
75+
<groupId>jakarta.ws.rs</groupId>
76+
<artifactId>jakarta.ws.rs-api</artifactId>
77+
<version>3.1.0</version>
78+
<scope>provided</scope>
79+
</dependency>
80+
<!-- jakarta.annotation-api: excluded from shading; plugin embeds it separately -->
81+
<dependency>
82+
<groupId>jakarta.annotation</groupId>
83+
<artifactId>jakarta.annotation-api</artifactId>
84+
<version>${jakarta-annotation-version}</version>
85+
<scope>provided</scope>
86+
</dependency>
87+
</dependencies>
88+
89+
<build>
90+
<plugins>
91+
<plugin>
92+
<groupId>org.apache.maven.plugins</groupId>
93+
<artifactId>maven-shade-plugin</artifactId>
94+
<version>3.5.3</version>
95+
<executions>
96+
<execution>
97+
<phase>package</phase>
98+
<goals>
99+
<goal>shade</goal>
100+
</goals>
101+
<configuration>
102+
<!-- The output JAR IS the main artifact (no classifier) -->
103+
<shadedArtifactAttached>false</shadedArtifactAttached>
104+
<createDependencyReducedPom>false</createDependencyReducedPom>
105+
<relocations>
106+
<!-- Relocate Jersey 3.x away from parent-first org.glassfish.jersey.* -->
107+
<relocation>
108+
<pattern>org.glassfish.jersey</pattern>
109+
<shadedPattern>com.codedx.shaded.jersey</shadedPattern>
110+
</relocation>
111+
<!-- Relocate HK2 away from parent-first org.glassfish.hk2.* -->
112+
<relocation>
113+
<pattern>org.glassfish.hk2</pattern>
114+
<shadedPattern>com.codedx.shaded.hk2</shadedPattern>
115+
</relocation>
116+
<relocation>
117+
<pattern>org.jvnet.hk2</pattern>
118+
<shadedPattern>com.codedx.shaded.jvnet.hk2</shadedPattern>
119+
</relocation>
120+
<relocation>
121+
<pattern>org.jvnet.tiger_types</pattern>
122+
<shadedPattern>com.codedx.shaded.jvnet.tiger_types</shadedPattern>
123+
</relocation>
124+
<relocation>
125+
<pattern>org.aopalliance</pattern>
126+
<shadedPattern>com.codedx.shaded.aopalliance</shadedPattern>
127+
</relocation>
128+
</relocations>
129+
<filters>
130+
<!-- Exclude server-side Jersey JARs entirely if accidentally pulled in -->
131+
<filter>
132+
<artifact>org.glassfish.jersey.core:jersey-server</artifact>
133+
<excludes>
134+
<exclude>**</exclude>
135+
</excludes>
136+
</filter>
137+
<filter>
138+
<artifact>org.glassfish.jersey.containers:*</artifact>
139+
<excludes>
140+
<exclude>**</exclude>
141+
</excludes>
142+
</filter>
143+
<!-- Exclude Jackson from the shaded JAR — the plugin module
144+
embeds Jackson separately. Including it here causes duplicate
145+
class warnings and potential version conflicts. -->
146+
<filter>
147+
<artifact>com.fasterxml.jackson.core:*</artifact>
148+
<excludes>
149+
<exclude>**</exclude>
150+
</excludes>
151+
</filter>
152+
<filter>
153+
<artifact>com.fasterxml.jackson.module:*</artifact>
154+
<excludes>
155+
<exclude>**</exclude>
156+
</excludes>
157+
</filter>
158+
<!-- Remove ALL multi-release JAR entries (META-INF/versions/*).
159+
The shade plugin does NOT relocate classes inside META-INF/versions/,
160+
so they would still have org.glassfish.jersey.* paths. AMPS extracts
161+
these entries and places them at the root, defeating the relocation.
162+
We don't need virtual thread support for this OSGi plugin. -->
163+
<filter>
164+
<artifact>*:*</artifact>
165+
<excludes>
166+
<exclude>META-INF/versions/**</exclude>
167+
<exclude>module-info.class</exclude>
168+
<exclude>META-INF/MANIFEST.MF</exclude>
169+
</excludes>
170+
</filter>
171+
</filters>
172+
<!-- ServicesResourceTransformer rewrites META-INF/services entries
173+
to use the relocated class names -->
174+
<transformers>
175+
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
176+
</transformers>
177+
</configuration>
178+
</execution>
179+
</executions>
180+
</plugin>
181+
</plugins>
182+
</build>
183+
184+
</project>

0 commit comments

Comments
 (0)