2013-05-21 3 views
1

Java 및 Travis CI를 처음 사용하고 프로젝트를 구성하는 중에 오류가 발생했습니다. 나는 개미를 사용하여 빌드하고 아이비를 사용하여 의존성을 관리합니다. 내 개미 빌드는 로컬에 아이비 jar 파일이없는 경우 직접 다운로드합니다. 내 컴퓨터에서 정상적으로 작동하지만 트래비스를 밀 때 실패합니다.Travis CI에서 Ivy jarfile을 찾을 수 없습니다.

수수께끼 같은 것 : 항아리를 다운로드하고 bootstrap-ivy 작업 중에 /home/travis/.ant/lib/에 넣는 것처럼 보이지만 다음에 나오는 resolve 작업에서 찾을 수 없습니다. 무슨 일있어? 전체 오류, 내 개미 buildfile 및 내 .travis.yml 모두 아래에 포함되어 있습니다.

Using worker: worker-linux-3-1.bb.travis-ci.org:travis-linux-13 
git.1 
$ git clone --depth=50 --branch=master git://github.com/ecmendenhall/Java-TTT.git ecmendenhall/Java-TTT 
Cloning into 'ecmendenhall/Java-TTT'... 
remote: Counting objects: 613, done. 
remote: Compressing objects: 100% (345/345), done. 
remote: Total 613 (delta 325), reused 421 (delta 133) 
Receiving objects: 100% (613/613), 102.29 KiB, done. 
Resolving deltas: 100% (325/325), done. 
$ cd ecmendenhall/Java-TTT 
git.2 
$ git checkout -qf 3a5201cc7e850d7cbad69712fce28a36c86ea6d1 
$ jdk_switcher use oraclejdk7 
Switching to Oracle JDK7 (java-7-oracle), JAVA_HOME will be set to /usr/lib/jvm/java-7-oracle 
update-alternatives: error: no alternatives for apt. 
update-alternatives: error: no alternatives for mozilla-javaplugin.so. 
update-alternatives: error: no alternatives for apt. 
$ java -version 
java version "1.7.0_17" 
Java(TM) SE Runtime Environment (build 1.7.0_17-b02) 
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode) 
$ javac -version 
javac 1.7.0_17 
$ ant resolve 
Buildfile: /home/travis/build/ecmendenhall/Java-TTT/build.xml 
    [mkdir] Created dir: /home/travis/build/ecmendenhall/Java-TTT/lib 
check-ivy: 
    [echo] Checking for Ivy .jar in local directories. 
bootstrap-ivy: 
    [echo] Bootstrapping Ivy installation. 
    [mkdir] Created dir: /home/travis/.ant/lib 
     [get] Getting: http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar 
     [get] To: /home/travis/.ant/lib/ivy.jar 
resolve: 
    [echo] Resolving project dependencies. 
BUILD FAILED 
/home/travis/build/ecmendenhall/Java-TTT/build.xml:52: Problem: failed to create task or type antlib:org.apache.ivy.ant:retrieve 
Cause: The name is undefined. 
Action: Check the spelling. 
Action: Check that any custom tasks/types have been declared. 
Action: Check that any <presetdef>/<macrodef> declarations have taken place. 
No types or tasks have been defined in this namespace yet 
This appears to be an antlib declaration. 
Action: Check that the implementing library exists in one of: 
     -/usr/share/ant/lib 
     -/home/travis/.ant/lib 
     -a directory added on the command line with the -lib argument 
Total time: 3 seconds 
The command "ant resolve" failed and exited with 1 during install. 
Your build has been stopped. 

가 여기 내 개미 빌드 파일입니다 : 여기

전체 트래비스 오류의

<?xml version="1.0" encoding="UTF-8"?> 
<project name="TicTacToe" basedir="." default="jar" xmlns:ivy="antlib:org.apache.ivy.ant"> 
    <description>Builds the TicTacToe command line application and its associated tests.</description> 

    <!-- Source and build directory defaults --> 
    <property name="src.dir" value="src"/> 
    <property name="resources.dir" value="resources"/> 

    <property name="build.dir" value="build"/> 
    <property name="classes.dir" value="${build.dir}/classes"/> 
    <property name="jar.dir" value="${build.dir}/jar"/> 

    <property name="main-class" value="com.cmendenhall.Main"/> 

    <mkdir dir="lib" /> 
    <property name="lib.dir" value="lib"/> 
    <property name="test.dir" value="test" /> 

    <path id="classpath"> 
     <fileset dir="${lib.dir}" includes="**/*.jar"/> 
    </path> 

    <path id="classpath.test"> 
     <fileset dir="${lib.dir}" includes="**/*.jar"/> 
     <pathelement location="${classes.dir}" /> 
     <pathelement location="${resources.dir}" /> 
    </path> 

    <path id="application" location="${jar.dir}/${ant.project.name}.jar"/> 

    <!-- Automatically download Ivy --> 
    <property name="ivy.jar.dir" value="${user.home}/.ant/lib" /> 
    <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" /> 

    <target name="check-ivy" unless="INTERN-ivy.jar.exists" description="Check if the Ivy .jar is already installed."> 
     <echo message="Checking for Ivy .jar in local directories." /> 
     <available property="INTERN-ivy.jar.exists" file="${ivy.jar.file}"/> 
    </target> 

    <target name="bootstrap-ivy" 
      description="Installs the Ivy jar before downloading dependencies." 
      unless="INTERN-ivy.jar.exists" 
      depends="check-ivy"> 
     <echo message="Bootstrapping Ivy installation." /> 
     <mkdir dir="${user.home}/.ant/lib"/> 
     <get dest="${user.home}/.ant/lib/ivy.jar" 
      src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar"/> 
     <mkdir dir="/usr/share/ant/lib" /> 
     <get dest="/usr/share/ant/lib/ivy.jar" 
      src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar" /> 
    </target> 

    <target name="resolve" description="Retrieve dependencies with Ivy." depends="check-ivy, bootstrap-ivy"> 
     <echo message="Resolving project dependencies." /> 
     <ivy:retrieve /> 
    </target> 

    <target name="clean" description="Cleans up automatically generated files and directories."> 
     <echo message="Cleaning up build directory." /> 
     <delete dir="${build.dir}"/> 
    </target> 

    <target name="compile" depends="resolve" description="Compiles project."> 
     <echo message="Compiling project." /> 
     <mkdir dir="${classes.dir}"/> 
     <javac includeantruntime="false" debug="true" srcdir="${src.dir}" destdir="${classes.dir}" > 
      <classpath refid="classpath" /> 
     </javac> 
    </target> 

    <target name="compile-tests" depends="resolve" description="Compiles JUnit tests." > 
     <echo message="Compiling JUnit tests." /> 
     <javac includeantruntime="false" debug="true" srcdir="${test.dir}" destdir="${classes.dir}" > 
      <classpath refid="classpath" /> 
     </javac> 
    </target> 

    <target name="jar" depends="compile" description="Packages project as .jar file."> 
     <echo message="Packaging project as .jar file." /> 
     <mkdir dir="${jar.dir}"/> 
     <jar destfile="${jar.dir}/${ant.project.name}.jar"> 
      <manifest> 
       <attribute name="Main-class" value="${main-class}"/> 
      </manifest> 
      <fileset dir="${classes.dir}"> 
       <include name="**/*.class" /> 
      </fileset> 
      <fileset dir="${resources.dir}"> 
       <include name="**/*.properties" /> 
      </fileset> 
     </jar> 
    </target> 

    <property name="junitpath" refid="classpath.test" /> 


    <target name="test" depends="compile, compile-tests" description="Runs JUnit tests."> 
     <echo message="Running JUnit tests." /> 
     <junit printsummary="on" haltonfailure="yes" failureproperty="test.failure"> 
      <jvmarg value="-Dfile.encoding=UTF-8:-XX:-UseSplitVerifier" /> 
      <formatter type="brief" usefile="false" /> 
      <classpath> 
       <path refid="classpath.test"/> 
      </classpath> 

      <batchtest fork="on"> 
       <fileset id="matchedtests" dir="${classes.dir}"> 
        <include name="**/*Test.class"/> 
        <exclude name="**/TicTacToeTest.class" /> 
       </fileset> 
      </batchtest> 
     </junit> 
    </target> 

    <target name="clean-build" depends="clean, jar" description="Cleans output directory and builds .jar."> 
     <echo message="Cleaning build directory and rebuilding .jar." /> 
    </target> 

    <target name="build-all" depends="clean, jar, test" description="Cleans output directory, retrieves dependencies, builds and packages project and tests."> 
     <echo message="Finishing build." /> 
    </target> 

</project> 

그리고 여기 내 .travis.yml입니다 :

language: java 
install: ant resolve 
jdk: 
    - oraclejdk7 
    - openjdk7 
    - openjdk6 

UPDATE : 여기 솔루션의 그 일한 나, 아래 조언 덕분. 트래비스 빌드에 대한 종속성 (Here are the docs를 해결하기 전에 ant init-ivy를 실행

<property name="ivy.install.version" value="2.1.0-rc2" /> 
    <condition property="ivy.home" value="${env.IVY_HOME}"> 
     <isset property="env.IVY_HOME" /> 
    </condition> 
    <property name="ivy.home" value="${user.home}/.ant" /> 
    <property name="ivy.jar.dir" value="${ivy.home}/lib" /> 
    <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" /> 

    <target name="download-ivy" unless="offline"> 

     <mkdir dir="${ivy.jar.dir}"/> 
     <!-- download Ivy from web site so that it can be used even without any special installation --> 
     <get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" 
      dest="${ivy.jar.file}" usetimestamp="true"/> 
    </target> 

    <target name="init-ivy" depends="download-ivy"> 
     <!-- try to load ivy here from ivy home, in case the user has not already dropped 
       it into ant's lib dir (note that the latter copy will always take precedence). 
       We will not fail as long as local lib dir exists (it may be empty) and 
       ivy is in at least one of ant's lib dir or the local lib dir. --> 
     <path id="ivy.lib.path"> 
      <fileset dir="${ivy.jar.dir}" includes="*.jar"/> 

     </path> 
     <taskdef resource="org/apache/ivy/ant/antlib.xml" 
       uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/> 
    </target> 

내가 .travis.ymlbefore_install 단계를 추가 :

은 내가 official docs에서 권장하는 download-ivyinit-ivy 작업을 내 사용자 지정 bootstrap-ivy 작업을 대체 주기) :

language: java 
before_install: ant init-ivy 
install: ant resolve 
jdk: 
    - oraclejdk7 
    - openjdk7 
    - openjdk6 

이제 모든 것이 작동합니다!

+0

'자동'섹션을 참조하십시오. ivy를 $ {user.home} /. ant/lib에 설치하면 충분합니다. 두 개의 병을 설치할 필요가 없습니다. –

답변

2

이것은 개미가 .ant/lib에서 항아리를로드하는 방식과 관련이 있습니다. 이 폴더는 Ant 부팅과 동시에 발견되며, jar 파일이 발견되면 핵심 클래스 로더에 추가됩니다. 여기에서는 .ant/lib이 빌드를 실행하는 동안 채워지므로 너무 늦습니다. 이 해결

두 가지 선택 : 두 번

+0

+1 ANT를 두 번 실행하는 가장 간단한 방법은 Travis 작업 내에 두 개의 빌드 단계를 만드는 것입니다. (나는 Jenkins와 더 친숙하지만 원칙은 동일합니다.) –

+0

고마워요! 2 단계 빌드 프로세스가 작동했습니다. – ecmendenhall

관련 문제