Plexus Compiler Component for javafxc (OpenJFX Compiler) / Updated 2009-01-17

Basic usage

You can build your JavaFX sources with Maven 2 using standard “maven-compiler-plugin”.

Put something similar in <build> section of POM file:

  <build>
      <sourceDirectory>src/main/fx</sourceDirectory>
      ...
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <configuration>
                  <compilerId>javafxc</compilerId>
                  <include>**/*.fx</include>
              </configuration>
              <dependencies>                
                  <dependency>
                      <groupId>net.sf.m2javafxc</groupId>
                      <artifactId>plexus-compiler-javafxc</artifactId>
                      <version>0.1-SNAPSHOT</version>
                  </dependency>
              </dependencies>
          </plugin>
      </plugins>
      ...
  </build>

Add m2-javafxc repository to <pluginRepositories>:

   <pluginRepositories>
      <pluginRepository>
          <id>m2-javafxc</id>
          <name>Sourceforge M2-javafxc static repo</name>
          <url>http://m2-javafxc.sourceforge.net/m2repo</url>
      </pluginRepository>
  </pluginRepositories>

Make sure you have $JFX_HOME environment variable set.


Add dependency to javafxrt.jar :

    <dependency>
      <groupId>net.java.dev.openjfx</groupId>
      <artifactId>javafxrt</artifactId>
      <version>1.0-SNAPSHOT</version>
    </dependency>

For compiling it is enough, but to compile with UI or/and to run (even simple CLI JavaFX application) you should have dependency to scenario.jar:

    <dependency>
      <groupId>net.java.dev.openjfx</groupId>
      <artifactId>scenario</artifactId>
      <version>0.6-SNAPSHOT</version>
    </dependency>

Currently there is no one public repository you could get javafxrt and scenario from, so there is 3 ways to get it in your local repo:

Advanced usage

“fork” mode

Yes, you may run javafxc as a sub process, just specify <fork> in config:

              <configuration>
                  <compilerId>javafxc</compilerId>
                  <include>**/*.fx</include>
                  <fork>true</fork>
              </configuration>

Specify JFX home manually

It is possible to specify location of javafx.jar directly in the POM (javafxc.jar will be looked up in the C:/jfx first):

              <configuration>                  
                  <fork>false</fork>
                  <compilerArguments>
                      <jfxHome>C:/jfx</jfxHome>
                  </compilerArguments>
              </configuration>

Use javafxc.jar as artifact

It is possible to run exact version of javafxc.jar as artifact (if you have it installed somewhere in Maven2 or local repo):

              <configuration>                  
                  <fork>false</fork>
                  <compilerArguments>
                      <jfxHome>false</jfxHome>
                  </compilerArguments>
              </configuration>

and add javafxc.jar for plugin runtime dependencies:

          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <configuration>
                  <compilerId>javafxc</compilerId>
                  <include>**/*.fx</include>
                  <fork>false</fork>
                  <compilerArguments>
                      <jfxHome>false</jfxHome>
                  </compilerArguments>
              </configuration>
              <dependencies>                
                  <dependency>
                      <groupId>net.sf.m2javafxc</groupId>
                      <artifactId>plexus-compiler-javafxc</artifactId>
                      <version>0.1-SNAPSHOT</version>
                  </dependency>
                  <dependency>
                      <groupId>net.java.dev.openjfx</groupId>
                      <artifactId>javafxc</artifactId>
                      <version>1.0-SNAPSHOT</version>
                  </dependency>
              </dependencies>
          </plugin>

Diagnostic

Sometimes it is hard to understand where the real javafxc.jar comes from... Use -X and -e option to understand what jar file in use.

That is all

If you have any suggestions, ideas or want to contribute, mail list is: m2-javafxc-develop@lists.sourceforge.net (archive http://sourceforge.net/mailarchive/forum.php?forum_name=m2-javafxc-develop). Thank you!

Happy coding! :)

SourceForge.net Logo