diff --git a/.travis.yml b/.travis.yml index 5c10081..317d4a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,13 +11,14 @@ before_install: - ssh-keyscan -t rsa localhost > ~/.ssh/known_hosts - chmod u+rw,go= ~/.ssh/known_hosts # Install dependencies for sample projects. - ## Gradle, Maven. + ## Gradle, Maven, Buck. - jdk_switcher use oraclejdk8 - java -version && javac -version ## Rust. - sudo curl -sf -L https://static.rust-lang.org/rustup.sh | sh ## Go. - sudo apt-get install golang --quiet --yes + - mv ~/.bashrc ~/.bashrc_original && echo -e "export GOROOT=$GOROOT\n" > ~/.bashrc && cat ~/.bashrc_original >> ~/.bashrc && rm ~/.bashrc_original ## Clang. - sudo apt-get install clang --quiet --yes ## GCC. @@ -32,6 +33,14 @@ before_install: - eval $ANDROID_SDK_INSTALL_COMPONENT "build-tools-25.0.2" - eval $ANDROID_SDK_INSTALL_COMPONENT "android-25" - mv ~/.bashrc ~/.bashrc_original && echo -e "export ANDROID_HOME=$ANDROID_HOME\nJAVA_HOME=$JAVA_HOME" > ~/.bashrc && cat ~/.bashrc_original >> ~/.bashrc && rm ~/.bashrc_original + ## Buck. + - sudo apt-get install ant python git + - git clone https://github.com/facebook/buck.git + - cd buck + - git checkout v2016.11.11.01 + - ant + - mv ~/.bashrc ~/.bashrc_original && echo -e "export PATH=$PATH:`pwd`/bin\n" > ~/.bashrc && cat ~/.bashrc_original >> ~/.bashrc && rm ~/.bashrc_original + - cd .. script: - bash test/test.sh --run-samples diff --git a/README.md b/README.md index 367268d..ea3a361 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ We have quite a bunch of samples showing off some practical applications. * [Clang](samples/clang) * [GCC](samples/gcc) * [Maven](samples/mvn) +* [Buck](samples/buck) * [Go](samples/go) ## Setup diff --git a/samples/buck/.buckconfig b/samples/buck/.buckconfig new file mode 100644 index 0000000..31b1b3d --- /dev/null +++ b/samples/buck/.buckconfig @@ -0,0 +1,4 @@ +[java] + src_roots = /src/main/java/ + source_level = 6 + target_level = 6 diff --git a/samples/buck/.gitignore b/samples/buck/.gitignore new file mode 100644 index 0000000..2cfffb7 --- /dev/null +++ b/samples/buck/.gitignore @@ -0,0 +1,2 @@ +buck-out +.buckd diff --git a/samples/buck/.mainframer/config b/samples/buck/.mainframer/config new file mode 100644 index 0000000..490161e --- /dev/null +++ b/samples/buck/.mainframer/config @@ -0,0 +1 @@ +remote_machine=sample@remotebuildmachine diff --git a/samples/buck/.mainframer/ignore b/samples/buck/.mainframer/ignore new file mode 100644 index 0000000..b03777e --- /dev/null +++ b/samples/buck/.mainframer/ignore @@ -0,0 +1,8 @@ +# .buckd folder contains machine specific loc and bin files, no need to sync it between machines. +/.buckd + +# Synching .git or other VCS folders is very bad idea, they are usually very heavy and not required for the build. +/.git + +# Synching IDE specific folders is really not needed for remote build. +/.idea diff --git a/samples/buck/.mainframer/localignore b/samples/buck/.mainframer/localignore new file mode 100644 index 0000000..d84c0fa --- /dev/null +++ b/samples/buck/.mainframer/localignore @@ -0,0 +1,2 @@ +# Usually you don't need to sync buck-out folder to remote machine since it will have one as result of build. +/buck-out diff --git a/samples/buck/.mainframer/remoteignore b/samples/buck/.mainframer/remoteignore new file mode 100644 index 0000000..33bcdad --- /dev/null +++ b/samples/buck/.mainframer/remoteignore @@ -0,0 +1,2 @@ +# Usually you don't need to sync sources back from remote to local machine. +/sample diff --git a/samples/buck/README.md b/samples/buck/README.md new file mode 100644 index 0000000..badadea --- /dev/null +++ b/samples/buck/README.md @@ -0,0 +1,18 @@ +## Sample Buck project + +Most interesting for you here is not the source code, but configs in [`.mainframer`](.mainframer) folder. + +This is a very common setup for basically any Buck project (including multimodule), but of course you might need to tune some ignore configs for your project. + +### How to build + +```bash +$ bash mainframer.sh buck build sample +``` + +Or any other Buck task you want, btw it integrates with IntelliJ pretty easily! TODO add link to docs. + +### Requirements + +* Buck installed on remote machine. +* JDK 8+ installed on remote machine. diff --git a/samples/buck/sample/BUCK b/samples/buck/sample/BUCK new file mode 100644 index 0000000..73debc2 --- /dev/null +++ b/samples/buck/sample/BUCK @@ -0,0 +1,10 @@ +java_binary( + name = "sample", + main_class = "com.gojuno.mainframer.Sample", + deps = [":main"] +) + +java_library( + name = "main", + srcs = glob(["src/main/java/**/*.java"]) +) diff --git a/samples/buck/sample/src/main/java/com/gojuno/mainframer/Sample.java b/samples/buck/sample/src/main/java/com/gojuno/mainframer/Sample.java new file mode 100644 index 0000000..e78ed91 --- /dev/null +++ b/samples/buck/sample/src/main/java/com/gojuno/mainframer/Sample.java @@ -0,0 +1,8 @@ +package com.gojuno.mainframer; + +class Sample { + + public static void main(String[] args) { + System.out.println("Build me on remote machine!"); + } +} diff --git a/test/sample_buck.sh b/test/sample_buck.sh new file mode 100755 index 0000000..7e93764 --- /dev/null +++ b/test/sample_buck.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +# You can run it from any directory. +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# Execute common pre-setup, include test functions. +source "$DIR/common.sh" + +printTestStarted + +# Copy Buck sample to build dir. +cp -a "$DIR/../samples/buck/." "$BUILD_DIR" + +# Overwrite config to work with test remote machine. +setTestRemoteMachineInConfig + +# Run mainframer.sh that builds Buck project. +bash "$REPO_DIR"/mainframer.sh 'buck clean && buck build sample' + +# Run jar to ensure that it was built fine. +java -jar "$BUILD_DIR/buck-out/gen/sample/sample.jar" + +printTestEnded