USER'S GUIDE SOURCE CODE SAMPLES CONTACT DONATE

In this guide, we are going to see how to install Jeta using gradle build system. Currently, jCenter repository is the way to get the artifacts. It may be available on maven repository in a future release.

Add next lines into your build.gradle:

repositories {
    jcenter()
}

dependencies {
    apt 'org.brooth.jeta:jeta-apt:2.3'
    compile 'org.brooth.jeta:jeta:2.3'
}

In order to use apt, you need to install an appropriate plugin as well. Follow gradle apt plugins page to find out the options. For this example let’s choose net.ltgt.apt:

buildscript {
    repositories {
        maven {
            url 'https://plugins.gradle.org/m2/'
        }
    }

    dependencies {
        classpath 'net.ltgt.gradle:gradle-apt-plugin:0.5'
    }
}

apply plugin: 'net.ltgt.apt'

After the plugin is applied, you can use apt to setup the annotation processing environment.

jeta.properties

In the next step, it’s recommended to create jeta.properties file to be able to config code generation behavior. You should put this file into root package of the source set. Complete configuration guide is on this page. At this step - to provide metasitory.package property is enough:

metasitory.package=com.example

Note metasitory.package has to be unique for any module. MapMetasitoryWriter uses this package to generate metasitory containers in it. Follow this guide to get information about metasitories.

To allow jeta.properties to be found by Jeta one extra step is needed. In case you put this file in the root package, you can provide the sourcepath by adding next snippet into your build.gradle:

compileJava {
    options.sourcepath = files('src/main/java')
}

For a reason Gradle doesn’t provide it by itself.

Another available option - jetaProperties apt argument. Some of the plugins support providing such arguments (net.ltgt.apt currently doesn’t)

apt {
    arguments {
        jetaProperties "$project.projectDir/src/main/java/jeta.properties"
    }
}

Complete build.gradle:

buildscript {
    repositories {
        maven {
            url 'https://plugins.gradle.org/m2/'
        }
    }
    dependencies {
        classpath 'net.ltgt.gradle:gradle-apt-plugin:+'
    }
}

apply plugin: 'net.ltgt.apt'

repositories {
    jcenter()
}

compileJava {
    options.sourcepath = files('src/main/java')
}

dependencies {
    apt 'org.brooth.jeta:jeta-apt:2.3'
    compile 'org.brooth.jeta:jeta:2.3'
}

At this point, you can start using Jeta, but properly configured, it’s the better way to go. Refer to the next guide to find out details.

How it works:

User's Guide:

Androjeta

Advanced

Stable version: 2.3
Available on Java 1.7+
Android Compatible
Fork me on GitHub