# HG changeset patch # User Jaroslav Tulach # Date 1424772107 -3600 # Node ID 3085649750a456064e4d498f74f7fda771848b3f # Parent 11679a57a895fdc013bc3817ec752bab19121aaf The closure compiler was broken due to presence of old version of sisu-guava. Exclude and test minification works on JavaQuery API. diff -r 11679a57a895 -r 3085649750a4 javaquery/demo-calculator/pom.xml --- a/javaquery/demo-calculator/pom.xml Mon Feb 23 09:00:13 2015 +0100 +++ b/javaquery/demo-calculator/pom.xml Tue Feb 24 11:01:47 2015 +0100 @@ -125,5 +125,11 @@ bck2brwsr provided + + org.testng + testng + 6.8.8 + test + diff -r 11679a57a895 -r 3085649750a4 javaquery/demo-calculator/src/test/java/org/apidesign/bck2brwsr/demo/calc/staticcompilation/MinifiedTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/demo-calculator/src/test/java/org/apidesign/bck2brwsr/demo/calc/staticcompilation/MinifiedTest.java Tue Feb 24 11:01:47 2015 +0100 @@ -0,0 +1,95 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ +package org.apidesign.bck2brwsr.demo.calc.staticcompilation; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.Enumeration; +import java.util.Map; +import java.util.jar.Attributes; +import java.util.jar.Manifest; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +public class MinifiedTest { + @Test public void minifiedVersionDoesNotContainFQN() throws Exception { + final ClassLoader l = MinifiedTest.class.getClassLoader(); + Enumeration en = l.getResources("META-INF/MANIFEST.MF"); + while (en.hasMoreElements()) { + URL u = en.nextElement(); + Manifest mf = new Manifest(u.openStream()); + for (Map.Entry entrySet : mf.getEntries().entrySet()) { + String key = entrySet.getKey(); + if (!key.contains("-min.js")) { + continue; + } + if (!key.contains("javaquery.api")) { + continue; + } + try (BufferedReader r = new BufferedReader(new InputStreamReader(l.getResourceAsStream(key)))) { + for (;;) { + String line = r.readLine(); + if (line == null) { + break; + } + if (line.contains(" org_apidesign_bck2brwsr_htmlpage_Knockout")) { + fail("Found FQN of non-public class. Is it minified version?: " + line + " in " + key); + } + } + } + // success + return; + } + } + fail("No minified javaquery found: " + System.getProperty("java.class.path")); + } + + @Test public void debugVersionContainsFQN() throws Exception { + final ClassLoader l = MinifiedTest.class.getClassLoader(); + Enumeration en = l.getResources("META-INF/MANIFEST.MF"); + while (en.hasMoreElements()) { + URL u = en.nextElement(); + Manifest mf = new Manifest(u.openStream()); + for (Map.Entry entrySet : mf.getEntries().entrySet()) { + String key = entrySet.getKey(); + if (!key.contains("-debug.js")) { + continue; + } + if (!key.contains("javaquery.api")) { + continue; + } + try (BufferedReader r = new BufferedReader(new InputStreamReader(l.getResourceAsStream(key)))) { + for (;;) { + String line = r.readLine(); + if (line == null) { + break; + } + if (line.contains(" org_apidesign_bck2brwsr_htmlpage_Knockout")) { + // ok, it should be there + return; + } + } + } + fail("Found no FQN of non-public Knockout class. Is it debug version?:" + key); + } + } + fail("No debug javaquery found: " + System.getProperty("java.class.path")); + } + +} diff -r 11679a57a895 -r 3085649750a4 rt/mojo/pom.xml --- a/rt/mojo/pom.xml Mon Feb 23 09:00:13 2015 +0100 +++ b/rt/mojo/pom.xml Tue Feb 24 11:01:47 2015 +0100 @@ -52,6 +52,12 @@ maven-plugin-api 3.0.4 jar + + + org.sonatype.sisu + sisu-guava + + org.apache.maven.plugin-tools