Travis CI is an awesome platform for opens source projects but it doesn’t support yet windows. However the Tea-CI platform does and work pretty like Travis except it is not that integrated with Java ecosystem.

To be able to use it with your github project, you need to :

  • log on tea-ci

  • search in the search box for your project ($user/$project format is the most efficient ;))

  • activate tea-ci. It will link github hooks to tea-ci and enable automatic builds when you push.

Now that we are ready, let’s see how to workaround this lack of java integration to build a java 8 maven project on that platform.

To build a maven project on windows using tea-ci, you need this .drone.yml file at the root of your project. This file describes which environment you use (ming, cygwin…), which platform (32/64 bits) and which commands you want to launch.

Here is the sample I use for maven/java8:

build:
 image: teaci/cygwin32
 shell: cygwin32
 pull: true
 commands:
   - cmd /c c:/cygwin-installer.exe --site http://mirrors.tea-ci.org/cygwin --local-package-dir Z:/tmp/cygwin -W -P cabextract,unzip -q
   - echo '' > run.bat
   - wget http://repo.apache.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
   - unzip apache-maven-3.3.9-bin.zip
   - wget '--header' 'Cookie:oraclelicense=accept-securebackup-cookie' '--no-cookies' '--no-check-certificate' "http://download.oracle.com/otn-pub/java/jdk/8u91-b15/jdk-8u91-windows-i586.exe"
   - chmod ogu+rwx jdk-8u91-windows-i586.exe
   - cabextract jdk-8u91-windows-i586.exe || echo "ignoring errors"
   - mkdir jdk && mv tools.zip jdk && cd jdk && unzip tools.zip && for i in jre/lib/charsets jre/lib/deploy jre/lib/ext/localedata jre/lib/javaws jre/lib/jsse jre/lib/plugin jre/lib/rt lib/tools; do ./bin/unpack200 -r -v -l "" $i.pack $i.jar; done && cd -
   - echo set JAVA_HOME=$(cygpath.exe --windows $PWD/jdk) > run.bat
   - echo set M2_HOME=$(cygpath.exe --windows $PWD/apache-maven-3.3.9) >> run.bat
   - echo 'set Path=%JAVA_HOME%\bin;%M2_HOME%\bin;%Path%' >> run.bat
   - echo '%JAVA_HOME%\bin\java -cp %M2_HOME%\boot\plexus-classworlds-2.5.2.jar -Dclassworlds.conf=%M2_HOME%/bin/m2.conf -Dmaven.home=%M2_HOME% -Dmaven.multiModuleProjectDirectory=. org.codehaus.plexus.classworlds.launcher.Launcher clean install' >> run.bat
   - cmd /c run.bat

This .drone.yml will use cygwin (32 bits but there is a 64 bits versions if you need). It will:

  • Install unzip and cabextract (not suze why unzip is not there by default)

  • Download Maven 3.3.9

  • Download a JDK 8

  • Unpack the JDK (the exe, the tools.zip in the exe then the .pack which needs to be converted to .jar)

  • Finally it will initialize the environment and launch maven

In this sample the maven command is a simple “mvn clean install” but any command works of course.
Have fun and stay portable ;)

From the same author:

In the same category: