A growing list of questions, and hopefully answers, as I learn about Kotlin, IDEA, OPENRNDR, and all that jazz.

In the following, I’ll probably say “best way” a lot. By that I mean “one or more decent ways”. I am not asserting that there exist absolutely best ways, or that if there do, we can know them. I’ll try to say more explicitly what I mean, but this article is intended for quick jotting down of concerns, and then, later, perhaps filling in some of what I’ve learned.

I freely grant that any competent IDEA/Kotlin/OPENRNDR/… developer would know these things. I freely grant that I am not competent with these particular tools, nor do I assert that I am particularly competent with some other set of tools. I’m just some guy, learning things, wondering things, working things out.

Dealing with GitHub
If we take up a joint project, the team needs a standard way of cloning a template and hooking up to a single repo. We should take measures to ensure we don’t break things on any of our various machines.

We’ll probably need special handling for build.gradle.kts or equivalent, as our machines are not configured identically, and cannot be.

Set Up a Remote
In IDEA, Git/GitHub/Share Project on GitHub will do the job, prompting for the new repo name.
Setting up a Project
I need to learn enough of the infrastructure to be able to get tests running and a standard config. Logs below address learnings.
Writing Tests
Test files need imports like these:
package com.ronjeffries.ship

import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.openrndr.math.Vector2

IDEA is pretty good about pulling these in, though I think not perfect. For that to work, the next item is important:

Test Framework
Before you can write and run tests, the build.gradle.kts must include testImplementation lines like these:
dependencies {
	...
    implementation(kotlin("stdlib-jdk8"))
    testImplementation(libs.junit)
    testImplementation("org.assertj:assertj-core:3.23.1")
    testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0")
}
Running Tests
For tests to be seen as runnable, build.gradle.kts must include:
tasks.test {
    useJUnitPlatform()
}

Logs

Captain’s Log, Stardate 20221015

Yesterday I made the following changes to the program environment, not necessarily in this order.

Added “New Package” under the kotlin folders, named com.ronjeffries.ship. I am told that this is the conventional way of naming packages.

Moved my existing Ship class into that package. Drag/drop caused IDEA to do the necessary minor refactoring of inserting package statements into the file(s). Subsequently moved the TemplateProgram.kts into the package as well.

Wrote a test under the test folder, including this at the top:

package com.ronjeffries.ship

import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.openrndr.math.Vector2

Tests were not yet recognized with green arrows, and the methods like assertThat were not recognized. Imports were showing red as not found. Realized they had to be in the gradle.

In dependencies in build.gradle.kts, added:

    testImplementation(libs.junit)
    testImplementation("org.assertj:assertj-core:3.23.1")
    testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0")

This allowed me to write the tests, causing IDEA to recognize assertThat and so on. The original values typed in included a reference to a string which I was unable to make work. (Missing quotes, difference between Kotlin and Groovy formatting.) When floating cursor over the version numbers on those lines, IDEA reports on newer versions and will change the references.

Tests were still not showing green arrows. From Stack Overflow, I found a solution.

In build.gradle.kts, added:

tasks.test {
    useJUnitPlatform()
}

This caused IDEA to recognize my tests as tests. Turned on the green arrows.

Tests are running, demo runs at 0813. Committing. “Mods to make testing possible”.

Received warnings including many on build.gradle.kts:

~/Dropbox/_2022_projects/openrndr-2/src/main/kotlin/com/ronjeffries/ship/TemplateProgram.kt
Warning:(14, 13) [unused] Variable 'font' is never used
~/Dropbox/_2022_projects/openrndr-2/src/main/kotlin/com/ronjeffries/ship/Ship.kt
Warning:(13, 9) Property "pointing" is never used
~/Dropbox/_2022_projects/openrndr-2/build.gradle.kts
Warning:(159, 17) Type OperatingSystem.Windows! is inaccessible in this context due to: public/*package*/ open class Windows : OperatingSystem defined in org.gradle.internal.os.OperatingSystem
Warning:(159, 42) Type OperatingSystem.Linux! is inaccessible in this context due to: public/*package*/ open class Linux : OperatingSystem.Unix defined in org.gradle.internal.os.OperatingSystem
Warning:(167, 17) Type OperatingSystem.MacOs! is inaccessible in this context due to: public/*package*/ open class MacOs : OperatingSystem.Unix defined in org.gradle.internal.os.OperatingSystem
Warning:(196, 42) Type OperatingSystem.MacOs! is inaccessible in this context due to: public/*package*/ open class MacOs : OperatingSystem.Unix defined in org.gradle.internal.os.OperatingSystem
Warning:(227, 9) Type OperatingSystem.Windows! is inaccessible in this context due to: public/*package*/ open class Windows : OperatingSystem defined in org.gradle.internal.os.OperatingSystem
Warning:(228, 9) Type OperatingSystem.MacOs! is inaccessible in this context due to: public/*package*/ open class MacOs : OperatingSystem.Unix defined in org.gradle.internal.os.OperatingSystem
Warning:(232, 9) Type OperatingSystem.Linux! is inaccessible in this context due to: public/*package*/ open class Linux : OperatingSystem.Unix defined in org.gradle.internal.os.OperatingSystem

Assuming that’s not my problem. The gradle file is heavily modified by the OPENRNDR people, with lots of live new code.