I'm trying to automate publishing of an openapi generated java client.
Its a huge pain because the generated client configures its own publishing config in the generated build.gradle file. Eg: line 82-102 in the generated java-client/build.gradle
file:
} else {
apply plugin: 'java'
apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
publishing {
publications {
maven(MavenPublication) {
artifactId = 'openapi-java-client'
from components.java
}
}
}
task execute(type:JavaExec) {
main = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}
}
I try to override these settings in a parent build.gradle file like so:
allprojects {
apply plugin: 'maven-publish'
apply plugin: 'java'
publishing {
publications {
maven(MavenPublication) {
groupId = 'com.mycompany'
artifactId = 'ARTIFACT-NAME'
version = "v7.1.2"
from components.java
}
}
repositories {
maven {
credentials {
username = System.env.ART_USERNAME
password = System.env.ART_PASSWORD
}
url "https://artifactory.myartifactoryurl/artifactory/maven"
}
}
}
}
Parent settings.gradle
inclues the line: include('lib', 'java-client')
This doesn't work because apparently overriding doesnt work....
Error message "Maven publication 'maven' cannot include multiple components"
On the line 'from components.java' in 'java-client/build.gradle' it throws the error:
* What went wrong:
A problem occurred evaluating project ':java-client'.
> Maven publication 'maven' cannot include multiple components
I don't know how they expect us to configure publishing without some sort of externalized config like npm has via the .npmrc
file.
Does anyone have any tips and tricks for overriding the maven-publish settings already defined in a subproject without modifying the subproject directly?
Thanks for any help! This is a huge PITA the maven-plugin should address in my opinion.