Merging teavm branch into default line, now when teavm 0.1 is out
authorJaroslav Tulach <jtulach@netbeans.org>
Thu, 20 Mar 2014 11:25:28 +0100
changeset 1164dce5ea7e13a
parent 110 fcdfcb9998eb
parent 115 c9ea9ae71c2c
child 117 b5562abbf0f3
Merging teavm branch into default line, now when teavm 0.1 is out
minesweeper/AndroidManifest.xml
minesweeper/pom.xml
minesweeper/src/main/java/org/apidesign/demo/minesweeper/MinesModel.java
pom.xml
     1.1 --- a/chess/pom.xml	Sun Mar 16 09:26:09 2014 +0100
     1.2 +++ b/chess/pom.xml	Thu Mar 20 11:25:28 2014 +0100
     1.3 @@ -141,6 +141,11 @@
     1.4        <scope>provided</scope>
     1.5        <type>jar</type>
     1.6      </dependency>
     1.7 +    <dependency>
     1.8 +      <groupId>org.netbeans.html</groupId>
     1.9 +      <artifactId>ko4j</artifactId>
    1.10 +      <version>${net.java.html.version}</version>
    1.11 +    </dependency>
    1.12    </dependencies>
    1.13    <profiles>
    1.14        <profile>
    1.15 @@ -252,5 +257,78 @@
    1.16                </dependency>
    1.17            </dependencies>
    1.18        </profile>
    1.19 +      <profile>
    1.20 +          <id>teabrwsr</id>
    1.21 +          <build>
    1.22 +              <plugins>
    1.23 +                  <plugin>
    1.24 +                      <groupId>org.teavm</groupId>
    1.25 +                      <artifactId>teavm-maven-plugin</artifactId>
    1.26 +                      <version>${teavm.version}</version>
    1.27 +                      <dependencies>
    1.28 +                          <dependency>
    1.29 +                              <groupId>org.teavm</groupId>
    1.30 +                              <artifactId>teavm-classlib</artifactId>
    1.31 +                              <version>${teavm.version}</version>
    1.32 +                          </dependency>
    1.33 +                          <!-- This module adds html4j support. It mainly includes JavaScriptBuilder support.
    1.34 +                          Also there are some little patches to JCL emulation, that are required to pass TCK -->
    1.35 +                          <dependency>
    1.36 +                              <groupId>org.teavm</groupId>
    1.37 +                              <artifactId>teavm-html4j</artifactId>
    1.38 +                              <version>${teavm.version}</version>
    1.39 +                          </dependency>
    1.40 +                      </dependencies>
    1.41 +                      <executions>
    1.42 +                          <execution>
    1.43 +                              <id>generate-minesweeper</id>
    1.44 +                              <goals>
    1.45 +                                  <goal>build-javascript</goal>
    1.46 +                              </goals>
    1.47 +                              <phase>process-classes</phase>
    1.48 +                              <configuration>
    1.49 +                                  <!-- Whether we want TeaVM to minify (obfuscate) the generated JavaScript -->
    1.50 +                                  <minifying>false</minifying>
    1.51 +                                  <properties>
    1.52 +                                      <!-- This classes (separated with , ; space) will be available through vm.loadClass() -->
    1.53 +                                      <html4j.entryPoints>org.apidesign.html.demo.chess.LoadMain</html4j.entryPoints>
    1.54 +                                  </properties>
    1.55 +                                  <!-- Don't include main page - we created it by ourselves -->
    1.56 +                                  <mainPageIncluded>false</mainPageIncluded>
    1.57 +                                  <!-- Merge runtime.js instead of putting as a separate file -->
    1.58 +                                  <runtime>MERGED</runtime>
    1.59 +                                  <!-- Name of the generated file -->
    1.60 +                                  <targetFileName>bck2brwsr.js</targetFileName>
    1.61 +                                  <targetDirectory>${project.build.directory}/teavm</targetDirectory>
    1.62 +                                  <!-- This transformer adds null checks before virtual calls. It is not included
    1.63 +                                  by default as we don't always need these null checks -->
    1.64 +                                  <transformers>
    1.65 +                                      <param>org.teavm.javascript.NullPointerExceptionTransformer</param>
    1.66 +                                  </transformers>
    1.67 +                              </configuration>
    1.68 +                          </execution>
    1.69 +                      </executions>
    1.70 +                  </plugin>
    1.71 +                  <plugin>
    1.72 +                      <artifactId>maven-assembly-plugin</artifactId>
    1.73 +                      <version>2.4</version>
    1.74 +                      <executions>
    1.75 +                          <execution>
    1.76 +                              <id>distro-assembly</id>
    1.77 +                              <phase>package</phase>
    1.78 +                              <goals>
    1.79 +                                  <goal>single</goal>
    1.80 +                              </goals>
    1.81 +                              <configuration>
    1.82 +                                  <descriptors>
    1.83 +                                      <descriptor>src/main/assembly/teabrwsr.xml</descriptor>
    1.84 +                                  </descriptors>
    1.85 +                              </configuration>
    1.86 +                          </execution>
    1.87 +                      </executions>                
    1.88 +                  </plugin>      
    1.89 +              </plugins>
    1.90 +          </build>
    1.91 +      </profile>
    1.92    </profiles>
    1.93  </project>
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/chess/src/main/assembly/teabrwsr.xml	Thu Mar 20 11:25:28 2014 +0100
     2.3 @@ -0,0 +1,47 @@
     2.4 +<?xml version="1.0"?>
     2.5 +<!--
     2.6 +
     2.7 +    The MIT License (MIT)
     2.8 +
     2.9 +    Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    2.10 +
    2.11 +    Permission is hereby granted, free of charge, to any person obtaining a copy
    2.12 +    of this software and associated documentation files (the "Software"), to deal
    2.13 +    in the Software without restriction, including without limitation the rights
    2.14 +    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    2.15 +    copies of the Software, and to permit persons to whom the Software is
    2.16 +    furnished to do so, subject to the following conditions:
    2.17 +
    2.18 +    The above copyright notice and this permission notice shall be included in
    2.19 +    all copies or substantial portions of the Software.
    2.20 +
    2.21 +    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    2.22 +    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    2.23 +    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    2.24 +    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    2.25 +    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    2.26 +    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    2.27 +    THE SOFTWARE.
    2.28 +
    2.29 +-->
    2.30 +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    2.31 +  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.32 +  
    2.33 +  <id>teabrwsr</id>
    2.34 +  <formats>
    2.35 +      <format>zip</format>
    2.36 +  </formats>
    2.37 +  <baseDirectory>public_html</baseDirectory>
    2.38 +  <fileSets>
    2.39 +      <fileSet>
    2.40 +          <directory>src/main/webapp/pages</directory>
    2.41 +          <outputDirectory>/</outputDirectory>
    2.42 +          <filtered>true</filtered>
    2.43 +      </fileSet>
    2.44 +      <fileSet>
    2.45 +          <directory>${project.build.directory}/teavm/</directory>
    2.46 +          <outputDirectory>/</outputDirectory>
    2.47 +          <filtered>false</filtered>
    2.48 +      </fileSet>
    2.49 +  </fileSets>
    2.50 +</assembly>
     3.1 --- a/minesweeper/AndroidManifest.xml	Sun Mar 16 09:26:09 2014 +0100
     3.2 +++ b/minesweeper/AndroidManifest.xml	Thu Mar 20 11:25:28 2014 +0100
     3.3 @@ -48,8 +48,8 @@
     3.4              </intent-filter>
     3.5          </activity>
     3.6          <meta-data android:name="loadPage" android:value="file:///android_asset/pages/index.html" />
     3.7 -        <meta-data android:name="loadClass" android:value="org.apidesign.demo.minesweeper.Main" />
     3.8 -        <meta-data android:name="invoke" android:value="onPageLoad" />
     3.9 +        <meta-data android:name="loadClass" android:value="org.apidesign.demo.minesweeper.MinesModel" />
    3.10 +        <meta-data android:name="invoke" android:value="main" />
    3.11      </application>
    3.12      
    3.13  </manifest>
    3.14 \ No newline at end of file
     4.1 --- a/minesweeper/pom.xml	Sun Mar 16 09:26:09 2014 +0100
     4.2 +++ b/minesweeper/pom.xml	Thu Mar 20 11:25:28 2014 +0100
     4.3 @@ -293,7 +293,79 @@
     4.4                    </plugin>
     4.5                </plugins>
     4.6            </build>
     4.7 -          
     4.8 +      </profile>
     4.9 +      <profile>
    4.10 +          <id>teabrwsr</id>
    4.11 +          <build>
    4.12 +              <plugins>
    4.13 +                  <plugin>
    4.14 +                      <groupId>org.teavm</groupId>
    4.15 +                      <artifactId>teavm-maven-plugin</artifactId>
    4.16 +                      <version>${teavm.version}</version>
    4.17 +                      <dependencies>
    4.18 +                          <dependency>
    4.19 +                              <groupId>org.teavm</groupId>
    4.20 +                              <artifactId>teavm-classlib</artifactId>
    4.21 +                              <version>${teavm.version}</version>
    4.22 +                          </dependency>
    4.23 +                          <!-- This module adds html4j support. It mainly includes JavaScriptBuilder support.
    4.24 +                          Also there are some little patches to JCL emulation, that are required to pass TCK -->
    4.25 +                          <dependency>
    4.26 +                              <groupId>org.teavm</groupId>
    4.27 +                              <artifactId>teavm-html4j</artifactId>
    4.28 +                              <version>${teavm.version}</version>
    4.29 +                          </dependency>
    4.30 +                      </dependencies>
    4.31 +                      <executions>
    4.32 +                          <execution>
    4.33 +                              <id>generate-minesweeper</id>
    4.34 +                              <goals>
    4.35 +                                  <goal>build-javascript</goal>
    4.36 +                              </goals>
    4.37 +                              <phase>process-classes</phase>
    4.38 +                              <configuration>
    4.39 +                                  <!-- Whether we want TeaVM to minify (obfuscate) the generated JavaScript -->
    4.40 +                                  <minifying>false</minifying>
    4.41 +                                  <properties>
    4.42 +                                      <!-- This classes (separated with , ; space) will be available through vm.loadClass() -->
    4.43 +                                      <html4j.entryPoints>org.apidesign.demo.minesweeper.MainBrwsr</html4j.entryPoints>
    4.44 +                                  </properties>
    4.45 +                                  <!-- Don't include main page - we created it by ourselves -->
    4.46 +                                  <mainPageIncluded>false</mainPageIncluded>
    4.47 +                                  <!-- Merge runtime.js instead of putting as a separate file -->
    4.48 +                                  <runtime>MERGED</runtime>
    4.49 +                                  <!-- Name of the generated file -->
    4.50 +                                  <targetFileName>bck2brwsr.js</targetFileName>
    4.51 +                                  <targetDirectory>${project.build.directory}/teavm</targetDirectory>
    4.52 +                                  <!-- This transformer adds null checks before virtual calls. It is not included
    4.53 +                                  by default as we don't always need these null checks -->
    4.54 +                                  <transformers>
    4.55 +                                      <param>org.teavm.javascript.NullPointerExceptionTransformer</param>
    4.56 +                                  </transformers>
    4.57 +                              </configuration>
    4.58 +                          </execution>
    4.59 +                      </executions>
    4.60 +                  </plugin>
    4.61 +                  <plugin>
    4.62 +                      <artifactId>maven-assembly-plugin</artifactId>
    4.63 +                      <version>2.4</version>
    4.64 +                      <executions>
    4.65 +                          <execution>
    4.66 +                              <id>distro-assembly</id>
    4.67 +                              <phase>package</phase>
    4.68 +                              <goals>
    4.69 +                                  <goal>single</goal>
    4.70 +                              </goals>
    4.71 +                              <configuration>
    4.72 +                                  <descriptors>
    4.73 +                                      <descriptor>src/main/assembly/teabrwsr.xml</descriptor>
    4.74 +                                  </descriptors>
    4.75 +                              </configuration>
    4.76 +                          </execution>
    4.77 +                      </executions>                
    4.78 +                  </plugin>      
    4.79 +              </plugins>
    4.80 +          </build>
    4.81        </profile>
    4.82    </profiles>  
    4.83  </project>
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/minesweeper/src/main/assembly/teabrwsr.xml	Thu Mar 20 11:25:28 2014 +0100
     5.3 @@ -0,0 +1,47 @@
     5.4 +<?xml version="1.0"?>
     5.5 +<!--
     5.6 +
     5.7 +    The MIT License (MIT)
     5.8 +
     5.9 +    Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    5.10 +
    5.11 +    Permission is hereby granted, free of charge, to any person obtaining a copy
    5.12 +    of this software and associated documentation files (the "Software"), to deal
    5.13 +    in the Software without restriction, including without limitation the rights
    5.14 +    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    5.15 +    copies of the Software, and to permit persons to whom the Software is
    5.16 +    furnished to do so, subject to the following conditions:
    5.17 +
    5.18 +    The above copyright notice and this permission notice shall be included in
    5.19 +    all copies or substantial portions of the Software.
    5.20 +
    5.21 +    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    5.22 +    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    5.23 +    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    5.24 +    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    5.25 +    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    5.26 +    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    5.27 +    THE SOFTWARE.
    5.28 +
    5.29 +-->
    5.30 +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    5.31 +  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    5.32 +  
    5.33 +  <id>teabrwsr</id>
    5.34 +  <formats>
    5.35 +      <format>zip</format>
    5.36 +  </formats>
    5.37 +  <baseDirectory>public_html</baseDirectory>
    5.38 +  <fileSets>
    5.39 +      <fileSet>
    5.40 +          <directory>src/main/webapp/pages</directory>
    5.41 +          <outputDirectory>/</outputDirectory>
    5.42 +          <filtered>true</filtered>
    5.43 +      </fileSet>
    5.44 +      <fileSet>
    5.45 +          <directory>${project.build.directory}/teavm/</directory>
    5.46 +          <outputDirectory>/</outputDirectory>
    5.47 +          <filtered>false</filtered>
    5.48 +      </fileSet>
    5.49 +  </fileSets>
    5.50 +</assembly>
     6.1 --- a/minesweeper/src/main/java/org/apidesign/demo/minesweeper/Main.java	Sun Mar 16 09:26:09 2014 +0100
     6.2 +++ b/minesweeper/src/main/java/org/apidesign/demo/minesweeper/Main.java	Thu Mar 20 11:25:28 2014 +0100
     6.3 @@ -30,20 +30,14 @@
     6.4  public final class Main {
     6.5      private Main() {
     6.6      }
     6.7 -    
     6.8 +
     6.9      /** Launches the browser */
    6.10      public static void main(String... args) throws Exception {
    6.11          BrowserBuilder.newBrowser().
    6.12              loadPage("pages/index.html").
    6.13 -            loadClass(Main.class).
    6.14 -            invoke("onPageLoad", args).
    6.15 +            loadClass(MinesModel.class).
    6.16 +            invoke("main", args).
    6.17              showAndWait();
    6.18          System.exit(0);
    6.19      }
    6.20 -    
    6.21 -    /** Called when page is ready */
    6.22 -    public static void onPageLoad(String... args) throws Exception {
    6.23 -        Mines m = new Mines();
    6.24 -        m.applyBindings();
    6.25 -    }
    6.26  }
     7.1 --- a/minesweeper/src/main/java/org/apidesign/demo/minesweeper/MainBrwsr.java	Sun Mar 16 09:26:09 2014 +0100
     7.2 +++ b/minesweeper/src/main/java/org/apidesign/demo/minesweeper/MainBrwsr.java	Thu Mar 20 11:25:28 2014 +0100
     7.3 @@ -26,7 +26,7 @@
     7.4  public class MainBrwsr {
     7.5      static {
     7.6          try {
     7.7 -            Main.onPageLoad();
     7.8 +            MinesModel.main();
     7.9          } catch (Exception ex) {
    7.10              throw new IllegalStateException(ex);
    7.11          }
     8.1 --- a/minesweeper/src/main/java/org/apidesign/demo/minesweeper/MinesModel.java	Sun Mar 16 09:26:09 2014 +0100
     8.2 +++ b/minesweeper/src/main/java/org/apidesign/demo/minesweeper/MinesModel.java	Thu Mar 20 11:25:28 2014 +0100
     8.3 @@ -39,7 +39,7 @@
     8.4      @Property(name = "state", type = MinesModel.GameState.class),
     8.5      @Property(name = "rows", type = Row.class, array = true),
     8.6  })
     8.7 -final class MinesModel {
     8.8 +public final class MinesModel {
     8.9      enum GameState {
    8.10          IN_PROGRESS, WON, LOST;
    8.11      }
    8.12 @@ -311,5 +311,12 @@
    8.13          Square sq = columns.get(x);
    8.14          return sq.isMine() ? 1 : 0;
    8.15      }
    8.16 -    
    8.17 +
    8.18 +    /**
    8.19 +     * Called when page is ready
    8.20 +     */
    8.21 +    public static void main(String... args) throws Exception {
    8.22 +        Mines m = new Mines();
    8.23 +        m.applyBindings();
    8.24 +    }
    8.25  }
     9.1 --- a/minesweeper/src/main/webapp/pages/index.html	Sun Mar 16 09:26:09 2014 +0100
     9.2 +++ b/minesweeper/src/main/webapp/pages/index.html	Thu Mar 20 11:25:28 2014 +0100
     9.3 @@ -142,13 +142,14 @@
     9.4                  target="_blank" href="http://bck2brwsr.apidesign.org"
     9.5                  role="button">Learn more &raquo;</a></p>
     9.6         </div>
     9.7 +      </div>
     9.8      </div>
     9.9 -        
    9.10 +
    9.11 +        <!-- boot bck2brwsr -->
    9.12          <script type="text/javascript" src="bck2brwsr.js"></script>
    9.13          <script>
    9.14              var vm = bck2brwsr('${project.build.finalName}.jar');
    9.15              vm.loadClass('org.apidesign.demo.minesweeper.MainBrwsr');
    9.16          </script>
    9.17 -        
    9.18      </body>
    9.19  </html>
    10.1 --- a/pom.xml	Sun Mar 16 09:26:09 2014 +0100
    10.2 +++ b/pom.xml	Thu Mar 20 11:25:28 2014 +0100
    10.3 @@ -15,6 +15,7 @@
    10.4        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    10.5        <net.java.html.version>0.7.6</net.java.html.version>
    10.6        <bck2brwsr.version>0.8.1</bck2brwsr.version>
    10.7 +      <teavm.version>0.1</teavm.version>
    10.8        <license>COPYING</license>
    10.9    </properties>
   10.10    <modules>