Search code examples
groovykotlingradle-kotlin-dslkotlin-dsl

How can I write this Gradle build script snippet in Groovy?


I recently cloned a Gradle projcet (from GitHub) that its scripts is in Kotlin DSL (that I'm not comfortable with it). I could convert all of its scripts to Groovy except below snippet:

publishing {
​    publications {
​        register("mavenJava", MavenPublication::class) {
​            artifactId = base.archivesBaseName
​            from(components["java"])
​        }
​    }
}

What is its equivalent in Groovy?


Solution

  • publishing {
        publications {
            register("mavenJava", MavenPublication) {
                artifactId = archivesBaseName
                from components.java
            }
        }
    }
    

    Refer to this link for more information:

    https://guides.gradle.org/migrating-build-logic-from-groovy-to-kotlin/