diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e2a651..13fea99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ # Axon Framework plugin Changelog +## [0.9.1] +- 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. + ## [0.9.0] - Plugin is now compatible with IDEA 2024.3 (IDEA 243.*) with minimum version of 2024.3 - Make plugin compatible with the K2 mode of IntelliJ IDEA diff --git a/src/main/kotlin/org/axonframework/intellij/ide/plugin/usage/AxonVersionService.kt b/src/main/kotlin/org/axonframework/intellij/ide/plugin/usage/AxonVersionService.kt index 1edc107..67bd273 100644 --- a/src/main/kotlin/org/axonframework/intellij/ide/plugin/usage/AxonVersionService.kt +++ b/src/main/kotlin/org/axonframework/intellij/ide/plugin/usage/AxonVersionService.kt @@ -26,7 +26,8 @@ import com.intellij.openapi.roots.OrderEnumerator class AxonVersionService(val project: Project) { private var enabled = false - private var messageShown = false + private var messageShownOutdated = false + private var messageShownExperimental = false private val regex = Regex(".*(axon-.*)-(\\d+)\\.(\\d+)\\.(\\d+)(.*)\\.jar") @@ -48,21 +49,27 @@ class AxonVersionService(val project: Project) { } val outdatedDeps = versions.outdated() - if (outdatedDeps.isEmpty()) { + val experimentalDeps = versions.experimental() + if (outdatedDeps.isEmpty() && experimentalDeps.isEmpty()) { enabled = true - if(messageShown) { - showReEnabledMessage() + if (messageShownOutdated) { + showReEnabledMessageForOutdatedDeps() + } + if (messageShownExperimental) { + showReEnabledMessageForExperimentalDeps() } return } + enabled = false - if (messageShown) { - // Was already shown before - return + if (!messageShownOutdated && outdatedDeps.isNotEmpty()) { + showDisabledMessage(outdatedDeps) + messageShownOutdated = true + } + if (!messageShownExperimental && experimentalDeps.isNotEmpty()) { + showExperimentalMessage(experimentalDeps) + messageShownExperimental = true } - - showDisabledMessage(outdatedDeps) - messageShown = true } private fun showDisabledMessage(outdatedDeps: List) { @@ -76,7 +83,30 @@ class AxonVersionService(val project: Project) { .notify(project) } - private fun showReEnabledMessage() { + private fun showExperimentalMessage(outdatedDeps: List) { + NotificationGroupManager.getInstance() + .getNotificationGroup("AxonNotificationGroup") + .createNotification( + "Your project has an Axon Framework version greater than 4, which is experimental. The specific dependencies are: " + outdatedDeps.joinToString( + separator = "," + ) { it.dependency.moduleName + "(${it.toVersionString()})" }, NotificationType.ERROR + ) + .notify(project) + } + + private fun showReEnabledMessageForOutdatedDeps() { + NotificationGroupManager.getInstance() + .getNotificationGroup("AxonNotificationGroup") + .createNotification( + "Your project no longer has any experimental Axon Framework dependencies. Plugin functionality has been re-enabled.", + NotificationType.INFORMATION + ) + .notify(project) + messageShownOutdated = false + } + + + private fun showReEnabledMessageForExperimentalDeps() { NotificationGroupManager.getInstance() .getNotificationGroup("AxonNotificationGroup") .createNotification( @@ -84,17 +114,18 @@ class AxonVersionService(val project: Project) { NotificationType.INFORMATION ) .notify(project) - messageShown = false + messageShownExperimental = false } fun isAxonEnabled(useCache: Boolean = false): Boolean { - if(useCache) { + if (useCache) { return enabled } return getAxonVersions().outdated().isEmpty() } private fun List.outdated() = filter { it.dependency.checkVersion && it.major < 4 } + private fun List.experimental() = filter { it.dependency.checkVersion && it.major > 4 } fun getAxonVersions() = OrderEnumerator.orderEntries(project) .librariesOnly() @@ -111,13 +142,21 @@ class AxonVersionService(val project: Project) { val match = regex.find(name)!! val (moduleName, majorVersion, minorVersion, patchVersion, remaining) = match.destructured val dependency = AxonDependency.entries.firstOrNull { it.moduleName == moduleName } ?: return null - return AxonDependencyVersion(dependency, + return AxonDependencyVersion( + dependency, Integer.parseInt(majorVersion), Integer.parseInt(minorVersion), - Integer.parseInt(patchVersion), remaining) + Integer.parseInt(patchVersion), remaining + ) } - data class AxonDependencyVersion(val dependency: AxonDependency, val major: Int, val minor: Int, val patch: Int, val remaining: String) { + data class AxonDependencyVersion( + val dependency: AxonDependency, + val major: Int, + val minor: Int, + val patch: Int, + val remaining: String + ) { fun toVersionString() = "$major.$minor.$patch$remaining" } }