Maven & Git - singhmahabir/allinone-rest-services GitHub Wiki
Maven need JAVA_HOME as jdk path MAVEN_HOME as maven path And in path java/bin and maven/bin path & %JAVA_HOME%\bin; %MAVEN_HOME%\bin;
It will generate artifact name as foo.jar in target folder. Default packaging type is jar.
****** scopes *******
There are 6 scopes are available compile (which is the default scope available everywhere) provided-like compile ,provided where it deployed Runtime - not needed for compilation , but for execution(driver class load runtime) Test- only available for the compilation and execution phase System- similar to provided, but don't use it Import-deals with dependencyManagement SCM-source code control module. Test and provided is not available in child project mean As a transitive dependency Test and provided are not available in child pom
plugin
org.apache.maven.plugins maven-compiler-plugin 3.2 Git & Github
Git pull is sum of git fetch plus git merge
Git is a widely adopted source control system It is a distributed source management system
GitHub:- It is a hosting service using git. Much more than just source code management.
3 States of Git : All these states are local Modified :- means the files have been changed but hasn't been committed in local data base yet Committed :- A data is saved in a local database Staged: mean modified file is marked to be part of the next commit snapshot
3/4 Area of Git Working directory :- file which are deleted added modified in local git database Staging area :- area where modified files are staged before they will be committed, basically when files are in staging area they are waiting to be commit . It probably part of the next commit. .git repo:- It is a directory entirely manage by git itself. It also gets created when we clone from another system or github Remote repo Github:- is the 4th area where the files can be saved. markdown(md file ) https://daringfireball.net/projects/markdown/syntax
Below will make list (mean using *)
- Red
- Green
- blue
Setting git global settings git config --global user.name "User Name" git config --global user.password "User password" git config --global user.email "User email"
To see git config file git config --edit --global Or manually go to folder and open .gitconfig
To set default file editor in git git config core.editor "notepad++" or notepad++ -multiInst -nosession""
git init :- initialize a git local repo git add: prepare a file to staging • git add -A stages all changes • git add . stages new files and modifications, without deletions • git add -u stages modifications and deletions, without new files • git remote -v will show if folder is linked to any remote repository • git remote add origin <> will linked local to remote repository • git push -u origin master will push the local contain to remote ssh-keygen -t rsa -b 4096 -c "email " ssh -T [email protected] to test
Change the commit message git commit --amend -m "[DVBMSBC-57]- Integration Test with database connection bcf service"
git clone -b feature/MBSERV-61 https://[email protected]/stash/scm/mbserv/mbapps-iheartradio-service.git feature/MBSERV-61 is branch name
git fetch It will download the changes from the remote to git data base and not merge git pull It will do fetch first and then do merge Git checkout branch name Git checkout -b branch name
Git branch -a
Git reset --hard
Git reset will remove added file
~/. Current directory
git diff --stat --cached origin/master after commit see how many files going
git push origin master:any_branch_name
git diff > foo.diff
Git fetch -p will delete local branch which is deleted in repository
• git merge branchname takes new commits from the branch branchname, and adds them to the current branch. If necessary, it automatically adds a "Merge" commit on top. • git rebase branchname takes new commits from the branch branchname, and inserts them "under" your changes. More precisely, it modifies the history of the current branch such that it is based on the tip of branchname, with any changes you made on top of that. • git pull is basically the same as git fetch; git merge origin/master. • git pull --rebase is basically the same as git fetch; git rebase origin/master.
From https://stackoverflow.com/questions/7200614/how-to-merge-remote-master-to-local-branch
How to specify the JDK version?
1) <java.version> is not referenced in the Maven documentation.
It is a Spring Boot specificity.
It allows to set the source and the target java version with the same version such as this one to specify java 1.8 for both :
<java.version>1.8</java.version>
Feel free to use it if you use Spring Boot.
2) Using maven-compiler-plugin or maven.compiler.source/maven.compiler.target properties to specify the source and the target are equivalent.
maven-compiler-plugin
Which is the best way to specify the JDK version? The first way (<java.version>) is allowed only if you use Spring Boot. For Java 8 and below : About the two other ways : valuing the maven.compiler.source/maven.compiler.target properties or using the maven-compiler-plugin, you can use one or the other. It changes nothing in the facts since finally the two solutions rely on the same properties and the same mechanism : the maven core compiler plugin. Well, if you don't need to specify other properties or behavior than Java versions in the compiler plugin, using this way makes more sense as this is more concise: <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> From Java 9 : The release argument (third point) is a way to strongly consider if you want to use the same version for the source and the target. What happens if the version differs between the JDK in JAVA_HOME and which one specified in the pom.xml? It is not a problem if the JDK referenced by the JAVA_HOME is compatible with the version specified in the pom but to ensure a better cross-compilation compatibility think about adding the bootstrap JVM option with as value the path of the rt.jar of the target version. An important thing to consider is that the source and the target version in the Maven configuration should not be superior to the JDK version referenced by the JAVA_HOME. A older version of the JDK cannot compile with a more recent version since it doesn't know its specification. To get information about the source, target and release supported versions according to the used JDK, please refer to java compilation : source, target and release supported versions.
How handle the case of JDK referenced by the JAVA_HOME is not compatible with the java target and/or source versions specified in the pom?
For example, if your JAVA_HOME refers to a JDK 1.7 and you specify a JDK 1.8 as source and target in the compiler configuration of your pom.xml, it will be a problem because as explained, the JDK 1.7 doesn't know how to compile with.
From its point of view, it is an unknown JDK version since it was released after it.
In this case, you should configure the Maven compiler plugin to specify the JDK in this way :
org.apache.maven.plugins
maven-compiler-plugin
true
D:\jdk1.8\bin\javac