In team project, it is better to have a dedicated server to synchronize all the developer team work. A small project which has only one developer doesn’t need it because the source code management only done by one person. However, imagine if you are in a project with 10 developers? How to manage the source code? How to synchronize and integrate your code with other developers? That is why we need source code management server, sometimes called SVN or subversion. Probably you’ve heard about Github, the most popular hub for sharing open source project.
The weakness of Github is it is only supported Public project for free usage. Sometimes people want to make their project private. But in Github, you need to pay for such features. Gitlab appears as alternative. You can make private project for free. Gitlab is not bad. Only the timing is bad haha If only Gitlab released earlier than Github haha
Choose your SVN
This article will talk about Gitlab, but its up to you. If you want use something light, SVN might be a good option too. Installation instruction in here.
First of all, you have two ways of installing or using Gitlab server as code management server.
- Deploy Gitlab Server on your own server.
- Using Gitlab Server
The first deployment requires a lot of resources. Your memory server must have at least 2GB RAM. Otherwise the server would be overloaded. I’ve tried deploy it at my Google Cloud server, and it keeps time out running. Because I chose the small server where the memory is only 1.7GB. If you don’t want to spend more money, better to use the Gitlab server to manage your code.
Register Gitlab Account
First of all, create GItlab account in Gitlab website. Then create your project name. Set the visibility as Public, Private, etc. For project team, you can invite another developers to the project.
Eclipse IDE + SpringBoot + Git Plugin Installation
Once all set up done on Gitlab server. Next is configuring your local development environment and connect it to the your own Gitlab Project server.
- Install the newest Eclipse IDE version.
- Install Spring Tool Suite from Eclipse Marketplace (Help -> Eclipse Marketplace)
- Activate Git Perspective on your Eclipse environment (Window -> Perspective -> Open Perspective -> Other -> Git)
- Choose Clone a Git Repository if you already did the above step (creating project on Gitlab), otherwise, you also can create new project directly from Eclipse.
- Input every information required. For URI, check in the main home page of your project, choose HTTPS or SSH. For me, I chose HTTPS because the connection was easier. Just put Gitlab username and password and it connects like magic.
Sync Local Project Workspace to Gitlab
You can do it two ways, develop the basic structure locally first then upload to Gitlab. Or Download from Gitlab to local if the source code is already exist. Since currently I create the program from scratch, I will generate SpringBoot project on my Eclipse and I will commit and push the code into Gitlab.
Create New Spring Boot Project
- File -> New -> Other -> Search “Spring” -> Spring Boot -> Spring Starter Project
- I choose Gradle as my library. But honestly Maven is more popular. If I got stuck, a lot of solution is based on Maven. But I want to challenge myself using Gradle haha I kind of used to it when learning about Android Programming
- I choose WAR for the deployment package
- Choose your project dependencies. Choose what necessary to you. For me, I added
- DevTools (recommended),
- Web (necessary),
- Thymeleaf (my UX interface template engine)
- etc (you can add more later)
Configure Git Repository
- From your Eclipse Project Explorer, Right click on your project -> Team -> Share Project
- Select existing repository
- Upload your initial code to Gitlab
- Go to Git Perspective
- Right click your repository
- Click Commit
- See Unstaged Changes windows
- Add all files that want to be pushed to Gitlab by clicking plus sign
- The file will be moved to Staged Changes
- Write Commit Message to track what is changes from the previous code
- Click Commit and Push
Checkout Existing Code from Gitlab to Local
Now, assume that you are supporting developer. You need to retrieve all existing and on-going project from Gitlab to your local environment. This is what you have to do:
- In the GIT Window Perspective, choose the project and right click, then click Import Projects
- Click this option “Show other specialized import wizards”
- Select existing Gradle project, (or Maven if the project is used Maven build library)
- Check your local Project Explorer to confirm the import.
Now, whenever you made a changes on your code. Simply commit and push to synchronize your project with your team mates. 😉
Preparation Stage End~