Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Groovy + Maven cant find JavaFx #75

Closed
nartz opened this issue Jun 2, 2017 · 2 comments
Closed

Groovy + Maven cant find JavaFx #75

nartz opened this issue Jun 2, 2017 · 2 comments

Comments

@nartz
Copy link

nartz commented Jun 2, 2017

Hi -

I am using Maven 3.3.9 + Spock Testing Framework + GMavenPlus (1.5) + Groovy 2.4 + JavaFX with Java8 on OSX 11.10. I'm trying to get mvn test to execute succesfully, but the groovy tests I have are not finding the javafx classes. The errors are like:

java.lang.ClassNotFoundException: javafx.scene.control.MenuBar

I believe the issue I'm having is due to java8 now by default includes the javafx jar on the classpath (/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext on OSX, which is below java home), it isn't an external dependency in maven. However, when running groovy with javafx, groovy doesn't seem to have the javafx jar on its path.

Other projects like https://github.com/groovyfx-project/groovyfx seem to need groovy to specifically specify the jar on the command line using '-cp '. Also, in gradle I found what I think is a similar bug: https://stackoverflow.com/questions/32570973/gradle-groovy-compilation-cannot-find-javafx-classes-in-tests.

Groovy seems to say that jars added in a ~/.groovy/lib folder will be added to the classpath, although putting the jfxrt.jar in there didn't seem to have an effect.

The main question is whats the best way to get groovy to find the javafx dependency jars so mvn test can succeed?

@nartz nartz changed the title Mvn test cant find JavaFx Groovy + Maven cant find JavaFx Jun 2, 2017
@keeganwitt
Copy link
Member

keeganwitt commented Jun 4, 2017

Right now you have to make sure the Java you want to use is on the path first until I can implement #43, I haven't had as much free time this last year to take that on and it's not a small change :(

Adding to the groovy lib dir I think only adds to the path for stuff executed with the Groovy commands (groovy, groovyc, groovyConsole, etc), you can see where they add this to the path in the Bash scripts that launch those. GMavenPlus executes purely on the Java-side, with no script calls so the path isn't changed. You could add it as a system dependency, like

<dependency>
  <groupId>com.oracle</groupId>
  <artifactId>javafx</artifactId>
  <version>2.2.3</version>
  <scope>system</scope>
  <systemPath>${project.basedir}/lib/jfxrt.jar</systemPath>
</dependency>

@keeganwitt
Copy link
Member

Closing for now, as I don't know that there's anything further to fix here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants