简体   繁体   English

当build.sbt不在根目录中时,在Travis中构建Scala项目

[英]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). 我有一个项目,其中build.sbt不在根目录内,而是在子目录build-sbt (出于这里无关紧要的原因)。 I thought I could get Travis.CI to build this using: 我以为我可以让Travis.CI使用以下命令来构建它:

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. 但是,它甚至没有尝试使用sbt而是进行假设,这可能是因为它首先在根目录中查找,甚至在更改目录之前,并在这里从过时的Ant构建中找到build.xml So Travis tries to run Ant, which it shouldn't: 因此Travis尝试运行Ant,但不应这样做:

$ 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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