I’m writing a binary plugin to centralize the publishing configuration for our org’s projects.
In essence, I want to have one place where all our maven publication and repository information is kept so that developers don’t have to add this information to every one of their build scripts.
I’m writing the plugin in Java per the documentation’s recommendation to use a static language. However, I can’t figure out a straightforward way to set up the maven-publish configuration programmatically via Java.
I’m relatively new to Gradle and Groovy.
This is what I have:
Task defaultMavenPublishTask = project.getProject() .getTasksByName("publish", false) .stream() .findFirst() .orElseThrow(() -> new RuntimeException()); // TODO how do I configure the maven publish task (i.e. add configurations and repository info) using Java? myPublishTask.dependsOn(defaultMavenPublishTask);