Skip to content

Commit 13874f1

Browse files
Disable plugin upon detection of Axon Framework 5
To prevent many errors in the IDE due to the experimental state, that also changes a lot of the structure the plugin assumes.
1 parent e917f28 commit 13874f1

File tree

2 files changed

+59
-13
lines changed

2 files changed

+59
-13
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
# Axon Framework plugin Changelog
44

5+
## [0.9.1]
6+
- Disable plugin when Axon Framework 5 or greater is detected. The plugin is not compatible with Axon Framework 5 and greater at this time, as it is an experimental branch. Future versions of the plugin will be compatible with Axon Framework 5 and greater, once it approaches release readiness.
7+
58
## [0.9.0]
69
- Plugin is now compatible with IDEA 2024.3 (IDEA 243.*) with minimum version of 2024.3
710
- Make plugin compatible with the K2 mode of IntelliJ IDEA

src/main/kotlin/org/axonframework/intellij/ide/plugin/usage/AxonVersionService.kt

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import com.intellij.openapi.roots.OrderEnumerator
2626

2727
class AxonVersionService(val project: Project) {
2828
private var enabled = false
29-
private var messageShown = false
29+
private var messageShownOutdated = false
30+
private var messageShownExperimental = false
3031

3132
private val regex = Regex(".*(axon-.*)-(\\d+)\\.(\\d+)\\.(\\d+)(.*)\\.jar")
3233

@@ -48,21 +49,31 @@ class AxonVersionService(val project: Project) {
4849
}
4950

5051
val outdatedDeps = versions.outdated()
51-
if (outdatedDeps.isEmpty()) {
52+
val experimentalDeps = versions.experimental()
53+
if (outdatedDeps.isEmpty() && experimentalDeps.isEmpty()) {
5254
enabled = true
53-
if(messageShown) {
54-
showReEnabledMessage()
55+
if (messageShownOutdated) {
56+
showReEnabledMessageForOutdatedDeps()
57+
}
58+
if (messageShownExperimental) {
59+
showReEnabledMessageForExperimentalDeps()
5560
}
5661
return
5762
}
5863
enabled = false
59-
if (messageShown) {
64+
if (messageShownOutdated) {
6065
// Was already shown before
6166
return
6267
}
6368

64-
showDisabledMessage(outdatedDeps)
65-
messageShown = true
69+
if (outdatedDeps.isNotEmpty()) {
70+
showDisabledMessage(outdatedDeps)
71+
messageShownOutdated = true
72+
}
73+
if (experimentalDeps.isNotEmpty()) {
74+
showExperimentalMessage(experimentalDeps)
75+
messageShownExperimental = true
76+
}
6677
}
6778

6879
private fun showDisabledMessage(outdatedDeps: List<AxonDependencyVersion>) {
@@ -76,25 +87,49 @@ class AxonVersionService(val project: Project) {
7687
.notify(project)
7788
}
7889

79-
private fun showReEnabledMessage() {
90+
private fun showExperimentalMessage(outdatedDeps: List<AxonDependencyVersion>) {
91+
NotificationGroupManager.getInstance()
92+
.getNotificationGroup("AxonNotificationGroup")
93+
.createNotification(
94+
"Your project has an Axon Framework version greater than 4, which is experimental. The specific dependencies are: " + outdatedDeps.joinToString(
95+
separator = ","
96+
) { it.dependency.moduleName + "(${it.toVersionString()})" }, NotificationType.ERROR
97+
)
98+
.notify(project)
99+
}
100+
101+
private fun showReEnabledMessageForOutdatedDeps() {
102+
NotificationGroupManager.getInstance()
103+
.getNotificationGroup("AxonNotificationGroup")
104+
.createNotification(
105+
"Your project no longer has any experimental Axon Framework dependencies. Plugin functionality has been re-enabled.",
106+
NotificationType.INFORMATION
107+
)
108+
.notify(project)
109+
messageShownOutdated = false
110+
}
111+
112+
113+
private fun showReEnabledMessageForExperimentalDeps() {
80114
NotificationGroupManager.getInstance()
81115
.getNotificationGroup("AxonNotificationGroup")
82116
.createNotification(
83117
"Your project no longer has any outdated Axon Framework dependencies. Plugin functionality has been re-enabled.",
84118
NotificationType.INFORMATION
85119
)
86120
.notify(project)
87-
messageShown = false
121+
messageShownExperimental = false
88122
}
89123

90124
fun isAxonEnabled(useCache: Boolean = false): Boolean {
91-
if(useCache) {
125+
if (useCache) {
92126
return enabled
93127
}
94128
return getAxonVersions().outdated().isEmpty()
95129
}
96130

97131
private fun List<AxonDependencyVersion>.outdated() = filter { it.dependency.checkVersion && it.major < 4 }
132+
private fun List<AxonDependencyVersion>.experimental() = filter { it.dependency.checkVersion && it.major > 4 }
98133

99134
fun getAxonVersions() = OrderEnumerator.orderEntries(project)
100135
.librariesOnly()
@@ -111,13 +146,21 @@ class AxonVersionService(val project: Project) {
111146
val match = regex.find(name)!!
112147
val (moduleName, majorVersion, minorVersion, patchVersion, remaining) = match.destructured
113148
val dependency = AxonDependency.entries.firstOrNull { it.moduleName == moduleName } ?: return null
114-
return AxonDependencyVersion(dependency,
149+
return AxonDependencyVersion(
150+
dependency,
115151
Integer.parseInt(majorVersion),
116152
Integer.parseInt(minorVersion),
117-
Integer.parseInt(patchVersion), remaining)
153+
Integer.parseInt(patchVersion), remaining
154+
)
118155
}
119156

120-
data class AxonDependencyVersion(val dependency: AxonDependency, val major: Int, val minor: Int, val patch: Int, val remaining: String) {
157+
data class AxonDependencyVersion(
158+
val dependency: AxonDependency,
159+
val major: Int,
160+
val minor: Int,
161+
val patch: Int,
162+
val remaining: String
163+
) {
121164
fun toVersionString() = "$major.$minor.$patch$remaining"
122165
}
123166
}

0 commit comments

Comments
 (0)