Maven-publish apply error

I have a huge project with several subproject and I would like to publish the output of it to a local archiva repo. But I stucked at the first step: when I add the maven-publish plugin to the subproject:

plugins {
    base
    `maven-publish`
}

I got the error:

An exception occurred applying plugin request [id: ‘org.gradle.maven-publish’]
Failed to apply plugin [class ‘org.gradle.api.publish.plugins.PublishingPlugin’]
Project#afterEvaluate(Action) on project ‘:ptt-kotlin’ cannot be executed in the current context.

My core build.kts (cleaned up a little):

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    kotlin("jvm") version Versions.kotlin
    java
    idea
    base
    application
}

group = "hu.vissy"
version = "1.0"

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

}

repositories {
    mavenCentral()
}

configure(allprojects) {
    repositories {
        maven("https://oss.sonatype.org/content/repositories/snapshots")
        maven("https://dl.bintray.com/jerady/maven")
        jcenter()
    }
}

configure(subprojects) {

    apply(plugin = "java")
    apply(plugin = "kotlin")

    dependencies {
        implementation(Libs.log4j2core)
        implementation(Libs.log4j2api)

        implementation(Libs.gson)
        implementation(Libs.guava)
        implementation(Libs.protobuf)

        implementation(kotlin("stdlib"))

        testImplementation(Libs.testNg)
    }

    tasks.withType<Test> {
        useTestNG()
    }

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

    configure<JavaPluginConvention> {
        sourceCompatibility = JavaVersion.VERSION_11
    }
}

And the whole submodule.build.kts is

plugins {
    base
    `maven-publish`
}

repositories {
    mavenCentral()
    jcenter()
//    maven {
//        credentials {
//            username="un"                // credentials of Archiva services
//            password="pwd"
//        }
//        url= uri("http://localhost:8080/repository/internal/")
//    }
}


dependencies {
    api(Libs.ptt)
}

//publishing {
//    publications {
//        create<MavenPublication>("maven") {
//            groupId = "org.gradle.sample"
//            artifactId = "project1-sample"
//            version = "1.1"
//
//            from(components["java"])
//
//        }
//    }
//}    

I’ve commented out all publish related code to see if it cause the error, but not, the apply itself.

Is there any idea, what I did wrong?