Skip to content

AlexandreLadriere/Java-Makefile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Java Makefile

GitHub license

I know that the concept of Makefile for Java project is stupid, but I think that having something like this script can be really useful if you are not developing with an IDE and if you want somthing really simple and quick to build your project.

You have to place this script at the root of your Java project, and run it from this root.

How to use

Initializing variables

First, you will have to modify some variables in the make.sh script in order to adapt it to your project. You have to set up all the variables in the PATHS section (the TEST_PATH variable is optional and can be left empty).

########## PATHS ##########
# Folder containing all src files
# ex: SRC_PATH="src/"
SRC_PATH=""
# Folder containing resources (must be in the SRC_PATH folder)
# ex: RESOURCES="main/resources/"
RESOURCES=""
# Folder where all .class files will be created
# ex: OUT_PATH="out/"
OUT_PATH=""
# Folder in which the javadoc will be created
# ex: DOC_PATH="doc/"
DOC_PATH=""
# Folder containing JUnit tests for instance. This path must have the following format: ./path*
# ex: TEST_PATH="./test*" (test/ is in src/ like main/)
TEST_PATH=""

Then, you also have to set up the variables in the USER VARIABLES section (the EXCLUDE array is optional and can be left empty).

########## USER VARIABLE ##########
# String array of files that you want to exclude from the compilation. You MUST give the full relative path of the files starting from the src/ subfolder
# ex: declare -a EXCLUDE=(
#       "./main/java/fr/alexandreladriere/shortestpath/gui/Case.java"
#       "./main/java/fr/alexandreladriere/shortestpath/gui/Gui.java"
#     )
declare -a EXCLUDE=()
# Main class name, without .jave extension and with full relative path starting from the src/ subfolder
# ex: MAIN="main/java/fr/alexandreladriere/shortestpath/ShortestPath"
MAIN=""

All examples given in the script were based on a project having the following structure:

├── make.sh
├── src
│    ├── main
│    │    ├── java
│    │    │    └── ... (packages and .java files)
│    │    └── resources
│    ├── test
│    │    ├── java
│    │    │    └── ... (packages and .java files)
└──  └──  └── resources

Command line uses

Build all .class files

$ sh make.sh build

Run the app

$ sh make.sh run # it will build the app if it is not done yet

Build JAR file

$ sh make.sh build-jar # it will build the app if it is not done yet

Windows users can simply double-click on the make.sh to build the jar

Create Javadoc

$ sh make.sh doc

Clean

$ sh make.sh clean

Help

$ sh make.sh help

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome 😄

Pull requests

Just a few guidelines:

  • Write clean code with appropriate comments and add suitable error handling.
  • Test the application and make sure no bugs/ issues come up.
  • Open a pull request, and I will be happy to acknowledge your contribution after some checking from my side.

Issues

If you find any bugs/issues, raise an issue.

Releases

No releases published

Packages

 
 
 

Languages