1.1 --- a/javaquery/demo-twitter/pom.xml Mon Apr 29 08:37:23 2013 +0200
1.2 +++ b/javaquery/demo-twitter/pom.xml Mon Apr 29 09:53:45 2013 +0200
1.3 @@ -45,6 +45,7 @@
1.4 <properties>
1.5 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1.6 <bck2brwsr.obfuscationlevel>MINIMAL</bck2brwsr.obfuscationlevel>
1.7 + <brwsr.startpage>org/apidesign/bck2brwsr/demo/twitter/index.html</brwsr.startpage>
1.8 </properties>
1.9 <build>
1.10 <plugins>
1.11 @@ -60,7 +61,7 @@
1.12 </execution>
1.13 </executions>
1.14 <configuration>
1.15 - <startpage>org/apidesign/bck2brwsr/demo/twitter/index.html</startpage>
1.16 + <startpage>${brwsr.startpage}</startpage>
1.17 <launcher>${brwsr}</launcher>
1.18 </configuration>
1.19 </plugin>
1.20 @@ -136,6 +137,45 @@
1.21 <properties>
1.22 <brwsr>fxbrwsr</brwsr>
1.23 </properties>
1.24 + <build>
1.25 + <plugins>
1.26 + <plugin>
1.27 + <groupId>org.apache.maven.plugins</groupId>
1.28 + <artifactId>maven-jar-plugin</artifactId>
1.29 + <version>2.4</version>
1.30 + <configuration>
1.31 + <archive>
1.32 + <manifest>
1.33 + <mainClass>org.apidesign.bck2brwsr.launcher.FXBrwsrLauncher</mainClass>
1.34 + <addClasspath>true</addClasspath>
1.35 + <classpathPrefix>lib/</classpathPrefix>
1.36 + </manifest>
1.37 + <manifestEntries>
1.38 + <StartPage>${brwsr.startpage}</StartPage>
1.39 + </manifestEntries>
1.40 + </archive>
1.41 + </configuration>
1.42 + </plugin>
1.43 + <plugin>
1.44 + <artifactId>maven-assembly-plugin</artifactId>
1.45 + <version>2.4</version>
1.46 + <executions>
1.47 + <execution>
1.48 + <id>distro-assembly</id>
1.49 + <phase>package</phase>
1.50 + <goals>
1.51 + <goal>single</goal>
1.52 + </goals>
1.53 + <configuration>
1.54 + <descriptors>
1.55 + <descriptor>src/main/assembly/fxbrwsr.xml</descriptor>
1.56 + </descriptors>
1.57 + </configuration>
1.58 + </execution>
1.59 + </executions>
1.60 + </plugin>
1.61 + </plugins>
1.62 + </build>
1.63 <dependencies>
1.64 <dependency>
1.65 <groupId>org.apidesign.html</groupId>
1.66 @@ -146,7 +186,7 @@
1.67 <groupId>${project.groupId}</groupId>
1.68 <artifactId>launcher.fx</artifactId>
1.69 <version>${project.version}</version>
1.70 - <scope>test</scope>
1.71 + <scope>runtime</scope>
1.72 </dependency>
1.73 </dependencies>
1.74 </profile>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/javaquery/demo-twitter/src/main/assembly/fxbrwsr.xml Mon Apr 29 09:53:45 2013 +0200
2.3 @@ -0,0 +1,42 @@
2.4 +<?xml version="1.0"?>
2.5 +<!--
2.6 +
2.7 + Back 2 Browser Bytecode Translator
2.8 + Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
2.9 +
2.10 + This program is free software: you can redistribute it and/or modify
2.11 + it under the terms of the GNU General Public License as published by
2.12 + the Free Software Foundation, version 2 of the License.
2.13 +
2.14 + This program is distributed in the hope that it will be useful,
2.15 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2.16 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.17 + GNU General Public License for more details.
2.18 +
2.19 + You should have received a copy of the GNU General Public License
2.20 + along with this program. Look for COPYING file in the top folder.
2.21 + If not, see http://opensource.org/licenses/GPL-2.0.
2.22 +
2.23 +-->
2.24 +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2.25 + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
2.26 +
2.27 + <id>fxbrwsr</id>
2.28 + <formats>
2.29 + <format>zip</format>
2.30 + </formats>
2.31 + <baseDirectory>${project.build.finalName}-fxbrwsr</baseDirectory>
2.32 + <dependencySets>
2.33 + <dependencySet>
2.34 + <useProjectArtifact>false</useProjectArtifact>
2.35 + <scope>runtime</scope>
2.36 + <outputDirectory>lib</outputDirectory>
2.37 + </dependencySet>
2.38 + </dependencySets>
2.39 + <files>
2.40 + <file>
2.41 + <source>${project.build.directory}/${project.build.finalName}.jar</source>
2.42 + <outputDirectory>/</outputDirectory>
2.43 + </file>
2.44 + </files>
2.45 +</assembly>
2.46 \ No newline at end of file
3.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/FXBrwsrLauncher.java Mon Apr 29 08:37:23 2013 +0200
3.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/FXBrwsrLauncher.java Mon Apr 29 09:53:45 2013 +0200
3.3 @@ -19,12 +19,15 @@
3.4
3.5 import org.apidesign.bck2brwsr.launcher.fximpl.FXBrwsr;
3.6 import java.io.IOException;
3.7 +import java.io.InputStream;
3.8 import java.lang.reflect.Method;
3.9 import java.net.URI;
3.10 import java.net.URL;
3.11 import java.net.URLClassLoader;
3.12 +import java.util.Enumeration;
3.13
3.14 import java.util.concurrent.Executors;
3.15 +import java.util.jar.Manifest;
3.16 import java.util.logging.Level;
3.17 import java.util.logging.Logger;
3.18 import javafx.application.Platform;
3.19 @@ -47,7 +50,7 @@
3.20 throw new LinkageError("Can't add jfxrt.jar on the classpath", ex);
3.21 }
3.22 }
3.23 -
3.24 +
3.25 public FXBrwsrLauncher(String ignore) {
3.26 super(null);
3.27 }
3.28 @@ -94,5 +97,33 @@
3.29 super.close();
3.30 Platform.exit();
3.31 }
3.32 +
3.33 + public static void main(String... args) throws IOException {
3.34 + String startPage = null;
3.35 +
3.36 + final ClassLoader cl = FXBrwsrLauncher.class.getClassLoader();
3.37 + startPage = findStartPage(cl, startPage);
3.38 + if (startPage == null) {
3.39 + throw new NullPointerException("Can't find StartPage tag in manifests!");
3.40 + }
3.41 +
3.42 + Launcher.showURL("fxbrwsr", cl, startPage);
3.43 + }
3.44
3.45 + private static String findStartPage(final ClassLoader cl, String startPage) throws IOException {
3.46 + Enumeration<URL> en = cl.getResources("META-INF/MANIFEST.MF");
3.47 + while (en.hasMoreElements()) {
3.48 + URL url = en.nextElement();
3.49 + Manifest mf;
3.50 + try (InputStream is = url.openStream()) {
3.51 + mf = new Manifest(is);
3.52 + }
3.53 + String sp = mf.getMainAttributes().getValue("StartPage");
3.54 + if (sp != null) {
3.55 + startPage = sp;
3.56 + break;
3.57 + }
3.58 + }
3.59 + return startPage;
3.60 + }
3.61 }