Project Url: eleish/Tagged
More: Author   ReportBugs   

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


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

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"


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.1.1'
    kapt 'com.github.eleish:Tagged:1.1.1'

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

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


Apache 2.0. See the LICENSE file for details.

About Me
GitHub: Trinea
Facebook: Dev Tools