--javaMaker 1.0 --by Mike Roam, June 1999 --applescript source code for scriptlet that will compile all .java files --in selected folder that don't have an up-to-date .class file. --This recursively goes into sub-folders while building its list of --files that will all be given to javac at once. on startMake(theFolder) --driver file to collect the (possibly recursively built) list of file paths set finalFileList to gatherFiles(theFolder) if (count items in finalFileList) < 1 then tell application "Finder" set temp to display dialog "No files needed compiling." end tell else tell application "Finder" set temp to display dialog "Going to compile " & (count items in finalFileList) & " files." end tell compile(finalFileList) of me end if end startMake on run --this starts the action if the script is run from the scriptEditor tell application "Finder" activate try set theFolder to choose folder with prompt "Select the folder:" --ALTERNATIVE instead use next line (specific path) if you want to lock in one file: --set theFolder to alias "my disk:Desktop Folder:Maker:samp:" on error -- e.g. user cancelled return end try startMake(theFolder) of me end tell end run on open X --this starts the action if the script is double clicked or has file dropped onto it tell application "Finder" set ErrorString to "Make process needs a folder. " & Â "Please try again with a folder." if (count items in X) ­ 1 then display dialog ErrorString buttons "OK" default button 1 return end if set y to item 1 of X if last character of (y as text) is ":" then --it's a folder startMake(X) of me else display dialog ErrorString buttons "OK" default button 1 end if end tell end open on gatherFiles(ChosenFolder) --recursively goes into any subfolders if necessary, returning mega-list of files that need compiling tell application "Finder" set FolderContents to list folder ChosenFolder set filesToCompile to {} --set temp to display dialog ("working on folder" & (FolderContents as text)) repeat with currentFile in FolderContents if visible of (info for alias ((ChosenFolder as text) & currentFile)) is false then --skip it, --display dialog ("skipping over invisible file '" & currentFile & "'") else if kind of alias ((ChosenFolder as text) & currentFile) is "alias" then --skip it--display dialog ("skipping over alias '" & currentFile & "'") else if kind of alias ((ChosenFolder as text) & currentFile) is "folder" then --this dies when hitting ascript?alias? set subFiles to gatherFiles(((ChosenFolder as text) & currentFile) as alias) of me --going recursive since we found a sub-folder: if (count items in subFiles) > 0 then --copy subFiles to the end of filesToCompile, but not as {,{sublist}} repeat with curItem in subFiles copy (the contents of curItem) to the end of filesToCompile --this copies each thing as itself! end repeat end if else if currentFile ends with ".java" then --if (hasJavaSuffix(currentFile) of me) then copy characters 1 through ((the length of currentFile) - 5) of currentFile to shortName --find out if the ".class" file even exists if ((shortName as text) & ".class") is not in FolderContents then copy (file ((ChosenFolder as text) & currentFile)) as alias to the end of filesToCompile else --check whether the ".class" file has been compiled since ".java" 's last modification set dateMod to modification date of alias ((ChosenFolder as text) & shortName & ".java") set dateCompd to modification date of alias ((ChosenFolder as text) & shortName & ".class") if dateMod > dateCompd then --display dialog (shortName as text) -- & ".class" & " is not in FolderContents") copy (file ((ChosenFolder as text) & currentFile)) as alias to the end of filesToCompile end if end if end if end repeat return filesToCompile end tell end gatherFiles on compile(fileList) --this is called at the end, after the full list of files has been gathered tell application "javac" activate open fileList repeat 1000 times --stall for time end repeat DoIt end tell end compile