To solve this problem, I created a very simple shell script and integrated it into Eclipse. Eclipse will run the script automatically every time any files in the project are saved or created. This way, my zip file always contains the most up-to-date source files.
To get started, you'll need to create a shell script by copying and pasting the following lines into an empty file, then save the file and make it executable using chmod 755 filename.
#! /bin/bash
#Prefix to prepend to dirname, used for naming the zip file
UNAME=$1
#get the name of the directory this is being run from
PROJECTNAME=$2
zip $UNAME$PROJECTNAME src/*.java
Once you've got the script saved in a safe place, open up your project in Eclipse. (Note that I name my projects according to the assignment.) Right click on your project in the Package Explorer pane and select Properties. Choose the Builders link from the list on the left. Click the New button on the right. Select Program from the next window that appears. Give your new configuration a name. Click Browse Filesystem and find your script for the first blank. Then Browse Workspace and pick your project for the "Working Directory" blank. At the bottom: Variables >> Edit Variables >> New. Name your variable something descriptive, like canvas_user_name, and provide a value, like daschelb. Then click OK >> OK, then select your new variable and click OK once more. Click variables again, only this time choose the one named project_name. Make sure there is a space between the variables in the "Arguments" area.
Finally click the Build Options tab and select Launch in background and During auto builds.
That's it. Eclipse will now start generating a zip file for you every time it compiles your code. (BTW, the script places the zip in the root of your project folder.)
No comments:
Post a Comment