简体   繁体   中英

Building Scala project in Travis when build.sbt is not in root directory

I have a project where the build.sbt is not inside the root directory, but inside a sub-directory build-sbt (for reasons which don't matter here). I thought I could get Travis.CI to build this using:

language: scala

scala:
  - 2.11.8

jdk:
  - oraclejdk8
  - openjdk7
  - openjdk6

env:
  - TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR/build-sbt

However, it doesn't even try to use sbt but assumes, possibly because it looks first in the root directory before even changing directory, and finds here a build.xml from an obsolete Ant build. So Travis tries to run Ant, which it shouldn't:

$ git clone --depth=50 --branch=sbtfied https://github.com/Sciss/weblaf.git Sciss/weblaf

Cloning into 'Sciss/weblaf'...    
remote: Counting objects: 7617, done.
remote: Compressing objects: 100% (4211/4211), done.
remote: Total 7617 (delta 4486), reused 5189 (delta 2765), pack-reused 0
Receiving objects: 100% (7617/7617), 11.24 MiB | 19.61 MiB/s, done.
Resolving deltas: 100% (4486/4486), done.
Checking connectivity... done.

$ cd Sciss/weblaf
$ git checkout -qf 33e4986d7e678a732cf8e18d9e4bedc8a967e3de
This job is running on container-based infrastructure, which does not allow use of 'sudo', setuid and setguid executables.
If you require sudo, add 'sudo: required' to your .travis.yml
See https://docs.travis-ci.com/user/workers/container-based-infrastructure/ for details.
Setting environment variables from .travis.yml
$ export TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR/build-sbt
$ jdk_switcher use oraclejdk8
Switching to Oracle JDK8 (java-8-oracle), JAVA_HOME will be set to /usr/lib/jvm/java-8-oracle
$ java -Xmx32m -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
$ javac -J-Xmx32m -version
javac 1.8.0_31
Using Scala 2.11.8
$ ant test
Buildfile: build.xml does not exist!

Build failed
The command "ant test" exited with 1.

Instead of setting an environment variable, the following script works:

script:
  - cd build-sbt
  - sbt ++$TRAVIS_SCALA_VERSION test

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM