Hi,
At our company, our product is a Java project which uses some non-jar artifacts. We put these artifacts in a bin folder and reference them in our project by their name.
We currently build them in TeamCity and download the latest artifact from there.
We would like to upload them to a Maven repository instead add add them to Gradle as dependencies. For this, I’m using maven-publish plugin and I’m repeating the following pattern:
task zipNAME (type: Zip) {
from _SOURCE_
baseName _BASE_NAME_
destinationDir = _DESTINATION_
}
publishing.publications {
_NAME_(MavenPublication) {
artifactId _ARTIFACT_ID_
artifact zip_NAME_.archivePath
}
}
generatePomFileFor_NAME_Publication.dependsOn zip_NAME_
task publish_NAME_ {
dependsOn publish_NAME_PublicationToMavenRepository
}
I would like to reduce this to something like:
publishing.publications {
_NAME_(MavenPublication) {
artifactId _ARTIFACT_ID_
artifactCreation {
from _SOURCE_
basename _BASE_NAME_
destinationDir = _DESTINATION_
}
}
}
What I tried:
- Writing a plugin with extension which created a publication and zip task, by following MavenPublishPlugin.java as an example. I got stuck when the task name from my extension wasn’t available when in my action.
- Creating my own MavenPublication interface, e.g., MavenZipPublication. But I’m not sure where I can “register” it and provide it’s implementation. When I just try to replace MavenPublication with zip version, I get the error:
Cannot create a MavenZipPublication because this type is not known to this container. Known types are: MavenPublication
I would appreciate any help or suggestions.
Thanks