kotlinx/ast

Error: There is no feature named GRADLE_METADATA

Closed this issue · 2 comments

Hi, I'm trying to get set up with this library for the first time so I can start using it. However, after following the instructions in #12 and running the gradle jar command, I keep getting this error: There is no feature named GRADLE_METADATA

I am confused how to proceed at this point? If I comment out that line, I get this error instead: KotlinSourceSet with name 'commonMain' not found. at build.gradle.kts' line: 27.

I am using Gradle 7.0 with Java 11. Below are my code files:

settings.gradle.kts
rootProject.name = "test"

enableFeaturePreview("GRADLE_METADATA")
build.gradle.kts
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    application
    kotlin("jvm") version "1.4.32"
}

group = "me.test"
version = "1.0-SNAPSHOT"

application {
    mainClass.set("MainKt")
}

repositories {
    mavenCentral()
    maven("https://jitpack.io")
}

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    api("com.github.kotlinx.ast:grammar-kotlin-parser-antlr-kotlin-jvm:816803892c")
}

kotlin {
    sourceSets {
        val commonMain by getting {
            dependencies {
                api("com.github.kotlinx.ast:grammar-kotlin-parser-antlr-kotlin:816803892c")
            }
        }
    }
}

tasks {
    withType<KotlinCompile> {
        kotlinOptions.jvmTarget = "11"
    }

    withType<Jar> {
        manifest {
            attributes["Main-Class"] = application.mainClass
        }
        exclude("**/module-info.class")
        from(configurations.runtimeClasspath.get().map {if (it.isDirectory) it else zipTree(it)})
    }

    test {
        useJUnitPlatform()
    }
}

Hi @takanuva15,

GRADLE_METADATA was removed in Gradle 7.0, you can just remove this line, it is no longer required.

You are using the JVM-only Kotlin Plugin kotlin("jvm"), but commonMain is a Multiplatform (kotlin("multiplatform")) SourceSet name, please try just main or the multiplatform plugin.

kotlin {
    sourceSets {
        val main by getting {

Sweet thanks! It's working now