Skip to content

Nikolaevdo/project-maven

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

  1. Fork from the repository https://github.com/vasylmalik/project-maven.git
  2. Download your version of the project to your computer. Next, we will work with the pom.xml file .
  3. Add dependencies:
  • org.apache.commons: commons-lang3: 3.12.0
  • org.openjfx: javafx-controls: 18.0.1
  • com.javarush: desktop-game-engine:1.0 (this dependency will be covered in a separate post)
  • org.junit.jupiter: junit-jupiter-engine: 5.8.2 (с scope test)
  1. Add plugins for:
  • installing the com.javarush: desktop-game-engine:1.0 dependency from the lib library to the local repository (google for help);
  • leave the maven-compiler-plugin plugin unchanged ;
  • a plugin that will collect all dependencies (with scope compile) and add them to some directory during the build;
  • the maven-jar-plugin plugin , which will make a jar file containing the game code and dependencies. In this plugin, you need to configure the MANIFEST.MF file to contain sections: Class-Path, Main-ClassandRsrc-Main-Class
  • All Class-Pathour JAR dependencies should be registered in.
  • A Main-Classclass must be written org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoaderin that can use the classpath from JAR files, and can also start a JavaFX application.
  • The Rsrc-Main-Classstarting class of the game (com.javarush.games.racer.RacerGame) must be registered in it.
  1. In the maven-surefire-plugin , make a configuration so that the StrangeTest test does not run on build. The rest of the tests should run.
  2. Add a “resources” section to say that the built JAR dependencies are a resource, so that the maven-jar-plugin puts them inside the JAR file in the lib/ folder
  3. Upload changes to your GitHub repository, send a link to it to the teacher.

Useful:

  1. The build must be run with the mvn clean install command .

  2. Running the game (via Maven) for the purpose of viewing can be done with the mvn javafx:run command.

  3. Some plugins need to override phase .

  4. The project uses JDK version 18.0.1. It must be downloaded on your computer.

  5. When building through Maven, there will be errors at first. Read them carefully and you will simplify your life.

  6. Do not change anything in the org.eclipse.jdt.internal.jarinjarloader package . It has a custom loader class (honestly copied from StackOverflow), in which the launch of the main method is changed to launch the JavaFX application. Use for educational purposes only.

  7. If you complete all the points, as a result of the assembly you will receive a fat-JAR file . You can start and check that everything is done correctly with the command:

     <path for java 18> -jar <name resulting jar file>
     
     //example
     "C:\Users\leo12\.jdks\openjdk-18.0.1.1\bin\java.exe" -jar "E:\temp\project-maven-1.0.jar"
    
  8. As a result you will see:

  9. The build depends on your operating system. That is, if a JAR file is built on Windows, it can be run on any Windows computer with Java18. And it can't be done on Mac and Linux.

How to run 1.Installing jar file as dependency in local .m2

    //example
    mvn install:install-file -Dfile=C:\Users\Administrator\IdeaProjects\project-maven/lib/desktop-game-engine.jar -DgroupId="com.javarush" -DartifactId=desktop-game-engine -Dversion="1.0" -Dpackaging=jar

2.Build

  //example
  mvn clean install
  1. jar file launch:

    //example java -jar "C:\Users\Administrator.m2\repository\jru\module3\project-maven\1.0\project-maven-1.0.jar"

About

project-maven-template

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%