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 1.8 1.8 UTF-8
			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

This is an H1

This is an H2

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 1.8 1.8 and <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> are equivalent according to the Maven documentation of the compiler plugin since the  and the  elements in the compiler configuration use the properties maven.compiler.source and maven.compiler.target if they are defined. source The -source argument for the Java compiler. Default value is: 1.6. User property is: maven.compiler.source. target The -target argument for the Java compiler. Default value is: 1.6. User property is: maven.compiler.target. About the default values for source and target, note that since the 3.8.0 of the maven compiler, the default values have changed from 1.5 to 1.6. 3) The maven-compiler-plugin 3.6 and later versions provide a new way : org.apache.maven.plugins maven-compiler-plugin 3.8.0 9 You could also declare just : <maven.compiler.release>9</maven.compiler.release> But at this time it will not work as the maven-compiler-plugin default version you use doesn't rely on a recent enough version. The Maven release argument conveys release : a new JVM standard option that we could pass from Java 9 : Compiles against the public, supported and documented API for a specific VM version. This way provides a standard way to specify the same version for the source, the target and the bootstrap JVM options. Note that specifying the bootstrap is a good practice for cross compilations and it will not hurt if you don't make cross compilations either.

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 1.8 1.8 1.8
true D:\jdk1.8\bin\javac

From https://stackoverflow.com/questions/38882080/specifying-java-version-in-maven-differences-between-properties-and-compiler-p

⚠️ **GitHub.com Fallback** ⚠️