Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to export a javafx-maven project with firebase

for now i have got my project to run on mvn javafx:run. but a module descriptor is required to execute mvn javaFx:jlink. there are some firebase related errors after creating the module info file.

some of the imports imports :

import com.google.api.core.ApiFuture;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.firestore.*;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;

requires in the module info file :

requires com.google.api.apicommon;
requires com.google.auth.oauth2;
requires firebase.admin;
requires google.cloud.firestore;

errors :

[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.3:run (default-cli) on project RathnapuraLabs: Error: Unable to execute mojo: Compilation failure: 
[ERROR] /C:/Users/Eshaka/IdeaProjects/RathnapuraLabs/src/main/java/back_end/TestManager.java:[14,35] cannot access com.google.cloud.Service
[ERROR]   class file for com.google.cloud.Service not found
[ERROR] /C:/Users/Eshaka/IdeaProjects/RathnapuraLabs/src/main/java/back_end/DBHandler.java:[69,33] cannot access com.google.auth.Credentials
[ERROR]   class file for com.google.auth.Credentials not found
[ERROR] /C:/Users/Eshaka/IdeaProjects/RathnapuraLabs/src/main/java/back_end/DBHandler.java:[100,85] cannot access com.google.cloud.Timestamp
[ERROR]   class file for com.google.cloud.Timestamp not found

how can i fix this error?

like image 219
Eshaka Avatar asked Oct 26 '22 23:10

Eshaka


1 Answers

I figured out a much easier way to export all the dependencies and all (firebase included). just use the maven-shape-plugin to package.

  1. Add the following plugin to the pom.xml

     <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-shade-plugin</artifactId>
         <version>3.0.0</version>
         <executions>
             <execution>
                 <phase>package</phase>
                 <goals>
                     <goal>shade</goal>
                 </goals>
                 <configuration>
                     <transformers>
                         <transformer
                                 implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                             <mainClass>Launcher</mainClass>
                         </transformer>
                     </transformers>
                 </configuration>
             </execution>
         </executions>
     </plugin>
    
  2. You need to create another class with a main that calls the main function of the main javafx class that extends the application as below.

     public class Launcher {
         public static void main(String[] args) {
             AppInit.main(args);
         }
     }
    
  3. finally run mvn clean package

like image 164
Eshaka Avatar answered Nov 14 '22 09:11

Eshaka