spring-scanner and shading in bamboo plugin Edited

Using the Atlassian SDK, I was able to successfully deploy a Bamboo plugin with a single task that injects EventPublisher using atlassian-spring-scanner 1.2.13.  Hooray!

Unfortunatly, when I attempted to integrate the same logic into an existing plugin that is fairly complex, things did not work so well.  What is different about this plugin is that it is using shading which causes the maven package task to hang when generating the manifest.

[INFO] Generating a manifest for this plugin
[INFO] using maven-bundle-plugin v2.5.3

According to this stackoverflow post, it is due to the order of the bamboo-maven-plugin which executes before shading has occured.

https://stackoverflow.com/questions/18280608/using-maven-bundle-plugin-with-the-maven-shade-plugin

I've tried most of the suggestions in this post (the ones I understand anyway) without much luck.  So basically my question is, what do I need to do in order to use maven-bamboo-plugin to prep the osgi dependencies in order to use atlassian-spring-scanner while still working with shading.

The relevant parts of my package are listed below.

 

 <plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-bamboo-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${bamboo.version}</productVersion>
<productDataVersion>${bamboo.data.version}</productDataVersion>

<enableQuickReload>true</enableQuickReload>
<enableFastdev>false</enableFastdev>

<!-- See here for an explanation of default instructions: -->
<!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
<instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>

<!-- Add package to export here -->
<Export-Package></Export-Package>

<!-- Add package import here -->
<import-Package>
org.springframework.osgi.*;resolution:="optional",
org.eclipse.gemini.blueprint.*;resolution:="optional",
*
</import-Package>

<!-- Ensure plugin is spring powered -->
<Spring-Context>*</Spring-Context>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<executions>
<execution>
<goals>
<goal>atlassian-spring-scanner</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
<configuration>
<scannedDependencies>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-external-jar</artifactId>
</dependency>
</scannedDependencies>
<verbose>false</verbose>
</configuration>
</plugin>
<!-- It appears upber jars are needed for Bamboo plugins -->
<!-- https://bitbucket.org/dehringer/bamboo-cloudfoundry-plugin/src/99b93a6aba4f7abfec3055da06303f5dba3fc5f9/pom.xml?at=master -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<!-- needed to make the shaded dependencies available on the remote
agent classpath -->
<!-- don't understand why this is necessary, but the plugin throws
a NoClassDef without it -->
<configuration>
<relocations>
<relocation>
<pattern>org.springframework</pattern>
<shadedPattern>com.shaded.cf.services.org.springframework</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.velocity</pattern>
<shadedPattern>com.shaded.cf.services.org.apache.velocity</shadedPattern>
</relocation>
</relocations>
<!-- exclude signatures of shaded jars -->
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>META-INF/*.EC</exclude>
</excludes>
</filter>
</filters>
<!-- Unnecessary jars can cause errors with class loading on the remote
agents. These are getting pulled in as test dependencies -->
<artifactSet>
<excludes>
<exclude>org.slf4j:slf4j-api</exclude>
<exclude>junit:junit</exclude>
<exclude>org.easymock</exclude>
<exclude>cglib:cglib-nodep</exclude>
<exclude>org.powermock</exclude>
<exclude>org.jacoco</exclude>
<exclude>org.springframework:spring-test</exclude>
<exclude>org.hamcrest</exclude>
<exclude>org.springframework:spring-core</exclude>
<exclude>org.objenesis:objenesis</exclude>
<exclude>org.javassist:javassist</exclude>
</excludes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

 

1 answer

1 accepted

For anyone stumbling here, it appears that the manifest creation did actually complete but it took quite a long time (30 seconds or so).   Ultimately, I ended up creating my own EmailService instead of using the atlassian wired EventPublisher service due to:

 

https://community.atlassian.com/t5/Bamboo-questions/EventPublisher-spring-scanner-and-remote-bamboo-agents/qaq-p/708714#M17004

Thanks for letting us know!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,664 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you