threadannotations is a light-weight Java-library for thread annotations with Java-agent to enforce them.
Annotate your classes and methods using
@SwingThread
@SingleThread
@MultiThread
and enforce annotatios using Java-agent while testing your code.
You can leave the annotations in your production code; without Java-agent, they cause no performance penalty.
- Add the maven repository
repositories { maven { url 'https://dl.bintray.com/sjappig/threadannotations' } }
- Add the annotations and start using them
dependencies { compile 'io.threadannotations:threadannotations:+' }
- Enforce the annotations during tests using the agent
configurations { testAgent } dependencies { testAgent 'io.threadannotations:threadannotations-agent:+' } // assuming java-plugin test.jvmArgs "-javaagent:${configurations.testAgent.singleFile}"
- If needed, enforce the annotations when running the application
// assuming application-plugin applicationDefaultJvmArgs << "-javaagent:${configurations.testAgent.singleFile}"