Hello from Seoul!

hello. I found this super nice new framework few days ago and It’s so lovely. thank you so much for this wonderful library and can’t wait to see will be update more.

can I ask something about IDE setup? (vscode)

I’m not a super professional programmer but having lot of experience with processing and openFrameworks. now a days been looking other frameworks like nannou(which is based on rust) and openRNDR.

I follow instruction IDE setup from guide document and everything works perfect but usually I don’t want to rely on specific IDE like xcode, Jetbrain IntelliJ CE. so I just want to try it on vscode.

since I don’t have deep experience with JAVA and especially kotlin (this is the first time I tried). so I’m not sure I’m doing right way. but clone repository https://github.com/openrndr/openrndr-template to new name and open in vscode. then for running, just type ./gradlew run then seems to work.

one things I want to do is that the autocomplete with language server. but I had a issue that in vscode there is an issue

Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
...

I found set kotlin version in settings.gradle.kts file

dependencyResolutionManagement {
    versionCatalogs {
        create("libs") {
            version("kotlin", "1.6.0")      // this line,

and change it to 1.6.0 then language server works. but is it right ?

btw, I’m macOS M1 environment. I’ll try in linux as well.

1 Like

Hii! Welcome to the forum :slight_smile:

Version 1.8.0 is quite new, just changed last week I think. Maybe the language server has not been updated yet? You could use 1.6.0 and try with the newer version later to see if it works?

I believe we are not using things that require 1.8.0.

I’m curious to hear how is the experience in vscode. In Idea I find it very good, but I understand is more convenient to use the same IDE for everything.

What kind of programs do you like writing? Looking forward to see what kind of experiments / creations you do :slight_smile:

Update: Here I see “bump to kotlin 1.6”:

Update: There’s a PR to update Kotlin:

aha! that’s why it doesn’t work. thank you for let me know that.

I’ve been do some interactive artwork and also teaching in school since few years ago(processing/arduino). about my works, some of them are running on desktop but also had experience build/running oF app on raspberry pi. recently designing PCB for bit engineering based project with arduino-based esp32 micro controller. I can say I mostly work as technician or tech-riding with other team/artists.

my coding environment is various. sometimes pc/linux/mac but sometimes on terminal. that’s why I don’t want to rely on specific OS or IDE. and I love vscode (also vim as well)

for beginner, I think vscode is stumbling block. but with task.json and shell script, it can be more easier.

for example, with this alias in .zshrc or .bashrc it can easily generate project folder. and open in vscode. (rm -Rf is for mac btw)

# generate OPENRNDR project
alias initOR='f(){ git clone https://github.com/openrndr/openrndr-template "$@"; cd "$@"; rm -Rf .git; code .;}; f'

1 Like

Nice to read about your approach and interests :slight_smile:

Thank you for that shortcut terminal function!

One thing I like in Idea is that I can have many programs inside the same project. I wonder if this might work in vscode too? I have over 200 programs in the same project XD. That way I don’t have so many Gradle projects and I can easily copy code from one file to another, or search and replace in all my programs. And the IDE checks that my code is still compatible with the latest releases of openrndr/orx, so programs still run 3 years after I wrote them.

I also like vim :slight_smile:

1 Like

still I’m not familiar with gradle and and intellij IDE. that might be much better idea instead of having seperate folder with same template. I also had kinda same question that ‘do i have to clone template for every projects?’ like you saids, indexing in backgrounds are totally same except source code.

I had same experience in nannou, which is written in Rust. in rust they have cargo package manager maintained in crates. so everytime I create project and build, duplicate crates are generated which is lots and huge file size.

what if using symbolic link? will it work? i need to understand how kotlin/Gradle compile. openFrameworks are share compiled library that’s why those project folder structure is hierarchical. actually project folder can be seperated because of the Makefile.

I know Nannou :slight_smile: The lead developers used to live here in Berlin and we met them sometimes in our creative coding meetups. Sound’s like you’ve tried every framework :slight_smile:

Once I tried to use symbolic links with Processing + Kotlin + Idea. In that case it didn’t work well. But maybe it works outside of the IDE? I just asked about running different programs from the command line with Gradle.

1 Like

nice to hear that meet with them! want to join in future :slight_smile:

I just found the way how to pass target source code to run, to gradle.
reference here

for example run /src/main/kotlin/test/test_01.kt file.

./gradlew run  --args='test/test_01.kt'

so maybe vscode can be more useful.

  • install Kotlin, Kotlin Launguage extension
    image

  • make new project → duplicate live/static template to new location.

  • run project → use keyboard shorcut to build with current opend file.

I will try more and post here.

1 Like

I tried this but it didn’t run the specified program for me, it only passed the arguments to

fun main(args: Array<String>) = application {

of TemplateProgram.kt.

Maybe there’s a way to parse that from Gradle and modify applicationMainClass.

1 Like

isn’t it kotlin code? can you try ./gradlew --args='_FILE_LOCATION' at top of openRNDR directory in terminal?

I did try :slight_smile: Did you make sure TemplateProgram.kt and test_01.kt look different? In the second one I made the circle green, but I see pink when running that line.

oh my. yeah you right. :confused:

I tried to modify like this and run task on terminal.

group = "org.openrndr.template"
version = "0.4.0"

// val applicationMainClass = "TemplateProgramKt"    // -> original 
val targetClass = findProperty("targetClass");
val applicationMainClass = targetClass

and terminal

./gradlew -PtargetClass=TemplateProgramKt run         # works
./gradlew -PtargetClass=TemplateLiveProgramKt run # works
./gradlew -PtargetClass=Test_01Kt run  # work 

any file in /src/main/kotlin directory works. can you confirm this? still doesn’t work in sub-directory.

Hmm i figured out. not sure though.

I guess gradle have kind a code search path like Makefile. so no matter what directory in side of src/main/kotlin, passing only fileName with -P option without directory name on ./gradlew works.

here is my build.gradle.kts

// val applicationMainClass = "TemplateProgramKt"      // original code
var applicationMainClass = "TemplateProgramKt"         

// override -P argument from terminal command
if(project.hasProperty("targetClass")){                             // check if has parameter 
    applicationMainClass = findProperty("targetClass").toString()
    println("file $applicationMainClass will be run")
} else {
    println("default $applicationMainClass will be run.")      // if not, use default 
}

image

so all of commands are work.

./gredlew run
./gredlew TemplateProgramKt
./gredlew TemplateLiveProgramKt
./gredlew Test_01Kt
./gredlew Test_02Kt

but then what if there are files have same fileName in different sub-directory?
image

I tested and result is quite interesting. there is no error. and last modified one launched.

Ah great that you figured it out! I did at the same time XD Thanks to the Gradle forum:

What if you use test.Test_02 or test2.Test_02? Does that help?

already tested but it launch default one.

Oh strange. For me it works.

./gradlew run -Plaunch=TemplateProgram

and

./gradlew run -Plaunch=winter.TemplateProgram

launch two different programs in the expected way.

Maybe if you copy what I did from the Gradle post it works? I think I wrapped it into application { } but you didn’t.

1 Like

finally. with vscode can run with command. shortcut setting also available.

put tasks.json in /openRNDR/.vscode/tasks.json and open openRNDR folder with vscode.

“tasks.json”

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    
    // vscode task for openRNDR
    "version": "2.0.0",
    "tasks": [
        {
            "label": "RUN",
            "type": "shell",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "command": "./gradlew run -PtargetClass=${fileBasenameNoExtension}Kt",
            "problemMatcher": []
        }
    ]
}

‘ctrl + shift + P’ and select Task : Run RaskRUN

maybe I miss something. can you share scripts? then I’ll update vscode side.

I sent a PR to make this standard:

I think what might be missing in your case is to specify the right package for files in subfolders. The first line in those .kt files should be package test or package test2. I hope that helps!

1 Like