Project structure - Raul6469/java-quickstart GitHub Wiki

.github/ folder

This folder holds some configuration files for GitHub, the website that hosts repositories.

In this repository, we only use it to hold some configuration for GitHub Actions. It's a tool integrated in GitHub that allows developers to ensure that the software they work has no errors. It consists of a "virtual machine", a new empty computer that boots just for you, and that can do anything you want. If it encounters any problem while doing what it is told to do, it will let you know.

Here, the build.yml file basically tells GitHub to get your code from your repository and compile it whenever you commit a change to GitHub. If there is a compilation error, you will get a :x: next to your commit message in GitHub.

It's like having another team mate install your project from scratch and try to compile it whenever you make a change. This way, you can always be sure that your project can easily be ran for anyone!

This feature is completely free and unlimited as long as your repository is public. Otherwise, only the first 2,000 build minutes will be free.

Don't want or need this? You can delete the whole folder!

.vscode/ folder

This folder holds configuration files used by Visual Studio Code so you don't have to set it up!

The launch.json file contains instructions to run and debug your app right within VS Code. The settings.json file sets some settings for code editing and Java automatic setup.

You can edit these files by yourself if you want to customize Visual Studio Code behaviour. This can be useful to share common configuration with the rest of your team.

.gradle/ folder

Gradle is a generic build tool that makes it easy to build and run apps, wether it's Java or another language. This folder contains a copy of Gradle so you don't have to install it by yourself by downloading it on their website.

Do not edit or delete these files, because you won't be able to build your app using Gradle. However, you will always be able to compile your Java source files individually with javac.

src/ folder

This is where your code lives! You will spend the vast majority of your time working in this folder without having to worry about the rest.

You will find two folders in it :

  • src/main/java : your application code! You will find the main method in the App.java file
  • src/test/java : this where you can write automated tests for your app. This is largely optional and you can delete the folder if you want. Learn more about it

Note that you need to keep this folder structure in order to be able to build and run your app using Gradle. This structure is conventional in Java and you will encounter in most Java projects.

.gitattributes and .gitignore

These are configuration files for git, a code versioning tool.

The .gitattributes file tells how git should manage your files.

The .gitignore file is the most important one for git in any project! It's a list of all files and folders you want git to ignore. For example, you probably don't want to version and share your compiled .class files, as they are compiled from the .java source files. Gradle will also create some files on your computer that are made specifically for you, that won't work for your teammates, and you don't want to share these files either.

When you make changes to your application, you only want to share changes on your source files (the .java files) and nothing else. Having a complete .gitignore makes it possible.

If you see in git a file that you don't understand or that you didn't change, it's probably a good idea to add specify it the .gitignore file

build.gradle and settings.gradle

These are files used by Gradle that contain some information about your project, such as the name of your application or the class name that holds the main method.

They are necessary for Gradle to work properly. You can edit them if you want to customize Gradle behaviour for your app, but be sure that you and your teammates can still build and run your project!

gradlew and gradlew.bat

These two files are the entrypoints for Gradle, that are executed whenever you use a ./gradlew command, such as ./gradlew run.

gradlew is for Linux and Mac OS, and gradlew.bat is for Windows. Thanks to them, you do not need to install Gradle by yourself and your able to run this project out of the box.

You should not edit or delete them, otherwise you won't be able to use any of the ./gradlew commands.

...and other files and folders

Here I only talked about the files you will find in this starter repository. Once you start building and running your project, so will see that other files are created (.project, .classpath, etc...).

These are ignored by git, and you should not worry about them.