'. '

Bck2BrwsrViaCLI

From APIDesign

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
-
The [[Bck2Brwsr]] project is publishing artifact snapshots to [[Maven]] repository since Feb 13, 2013. That means there is an easy, three steps, way to start coding for the browser yourself. All you need is [[Java]] and [[Maven]] installed. Type:
+
The [[Bck2Brwsr]] project is publishing artifact snapshots to [[Maven]] repository since Feb 13, 2013. That means there is an easy, three steps, way to start coding for the browser yourself. All you need is [[Java]] and [[Maven]] installed.
 +
 
 +
=== [[Knockout4Java]] + [[Bck2Brwsr]] Archetype ===
 +
 
 +
The latest archetype now focuses on integration with [[Knockout4Java]] and its execution in [[Bck2Brwsr]] (for deployment) and [[FXBrwsr]] (for debugging) modes:
 +
 
 +
<source lang="java">
 +
$ mvn archetype:generate -DarchetypeGroupId=org.apidesign.bck2brwsr \
 +
-DarchetypeArtifactId=knockout4j-archetype -DarchetypeVersion=0.8
 +
</source>
 +
 
 +
Possibly replace the ''0.8'' version with ''0.9-SNAPSHOT'' or newer versions when available.
 +
[[Maven]] will download its libraries. Then it asks few questions (for example name of the project you want to create) and generates the skeleton project for you. When the project is successfully created, switch to the created subfolder and execute following command in it
 +
 
 +
<source lang="bash">
 +
$ mvn process-classes bck2brwsr:brwsr -Pfxbrwsr
 +
</source>
 +
 
 +
to run the application in [[FXBrwsr]] mode (suitable for debugging). To run the application in real browser, use:
 +
 
 +
<source lang="bash">
 +
$ mvn process-classes bck2brwsr:brwsr -Pbck2brwsr
 +
</source>
 +
 
 +
Of course, you don't have to work only from command line. [[Good]] IDEs, including [[NetBeans]] will recognize the generated project without any struggle and provide you all the comfort you are used to when coding in [[Java]].
 +
 
 +
==== [[Eclipse]] Support ====
 +
 
 +
Yesterday we (me and Jonathan Fuerth) managed to open the generated (and compiled) project in [[Eclipse]]. Showed up without errors after adding ''target/generated-sources/annotations/'' as additional source path root. The support for [[AnnotationProcessor]]s was limited, when we added new ''@Property(...)'', we needed to recompile for the IDE to realize what is going on. However the behavior seems acceptable and certainly better than I expected given the fact nobody tested it and designed for it yet.
 +
 
 +
=== Old Archetype with Query API ===
 +
 
 +
This is the original style using experimental ''javaquery'' [[API]]. Just type:
<source lang="bash">
<source lang="bash">
$ mvn archetype:generate -DarchetypeGroupId=org.apidesign.bck2brwsr \
$ mvn archetype:generate -DarchetypeGroupId=org.apidesign.bck2brwsr \
-
-DarchetypeArtifactId=bck2brwsr-archetype-html-sample -DarchetypeVersion=0.6 \
+
-DarchetypeArtifactId=bck2brwsr-archetype-html-sample -DarchetypeVersion=0.7
-
-DarchetypeRepository=https://maven.java.net/content/repositories/releases/
+
</source>
</source>
Line 16: Line 47:
<source lang="bash">
<source lang="bash">
-
$ mvn process-classes org.apidesign.bck2brwsr:mojo:0.6:brwsr
+
$ mvn process-classes bck2brwsr:brwsr
</source>
</source>

Revision as of 16:25, 26 September 2013

The Bck2Brwsr project is publishing artifact snapshots to Maven repository since Feb 13, 2013. That means there is an easy, three steps, way to start coding for the browser yourself. All you need is Java and Maven installed.

Knockout4Java + Bck2Brwsr Archetype

The latest archetype now focuses on integration with Knockout4Java and its execution in Bck2Brwsr (for deployment) and FXBrwsr (for debugging) modes:

$ mvn archetype:generate -DarchetypeGroupId=org.apidesign.bck2brwsr \
  -DarchetypeArtifactId=knockout4j-archetype -DarchetypeVersion=0.8

Possibly replace the 0.8 version with 0.9-SNAPSHOT or newer versions when available. Maven will download its libraries. Then it asks few questions (for example name of the project you want to create) and generates the skeleton project for you. When the project is successfully created, switch to the created subfolder and execute following command in it

$ mvn process-classes bck2brwsr:brwsr -Pfxbrwsr

to run the application in FXBrwsr mode (suitable for debugging). To run the application in real browser, use:

$ mvn process-classes bck2brwsr:brwsr -Pbck2brwsr

Of course, you don't have to work only from command line. Good IDEs, including NetBeans will recognize the generated project without any struggle and provide you all the comfort you are used to when coding in Java.

Eclipse Support

Yesterday we (me and Jonathan Fuerth) managed to open the generated (and compiled) project in Eclipse. Showed up without errors after adding target/generated-sources/annotations/ as additional source path root. The support for AnnotationProcessors was limited, when we added new @Property(...), we needed to recompile for the IDE to realize what is going on. However the behavior seems acceptable and certainly better than I expected given the fact nobody tested it and designed for it yet.

Old Archetype with Query API

This is the original style using experimental javaquery API. Just type:

$ mvn archetype:generate -DarchetypeGroupId=org.apidesign.bck2brwsr \
  -DarchetypeArtifactId=bck2brwsr-archetype-html-sample -DarchetypeVersion=0.7

Maven will download its libraries. Then it asks few questions (for example name of the project you want to create) and generates the skeleton project for you. When the project is successfully created, switch to the created subfolder:

$ cd nameofyourproject

and you are ready to compile and launch your first Bck2Brwsr project:

$ mvn process-classes bck2brwsr:brwsr

A browser window opens and you can check how easy it is to synchronize content of various elements on the HTML page, to compute derived properties and how to draw a text on an HTML canvas.

Of course, you don't have to work only from command line. Good IDEs, including NetBeans will recognize the generated project without any struggle and provide you all the comfort you are used to when coding in Java.

Your favourite language has just returned bck2brwsr!

Personal tools
buy