Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 869 Bytes

Readme.md

File metadata and controls

34 lines (26 loc) · 869 Bytes

Groovy Get-Source

CircleCI

This is a small AST transformation that allows you to get the source code of a Class at run-time.

Example

@SaveSource
class AClass {

    def getCode() {
        SourceCode sourceCode = this.class.getAnnotation(SourceCode)
        return sourceCode.value()
    }
}

Usage

You can add a dependency to you build via jitpack.

repositories {
    maven { url 'https://jitpack.io' }
}
dependencies {
    compile 'com.github.MeneDev:groovy-get-source:96746d39f3'
}

Notes

This was created as an answer to the question Source code of current file in Groovy on Stackoverflow.