Saturday, 22 August 2020

Create Your First Maven Project and Migrate to Source Control(Bitbucket) Using Git Bash and Vscode- PT 1

 To Complete this Task, You need to have the following :

Bitbucket account: https://bitbucket.org/product

Git Bash: https://git-scm.com/

Vscode: https://code.visualstudio.com/

Maven and Java: Refer to previous posts

 https://violetstreamstechnology.blogspot.com/2020/08/how-to-install-maven-and-java-jdk-in.html

https://violetstreamstechnology.blogspot.com/2020/08/pleasefollow-steps-to-install-java.html

Step 1: Create a New Project folder in your PC


Right click on your workspace ---->New----Folder

You can Name it whatever you like. ( I name mine projects)

Step 2: Go into the folder, launch Git Bash

Go into the folder---right click---Select--- Git Bash Here

This will launch Git Bash in your current folder

Step 3: Create First Maven Project

To create your first maven project copy and paste the following command in Git Bash console:

mvn archetype:generate -DgroupId=com.mkyong -DartifactId=MyWebApp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false


This will create a folder called MyWebApp

Step 4: Load Project into Vscode

Go to the Git Bash Console and Type the following to load the Maven project into Vscode

code .

This will launch Vscode with the project in your current directory

Step 5: Setup SSH keys in Bitbucket

Go to Git bash console and type

ssh-keygen

It will prompt you to specify where you want to save the ssh keys and to enter passwords.

You can use default location and no password. Type enter 3 times


Go to the location your public key is(mine is /c/Users/FCP/.ssh/id_rsa.pub), you can open the file with notepad and copy the text or use the cat command to view it in git bash. You can also navigate to the file and view it using vscode. All examples are below

Using git bash:

Eg Enter

cat /c/Users/FCP/.ssh/id_rsa.pub

This will give you something like this:
$ cat /c/Users/FCP/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC5brfa2BmLK0mXytu/ePZw+IGP0yiaZGSOl3AWeQNWeSG2M9IZC8Vndodq93/jNX/AZakKag4sFripB7usvMzFqW6ctWbbBsom+objw0m14PN+PegqSHtQapxWe66Dg11tAz8+mZ5VSwyf14nujqUi/+kiiqfLYnshAYYoQSeeEtufP14ws/co5/Ckx49RyZfpWu1U3GqBoqVbD6/n65dLdPenlZ0gjCpAUC6ggwwqqq05zqoOUIakGhiqi9iFBWjXn9NHQ47DoAjZtr8NtCRkx1WPpnaw7Pyu9YnjTzRYUYLdVq7+tYEtssqwqddeem20oPNowJIJE0RI9TbgVsyrxJBv/CjtuP4CL+WJPSObFIb2MCtiJ+DKgY9pLhJDq858p99m9Rp6j//EWMTUaSwgYVDEHpMbqvGNuUUws01XowWT8vnjC+GFncIe+1kGxPTVxe/R1JamdXcm/AvrilfyODCLcfy0mcfevkSqWQHfSNJfCekOWNh95ufZwaZQDho8orhxQs30jUls= FCP@DESKTOP-Q59LJHR2J

Copy only the section Highlighted in Green Above
Step 5.1: Create a New Repo In Bitbucket

Go to your Bitbucket Account and Create a New Repo

Workspace: You can leave this as its default value or define it so that team members can collaborate. We will leave this as default.
Project name: Name of your project. we shall use MyWebApp
Repository name: Name of your repository. we shall use MyFirstRepo
Access level: Private repository . This repo wont be open to the public
 Then click Create 


Step 5.2: Copy SSH keys to your Repo
Go to your new repo. Click on Repository settings
Click Access keys then  click Add keys


Copy and Paste your ssh keys into the box the click Add SSH keys

Go to your repo home and copy the ssh command to clone your repo

Go to your Git Bash console and paste the command to clone your new repo


Congrats you have successfully Cloned your first Repo!!!!!!!!!!