Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Want to use latest gson library, but bamboo plugin defaults to atlassian-gson library

Nikita Bedmutha July 6, 2018

I want to use the latest gson-2.8.0 jar in my bamboo plugin, however bamboo defaults to using gson-2.2.2-atlassian-1.jar . I tried adding dependency in pom.xml to use :

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version><scope>compile</scope>
 </dependency>

But still didn't work.  Please guide on how to achieve this?

2 answers

0 votes
Guillermo Varela
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 3, 2019

I'm also facing this problem: https://community.atlassian.com/t5/Bamboo-questions/How-to-use-a-Gson-version-that-is-bundled-with-a-Bamboo-plugin/qaq-p/1242644

 

Currently the OSGi bundle with the custom plugin always uses the Gson implementation from Bamboo instead of the one inside the bundle itself.

To test this I had this on the plugin code:

Class klass = Gson.class;

URL location = klass.getResource('/' + klass.getName().replace('.', '/') + ".class");

log.warn("Gson: " + location);


Class klass2 = SerializedName.class;

URL location2 = klass2.getResource('/' + klass2.getName().replace('.', '/') + ".class");

log.warn("@SerializedName: " + location2);

And this on pom.xml:

<Import-Package>

  ...

  !com.google.gson*

</Import-Package>

<Private-Package>

  ...

  com.google.gson*

</Private-Package>

The expected result is that all code that uses classes from the Gson packages should come from the bundle itself, not the one provided by the environment (Bamboo).

But the result was:

Gson: jar:file:/opt/atlassian/bamboo/atlassian-bamboo/WEB-INF/lib/gson-2.2.2-atlassian-1.jar!/com/google/gson/Gson.class
@SerializedName: bundle://116.0:7/com/google/gson/annotations/SerializedName.class

This means, Gson class was loaded from Bamboo but the annotation SerializedName came from the bundle, which is a problem in our case because the annotation is being ignored when parsing a JSON file.

Having an import for all Gson packages from Bamboo is not an option to us because we use features that are only available after Gson 2.3.

 

Is there a way to use the Gson package that is bundled with the plugin itself?

 

Thanks.

0 votes
Gabriel Ribeiro
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 13, 2018

Hi Nikita,

What error exactly you're seeing? Is Maven being able to pull the dependency?

thanks

Nikita Bedmutha July 15, 2018

There is no error as such.There is change in behaviour of the gson library which allows identifying that old library is getting used by plugin.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events