The_Wizard_of_wind_Oz
asked on
Compiling both Java and JavaFX files in the same Maven project
Hi,
I am currently trying to build a Maven project where I have both Java and JavaFX classes.
I have a main project, with two modules : a Java subproject and a JavaFX subproject.
myMainProject
|- java-project
\- javafx-project
I declared a specific maven-compiler-plugin for each of these projects, instead of only declaring a global one in the parent project.
The Java project doesn't require any specific compiler (the standard plexus-compiler-javac that hasn't to be declared), but I am using a specific plexus compiler for JavaFX (plexus-compiler-javafxc). I have given their configuration below.
If I try to compile the parent project, the first project to be compiled is ok (the Java project), but I get an error on the second one:
[INFO] -------------------------- ---------- ---------- ---------- ---------- ------
[ERROR] BUILD ERROR
[INFO] -------------------------- ---------- ---------- ---------- ---------- ------
[INFO] No such compiler 'javafxc'.
[INFO] -------------------------- ---------- ---------- ---------- ---------- ------
[INFO] For more information, run Maven with the -e switch
[INFO] -------------------------- ---------- ---------- ---------- ---------- ------
The weird thing is that if I try to compile the project separately, there is no problem. It looks like if the maven-compiler-plugin is only set up once for the whole Maven execution, so the second time, it is still the javac compiler that is configured, that's why the javafxc compiler isn't found (I'm only guessing).
Does someone know if I can change this in the configuration or not?
I could create completely separate projects (one for Java classes, and one for JavaFX classes) but I would like to understand why this error occurs (and try to fix it!).
Thank you very much.
I am currently trying to build a Maven project where I have both Java and JavaFX classes.
I have a main project, with two modules : a Java subproject and a JavaFX subproject.
myMainProject
|- java-project
\- javafx-project
I declared a specific maven-compiler-plugin for each of these projects, instead of only declaring a global one in the parent project.
The Java project doesn't require any specific compiler (the standard plexus-compiler-javac that hasn't to be declared), but I am using a specific plexus compiler for JavaFX (plexus-compiler-javafxc).
If I try to compile the parent project, the first project to be compiled is ok (the Java project), but I get an error on the second one:
[INFO] --------------------------
[ERROR] BUILD ERROR
[INFO] --------------------------
[INFO] No such compiler 'javafxc'.
[INFO] --------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] --------------------------
The weird thing is that if I try to compile the project separately, there is no problem. It looks like if the maven-compiler-plugin is only set up once for the whole Maven execution, so the second time, it is still the javac compiler that is configured, that's why the javafxc compiler isn't found (I'm only guessing).
Does someone know if I can change this in the configuration or not?
I could create completely separate projects (one for Java classes, and one for JavaFX classes) but I would like to understand why this error occurs (and try to fix it!).
Thank you very much.
The maven-compiler-plugin in the Java project:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>${encoding}</encoding>
</configuration>
</plugin>
The maven-compiler-plugin in the JavaFX project:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerId>javafxc</compilerId>
<include>**/*.fx</include>
<compilerArgument>
<jfxHome>false</jfxHome>
</compilerArgument>
</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>
try using two separate pom.xml file one for java and other for javafx in their respective folders and another pom.xml which uses the other 2
ASKER
That's indeed what I already have.
There is one project (with its own POM file) for Java, another project (with its own POM file) for JavaFX, and a third project that is the parent of the two other ones (which also has a POM file).
There is one project (with its own POM file) for Java, another project (with its own POM file) for JavaFX, and a third project that is the parent of the two other ones (which also has a POM file).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.