Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project tidy up #34

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 6 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ jobs:
command: |
sudo apt-get update
sudo apt-get install fakeroot
- run:
name: "Run lint check"
command: ./gradlew ktlintCheck
- run:
name: "Run test"
command: ./gradlew test
Expand All @@ -66,8 +69,8 @@ jobs:
command: mkdir -p artifacts; cp -r ~/repo/build/compose/logs/* artifacts/
when: always
- run:
name: "Store deb to workspace"
command: cp ~/repo/build/compose/binaries/main/deb/* artifacts/
name: "Store deb to workspace"
command: cp ~/repo/build/compose/binaries/main/deb/* artifacts/
- write_cache_linux
- persist_to_workspace:
root: artifacts
Expand All @@ -83,7 +86,7 @@ jobs:
- checkout
- read_cache_mac
- attach_workspace:
at: artifacts
at: artifacts
- run:
name: "Decode signing cert"
command: base64 -D -o cert.p12 \<<< $SIGNING_CERT_TEMP
Expand Down
16 changes: 8 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.8.20"
id("org.jetbrains.compose") version "1.6.0"
kotlin("jvm") version "2.0.20"
id("org.jetbrains.compose") version "1.6.11"
id("org.jetbrains.kotlin.plugin.compose") version "2.0.20"
id("org.jlleitschuh.gradle.ktlint") version "11.3.2"
}

Expand Down Expand Up @@ -71,7 +72,6 @@ dependencies {
implementation("org.jetbrains.compose.material:material-icons-extended:$composeVersion")
implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-script-runtime:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-script-util:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-scripting-jsr223:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-scripting-jvm-host:$kotlinVersion")
Expand Down Expand Up @@ -127,9 +127,9 @@ ktlint {
}

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
allWarningsAsErrors = true
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
allWarningsAsErrors.set(true)
}
}

Expand All @@ -151,9 +151,9 @@ val copyCommonProtoJarToResources by tasks.creating(Copy::class) {
filteredFiles.forEach { file ->
val originalFileName = file.name
val newFileName = if (originalFileName.endsWith("$googleCommonProtos.jar")) {
originalFileName.replace("$googleCommonProtos", "original")
originalFileName.replace(googleCommonProtos, "original")
} else {
originalFileName.replace("$protoktVersion", "protoKT")
originalFileName.replace(protoktVersion, "protoKT")
}
rename(originalFileName, newFileName)
}
Expand Down
26 changes: 13 additions & 13 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
assertJVersion=3.24.2
composeVersion=1.6.0
googleCommonProtos=2.17.0
jacksonVersion=2.15.0
jUnitVersion=5.9.3
kotlinVersion=1.8.20
assertJVersion=3.26.3
composeVersion=1.6.11
googleCommonProtos=2.45.1
jacksonVersion=2.18.0
jUnitVersion=5.11.1
kotlinVersion=2.0.20
kotlin.code.style=official
mockkVersion=1.13.5
protobufUtils=3.22.3
protoktVersion=0.10.2
pulsarVersion=2.11.1
mockkVersion=1.13.12
protobufUtils=4.28.2
protoktVersion=0.12.1
pulsarVersion=3.3.1
reflectionsVersion=0.10.2
rsyntaxVersion=3.3.3
sl4jNoop=2.0.7
testContainerPulsar=1.18.0
rsyntaxVersion=3.5.1
sl4jNoop=2.0.16
testContainerPulsar=1.20.1
1 change: 1 addition & 0 deletions src/main/kotlin/com/toasttab/pulseman/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ fun main() = application {
appState.save(true)
exitApplication()
}

JOptionPane.NO_OPTION -> {
exitApplication()
}
Expand Down
12 changes: 8 additions & 4 deletions src/main/kotlin/com/toasttab/pulseman/files/FileManagement.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ object FileManagement {
fun makeFolder(file: File) {
val path: Path = Paths.get(file.toURI())
Files.createDirectories(path)
if (!file.exists() && !file.mkdir())
if (!file.exists() && !file.mkdir()) {
throw Exception(FAILED_TO_CREATE_DIRECTORY)
}
}

fun addFileDialog(jarFolder: File, action: (File) -> Unit) {
Expand All @@ -92,8 +93,9 @@ object FileManagement {
}

fun deleteFile(file: File) {
if (file.exists())
if (file.exists()) {
file.delete()
}
}

fun saveProject(tabsJson: String, quickSave: Boolean, jarFolders: List<File>) {
Expand Down Expand Up @@ -132,7 +134,7 @@ object FileManagement {
title = PROJECT_FILE_DIALOG_TITLE,
mode = FileDialogMode.LOAD,
extensionFilters = listOf(ZIP_EXTENSION),
directory = projectFolder.absolutePath,
directory = projectFolder.absolutePath
)

fileDialog.show()
Expand All @@ -150,7 +152,9 @@ object FileManagement {
if (it.exists()) {
val lastLoadedFile = File(it.readText())
if (lastLoadedFile.exists()) lastLoadedFile else null
} else null
} else {
null
}
}

fun loadedJars(jarFolder: File) = jarFolder.walk().filter { it.isFile }.toMutableSet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import com.toasttab.pulseman.AppStrings.PROPERTIES
import com.toasttab.pulseman.entities.ReceivedMessages
import com.toasttab.pulseman.entities.SingleSelection
import com.toasttab.pulseman.pulsar.handlers.PulsarMessageClassInfo
import java.time.Instant
import org.apache.pulsar.client.api.Message
import java.time.Instant

/**
* This class handles printing received pulsar messages and logs the related class info
Expand Down
9 changes: 5 additions & 4 deletions src/main/kotlin/com/toasttab/pulseman/pulsar/Pulsar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ import com.toasttab.pulseman.AppStrings.SERVICE_URL_NOT_SET
import com.toasttab.pulseman.AppStrings.TOPIC_NOT_SET
import com.toasttab.pulseman.jars.RunTimeJarLoader.addJarsToClassLoader
import com.toasttab.pulseman.state.PulsarSettings
import java.util.UUID
import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeUnit
import org.apache.pulsar.client.api.Authentication
import org.apache.pulsar.client.api.Consumer
import org.apache.pulsar.client.api.Message
Expand All @@ -45,6 +42,9 @@ import org.apache.pulsar.client.api.PulsarClient
import org.apache.pulsar.client.api.Schema
import org.apache.pulsar.client.api.SubscriptionMode
import org.apache.pulsar.client.api.SubscriptionType
import java.util.UUID
import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeUnit

/**
* Handles
Expand Down Expand Up @@ -156,8 +156,9 @@ class Pulsar(
setUserFeedback(NO_CLASS_GENERATED_TO_SEND)
wrongSettings = true
}
if (wrongSettings)
if (wrongSettings) {
return false
}

try {
(producer ?: createNewProducer(topic))
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/com/toasttab/pulseman/pulsar/PulsarConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package com.toasttab.pulseman.pulsar
import com.toasttab.pulseman.AppStrings.EXCEPTION
import com.toasttab.pulseman.AppStrings.FAILED_TO_RETRIEVE_TOPICS
import com.toasttab.pulseman.state.PulsarSettings
import java.util.concurrent.TimeUnit
import org.apache.pulsar.client.admin.PulsarAdmin
import java.util.concurrent.TimeUnit

/**
* Handles connecting to pulsar admin and retrieving a list of topics, this is currently limited to unauthenticated
Expand All @@ -28,7 +28,6 @@ import org.apache.pulsar.client.admin.PulsarAdmin
class PulsarConfig(private val setUserFeedback: (String) -> Unit) {
fun getTopics(pulsarUrl: String, pulsarSettings: PulsarSettings): List<String> {
try {

val builder = PulsarAdmin.builder()

PulsarAuth(pulsarSettings).getAuthHandler()?.let { authHandler ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ data class KTMessageHandler(override val cls: Class<out KtMessage>, override val
it.name !in IGNORE_FIELDS
}
.forEach {
if (!it.type.isPrimitive)
if (!it.type.isPrimitive) {
importSet.add(it.type.name.replace("$", "."))
}
variables.appendLine("\t${it.name} = //$TODO")
}
val imports = StringBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,3 @@ object KotlinScripting {

private const val KTS_EXTENSION = "kts"
}

6 changes: 4 additions & 2 deletions src/main/kotlin/com/toasttab/pulseman/state/AuthSelector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ class AuthSelector(

private fun onSelectedAuthClass(newValue: PulsarAuthHandler) {
selectedAuthClass.selected =
if (selectedAuthClass.selected == newValue)
if (selectedAuthClass.selected == newValue) {
null
else newValue
} else {
newValue
}
setUserFeedback("$SELECTED ${newValue.cls.name}")
onChange()
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/com/toasttab/pulseman/state/ReceiveMessage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ import com.toasttab.pulseman.jars.RunTimeJarLoader.addJarsToClassLoader
import com.toasttab.pulseman.pulsar.MessageHandling
import com.toasttab.pulseman.pulsar.Pulsar
import com.toasttab.pulseman.view.receiveMessageUI
import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import org.apache.pulsar.client.api.Consumer
import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeUnit

class ReceiveMessage(
private val setUserFeedback: (String) -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum class ConvertType {
.map { it.toInt(16).toByte() }
.toByteArray()
}

BASE64 -> {
value
.filter { !it.isWhitespace() }
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/toasttab/pulseman/util/FileDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FileDialog(
mode: FileDialogMode,
directory: String? = null,
file: String? = null,
private val extensionFilters: List<String> = emptyList(),
private val extensionFilters: List<String> = emptyList()
) {
private val fileDialog: AwtFileDialog = AwtFileDialog(Frame(), title, mode.ordinal)

Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/com/toasttab/pulseman/view/AuthSelectorUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,11 @@ fun authSelectorUI(
onSelectedAuthClass(classInfo)
}
) {
if (selectedAuthClass === classInfo)
if (selectedAuthClass === classInfo) {
Icon(Icons.Default.CheckCircle, SELECTED_CLASS)
else
} else {
Icon(Icons.Default.Clear, CLICK_TO_SELECT)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fun jarManagementUI(
loadedJars: List<File>,
jarFolder: File,
onRemoveJar: (File) -> Unit,
onAddJar: (File) -> Unit,
onAddJar: (File) -> Unit
) {
Surface {
Box {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@ fun messageClassSelectorUI(
modifier = Modifier.weight(0.1F),
onClick = { onSelectedClass(classInfo) }
) {
if (selectedClass === classInfo)
if (selectedClass === classInfo) {
Icon(Icons.Default.RadioButtonChecked, SELECTED_CLASS)
else
} else {
Icon(Icons.Default.RadioButtonUnchecked, CLICK_TO_SELECT)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fun pulsarSettingsUI(
Row {
Button(
modifier = Modifier.padding(4.dp),
onClick = { onShowJarManagementChange(true) },
onClick = { onShowJarManagementChange(true) }
) {
Text(JARS)
}
Expand All @@ -122,7 +122,7 @@ fun pulsarSettingsUI(

Button(
modifier = Modifier.padding(4.dp),
onClick = { onShowAuthSettingsChange(true) },
onClick = { onShowAuthSettingsChange(true) }
) {
Text(AUTH_SETTINGS)
}
Expand All @@ -140,7 +140,7 @@ fun pulsarSettingsUI(

Button(
modifier = Modifier.padding(4.dp),
onClick = { onShowPropertySettingsChange(true) },
onClick = { onShowPropertySettingsChange(true) }
) {
Text(PROPERTIES)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,19 @@ fun receiveMessageUI(

Text(
text = AnnotatedString(receivedMessage.header),
modifier = Modifier.weight(1F).align(Alignment.CenterVertically),
modifier = Modifier.weight(1F).align(Alignment.CenterVertically)
)

Spacer(modifier = Modifier.width(8.dp))

IconButton(
onClick = { receivedMessage.expanded.value = !receivedMessage.expanded.value }
) {
if (receivedMessage.expanded.value)
if (receivedMessage.expanded.value) {
Icon(Icons.Default.ArrowDropUp, contentDescription = COLLAPSE)
else
} else {
Icon(Icons.Default.ArrowDropDown, contentDescription = EXPAND)
}
}

Spacer(modifier = Modifier.width(8.dp))
Expand Down
Loading