From bfd8782e5b028dc47655eb332b43cbde7697bfda Mon Sep 17 00:00:00 2001 From: Julia McCauley Date: Tue, 30 Mar 2021 21:22:31 -0400 Subject: set up project structure --- .gitignore | 6 + .idea/misc.xml | 7 + ...rm-project-cohwille-jmccaul3-mfoiani-rhunt2.iml | 51 +++- config/cs32_checks.xml | 166 +++++++++++ config/cs32_intellij_checks.xml | 166 +++++++++++ data/README.md | 4 + pom.xml | 318 +++++++++++++++++++++ run | 49 ++++ src/main/java/edu/brown/cs/student/stars/Main.java | 62 ++++ tests/README.md | 4 + 10 files changed, 829 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100644 config/cs32_checks.xml create mode 100644 config/cs32_intellij_checks.xml create mode 100644 data/README.md create mode 100644 pom.xml create mode 100755 run create mode 100644 src/main/java/edu/brown/cs/student/stars/Main.java create mode 100644 tests/README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0fb7610 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +target/ +.mvn-classpath +.classpath +.idea/ +**.DS_Store** +maps.sqlite3 \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 1763e15..d460235 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,12 @@ + + + diff --git a/.idea/term-project-cohwille-jmccaul3-mfoiani-rhunt2.iml b/.idea/term-project-cohwille-jmccaul3-mfoiani-rhunt2.iml index d6ebd48..e5e71fc 100644 --- a/.idea/term-project-cohwille-jmccaul3-mfoiani-rhunt2.iml +++ b/.idea/term-project-cohwille-jmccaul3-mfoiani-rhunt2.iml @@ -1,9 +1,52 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/cs32_checks.xml b/config/cs32_checks.xml new file mode 100644 index 0000000..c0805f9 --- /dev/null +++ b/config/cs32_checks.xml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/cs32_intellij_checks.xml b/config/cs32_intellij_checks.xml new file mode 100644 index 0000000..69d8e0d --- /dev/null +++ b/config/cs32_intellij_checks.xml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/data/README.md b/data/README.md new file mode 100644 index 0000000..539798b --- /dev/null +++ b/data/README.md @@ -0,0 +1,4 @@ +# Data Files + +Keep data files for each project here, under separate subdirectories named by project. Try to avoid storing large files (~1GB or more) in Git by adding them to your `.gitignore` file. + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a2bd1a7 --- /dev/null +++ b/pom.xml @@ -0,0 +1,318 @@ + + + + 4.0.0 + + edu.brown.cs + + term-project + + jar + + 1.0 + + + + UTF-8 + + + + + + + + net.sf.jopt-simple + jopt-simple + 6.0-alpha-3 + + + + + junit + junit + 4.13 + + + + + org.hamcrest + hamcrest-all + 1.3 + + + + + org.slf4j + slf4j-api + 2.0.0-alpha1 + + + + + org.slf4j + slf4j-jdk14 + 2.0.0-alpha1 + + + + + com.google.guava + guava + 28.2-jre + + + + + com.google.code.gson + gson + 2.8.6 + + + + + com.sparkjava + spark-core + 2.9.1 + + + + + com.sparkjava + spark-template-freemarker + 2.7.1 + + + + + org.xerial + sqlite-jdbc + 3.30.1 + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + -Xlint:all + true + true + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + + default-prepare-agent + + prepare-agent + + + + default-report + + report + + + + default-check + + check + + + + + BUNDLE + + + COMPLEXITY + COVEREDRATIO + 0.50 + + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M4 + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M3 + + + enforce-maven + + enforce + + + + + 3.6.0 + + + + + + + + + + + + + + + + maven-project-info-reports-plugin + 2.7 + + + false + + false + + + + + + org.apache.maven.plugins + maven-jxr-plugin + 3.0.0 + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.1.1 + + + + javadoc + + + + + ${java.home}/bin/javadoc + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.1.0 + + config/cs32_checks.xml + + + + + + org.apache.maven.plugins + maven-pmd-plugin + 3.12.0 + + + + + com.github.spotbugs + spotbugs-maven-plugin + 3.1.12.2 + + + Max + + Low + + + + + + org.apache.maven.plugins + maven-surefire-report-plugin + 3.0.0-M4 + + + org.jacoco + jacoco-maven-plugin + + + + + report + + + + + + + + \ No newline at end of file diff --git a/run b/run new file mode 100755 index 0000000..2d8fdae --- /dev/null +++ b/run @@ -0,0 +1,49 @@ +#!/bin/sh + +# To run our code, we must have it in our classpath. +# We use $(ls target/*.jar) instead of target/stars-1.0.jar so that +# this script can be reused in other projects more easily. + +TARGET=$(ls target/*.jar 2>/dev/null) +if [ -z "$TARGET" ]; then + echo "No jar file in target/, try 'mvn package'". + exit 1 +fi + +# In the pom.xml, we've already explained other what libraries we +# depend on. Maven downloaded them, and put them "somewhere" (our +# repository). Now we ask maven to build up the CLASSPATH that let us +# run against those libraries. + +# First, we put the CLASSPATH in .classpath if the pom.xml is newer +# than out existing .classpath file. (We avoid this command if +# .classpath is fresh, since it's rather slow.) +if [ ! .mvn-classpath -nt pom.xml ]; then + mvn dependency:build-classpath -Dmdep.outputFile=.mvn-classpath -q +fi + +# Now, we set $CP to the contents of the .classpath file. +CP=$(cat .mvn-classpath) + +# We're trying to make the script more reusable by finding the package +# name, instead of hard coding. But this relies on some conventions +# in naming. You'll have to call your class "Main" and use our +# recommended package structure. + +# Find Main.java. It should be in a package below your username package. +MAIN=$(ls src/main/java/edu/brown/cs/*/*/Main.java) +[ -z "$MAIN" ] && echo "You need a Main.java" && exit 1 +[ ! -e "$MAIN" ] && echo "You can only have one Main.java" && exit 1 +STUDENT=$(basename $(dirname $(dirname $MAIN))) +MAINPKG=$(basename $(dirname $MAIN)) + +# No guarantees yet, but we're trying to support Windows, which uses a +# different Path Separator in classpaths. +PATHSEP=":" +if [ "$OSTYPE" = 'cygwin' -o "$OSTYPE" = 'msys' ]; then + PATHSEP=";" +fi + +# The symbol "$@" passes the command-line arguments from +# this script to your Java program. +java -ea -cp "$TARGET$PATHSEP$CP" edu.brown.cs.$STUDENT.$MAINPKG.Main "$@" diff --git a/src/main/java/edu/brown/cs/student/stars/Main.java b/src/main/java/edu/brown/cs/student/stars/Main.java new file mode 100644 index 0000000..61127b5 --- /dev/null +++ b/src/main/java/edu/brown/cs/student/stars/Main.java @@ -0,0 +1,62 @@ +package edu.brown.cs.student.stars; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Map; + +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import spark.ExceptionHandler; +import spark.ModelAndView; +import spark.Request; +import spark.Response; +import spark.Spark; +import spark.TemplateViewRoute; +import spark.template.freemarker.FreeMarkerEngine; + +import com.google.common.collect.ImmutableMap; + +import freemarker.template.Configuration; + +/** + * The Main class of our project. This is where execution begins. + * + */ +public final class Main { + + private static final int DEFAULT_PORT = 4567; + + /** + * The initial method called when execution begins. + * + * @param args + * An array of command line arguments + */ + public static void main(String[] args) { + new Main(args).run(); + } + + private String[] args; + + private Main(String[] args) { + this.args = args; + } + + private void run() { + // Parse command line arguments + OptionParser parser = new OptionParser(); + parser.accepts("gui"); + parser.accepts("port").withRequiredArg().ofType(Integer.class) + .defaultsTo(DEFAULT_PORT); + OptionSet options = parser.parse(args); + + if (options.has("gui")) { + //do a gui type thing + //runSparkServer((int) options.valueOf("port")); + } + + // TODO: Process commands in a REPL + } +} \ No newline at end of file diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..97d2f16 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,4 @@ +# System Tests + +All system tests should be stored in this directory. Please keep the tests you write separate from TA provided tests. + -- cgit v1.2.3-70-g09d2