GithubHelp home page GithubHelp logo

demo-ci's Introduction

Continuous Integration Demo

Status of last Travis CI build: Build Status

Demo project using Travis CI to build and test a Java project.

If you want to test this project using Travis CI, then you need to create your own Github repo for it.

Therefore, do not clone this repo from Github. Download it as a ZIP file, create your own repo, then add Github as remote origin and push.

After that, give Travis access to your Github repo and trigger a build on Travis.

Travis-CI is a continuous integration server for building, testing, and deploying software projects. It works with many lanaguages and integrates easily with Github.

Building the Application

To build a Java project on Travis-CI, use Ant, Gradle, or Maven. In this demo project we use good-old Apache Ant, a standard Java build tool.

The Ant Build File

The Ant build file is build.xml. Open the file in an editor (not a web browser) to see what it looks like.

There are several Ant "targets" defined in the build file, such as clean, compile, and test. There is also a deps target used by Travis CI to install dependencies needed for Travis to build and test this project. Type ant -p to print all targets.

Here is part of the build file:

    <property name="base.dir" location="." />
    <property name="src.dir" location="${base.dir}/src"/>
    <property name="build.dir" location="${base.dir}/bin"/>

    <!-- compile the source code -->
    <target name="compile" depends="init" description="Compile source code" >
        <javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" />
    </target>

The target is named "compile", which requires another target ("init") be done first. The "compile" target contains one task to perform: javac. javac is an Ant pre-defined task that will compile everything in the srcdir and subdirs, and put the compiler output in corresponding directory in destdir.

If there are any errors, the task will print error messages and ant will stop.

Build and Test Locally

Ant requires the JUnit libraries on the classpath. In the build.xml, it uses lib.dir for the directory containing Jars. Do one of these:

  • copy JUnit Jars to a lib dir inside this project
  • use a command line argument to set lib.dir to refer to your JUnit directory (of course you have JUnit installed, right?):
ant -Dlib.dir=/your/junit/lib  test
  • Install them using an Ant task:
ant deps

Then run the tests using:

ant test

You'll see Ant run the init, compile, and test-compile tasks before running test.

If you type ant test a second time, the "init", "compile", and "test-compile" tasks are run but don't do anything, because their outputs are already up-to-date.

Managing Dependencies

This project needs JUnit JARs to run tests. These are (suprisingly) not on the CLASSPATH of the Travis Virtual Machine, so they need to be installed before compiling the code. Travis automatically runs an "ant deps" task to setup dependencies. So in build.xml there is a deps target that download JUnit JARs into a ./lib directory.

Enable Travis on Github

See links below for how to add Travis as an "Application" to your Github account. You do this from the Travis-ci.com web site. Don't use the older travis-ci.org site.

The Travis-CI site lets you configure project-specific settings, such as what branch it should build, and what triggers a build. You can add pull requests as a trigger.

You may need to force Travis to do an initial build of your project. Use the "More Options" menu on the right-side of Travis screen for your project.


More Info

Building a Java Project with Travis CI. Info on Ant builds is a bit sketchy.

Travis Getting Started Guide

demo-ci's People

Contributors

jbrucker avatar fatalaijon avatar

Watchers

James Cloos avatar  avatar

demo-ci's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.