Hey folks! I’m working on two Jira add-ons that have pretty much the same features and APIs but different UIs. I want to avoid writing the same code twice. Does anyone know if there’s a way to use the same codebase for both add-ons in Java Spring Boot?
I’m currently using these starters:
atlassian-connect-spring-boot-starter
atlassian-connect-spring-boot-jpa-starter
Here’s a snippet of what my add-on config looks like:
The problem is, the atlassian-connect-starter seems to be blocking me from using the same code for another add-on. Is there a way to tweak the starter to make this work? Any ideas would be super helpful!
I’ve actually tackled a similar challenge before. While the Atlassian Connect framework doesn’t directly support sharing code between add-ons, there are workarounds.
One approach that worked well for me was creating a shared library. I extracted all the common logic, APIs, and services into a separate Java library project. Then, I included this library as a dependency in both add-on projects.
For the UI differences, I used a strategy pattern. Each add-on implemented its own UI components, but they all called into the shared business logic from the common library.
To manage the add-on configurations, I created a base config file and extended it for each specific add-on. This allowed me to keep most settings consistent while customizing the necessary parts like the add-on key and name.
It takes some initial setup, but in the long run, it saved me tons of time on maintenance and feature additions. Just make sure to version your shared library carefully to avoid breaking changes between add-ons.
Having dealt with similar situations, I can offer some insights. While direct code sharing between Jira add-ons isn’t straightforward, you can implement a modular architecture. Consider creating a core module with shared logic and separate modules for each add-on’s unique UI. This approach allows for code reuse while maintaining flexibility.
Utilize dependency injection to manage the shared components across your add-ons. This method ensures that common functionalities are accessible without duplicating code. For configuration management, implement a strategy where you have a base configuration file that’s extended or overridden for each specific add-on.
Remember to thoroughly test each add-on independently to ensure that shared code changes don’t inadvertently affect other add-ons. This structure might require initial refactoring, but it significantly reduces long-term maintenance efforts and promotes consistency across your add-ons.
hey ethan, been there! u could try makin a shared java library for common stuff. put it in both addons as dependency. for UI, use different controllers but same services. might need som tweaks to atlassian-connect setup, but should work. goodluck mate!