This message was deleted.
# community-support
s
This message was deleted.
v
Afair you can use the idea-ext plugin to configure run configurations. Not sure wether you can also configure the run configuration templates, but even if not, you could it in the generic post-processing step of it.
e
Thanks for the hint, but getting the
idea-ext
plugin to work is much harder than it should be... still trying... Apparently, in
settings.gradle.kts
this is meaningless
Copy code
pluginManagement {
    plugins {
        application             // includes the Java and Distribution plugins
        idea
        id("org.jetbrains.gradle.plugin.idea-ex") version "1.1.6"
    }
    resolutionStrategy {
    }
    repositories {
        repositories.maven("<https://plugins.gradle.org/m2/>")
    }
}
resulting in
Copy code
Build file '/Users/eric.kolotyluk/git/autonomous-iam/poc/loom-laboratory/build.gradle.kts' line: 7

Plugin [id: 'org.jetbrains.gradle.plugin.idea-ex', version: '1.1.6'] was not found in any of the following sources:
v
ext, not ex
e
Thanks... I guess Gradle does not check for such things. I keep getting tripped up by typos, especially copy/paste errors The new error is
Copy code
e: /Users/eric.kolotyluk/git/autonomous-iam/poc/loom-laboratory/build.gradle.kts:62:1: Unresolved reference: runConfigurations
v
Well, did you apply the plugin?
e
This does not work in Gradle 8
Copy code
idea {
  project {
    settings {
      runConfigurations { }
      copyright { }
       // other project level settings
      }
    }
  }
so I am trying something like
Copy code
idea {
    project {
        configurations {
            run {
                default.configure {
                }

            }
        }
    }
}
But I cannot find any place to invoke
runConfigurations
Maybe
idea-ext
is just incompatible with Gradle 8 🤔
v
What's the error with the first of the two snippets? Looks fine at first look.
e
Copy code
e: /Users/eric.kolotyluk/git/autonomous-iam/poc/loom-laboratory/build.gradle.kts:76:9: Unresolved reference: settings
v
import org.jetbrains.gradle.ext.settings
Again, did you actually apply the plugin?
e
Do you mean, that with 3rd party plugins they must be explicitly applied?
v
Any plugin must be applied explicitly, built-in the same as 3rd party
Does it also complain when you build on commandline?
e
Copy code
eric.kolotyluk@Y2RCV7009N loom-laboratory % ./gradlew clean

> Configure project :
e: /Users/eric.kolotyluk/git/autonomous-iam/poc/loom-laboratory/build.gradle.kts:81:13: Unresolved reference: runConfigurations
e: /Users/eric.kolotyluk/git/autonomous-iam/poc/loom-laboratory/build.gradle.kts:82:13: Unresolved reference: copyright

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/eric.kolotyluk/git/autonomous-iam/poc/loom-laboratory/build.gradle.kts' line: 81

* What went wrong:
Script compilation errors:

  Line 81:             runConfigurations { }
                       ^ Unresolved reference: runConfigurations

  Line 82:             copyright { }
                       ^ Unresolved reference: copyright

2 errors
v
Yep, so
settings
is found, you just did not refresh the project. You also need to import those accessors.
Refresh the Gradle project and the code completion should also work properly
e
Doesn't help
v
?
e
Sorry, was on the phone... I will play around with it a bit more, it would be nice to get it working, but not a show stopper... I appreciate the help...
Okay, this helps
Copy code
import org.jetbrains.gradle.ext.settings
import org.jetbrains.gradle.ext.runConfigurations
but, before I could do that, I had to refresh in such a way that it downloaded stuff
Copy code
> Task :prepareKotlinBuildScriptModel UP-TO-DATE
Download <https://plugins.gradle.org/m2/gradle/plugin/org/jetbrains/gradle/plugin/idea-ext/gradle-idea-ext/1.1.6/gradle-idea-ext-1.1.6-sources.jar>, took 86 ms (23.15 kB)
Download <https://plugins.gradle.org/m2/com/google/guava/guava/28.2-jre/guava-28.2-jre-sources.jar>, took 185 ms (1.67 MB)
Download <https://plugins.gradle.org/m2/org/checkerframework/checker-qual/2.10.0/checker-qual-2.10.0-sources.jar>, took 74 ms (227.35 kB)

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See <https://docs.gradle.org/8.0-milestone-3/userguide/command_line_interface.html#sec:command_line_warnings>

BUILD SUCCESSFUL in 4s
So, it's important to do things in the right order...
But I don't know how to get defaults to work...
Some success
Copy code
idea {
    project {
        settings {
            compiler {
                javac {
                    javacAdditionalOptions = "--enable-preview"
                }
            }
        }
    }
}
Does the right thing, and loads Idea with the correct compiler setting, but I cannot figure out how to make
runConfiguration
work.
The problem may be that https://github.com/JetBrains/gradle-idea-ext-plugin/wiki#runConfigurations gives examples in Groovy, and I don't know how to translate Groovy to Kotlin.
v
That's the wrong bug tracker actually.
That issue also links to the tests that show how to use it from Kotlin as long as documentation is not updated
e
I tried using the example, but I still have problems...
v
Well, you have an error displayed. Look at it and it should be obvious that you use the wrong
Application
class.
Import the corret
Application
class from the idea-ext plugin and it will work
Besides that I would use the nicer kotlin dsl:
Copy code
create<Application>("Application") {
    ...
}
or to not use string identifiers
Copy code
val Application by creating(Application::class) {
    ...
}
Just like usualy with those named domain object containers in the kotlin dsl
e
Okay, this seems to work
Copy code
import org.jetbrains.gradle.ext.Application
. . .
idea {
    project {
        settings {
            compiler {
                javac {
                    if (javacAdditionalOptions == null) {
                        javacAdditionalOptions = "--enable-preview"
                    } else {
                        javacAdditionalOptions += " --enable-preview"
                    }
                }
            }
            runConfigurations {
                runConfigurations {
                    create("Run application", Application::class) {
                        mainClass = "com.forgerock.poc.loom.Application"
                        jvmArgs = "--enable-preview"
                    }
                }
            }
        }
    }
}
In this case, the Kotlin looks very different from the equivalent Groovy
Your improvement works too
Copy code
idea {
    project {
        settings {
            compiler {
                javac {
                    if (javacAdditionalOptions == null) {
                        javacAdditionalOptions = "--enable-preview"
                    } else {
                        javacAdditionalOptions += " --enable-preview"
                    }
                }
            }
            runConfigurations {
                runConfigurations {
                    create<Application>("Application") {
                        mainClass = "com.forgerock.poc.loom.Application"
                        jvmArgs = "--enable-preview"
                    }
                }
            }
        }
    }
}
However, I cannot find any way to set the classpath... 🤔
Okay, this helps
Copy code
runConfigurations {
                runConfigurations {
                    create<Application>("Run Application") {
                        mainClass = "com.forgerock.poc.loom.Application"
                        jvmArgs = "--enable-preview"
                        moduleName = "loom-laboratory.main"
                    }
                }
            }
v
runConfigurations
within
runConfigurations
does not make much sense though, that's just unnecessary noise
e
Doh! Bloody copy/paste...
v
And except for the
create
call it should be pretty similar to the Groovy version. Which is due to the extreme high flexibility and duck-typing Groovy provides opposed to Kotlin. But I still would always prefer Kotlin for much better IDE support and type-safety.
e
Yes, others have indicated that Kotlin will likely be be better supported than Groovy, so I doing my new work in Kotlin... in preparation from washing our Big Ball of Mud in the future...
Also, while I was fond of Groovy in the past, it is not as relevant to me as it used to be... The creator of Groovy said, if Scala had come earlier, he would not have created Groovy.
But, I know from experience that Kotlin is much safer than Scala.
v
I don't see where Kotlin will be better supported, except in the IDE. At least in Gradle they are equal and as far as I know will stay equally supported for the forseeable future. I just like the type-safety, the much better IDE support, und the more meaningful errors in some situations.
e
I think it was @Chris Lee who might have told me, or it could be someone else...
c
my comments were around the improved type-safety, IDE support, and error messages offer from Kotlin DSL vs Groovy DSL.
1
e
Anyway, I am practicing my Kotlin DSL now..., and will try to transition the Big Ball of Mud there some day...
👌 1
v
Yeah, so what I also said 🙂
👍 1
🤣 1
e
Also, Kotlin will continue to evolve as a language, but I doubt Groovy will Maybe they should rename Gradle to Kradle 😉
It was originally called Cradle...
So, it took a lot of effort, but now that I have
runConfigurations
working, I still cannot get
./gradlew run
to work with my app... but I will start a separate thread for that... Thanks @Vampire, you helped a lot
v
./gradlew run
has nothing to do with the run configurations you configure for IntelliJ
e
Yes, I know, which is why I will start a separate thread
👌 1
v
Btw. when was Gradle called Cradle? I use it since pre-1.0 and never seen "Cradle". And sure Groovy still evolves as a language. Not long ago Groovy 4 was released.
e

https://www.youtube.com/watch?v=FNeQOA2u8vQ

As an aside, I have spent so much time in Gradle this year, I am having trouble reading pom.xml files... all my Maven is getting evicted from my cache memory... 🙄
👌 1
v
Excellent 🙂
The video does not say it was called "Cradle". It says when Hans thought about a name he considered "Cradle", but didn't quite like it because it is not unique, so he thought "it is a Groovy cradle", let's call it "Gradle". 🙂
e
Yes, I know, I was taking a shortcut 😉
On the internet, when you say something wrong or imprecise, you will get noticed more than if you speak with veracity
v
That's a bad reason to spread fake news. 😄
e
LOL... and know we know the true power of fake news and alternate facts 😉
Anyway, it was not intentional, I could not remember the specific details of the video...
v
Yeah, no blame. Just wondered as I never heard of that. Besides of people using auto-correction calling it Cradle and just wanted to know for sure before I add it to my stock of useless facts. 😄
e
People who don't study history are doomed to repeat it...