1.1 --- a/javaquery/demo-calculator/nbactions.xml Tue Jun 03 16:05:21 2014 +0200
1.2 +++ b/javaquery/demo-calculator/nbactions.xml Mon Jun 09 09:38:03 2014 +0200
1.3 @@ -23,10 +23,11 @@
1.4 <actionName>run</actionName>
1.5 <goals>
1.6 <goal>package</goal>
1.7 - <goal>bck2brwsr:brwsr</goal>
1.8 + <goal>bck2brwsr:show</goal>
1.9 </goals>
1.10 <properties>
1.11 <skipTests>true</skipTests>
1.12 + <bck2brwsr.obfuscationlevel>NONE</bck2brwsr.obfuscationlevel>
1.13 </properties>
1.14 </action>
1.15 </actions>
2.1 --- a/javaquery/demo-calculator/pom.xml Tue Jun 03 16:05:21 2014 +0200
2.2 +++ b/javaquery/demo-calculator/pom.xml Mon Jun 09 09:38:03 2014 +0200
2.3 @@ -13,6 +13,7 @@
2.4 <properties>
2.5 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2.6 <bck2brwsr.obfuscationlevel>FULL</bck2brwsr.obfuscationlevel>
2.7 + <netbeans.compile.on.save>NONE</netbeans.compile.on.save>
2.8 </properties>
2.9 <build>
2.10 <plugins>
2.11 @@ -24,7 +25,7 @@
2.12 <execution>
2.13 <goals>
2.14 <goal>aot</goal>
2.15 - <goal>brwsr</goal>
2.16 + <goal>show</goal>
2.17 </goals>
2.18 </execution>
2.19 </executions>
3.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Tue Jun 03 16:05:21 2014 +0200
3.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Mon Jun 09 09:38:03 2014 +0200
3.3 @@ -131,10 +131,12 @@
3.4 if (!startpage.startsWith("/")) {
3.5 startpage = "/" + startpage;
3.6 }
3.7 - String prefix = "";
3.8 - int last = startpage.lastIndexOf('/');
3.9 - if (last >= 0) {
3.10 - prefix = startpage.substring(0, last);
3.11 + String prefix = null;
3.12 + if (!new File(dir, "bck2brwsr.js").exists()) {
3.13 + int last = startpage.lastIndexOf('/');
3.14 + if (last >= 0) {
3.15 + prefix = startpage.substring(0, last);
3.16 + }
3.17 }
3.18 HttpServer s = initServer(dir.getPath(), addClasses, prefix);
3.19 try {
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/ShowMojo.java Mon Jun 09 09:38:03 2014 +0200
4.3 @@ -0,0 +1,84 @@
4.4 +/**
4.5 + * Back 2 Browser Bytecode Translator
4.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
4.7 + *
4.8 + * This program is free software: you can redistribute it and/or modify
4.9 + * it under the terms of the GNU General Public License as published by
4.10 + * the Free Software Foundation, version 2 of the License.
4.11 + *
4.12 + * This program is distributed in the hope that it will be useful,
4.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.15 + * GNU General Public License for more details.
4.16 + *
4.17 + * You should have received a copy of the GNU General Public License
4.18 + * along with this program. Look for COPYING file in the top folder.
4.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
4.20 + */
4.21 +package org.apidesign.bck2brwsr.mojo;
4.22 +
4.23 +import java.io.Closeable;
4.24 +import org.apache.maven.plugin.AbstractMojo;
4.25 +
4.26 +import java.io.File;
4.27 +import java.io.IOException;
4.28 +import java.net.MalformedURLException;
4.29 +import java.net.URL;
4.30 +import java.net.URLClassLoader;
4.31 +import java.util.ArrayList;
4.32 +import java.util.Collection;
4.33 +import java.util.List;
4.34 +import org.apache.maven.artifact.Artifact;
4.35 +import org.apache.maven.model.Resource;
4.36 +import org.apache.maven.plugin.MojoExecutionException;
4.37 +import org.apache.maven.plugins.annotations.LifecyclePhase;
4.38 +import org.apache.maven.plugins.annotations.Mojo;
4.39 +import org.apache.maven.plugins.annotations.Parameter;
4.40 +import org.apache.maven.plugins.annotations.ResolutionScope;
4.41 +import org.apache.maven.project.MavenProject;
4.42 +import org.apidesign.bck2brwsr.launcher.Launcher;
4.43 +
4.44 +/** Executes given HTML page in a browser. */
4.45 +@Mojo(
4.46 + name="show",
4.47 + requiresDependencyResolution = ResolutionScope.RUNTIME,
4.48 + defaultPhase=LifecyclePhase.NONE
4.49 +)
4.50 +public class ShowMojo extends AbstractMojo {
4.51 + public ShowMojo() {
4.52 + }
4.53 +
4.54 + /** The identification of a launcher to use. Known values <code>fxbrwsr</code>,
4.55 + * <code>bck2brwsr</code>, or
4.56 + * name of an external process to execute.
4.57 + */
4.58 + @Parameter
4.59 + private String launcher;
4.60 +
4.61 +
4.62 + /** Resource to show as initial page */
4.63 + @Parameter
4.64 + private String startpage;
4.65 +
4.66 + /** Root of all pages, and files, etc. */
4.67 + @Parameter
4.68 + private File directory;
4.69 +
4.70 + @Override
4.71 + public void execute() throws MojoExecutionException {
4.72 + if (startpage == null) {
4.73 + throw new MojoExecutionException("You have to provide a start page");
4.74 + }
4.75 + if (directory == null) {
4.76 + throw new MojoExecutionException("You have to provide a root directory");
4.77 + }
4.78 + try {
4.79 + Closeable httpServer;
4.80 + httpServer = Launcher.showDir(launcher, directory, null, startpage);
4.81 + System.in.read();
4.82 + httpServer.close();
4.83 + } catch (IOException ex) {
4.84 + throw new MojoExecutionException("Can't show the browser", ex);
4.85 + }
4.86 + }
4.87 +}