For the location problem of the JS files we tried an other approach: Rewriting the @JavaScript at runtime
See following post - sources included
https://vaadin.com/forum#!/thread/4991257
Code for rewriting the annotations at runtime
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import at.sciencesoft.mathjax.MathJax;
import com.vaadin.annotations.JavaScript;
import com.vaadin.annotations.StyleSheet;
public class ChangeAnnotation {
static public void addJSpathToJavaScriptAnno(Class<?> clazz, String[] jsPathList)
throws Exception {
Annotation a = clazz.getAnnotation(JavaScript.class);
Object invocationHandler = Proxy.getInvocationHandler(a);
Field field = invocationHandler.getClass().getDeclaredField(
"memberValues");
field.setAccessible(true);
@SuppressWarnings("unchecked")
LinkedHashMap<String, String[]> map = (LinkedHashMap<String, String[]
>) field
.get(invocationHandler);
String[] paths = map.get("value");
ArrayList<String> pathList = new ArrayList<String>();
for (String s : paths) {
pathList.add(s);
}
for (String s : jsPathList) {
pathList.add(s);
}
map.put("value", pathList.toArray(new String[pathList.size()]
));
field.set(invocationHandler, map);
}
static public void setStyleSheet(Class<?> clazz, String[] cssPathList)
throws Exception {
Annotation a = clazz.getAnnotation(StyleSheet.class);
Object invocationHandler = Proxy.getInvocationHandler(a);
Field field = invocationHandler.getClass().getDeclaredField(
"memberValues");
field.setAccessible(true);
@SuppressWarnings("unchecked")
LinkedHashMap<String, String[]> map = (LinkedHashMap<String, String[]
>) field
.get(invocationHandler);
map.put("value",cssPathList);
field.set(invocationHandler, map);
}
}