Skip to content

Commit c9005c7

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 c9005c7

File tree

2 files changed

+58
-16
lines changed

2 files changed

+58
-16
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: 55 additions & 16 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,27 @@ 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
}
63+
5864
enabled = false
59-
if (messageShown) {
60-
// Was already shown before
61-
return
65+
if (!messageShownOutdated && outdatedDeps.isNotEmpty()) {
66+
showDisabledMessage(outdatedDeps)
67+
messageShownOutdated = true
68+
}
69+
if (!messageShownExperimental && experimentalDeps.isNotEmpty()) {
70+
showExperimentalMessage(experimentalDeps)
71+
messageShownExperimental = true
6272
}
63-
64-
showDisabledMessage(outdatedDeps)
65-
messageShown = true
6673
}
6774

6875
private fun showDisabledMessage(outdatedDeps: List<AxonDependencyVersion>) {
@@ -76,25 +83,49 @@ class AxonVersionService(val project: Project) {
7683
.notify(project)
7784
}
7885

79-
private fun showReEnabledMessage() {
86+
private fun showExperimentalMessage(outdatedDeps: List<AxonDependencyVersion>) {
87+
NotificationGroupManager.getInstance()
88+
.getNotificationGroup("AxonNotificationGroup")
89+
.createNotification(
90+
"Your project has an Axon Framework version greater than 4, which is experimental. The specific dependencies are: " + outdatedDeps.joinToString(
91+
separator = ","
92+
) { it.dependency.moduleName + "(${it.toVersionString()})" }, NotificationType.ERROR
93+
)
94+
.notify(project)
95+
}
96+
97+
private fun showReEnabledMessageForOutdatedDeps() {
98+
NotificationGroupManager.getInstance()
99+
.getNotificationGroup("AxonNotificationGroup")
100+
.createNotification(
101+
"Your project no longer has any experimental Axon Framework dependencies. Plugin functionality has been re-enabled.",
102+
NotificationType.INFORMATION
103+
)
104+
.notify(project)
105+
messageShownOutdated = false
106+
}
107+
108+
109+
private fun showReEnabledMessageForExperimentalDeps() {
80110
NotificationGroupManager.getInstance()
81111
.getNotificationGroup("AxonNotificationGroup")
82112
.createNotification(
83113
"Your project no longer has any outdated Axon Framework dependencies. Plugin functionality has been re-enabled.",
84114
NotificationType.INFORMATION
85115
)
86116
.notify(project)
87-
messageShown = false
117+
messageShownExperimental = false
88118
}
89119

90120
fun isAxonEnabled(useCache: Boolean = false): Boolean {
91-
if(useCache) {
121+
if (useCache) {
92122
return enabled
93123
}
94124
return getAxonVersions().outdated().isEmpty()
95125
}
96126

97127
private fun List<AxonDependencyVersion>.outdated() = filter { it.dependency.checkVersion && it.major < 4 }
128+
private fun List<AxonDependencyVersion>.experimental() = filter { it.dependency.checkVersion && it.major > 4 }
98129

99130
fun getAxonVersions() = OrderEnumerator.orderEntries(project)
100131
.librariesOnly()
@@ -111,13 +142,21 @@ class AxonVersionService(val project: Project) {
111142
val match = regex.find(name)!!
112143
val (moduleName, majorVersion, minorVersion, patchVersion, remaining) = match.destructured
113144
val dependency = AxonDependency.entries.firstOrNull { it.moduleName == moduleName } ?: return null
114-
return AxonDependencyVersion(dependency,
145+
return AxonDependencyVersion(
146+
dependency,
115147
Integer.parseInt(majorVersion),
116148
Integer.parseInt(minorVersion),
117-
Integer.parseInt(patchVersion), remaining)
149+
Integer.parseInt(patchVersion), remaining
150+
)
118151
}
119152

120-
data class AxonDependencyVersion(val dependency: AxonDependency, val major: Int, val minor: Int, val patch: Int, val remaining: String) {
153+
data class AxonDependencyVersion(
154+
val dependency: AxonDependency,
155+
val major: Int,
156+
val minor: Int,
157+
val patch: Int,
158+
val remaining: String
159+
) {
121160
fun toVersionString() = "$major.$minor.$patch$remaining"
122161
}
123162
}

0 commit comments

Comments
 (0)