0

I am migrating my groovy syntac to kotlin dsl and struggling while building the buildRpm() task provided by nebula plugin.

Currntly I have in my builod.gradle.kts

plugins {

  id("nebula.ospackage") version "8.3.0"

}
apply(plugin = "nebula.rpm")

I am creating my task with the following:

val buildRpm by creating(Rpm::class) {
  println("building")
}

and when running ./gradlew buildRpm I get Unresolved reference: Rpm

How can I create Rpm with kotlin dsl then ?

JPV
  • 1,079
  • 1
  • 18
  • 44

1 Answers1

0

Here is how you want to set up your Gradle:

plugins {
  id("nebula.ospackage") version "8.3.0"
}

You don't need apply here as that is already done when you declare your plugin usage as above above.

And the task:

val buildRpm by tasks.creating(Rpm::class) {

}

And make sure to import the Rpm task at the top of the file.

GreenSaguaro
  • 2,968
  • 2
  • 22
  • 41
  • Two thingns: intellIj does not offer autocompletion and second if I execute that task in the main script it runs successful but not in when it is this external file – JPV Jul 12 '23 at 19:34
  • IntelliJ does have auto-completion for Gradle Kotlin DSL. I use it all the time. Maybe you need to upgrade your IntelliJ version or check the configuration? – GreenSaguaro Jul 13 '23 at 15:40
  • For the second part, what do you mean by "external file"? Can you explain that? – GreenSaguaro Jul 13 '23 at 15:41
  • I want to brake the main build.gradle.kts into sub files since the files is gettting too big – JPV Jul 14 '23 at 07:22
  • To do this, you add a `build.gradle.kts` into each subproject directory. – GreenSaguaro Jul 14 '23 at 20:03