Unable to publish to maven local with gradle 7.3.3.
project's build.gradle:
plugins {
id 'java'
id 'java-library'
id 'maven-publish'
}
def gitBranch() {
def branch = ""
def proc = "git rev-parse --abbrev-ref HEAD".execute()
proc.in.eachLine { line -> branch = line }
proc.err.eachLine { line -> println line }
proc.waitFor()
branch
}
group = 'my.project'
version = gitBranch()
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
test {
useJUnitPlatform()
}
subprojects {
project.version = gitBranch()
apply plugin: 'maven-publish'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
flatDir {
dirs "../ZKM"
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifactId = jar.archiveBaseName
}
}
}
repositories {
mavenLocal()
mavenCentral()
}
}
This returns the error:
A problem occurred evaluating root project 'my-project'. Could not get unknown property 'java' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.