Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pipeline {
}
}

// Build the local shaded Jersey module first so the root plugin can resolve com.codedx:jersey-shaded
sh 'cd jersey-shaded && atlas-mvn install -DskipTests'
sh 'atlas-unit-test'
sh 'atlas-package'
}
Expand Down
37 changes: 35 additions & 2 deletions jersey-shaded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.codedx</groupId>
<artifactId>jersey-shaded</artifactId>
<version>2.0.1</version>
<version>3.0.0</version>
<packaging>jar</packaging>
<name>Jersey 3.x Shaded (relocated to com.codedx.shaded.*)</name>
<description>
Expand Down Expand Up @@ -91,7 +91,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -168,6 +168,39 @@
<exclude>META-INF/MANIFEST.MF</exclude>
</excludes>
</filter>
<!-- Exclude jakarta.inject, jakarta.activation, and jakarta.xml.bind
from the shaded JAR. These are provided by Bamboo's webapp
classloader (parent-first). Including them in the shaded JAR
causes AMPS to extract them into the plugin bundle root, creating
a classloader split-brain with Bamboo's own copies and resulting
in ClassCastException at runtime. -->
<filter>
<artifact>jakarta.inject:jakarta.inject-api</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
<filter>
<artifact>jakarta.activation:jakarta.activation-api</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
<filter>
<artifact>jakarta.xml.bind:jakarta.xml.bind-api</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
<!-- Exclude javassist — it is a transitive dep of HK2 but is
provided by Bamboo's webapp classloader. Excluding it prevents
AMPS from extracting javassist/ classes into the plugin bundle root. -->
<filter>
<artifact>org.javassist:javassist</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
</filters>
<!-- ServicesResourceTransformer rewrites META-INF/services entries
to use the relocated class names -->
Expand Down
133 changes: 119 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.codedx</groupId>
<artifactId>codedx-bamboo-plugin</artifactId>
<version>2.0.1</version>
<version>3.0.0</version>

<organization>
<name>Code Dx</name>
Expand All @@ -19,10 +19,9 @@
<packaging>atlassian-plugin</packaging>

<properties>
<!-- note: change to 9.0.0 for local development with `atlas-run` etc., prior versions have a broken UI -->
<bamboo.version>10.2.0</bamboo.version>
<bamboo.version>12.0.0</bamboo.version>
<bamboo.data.version>${bamboo.version}</bamboo.data.version>
<amps.version>9.11.6</amps.version>
<amps.version>9.12.1</amps.version>
<plugin.testrunner.version>2.0.2</plugin.testrunner.version>
<atlassian.spring.scanner.version>6.0.2</atlassian.spring.scanner.version>
<jersey-version>3.1.11</jersey-version>
Expand Down Expand Up @@ -57,7 +56,7 @@
<dependency>
<groupId>com.codedx</groupId>
<artifactId>jersey-shaded</artifactId>
<version>2.0.1</version>
<version>3.0.0</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.jersey.core</groupId>
Expand Down Expand Up @@ -155,15 +154,16 @@
</dependency>

<!--
jakarta.ws.rs-api is provided by Bamboo (JAX-RS 2.x), but we need JAX-RS 3.1
(jakarta.* namespace). Include it as compile scope so it gets embedded.
The shaded JAR already contains it, but we also need it on the compile classpath
for our source code that uses jakarta.ws.rs.* directly.
jakarta.ws.rs-api: needed on the compile classpath (ApiClient.java uses jakarta.ws.rs.*).
Bamboo 12.x provides jakarta.ws.rs 3.1.0 parent-first via its webapp classloader,
so this must be 'provided' — embedding it causes AMPS to extract jakarta.ws.rs.*
classes into the plugin bundle root, creating a classloader split-brain.
-->
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>

<dependency>
Expand Down Expand Up @@ -210,6 +210,16 @@
<groupId>org.glassfish.hk2</groupId>
<artifactId>osgi-resource-locator</artifactId>
</exclusion>
<!--
net.sf.ehcache:ehcache:2.10.9.4.10 is an Atlassian-patched version that
does not exist in Maven Central and is not reliably available in
atlassian-public. Since atlassian-bamboo-web is 'provided', Bamboo
supplies ehcache at runtime — we do not need to resolve it here.
-->
<exclusion>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand Down Expand Up @@ -251,11 +261,47 @@
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jakarta-xmlbind-annotations</artifactId>
<version>${jackson-version}</version>
<exclusions>
<!--
jakarta.xml.bind-api and jakarta.activation-api are transitive compile-scope
deps of this module. Bamboo 12.x provides these parent-first, so we must
exclude them here to prevent AMPS from copying their classes into the bundle root.
-->
<exclusion>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.istack</groupId>
<artifactId>istack-commons-runtime</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.xml.fastinfoset</groupId>
<artifactId>FastInfoset</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>${jakarta-annotation-version}</version>
<scope>provided</scope>
</dependency>

<!-- Note: Required by Swagger-generated API client impl. for Basic Auth, but basic auth is not used here -->
Expand All @@ -267,6 +313,69 @@

</dependencies>

<dependencyManagement>
<dependencies>
<!--
Override old org.glassfish.jaxb:jaxb-runtime versions that have broken POMs
referencing defunct http://maven.java.net/ repositories. These old versions
appear in dependency management of Bamboo's transitive deps and cause Maven
to fail POM resolution. Overriding with a modern version avoids the issue.
-->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>4.0.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.istack</groupId>
<artifactId>istack-commons-runtime</artifactId>
<version>4.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.fastinfoset</groupId>
<artifactId>FastInfoset</artifactId>
<version>2.1.1</version>
<scope>provided</scope>
</dependency>
<!--
Force jakarta.* packages that Bamboo 12.x provides parent-first to 'provided'
scope so AMPS never copies their classes into the plugin bundle root.
-->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>2.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
<version>2.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
<version>2.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -298,18 +407,14 @@
!jdk.internal*,
!sun.misc*,
!javassist*,
!jakarta.inject*,
!jakarta.annotation*,
!org.aopalliance*,
!jakarta.validation*,
!com.opensymphony*,
jakarta.*;resolution:=optional,
*;resolution:=optional
</Import-Package>
<DynamicImport-Package></DynamicImport-Package>
<Embed-Dependency>
jersey-shaded,
jakarta.ws.rs-api,
jakarta.annotation-api,
jackson-core,
jackson-annotations,
jackson-databind,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import org.apache.log4j.Logger;

import javax.net.ssl.SSLHandshakeException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.ConnectException;
import java.net.UnknownHostException;
Expand Down
23 changes: 17 additions & 6 deletions src/main/java/com/codedx/plugins/bamboo/ServerConfigServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import org.apache.log4j.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
Expand All @@ -20,6 +20,13 @@ public class ServerConfigServlet extends HttpServlet {

private static final Logger log = Logger.getLogger(ServerConfigServlet.class);

private static final String SAVED_BANNER_HTML =
"<div id=\"codedx-saved-banner\" class=\"codedx-success-banner\">" +
" <i class=\"fas fa-check-circle\"></i>" +
" <span>Configuration saved successfully.</span>" +
" <button class=\"close-btn\" onclick=\"document.getElementById('codedx-saved-banner').style.display='none'\">&times;</button>" +
"</div>";

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
Expand All @@ -33,11 +40,15 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
String atlToken = req.getParameter("atl_token");
if (atlToken == null) atlToken = "";

boolean saved = "true".equals(req.getParameter("saved"));
String savedBanner = saved ? SAVED_BANNER_HTML : "";

String html = loadTemplate();
html = html.replace("${url}", escapeHtml(url));
html = html.replace("${apiKey}", escapeHtml(apiKey));
html = html.replace("${fingerprint}", escapeHtml(fingerprint));
html = html.replace("${atl_token}", escapeHtml(atlToken));
html = html.replace("${savedBanner}", savedBanner);

resp.setContentType("text/html;charset=UTF-8");
PrintWriter out = resp.getWriter();
Expand All @@ -60,8 +71,8 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp)

log.info("Configuration saved successfully");

// Redirect back to GET to show the saved values (PRG pattern)
resp.sendRedirect(req.getRequestURI());
// PRG pattern: redirect back to GET with saved=true to show success banner
resp.sendRedirect(req.getRequestURI() + "?saved=true");
}

private String loadTemplate() throws IOException {
Expand Down
Loading