Hello People,
This blog is regarding build and test any java project without maven i hope it will help beginner who started learning java course.
First Create a account in github and create a repostory and add .java code in the github.
For example i am testing with below sample java program in the travis ci and github using official java docker.
HelloWorld.java
public class HelloWorld
public class HelloWorld{
public static void main(String h[])
{
System.out.println(“Hello World !”);
}
}
After creating java program and commit in github, visit : https://travis-ci.org and signup/signin with github account, import the github project in travis ci and enable project for build and testing in travis ci.
After enabling in travis ci go to github and create .travis.yml file as below
language: bash
services:
– docker
before_script:
– docker pull java:7
script:
– docker run –rm -v”$PWD”:/usr/src/myapp -w /usr/src/myapp java:7 javac HelloWorld.java
– echo “Listing class files”
– ls -la
– echo “Output of java file”
– docker run –rm -v”$PWD”:/usr/src/myapp -w /usr/src/myapp java:7 java HelloWorld
after_script:
– docker rmi $(docker images -aq)
As soon as above program is committed in github, travis ci will automatically detect new commit in the master branch it will start build and testing based on .travis.yml configuration.
You can find the sample log in link : https://travis-ci.org/hemanth22/First_Java_Helloworld
I have created a sample project in github please visit to below link.
https://github.com/hemanth22/First_Java_Helloworld
If you are patching code and creating a pull request between master and patch branch, it will start building and testing the code parallelly as a checks before merging into master branch as shown below.
This will give you confidence before merging patch branch to master or main branch of program.
If you like the post please share and like.
Thanks.