- Old project with no build automation tool (like Gradle)
- The
ConsolePG.jaris the library that was provided to easily draw content to the screen - In IntelliJ, go to Project Structure -> Libraries -> Add the library
ConsolePG.jar - The .idea only has the artifacts and run configurations
- https://www.jetbrains.com/help/idea/compiling-applications.html#package_into_jar
- If the ConsolePG.jar was added into the Project, there's no need to explicitly add it in the artifact
- The config will be at
.idea/artifacts/Snake_Game_Artifact_jar.xml - The artifact
Snake_Game_Artifact_Finaljust includes the copy of the levels.txt
- Since using the wildcard '*' only searches in 1 directory and doesn't perform a recursive search, the Single Argument File option should be used. So we need to generate a file that lists all the .java files as the list of arguments to pass to the java compiler.
- Linux (Bash) ->
find -name "*.java" > sources.txt - Windows (in Command Line aka Command Prompt, not PowerShell (used by default in IntelliJ)) ->
dir /s /B .\src\isel\poo\*.java > sources.txt
- Linux (Bash) ->
javac -d ./build @sources.txt -cp ConsolePG.jar- Make sure you have a META-INF folder inside src/. It should have a MANIFEST.MF file with:
Manifest-Version: 1.0
Main-Class: isel.poo.snake.ctrl.Snake
Creating the artifact through IntelliJ interface automatically creates this file.
cd build && jar xf ..\ConsolePG.jar && cd ..// extract the contents of the .jar file to the build directoryjar cfm .\out\artifacts\Snake-Game-Manual.jar .\src\META-INF\MANIFEST.MF -C ConsolePG.jar . -C .\build .//cfm -> create a JAR file, m -> merge manifest, f -> output to filecopy levels.txt .\out\artifacts\
java -jar out/artifacts/Snake_Game_Artifact_jar/Snake-Game-Artifact.jar//Option 1java -jar out/artifacts/Snake-Game-Manual.jar//Option 2
Note
In the examples, I'm using the format of specifying file locations as in Windows by mostly using '\', in Linux forward slash should be used '/'
Done in group with Tiago Cardoso

