[github + Travis-ci]在线编译

需要github仓库里面有.travis.yml和一个build.xml
我本地使用的是NetBeans和ant
由于travis-ci在线的默认也是ant所以我就学着用了ant了

下面是我的两个配置文件
.travis.yml

language: java

在travis-ci上编译需要有一个name为test的target,其实可以将其看作是build,将build弄过来就行了。

2019/3/26
继续修改

build.xml

 
<project name="Lab2-1171000106" default="build"> 
    <property name="build.dir" value="bin">property>  
    <property name="src.dir" value="src">property>  
    <property name="src-test" value="test">property>  
    <property name="lib" value="lib">property>  
    <property name="testReport" value="testReport">property>  
    <path id="javac-lib">  
    <fileset dir="${lib}">  
        <include name="*.jar" />  
    fileset>  
      
      
    <pathelement location="${build.dir}"/>  
    path>   
  
    <target name="compile">  
		<mkdir dir="${build.dir}"/> 
       <javac destdir="${build.dir}" source="1.8" target="1.8" debug="true"
		  deprecation="false" optimize="false" failonerror="true"  encoding="UTF-8">  
        <src path="src" />  
		<src path="test"/>
        <classpath refid="javac-lib" />  
    javac>  
    target>      
  
    <target name="test" depends="compile">   
    <delete dir="${testReport}" />  
    <mkdir dir="${testReport}" />  
    <mkdir dir="${build.dir}"/>  
       
    <junit printsummary="yes">   
        <classpath refid="javac-lib"/>   
        <formatter type="xml"/>   
        <batchtest todir="${testReport}">   
            <fileset dir="${build.dir}">   
                <include name="**/*Test.class"/>   
            fileset>   
        batchtest>   
    junit>   
      
       
    <junitreport todir="${testReport}">   
        <fileset dir="${testReport}">  
            <include name="TEST-*.xml"/>   
        fileset>   
        <report format="frames" todir="${testReport}"/>  
    junitreport>   
  
     
    target>
	<target name="build">
		 <mkdir dir="${build.dir}"/> 
		<javac destdir="${build.dir}" source="1.8" target="1.8" debug="true"
		  deprecation="false" optimize="false" failonerror="true" encoding="UTF-8">
		  <src path="${src.dir}"/> 
		  <classpath refid="javac-lib"/> 
		javac> 
	target>
	
	<target name="clean" description="Clean output directories"> 
		<delete> 
			<fileset dir="${build.dir}">
			<include name="**/*"/>
			fileset> 
		delete> 
		<delete dir="${testReport}">  
			<include name="**/*" />  
		delete>
	target> 
project>

你可能感兴趣的:(java)