How do you extract Gradle subprojects into standalone libraries?

142 Views Asked by At

In one of my coding projects, I created an extensive utility API as a Gradle subproject. Now, I've realized that the code I've written is really powerful, and I want to extract it into a standalone Gradle project that can be uploaded to Maven. How do you do this?

1

There are 1 best solutions below

0
On BEST ANSWER

Create a new Gradle project via init plugin, select Java library: https://docs.gradle.org/current/userguide/build_init_plugin.html#sec:java_library

Following the documentation for building Java libraries: https://docs.gradle.org/current/samples/sample_building_java_libraries.html

You should also read more about the Java Library plugin as well: https://docs.gradle.org/current/userguide/java_library_plugin.html

Once you are ready to publish, you will want to configure the Maven Publish plugin: https://docs.gradle.org/current/userguide/publishing_maven.html

There is also a plugin that can aid publishing to Central: https://github.com/gradle-nexus/publish-plugin