[[build-tool-plugins.other-build-systems]]
= Supporting Other Build Systems

If you want to use a build tool other than Maven, Gradle, or Ant, you likely need to develop your own plugin.
Executable jars need to follow a specific format and certain entries need to be written in an uncompressed form (see the xref:specification:/executable-jar/index.adoc[executable jar format] section in the appendix for details).

The Spring Boot Maven and Gradle plugins both make use of `spring-boot-loader-tools` to actually generate jars.
If you need to, you may use this library directly.



[[build-tool-plugins.other-build-systems.repackaging-archives]]
== Repackaging Archives

To repackage an existing archive so that it becomes a self-contained executable archive, use javadoc:org.springframework.boot.loader.tools.Repackager[].
The javadoc:org.springframework.boot.loader.tools.Repackager[] class takes a single constructor argument that refers to an existing jar or war archive.
Use one of the two available `repackage()` methods to either replace the original file or write to a new destination.
Various settings can also be configured on the repackager before it is run.



[[build-tool-plugins.other-build-systems.nested-libraries]]
== Nested Libraries

When repackaging an archive, you can include references to dependency files by using the javadoc:org.springframework.boot.loader.tools.Libraries[] interface.
We do not provide any concrete implementations of javadoc:org.springframework.boot.loader.tools.Libraries[] here as they are usually build-system-specific.

If your archive already includes libraries, you can use javadoc:org.springframework.boot.loader.tools.Libraries#NONE[].



[[build-tool-plugins.other-build-systems.finding-main-class]]
== Finding a Main Class

If you do not use `Repackager.setMainClass()` to specify a main class, the repackager uses https://asm.ow2.io/[ASM] to read class files and tries to find a suitable class with a `public static void main(String[] args)` method.
An exception is thrown if more than one candidate is found.



[[build-tool-plugins.other-build-systems.example-repackage-implementation]]
== Example Repackage Implementation

The following example shows a typical repackage implementation:

include-code::MyBuildTool[]
