Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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<AxonDependencyVersion>) {
Expand All @@ -76,25 +83,49 @@ class AxonVersionService(val project: Project) {
.notify(project)
}

private fun showReEnabledMessage() {
private fun showExperimentalMessage(outdatedDeps: List<AxonDependencyVersion>) {
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(
"Your project no longer has any outdated Axon Framework dependencies. Plugin functionality has been re-enabled.",
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<AxonDependencyVersion>.outdated() = filter { it.dependency.checkVersion && it.major < 4 }
private fun List<AxonDependencyVersion>.experimental() = filter { it.dependency.checkVersion && it.major > 4 }

fun getAxonVersions() = OrderEnumerator.orderEntries(project)
.librariesOnly()
Expand All @@ -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"
}
}
Loading