@@ -26,7 +26,8 @@ import com.intellij.openapi.roots.OrderEnumerator
26
26
27
27
class AxonVersionService (val project : Project ) {
28
28
private var enabled = false
29
- private var messageShown = false
29
+ private var messageShownOutdated = false
30
+ private var messageShownExperimental = false
30
31
31
32
private val regex = Regex (" .*(axon-.*)-(\\ d+)\\ .(\\ d+)\\ .(\\ d+)(.*)\\ .jar" )
32
33
@@ -48,21 +49,31 @@ class AxonVersionService(val project: Project) {
48
49
}
49
50
50
51
val outdatedDeps = versions.outdated()
51
- if (outdatedDeps.isEmpty()) {
52
+ val experimentalDeps = versions.experimental()
53
+ if (outdatedDeps.isEmpty() && experimentalDeps.isEmpty()) {
52
54
enabled = true
53
- if (messageShown) {
54
- showReEnabledMessage()
55
+ if (messageShownOutdated) {
56
+ showReEnabledMessageForOutdatedDeps()
57
+ }
58
+ if (messageShownExperimental) {
59
+ showReEnabledMessageForExperimentalDeps()
55
60
}
56
61
return
57
62
}
58
63
enabled = false
59
- if (messageShown ) {
64
+ if (messageShownOutdated ) {
60
65
// Was already shown before
61
66
return
62
67
}
63
68
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
+ }
66
77
}
67
78
68
79
private fun showDisabledMessage (outdatedDeps : List <AxonDependencyVersion >) {
@@ -76,25 +87,49 @@ class AxonVersionService(val project: Project) {
76
87
.notify(project)
77
88
}
78
89
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 () {
80
114
NotificationGroupManager .getInstance()
81
115
.getNotificationGroup(" AxonNotificationGroup" )
82
116
.createNotification(
83
117
" Your project no longer has any outdated Axon Framework dependencies. Plugin functionality has been re-enabled." ,
84
118
NotificationType .INFORMATION
85
119
)
86
120
.notify(project)
87
- messageShown = false
121
+ messageShownExperimental = false
88
122
}
89
123
90
124
fun isAxonEnabled (useCache : Boolean = false): Boolean {
91
- if (useCache) {
125
+ if (useCache) {
92
126
return enabled
93
127
}
94
128
return getAxonVersions().outdated().isEmpty()
95
129
}
96
130
97
131
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 }
98
133
99
134
fun getAxonVersions () = OrderEnumerator .orderEntries(project)
100
135
.librariesOnly()
@@ -111,13 +146,21 @@ class AxonVersionService(val project: Project) {
111
146
val match = regex.find(name)!!
112
147
val (moduleName, majorVersion, minorVersion, patchVersion, remaining) = match.destructured
113
148
val dependency = AxonDependency .entries.firstOrNull { it.moduleName == moduleName } ? : return null
114
- return AxonDependencyVersion (dependency,
149
+ return AxonDependencyVersion (
150
+ dependency,
115
151
Integer .parseInt(majorVersion),
116
152
Integer .parseInt(minorVersion),
117
- Integer .parseInt(patchVersion), remaining)
153
+ Integer .parseInt(patchVersion), remaining
154
+ )
118
155
}
119
156
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
+ ) {
121
164
fun toVersionString () = " $major .$minor .$patch$remaining "
122
165
}
123
166
}
0 commit comments