Import registered task from BuildSrc to build.gradle.kts

134 Views Asked by At

I have achieved to migrate my gradle task performing RPM packages from as a custom script inside the buildSrc directory.

The file is located in : buildSrc/main/kotlin/rpm.gradle.kts

import com.netflix.gradle.plugins.rpm.Rpm

buildscript {
  repositories {
  jcenter()
  mavenCentral()
  }
}


apply(plugin="nebula.rpm")


tasks.register<Rpm>("MyTask") {
  os = org.redline_rpm.header.Os.LINUX
  packageName="app"
  release = "1"
  user = "root"
  packageGroup = "root"
  permissionGroup = "root"
  epoch = 0
  version = "test"
}

I am trying to import the task into the main build.gradle.kts and run MyTask to perform an RPM package but not possible. Note that I am trying to import my custom script inside the plugins block without success

plugins {

    id("rpm")
}

Gradle says rpm is not detected and throwing an error.

Note: My buildSrc/build.gradle.kts looks like

repositories {
  mavenCentral()
  maven {
    url = uri("https://plugins.gradle.org/m2/")
  }
}

plugins {
  kotlin("jvm") version "1.3.72"
  //id("org.gradle.kotlin.kotlin-dsl")
  `kotlin-dsl`
  `java-gradle-plugin`
  `kotlin-dsl-precompiled-script-plugins`
}



dependencies {

  implementation("com.netflix.nebula:gradle-ospackage-plugin:8.4.1")

}

Thanks

0

There are 0 best solutions below