Sheath Gradle Plugin

A Kotlin compiler plugin to avoid adding kapt to most modules in a dagger-android project.

License

License

Categories

Categories

Gradle Build Tools
GroupId

GroupId

dev.quiro.sheath
ArtifactId

ArtifactId

gradle-plugin
Last Version

Last Version

0.6.3
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

Sheath Gradle Plugin
A Kotlin compiler plugin to avoid adding kapt to most modules in a dagger-android project.
Project URL

Project URL

https://github.com/quiro91/sheath
Source Code Management

Source Code Management

https://github.com/quiro91/sheath

Download gradle-plugin

Dependencies

compile (1)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.4.32

runtime (2)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-gradle-plugin jar 1.4.32
org.jetbrains.kotlin : kotlin-gradle-plugin-api jar 1.4.32

Project Modules

There are no modules declared in this project.

Sheath

Maven Central CI

Sheath is a Kotlin compiler plugin created to improve build performances when using Dagger and Dagger-Android. Sheath allows you to generate Factory classes that usually the Dagger annotation processor would generate for @Provides methods, @Inject constructors, @Inject fields and @ContributesAndroidInjector methods. The benefit of this feature is that you don't need to enable the Dagger annotation processor in this module. That often means you can skip KAPT and the stub generating task. In addition Sheath generates Kotlin instead of Java code, which allows Gradle to skip the Java compilation task. The result is faster builds.

Sheath was forked from Anvil, an amazing project which helped me understanding Kotlin compiler plugins.

Setup

The plugin consists of a Gradle plugin and Kotlin compiler plugin. The Gradle plugin automatically adds the Kotlin compiler plugin and annotation dependencies. It needs to be applied in all modules that either contribute classes to the dependency graph or merge them:

plugins {
  id 'dev.quiro.sheath' version "${latest_version}"
}

Or you can use the old way to apply a plugin:

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath "dev.quiro.sheath:gradle-plugin:${latest_version}"
  }
}

apply plugin: 'dev.quiro.sheath'

Performance

Coming soon

Limitations

No Java support

Sheath is a Kotlin compiler plugin, thus Java isn’t supported. You can use Sheath in modules with mixed Java and Kotlin code for Kotlin classes, though.

Incremental Kotlin compilation breaks compiler plugins

There are two bugs that affect the Sheath Kotlin compiler plugin:

The Gradle plugin implements workarounds for these bugs, so you shouldn't notice them. Side effects are that incremental Kotlin compilation is disabled for stub generating tasks (which don't run a full compilation before KAPT anyways). The flag usePreciseJavaTracking is disabled, if the module contains Java code.

License

Copyright 2020 Square, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Versions

Version
0.6.3
0.6.2
0.6.0
0.5.0
0.4.3
0.4.2
0.4.1
0.4.0
0.3.0
0.2.0
0.1.0