Using Manifold with Kotlin (and other JVM languages)

Although Manifold is a Java compiler plugin, you can reap many of its benefits from Kotlin and other JVM languages. For instance, Manifold support for GraphQL, JSON, XML, and Templates applies equally to other JVM languages such as Kotlin.

These features are called type manifolds and they work by automatically transforming resources such as .graphql, .json, and .xml files directly to Java types without a code generation step or compiling between changes in your IDE. With Kotlin these resources must be placed in a separate Java module, the indirection allows Manifold to transform the resources into types accessible from Kotlin. Perhaps the most important detail involves the Manifold IDE plugin. The development experience is identical to Java’s. For instance, you can drop a .graphql schema file into your project and immediately use the types it defines. Create your own .graphql query files and type-safely access them from Kotlin. Instantly use changes. All without compiling. Use IntelliJ or Android Studio to deterministically refactor/rename, find Kotlin usages from GraphQL, navigate to GraphQL declarations, code completion, etc. The same applies to all Manifold-enabled types including JSON, XML, Templates, etc.

Get the Manifold plugin

Get the Manifold plugin directly from within IntelliJ IDEA or Android Studio via Settings | Plugins | Marketplace | search "Manifold". You must restart Android Studio to enable the plugin.

The Kotlin sample application

The Kotlin sample application best illustrates how to setup your environment and build for use with Manifold. Use it as a reference to use Manifold with your own Kotlin app.

Note, Kotlin support is limited to type manifolds. Other Manifold features are exclusive to the Java language, these include the preprocessor, structural typing, extension classes, operator overloading, unit expressions, type-safe reflection, and the Self type.