Java Ant script now works with run-at-startup

Change-Id: Ie19f8ec1a4d2346c23e19fddba274e30d67da9ce
This commit is contained in:
thomasclark
2014-06-27 17:25:54 -04:00
parent 0926fa4937
commit 256b052a55
5 changed files with 48 additions and 36 deletions

View File

@@ -2,8 +2,10 @@
username=admin
password=
deploy.dir=/home/admin
deploy.run.command=./runjavaprogram
deploy.debug.command=./debugjavaprogram
deploy.kill.command=/usr/local/frc/bin/frcKillRobot.sh -t -r
deploy.run.command=/usr/local/frc/bin/frcRunRobot.sh
deploy.debug.command = /usr/local/frc/JRE/bin/java -XX:+UsePerfData -agentlib:jdwp=transport=dt_socket,address=8348,server=y,suspend=y -jar ${deploy.dir}/FRCUserProgram.jar
command.dir=/home/lvuser/
# Libraries to use
wpilib=${user.home}/wpilib/java/${version}
@@ -34,4 +36,5 @@ dist.jar=${dist.dir}/${jar}
simulation.dist.jar=${dist.dir}/FRCUserProgramSim.jar
wpilib.sim=${wpilib}/sim
wpilib.sim.lib=${wpilib.sim}/lib
wpilib.sim.tools=${wpilib.sim}/tools
wpilib.sim.tools=${wpilib.sim}/tools

View File

@@ -24,11 +24,11 @@
<property name="target" value="10.${ip.upper}.${ip.lower}.2" />
<echo>Target IP: ${target}</echo>
</target>
<target name="compile" description="Compile the source code.">
<mkdir dir="${build.dir}"/>
<echo>[athena-compile] Compiling ${src.dir} with classpath=${classpath} to ${build.dir}</echo>
<javac srcdir="${src.dir}"
destdir="${build.dir}"
includeAntRuntime="no"
@@ -40,7 +40,7 @@
debug="true">
</javac>
</target>
<target name="jar" depends="compile">
<echo>[athena-jar] Making jar ${dist.jar}.</echo>
<mkdir dir="${dist.dir}" />
@@ -52,55 +52,67 @@
<pathelement path="${classpath}"/>
</path>
</copy>
<jar destfile="${dist.jar}" update="false">
<manifest>
<attribute name="Main-Class" value="edu.wpi.first.wpilibj.RobotBase"/>
<attribute name="Robot-Class" value="${robot.class}"/>
<attribute name="Class-Path" value="."/>
</manifest>
<fileset dir="${build.dir}" includes="**/*.class"/>
<zipgroupfileset dir="${build.jars}">
<include name="**/*.jar" />
</zipgroupfileset>
</jar>
</target>
<target name="deploy" depends="get-target-ip,jar" description="Deploy the jar and start the program running.">
<target name="kill" depends="get-target-ip" description="Kill any previously running program.">
<echo>[athena-deploy] Killing current program.</echo>
<sshexec host="${target}"
username="${username}"
password="${password}"
trust="true"
command=". /etc/profile.d/natinst-path.sh; chmod a+x run*program; ${deploy.kill.command}"/>
</target>
<target name="deploy" depends="get-target-ip,jar,kill" description="Deploy the jar and start the program running.">
<echo>[athena-deploy] Copying code over.</echo>
<scp file="${dist.jar}" todir="${username}@${target}:${deploy.dir}"
password="${password}" trust="true"/>
<scp file="${wpilib.ant.dir}/runjavaprogram" todir="${username}@${target}:${deploy.dir}"
password="${password}" trust="true"/>
<scp file="${dist.jar}" todir="${username}@${target}:${deploy.dir}" password="${password}" trust="true"/>
<scp file="${wpilib.ant.dir}/robotCommand" todir="${username}@${target}:${command.dir}" password="${password}" trust="true"/>
<sshexec host="${target}"
username="${username}"
password="${password}"
trust="true"
failonerror="false"
command=". /etc/profile.d/natinst-path.sh; rm ${deploy.debug.file}"/>
<echo>[athena-deploy] Starting program.</echo>
<sshexec host="${target}"
username="${username}"
password="${password}"
trust="true"
command="chmod a+x run*program; ${deploy.run.command}"/>
command=". /etc/profile.d/natinst-path.sh; ${deploy.run.command}"/>
</target>
<target name="debug-deploy" depends="get-target-ip,jar" description="Deploy the jar and start the program running in debug mode.">
<echo>[athena-debug-deploy] Copying code over.</echo>
<scp file="${dist.jar}" todir="${username}@${target}:${deploy.dir}"
password="${password}" trust="true"/>
<echo>[athena-debug-deploy] Copying Debug Script Over.</echo>
<scp file="${wpilib.ant.dir}/debugjavaprogram" todir="${username}@${target}:${deploy.dir}"
password="${password}" trust="true"/>
<echo>[athena-debug-deploy] Starting program.</echo>
<target name="debug-deploy" depends="get-target-ip,jar,kill" description="Deploy the jar and start the program running.">
<echo>[athena-deploy] Copying code over.</echo>
<scp file="${dist.jar}" todir="${username}@${target}:${deploy.dir}" password="${password}" trust="true"/>
<echo>[athena-deploy] Starting program.</echo>
<sshexec host="${target}"
username="${username}"
password="${password}"
trust="true"
command="chmod a+x debug*program; ${deploy.debug.command}"/>
command=". /etc/profile.d/natinst-path.sh; ${deploy.debug.command}"/>
</target>
<!-- Simulate -->
<target name="jar-for-simulation" depends="compile">
<echo>[jar-for-simulation] Building jar.</echo>
<jar destfile="${simulation.dist.jar}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
@@ -123,12 +135,14 @@
</exec>
</sequential>
<sequential>
<sleep seconds="5"/>
<echo>[simulate] Running DriverStation.</echo>
<java jar="${wpilib.sim.tools}/SimDS.jar" fork="true">
<jvmarg value="-Djava.library.path=${wpilib.sim.lib}" />
</java>
</sequential>
<sequential>
<sleep seconds="5"/>
<echo>[simulate] Running Code.</echo>
<java jar="${simulation.dist.jar}" fork="true">
<jvmarg value="-Djava.library.path=${wpilib.sim.lib}" />
@@ -146,12 +160,14 @@
</exec>
</sequential>
<sequential>
<sleep seconds="5"/>
<echo>[debug-simulate] Running DriverStation.</echo>
<java jar="${wpilib.sim.tools}/SimDS.jar" fork="true">
<jvmarg value="-Djava.library.path=${wpilib.sim.lib}" />
</java>
</sequential>
<sequential>
<sleep seconds="5"/>
<echo>[debug-simulate] Running Code.</echo>
<java jar="${simulation.dist.jar}" fork="true">
<jvmarg value="-Xdebug" />
@@ -162,3 +178,4 @@
</parallel>
</target>
</project>

View File

@@ -1,5 +0,0 @@
#. ./.profile
killall java
sleep 1
/usr/local/frc/JRE/bin/java -XX:+UsePerfData -agentlib:jdwp=transport=dt_socket,address=8348,server=y,suspend=y -jar FRCUserProgram.jar
#nohup java -Djna.library.path=$LD_LIBRARY_PATH -Xmx32M -agentlib:jdwp=transport=dt_socket,address=8348,server=y,suspend=y -jar FRCUserProgram.jar

View File

@@ -0,0 +1,3 @@
/usr/local/frc/JRE/bin/java
-jar /home/admin/FRCUserProgram.jar

View File

@@ -1,6 +0,0 @@
#. ./.profile
killall java
killall FRCUserProgram
sleep 1
nohup /usr/local/frc/JRE/bin/java -jar FRCUserProgram.jar
#nohup /usr/local/frc/JRE/bin/java -Djna.library.path=$LD_LIBRARY_PATH -Xmx32M -jar FRCUserProgram.jar