#!/bin/bash # This script creates/updates the IntelliJ project files by copying the relevant # .idea and .lift subdirectories from a template project (hello). It also # creates a .zip file for distribution to students. # Warning: make sure that the proper Linux file privileges (incluidng group permissions) # are set properly. We strongly recommend running from the ~cos126 acccount. # names of assignments COURSE_HOME="/n/fs/class/courses/cos126" # names of assignments PROJECTS=(hello loops arrays io functions recursion performance oop1 oop2 barchart) # create files/ subdirectory if necessary for project in "${PROJECTS[@]}"; do mkdir -p "${project}/files" chmod 2775 "${project}/files" done # remove any pesky Mac OS X .DS_Store files find . -name '*.DS_Store' -type f -delete # remove any pesky Mac OS X Icon files find . -name 'Icon?' -size 0 -type f -delete # the template project, containing a clean copy of the IntelliJ settings (.lift and .idea directories) TEMPLATE_PROJECT="hello" # transfer these IntelliJ settings from autograder to template project rsync --times "${COURSE_HOME}/assignments/bin/checkstyle-lift.jar" "${TEMPLATE_PROJECT}/files/.lift/" rsync --times "${COURSE_HOME}/assignments/bin/checkstyle-coursera.xml" "${TEMPLATE_PROJECT}/files/.lift/" rsync --times "${COURSE_HOME}/assignments/bin/checkstyle-suppressions.xml" "${TEMPLATE_PROJECT}/files/.lift/" rsync --times "${COURSE_HOME}/assignments/bin/spotbugs.xml" "${TEMPLATE_PROJECT}/files/.lift/" rsync --times "${COURSE_HOME}/assignments/java-classpath/stdlib.jar" "${TEMPLATE_PROJECT}/files/.lift/" rsync --times "${COURSE_HOME}/assignments/java-classpath/introcs.jar" "${TEMPLATE_PROJECT}/files/.lift/" chmod 664 "$TEMPLATE_PROJECT"/files/.lift/* # copy .idea and .lift directories from template projects to all other projects echo "" echo "Syncing projects" echo "------------------------------------------------" for project in "${PROJECTS[@]}"; do # skip if project does not exist or project is the template project if [ "$TEMPLATE_PROJECT" == "$project" ] || [ ! -d "$project" ]; then continue fi echo "${project}:" rsync --archive \ --quiet \ --exclude 'runConfigurations' \ --exclude '*.save' \ --exclude '.name' \ --exclude 'File Header.java' \ "${TEMPLATE_PROJECT}/files/.idea/" "${project}/files/.idea/" rsync --archive \ --quiet \ "${TEMPLATE_PROJECT}/files/.lift/" "${project}/files/.lift/" # copy iml file cp -p "${TEMPLATE_PROJECT}/files/Computer Science.iml" "${project}/files" # copy File Header.java if it doesn't exist if [ ! -f "${project}/files/.idea/fileTemplates/includes/File Header.java" ]; then cp -p "${TEMPLATE_PROJECT}/files/.idea/fileTemplates/includes/File Header.java" "${project}/files/.idea/fileTemplates/includes/File Header.java" fi done # create .zip files, put files at top level (as Windows and OS X will create directories automatically) echo "" echo "Creating/updating zip files" echo "------------------------------------------------" for project in "${PROJECTS[@]}"; do if [ -d "${project}/files" ]; then echo "${project}: " # use subshell so that cd is not remembered (cd "${project}/files"; zip --recurse-paths --filesync "../${project}.zip" .lift .idea *) chmod 664 "${project}/${project}.zip" echo "" fi done chgrp -R coursera .