summaryrefslogtreecommitdiffstats
path: root/test/dependency-rewrite-addon
diff options
context:
space:
mode:
authorArtur <artur@vaadin.com>2017-05-02 08:30:59 +0300
committerIlia Motornyi <elmot@vaadin.com>2017-05-02 08:30:59 +0300
commitf8921dc387a572b12ac7c9c6f4677e5a1d0e5b70 (patch)
treebe13f735bb10458e54d80e722242c902c5f2b8e5 /test/dependency-rewrite-addon
parent9c443c9de42343a94df5f7040bfed731f8d8f84e (diff)
downloadvaadin-framework-f8921dc387a572b12ac7c9c6f4677e5a1d0e5b70.tar.gz
vaadin-framework-f8921dc387a572b12ac7c9c6f4677e5a1d0e5b70.zip
Add support for pluggable filters for rewriting dependencies (#9182)
* Add support for pluggable filters for rewriting dependencies Fixes #9151
Diffstat (limited to 'test/dependency-rewrite-addon')
-rw-r--r--test/dependency-rewrite-addon/pom.xml19
-rw-r--r--test/dependency-rewrite-addon/src/main/java/com/vaadin/test/dependencyrewriteaddon/RewriteJQueryFilter.java28
-rw-r--r--test/dependency-rewrite-addon/src/main/resources/META-INF/services/com.vaadin.server.DependencyFilter1
3 files changed, 48 insertions, 0 deletions
diff --git a/test/dependency-rewrite-addon/pom.xml b/test/dependency-rewrite-addon/pom.xml
new file mode 100644
index 0000000000..f822e34b77
--- /dev/null
+++ b/test/dependency-rewrite-addon/pom.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-test</artifactId>
+ <version>8.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>vaadin-test-dependency-rewrite-addon</artifactId>
+ <packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-test-widget-set-testutil</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/test/dependency-rewrite-addon/src/main/java/com/vaadin/test/dependencyrewriteaddon/RewriteJQueryFilter.java b/test/dependency-rewrite-addon/src/main/java/com/vaadin/test/dependencyrewriteaddon/RewriteJQueryFilter.java
new file mode 100644
index 0000000000..415bb9b093
--- /dev/null
+++ b/test/dependency-rewrite-addon/src/main/java/com/vaadin/test/dependencyrewriteaddon/RewriteJQueryFilter.java
@@ -0,0 +1,28 @@
+package com.vaadin.test.dependencyrewriteaddon;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import com.vaadin.server.DependencyFilter;
+import com.vaadin.ui.Dependency;
+import com.vaadin.ui.Dependency.Type;
+
+public class RewriteJQueryFilter implements DependencyFilter {
+
+ @Override
+ public List<Dependency> filter(List<Dependency> dependencies,
+ FilterContext filterContext) {
+ List<Dependency> filtered = new ArrayList<>();
+ for (Dependency dependency : dependencies) {
+ if (dependency.getType() == Type.JAVASCRIPT && dependency.getUrl()
+ .toLowerCase(Locale.ENGLISH).contains("jquery")) {
+ filtered.add(
+ new Dependency(Type.JAVASCRIPT, "vaadin://jquery.js"));
+ } else {
+ filtered.add(dependency);
+ }
+ }
+ return filtered;
+ }
+}
diff --git a/test/dependency-rewrite-addon/src/main/resources/META-INF/services/com.vaadin.server.DependencyFilter b/test/dependency-rewrite-addon/src/main/resources/META-INF/services/com.vaadin.server.DependencyFilter
new file mode 100644
index 0000000000..f62efa26fd
--- /dev/null
+++ b/test/dependency-rewrite-addon/src/main/resources/META-INF/services/com.vaadin.server.DependencyFilter
@@ -0,0 +1 @@
+com.vaadin.test.dependencyrewriteaddon.RewriteJQueryFilter