Skip to content

Instantly share code, notes, and snippets.

@xhanin
xhanin / README.md
Created April 7, 2014 19:42
Java Annotation Processing Notes

A few notes on java annotation processing, collected when working on RESTX annotation processor.

Don't register multiple annotation processor on same annotation.

It fails silently.

Disable annotation processing in module defining an annotation processor.

Use -proc:none javac option. In restx build you can use this fragment: classpath:///restx/build/fragments/maven/annotation-processing-disable.xml

@xhanin
xhanin / endpoint-fragment.java
Created April 6, 2014 19:57
RESTX java 8 endpoint with lambda capturing local variable
@GET("/helloConcat")
@PermitAll
public Iterable<String> concatMessages(String q) {
String c = q + "test";
return asList(NAMES)
.stream()
.map((s) -> (s + c))
.collect(Collectors.toList());
}
@xhanin
xhanin / maven-copy-dependencies-fragment.xml
Created April 5, 2014 12:26
maven copy dependencies fragment
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
@xhanin
xhanin / maven-snapshot-repositories-fragment.xml
Created April 5, 2014 12:26
Maven Snapshot repository fragment
<repositories>
<repository>
<id>snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>
@xhanin
xhanin / DirWatcher.groovy
Created April 3, 2014 09:09
Simple groovy script to watch a directory, using RESTX API
#!/bin/groovy
@Grab(group='io.restx', module='restx-common', version='0.31.1')
@Grab(group='io.restx', module='restx-barbarywatch', version='0.31.1') // useful for MacOSX only
import restx.common.MoreFiles
import restx.common.watch.FileWatchEvent
import restx.common.watch.WatcherSettings
import com.google.common.eventbus.EventBus
import com.google.common.eventbus.Subscribe
<repositories>
<repository>
<id>project.local</id>
<name>project</name>
<url>file:${project.basedir}/repo</url>
</repository>
</repositories>
@xhanin
xhanin / gist:6965995
Created October 13, 2013 18:57
diff 2 directories in zsh
# suppose you have a set of files in target/base-deps
# and want to remove files in target/dependency with the same names
for f (target/base-deps/*.jar) {rm $f:s/base-deps/dependency/}
@xhanin
xhanin / install-mongodb-deb.sh
Created September 11, 2013 21:52
A script to install MongoDB on Debian, based on instructions provided here: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install -y mongodb-10gen
@xhanin
xhanin / plugin.groovy
Created February 18, 2013 17:16
Remove all setters or getters in a class (IntellijEval plugin). Example use case: move from regular getters/setters to fluent interface: - use this plugin to remove getters / setters - use http://code.google.com/p/idea-generate-fluent-interface/ to generate fluent interface methods
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiModifier
import com.intellij.psi.util.PsiTreeUtil
import static intellijeval.PluginUtil.*
def findContextClass = { project ->
def editor = currentEditorIn(event.project);
@xhanin
xhanin / plugin.groovy
Created February 13, 2013 22:20
ISO DateTime / Epoch timestamp converter plugin for IntellijEval
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.editor.SelectionModel
import org.joda.time.*
import static intellijeval.PluginUtil.*
// add-to-classpath $HOME/.m2/repository/joda-time/joda-time/2.1/joda-time-2.1.jar
registerAction("TransformDateISOEpoch", "ctrl alt shift T") { AnActionEvent event ->
def editor = currentEditorIn(event.project)