# HG changeset patch # User Jaroslav Tulach # Date 1429111288 -7200 # Node ID e678bb6beb1f74d5651ff9147ce9372b4b8b1ad9 # Parent 9fb23d7831dacedb00cb60581d708b3d8ad1b470 Never include @JavaScriptResource files in generated library wrappers diff -r 9fb23d7831da -r e678bb6beb1f ko/bck2brwsr/pom.xml --- a/ko/bck2brwsr/pom.xml Wed Apr 15 14:32:54 2015 +0200 +++ b/ko/bck2brwsr/pom.xml Wed Apr 15 17:21:28 2015 +0200 @@ -48,6 +48,18 @@ false + + maven-failsafe-plugin + 2.16 + + + + integration-test + verify + + + + diff -r 9fb23d7831da -r e678bb6beb1f ko/bck2brwsr/src/test/java/org/apidesign/bck2brwsr/ko2brwsr/MinifiedIT.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ko/bck2brwsr/src/test/java/org/apidesign/bck2brwsr/ko2brwsr/MinifiedIT.java Wed Apr 15 17:21:28 2015 +0200 @@ -0,0 +1,60 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012-2015 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.ko2brwsr; + +import java.io.File; +import java.io.InputStream; +import java.net.URL; +import java.util.Enumeration; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import org.testng.annotations.Test; +import static org.testng.Assert.*; +import org.testng.annotations.BeforeMethod; +import org.testng.reporters.Files; + +public class MinifiedIT { + private File file; + + @BeforeMethod public void findPrecompiledLibraries() throws Exception { + File dir = new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile(); + for (File f : dir.listFiles()) { + if (f.getName().endsWith("-bck2brwsr.jar")) { + file = f; + return; + } + } + fail("Cannot find precompiled libraries in " + dir); + } + + @Test public void minifiedVersionDoesNotContainFQN() throws Exception { + JarFile jf = new JarFile(file); + Enumeration en = jf.entries(); + while (en.hasMoreElements()) { + JarEntry e = en.nextElement(); + String content; + try (InputStream is = jf.getInputStream(e)) { + content = Files.readFile(is); + } + if (content.contains("registerResource']('org/netbeans/html/ko4j/knockout")) { + fail("@JavaScriptResource resource should be missing: "+ e.getName() + " in " + file); + } + } + } + +} diff -r 9fb23d7831da -r e678bb6beb1f rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java Wed Apr 15 14:32:54 2015 +0200 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java Wed Apr 15 17:21:28 2015 +0200 @@ -691,6 +691,7 @@ @Override protected void requireResource(String resourcePath) throws IOException { requireResourceImpl(resourcePath); + super.asBinary.remove(resourcePath); } } @@ -791,6 +792,7 @@ @Override protected void requireResource(String resourcePath) throws IOException { requireResourceImpl(resourcePath); + super.asBinary.remove(resourcePath); } } }