Skip to content
No description, website, or topics provided.
Kotlin
Branch: master
Clone or download
Mohamed Eleish
Mohamed Eleish added com.mohamedeleish.tagged.processor.TaggedProcessor to tagged/sr…
…c/main/resources/META-INF/services to eliminat the need for google auto services dependency and java target from the app module gradle file
Latest commit 666cd08 Nov 27, 2019

README.md

Tagged

Tagged is a simple library built in kotlin to automate fragments tags declaration and initialization using annotation processing and code generation.

Usage

Simply annotate your fragments with @Tagged to generate a tag with the fully qualified name

@Tagged
class SampleFragmentOne: Fragment()

you can also pass in your custom tag

@Tagged(customTag = "MyCustomTag")
class SampleFragmentTwo : Fragment()

and you can also pass in your custom tag val name to prevent changes after refactoring a fragment name

@Tagged(customValName = "MyCustomValName")
class SampleFragmentThree : Fragment()

rebuild your project and you will find your generated Tags.kt file in the java(generated) folder under tagged.generated

package tagged.generated

import kotlin.String

const val MyCustomValName: String = "com.mohamedeleish.tagged.sample.SampleFragmentThree"

const val SAMPLE_FRAGMENT_ONE_TAG: String = "com.mohamedeleish.tagged.sample.SampleFragmentOne"

const val SAMPLE_FRAGMENT_TWO_TAG: String = "MyCustomTag"

Setup

1 - In build.gradle (app module)

// 1 - Add kotlin annotation processor plugin to the top of the file
apply plugin: 'kotlin-kapt' 
   
android {
    defaultConfig {
        // 2 - Set includeCompileClasspath to false
        javaCompileOptions {
             annotationProcessorOptions {
                includeCompileClasspath false
            }
        }
     } 
}  
   
dependencies { 
    // 3 - Add the library dependancy
    implementation 'com.github.eleish:Tagged:1.0.0'
    kapt 'com.github.eleish:Tagged:1.0.0'
}

2 - In build.gradle (project) add the required repositories

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

License

Apache 2.0. See the LICENSE file for details.

You can’t perform that action at this time.