Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Compiling both Java and JavaFX files in the same Maven project

Posted on 2009-05-07
3
2,129 Views
Last Modified: 2013-12-22
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.
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>

Open in new window

0
Comment
Question by:The_Wizard_of_wind_Oz
  • 2
3 Comments
 
LVL 12

Expert Comment

by:Gibu George
ID: 24334602
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
0
 

Author Comment

by:The_Wizard_of_wind_Oz
ID: 24343014
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).
0
 

Accepted Solution

by:
The_Wizard_of_wind_Oz earned 0 total points
ID: 24345960
I have found what was the problem!

There is only one instance of maven-compiler-plugin that is created during a build.
Therefore, when the Java project was compiled, the first - and only - instance was created, without the JavaFX compiler dependency.
When the second call to the maven-compiler-plugin was made (during the compilation of the JavaFX project), it was the same instance that was called, without the dependencies to the JFX compiler.

After knowing that, the solution was quite easy to find: I had to make sure that the JFX compiler dependency could be found at any moment during Maven's execution, si I only had to update the <pluginManagement /> in the parent POM file (see attached code below).
<pluginManagement>
	<plugin>
		<groupId>org.apache.maven.plugins</groupId>
		<artifactId>maven-compiler-plugin</artifactId>
		<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>
</pluginManagement>

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error in @AspectJ Based AOP with Spring 2 18
String array comparison 4 38
Where are the c++ header files to use in Eclipse? 4 23
Java program running SQL query 5 37
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question