juju
juju

Reputation: 33

JavaFx with Maven: doesn't find the mainClass

I have a multi modules maven project and I have a problem with javaFx (I used the plugin zenJava).

When I want to build the jar, I have this error: Failed to execute goal com.zenjava:javafx-maven-plugin:8.8.3:build-jar (default-cli) on project XXXX: The parameters 'mainClass' for goal com.zenjava:javafx-maven-plugin:8.8.3:build-jar are missing or invalid

But, I defined the mainClass in the parent pom.

This is the parent pom:

    <dependencyManagement>
        <dependencies>
            <dependency>
               <groupId>commons-lang</groupId>
               <artifactId>commons-lang</artifactId>
                <version>2.6</version>
           </dependency>
       </dependencies>
  </dependencyManagement>
  <build>
    <pluginManagement>
        <plugins>
            <plugin>
                  <groupId>com.zenjava</groupId>
                  <artifactId>javafx-maven-plugin</artifactId>
                   <version>${javafx.version}</version>
                   <configuration>
                        <vendor>XXX</vendor>                
                        <mainClass>com.package.gui</mainClass>
                        <verbose>true</verbose>
                        <jarFileName>XXXX.jar</jarFileName>
                        <bundler>EXE</bundler>
                         <nativeInstallers/>
                    </configuration>
                    <executions>
                        <execution>
                            <id>create-jfxjar</id>
                            <phase>package</phase>
                            <goals>
                                <goal>build-jar</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>create-native</id>
                            <phase>package</phase>
                            <goals>
                                <goal>build-native</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.6.1</version>
                    <configuration>
                      <source>1.8</source>
                      <target>1.8</target>
                    </configuration>
            </plugin>
        </plugins>
    </build>

And this is the pom of GUI module

 <build>
        <plugins>
            <plugin>
                <groupId>com.zenjava</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
            </plugin>
        </plugins> 
    </build>

Upvotes: 2

Views: 2537

Answers (1)

Stugal
Stugal

Reputation: 880

Try moving the <pluginManagement> block from parent pom to GUI pom and run the build command on the GUI pom (that's how i have it set up for my multi module JavaFX project and it works no problem)

Upvotes: 1

Related Questions