Browse Source

Merge branch 'master' of git://github.com/ov7a/jplag into ov7a-master

Mathias Landhäußer 8 years ago
parent
commit
a1045f1272

+ 7 - 2
README.md

@@ -2,11 +2,11 @@
 Download a released version - all releases are single-JAR releases.
 Download a released version - all releases are single-JAR releases.
 
 
 Type `java -jar jplag-yourVersion.jar` in a console to see the command line options.
 Type `java -jar jplag-yourVersion.jar` in a console to see the command line options.
-The options as of 2016/02/29 are:
+The options as of 2017/09/17 are:
 
 
 ```
 ```
 JPlag (Version 2.11.9-SNAPSHOT), Copyright (c) 2004-2017 KIT - IPD Tichy, Guido Malpohl, and others.
 JPlag (Version 2.11.9-SNAPSHOT), Copyright (c) 2004-2017 KIT - IPD Tichy, Guido Malpohl, and others.
-Usage: JPlag [ options ] <root-dir>
+Usage: JPlag [ options ] [<root-dir>] [-c file1 file2 ...]
  <root-dir>        The root-directory that contains all submissions
  <root-dir>        The root-directory that contains all submissions
 
 
 options are:
 options are:
@@ -32,6 +32,7 @@ options are:
  -r <dir>        (Result) Name of directory in which the web pages will be
  -r <dir>        (Result) Name of directory in which the web pages will be
                  stored (default: result)
                  stored (default: result)
  -bc <dir>       Name of the directory which contains the basecode (common framework)
  -bc <dir>       Name of the directory which contains the basecode (common framework)
+ -c [files]      Compare a list of files.
  -l <language>   (Language) Supported Languages:
  -l <language>   (Language) Supported Languages:
                  java17 (default), java15, java15dm, java12, java11, python3, c/c++, c#-1.2, char, text, scheme
                  java17 (default), java15, java15dm, java12, java11, python3, c/c++, c#-1.2, char, text, scheme
 ```
 ```
@@ -57,6 +58,10 @@ The option `-x` requires an exclusion list saved as `<file>`.
 The exclusion list contains a  number of suffixes.
 The exclusion list contains a  number of suffixes.
 JPlag will ignore all files that end with one of the suffixes.
 JPlag will ignore all files that end with one of the suffixes.
 
 
+### `-c [files]`   (Compare) Compare a list of files
+Example: `java -jar jplag-yourVersion.jar -l java17 -c student1_file student2_file student3_file`
+This option must be the last one.
+JPlag will compare just a list of files pairwise.
 
 
 # Building JPlag
 # Building JPlag
 To build and run a local installation of JPlag, you can use the pom.xml in this directory (aggregator). It builds JPlag and the available frontends. 
 To build and run a local installation of JPlag, you can use the pom.xml in this directory (aggregator). It builds JPlag and the available frontends. 

+ 19 - 1
jplag/src/main/java/jplag/Program.java

@@ -443,6 +443,21 @@ public class Program implements ProgramI {
         }
         }
     }
     }
 
 
+	private void createSubmissionsFileList() throws jplag.ExitException {
+		submissions = new Vector<Submission>();
+		File f = null;
+		if (options.root_dir != null) {
+			f = new File(options.root_dir);
+			if (!f.isDirectory()) {
+				throw new jplag.ExitException(options.root_dir + " is not a directory!");
+			}
+		}
+		for (String file : options.fileList){
+			submissions.addElement(new Submission(file, f, this, get_language()));
+		}
+	}
+
+
     /**
     /**
      * THIS IS FOR THE EMPIRICAL STUDY
      * THIS IS FOR THE EMPIRICAL STUDY
      */
      */
@@ -1128,7 +1143,10 @@ public class Program implements ProgramI {
             print(null, "Root-dir: " + options.root_dir + "\n"); // server
             print(null, "Root-dir: " + options.root_dir + "\n"); // server
         // this file contains all files names which are excluded
         // this file contains all files names which are excluded
         readExclusionFile();
         readExclusionFile();
-        if (options.include_file == null) {
+
+        if (options.fileListMode) {
+	        createSubmissionsFileList();
+        } else if (options.include_file == null) {
             createSubmissions();
             createSubmissions();
             System.out.println(submissions.size() + " submissions");
             System.out.println(submissions.size() + " submissions");
         } else
         } else

+ 8 - 2
jplag/src/main/java/jplag/options/CommandLineOptions.java

@@ -317,11 +317,17 @@ public class CommandLineOptions extends Options {
             System.out.println();
             System.out.println();
             i++;
             i++;
         } else if (arg.equals("-title") && i+1 < args.length) {
         } else if (arg.equals("-title") && i+1 < args.length) {
-            if (args[i+1].equals("")) {
+            if (args[i + 1].equals("")) {
                 throw new jplag.ExitException("Title is empty!");
                 throw new jplag.ExitException("Title is empty!");
             }
             }
-            this.title = args[i+1];
+            this.title = args[i + 1];
             i++;
             i++;
+        } else if (arg.equals("-c") && i + 2 < args.length){
+            this.fileListMode = true;
+            while (i + 1 < args.length){
+                this.fileList.add(args[i + 1]);
+                i++;
+            }
         } else if (!scanOption(arg))
         } else if (!scanOption(arg))
             throw new jplag.ExitException("Unknown option: " + arg,
             throw new jplag.ExitException("Unknown option: " + arg,
                     ExitException.BAD_PARAMETER);
                     ExitException.BAD_PARAMETER);

+ 12 - 3
jplag/src/main/java/jplag/options/Options.java

@@ -12,6 +12,9 @@ import jplag.Language;
 import jplag.Program;
 import jplag.Program;
 import jplag.clustering.SimilarityMatrix;
 import jplag.clustering.SimilarityMatrix;
 
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
 /**
  * @Author Emeric Kwemou 30.01.2005
  * @Author Emeric Kwemou 30.01.2005
  *  
  *  
@@ -58,7 +61,7 @@ public abstract class Options {
 
 
 	public String sub_dir = null;
 	public String sub_dir = null;
 
 
-	public String root_dir = "";
+	public String root_dir = null;
 
 
 	public String original_dir = null;
 	public String original_dir = null;
 	
 	
@@ -129,6 +132,11 @@ public abstract class Options {
 
 
 	public jplag.Language language;
 	public jplag.Language language;
 
 
+	//compare list of files options
+	public boolean fileListMode = false;
+
+	public List<String> fileList = new ArrayList<String>();
+
 	// "FINAL" OPTIONS
 	// "FINAL" OPTIONS
 	public boolean debugParser = false;
 	public boolean debugParser = false;
 
 
@@ -181,8 +189,8 @@ public abstract class Options {
 	public static void usage() {
 	public static void usage() {
 		System.out.print(Program.name_long
 		System.out.print(Program.name_long
 						+ ", Copyright (c) 2004-2017 KIT - IPD Tichy, Guido Malpohl, and others.\n"
 						+ ", Copyright (c) 2004-2017 KIT - IPD Tichy, Guido Malpohl, and others.\n"
-						+ "Usage: JPlag [ options ] <root-dir>\n"
-						+ " <root-dir>        The root-directory that contains all submissions\n\n"
+						+ "Usage: JPlag [ options ] <root-dir> [-c file1 file2 ...]\n"
+						+ " <root-dir>        The root-directory that contains all submissions.\n\n"
 						+ "options are:\n"
 						+ "options are:\n"
 						+ " -v[qlpd]        (Verbose)\n"
 						+ " -v[qlpd]        (Verbose)\n"
 						+ "                 q: (Quiet) no output\n"
 						+ "                 q: (Quiet) no output\n"
@@ -204,6 +212,7 @@ public abstract class Options {
 						+ " -r <dir>        (Result) Name of directory in which the web pages will be\n"
 						+ " -r <dir>        (Result) Name of directory in which the web pages will be\n"
 						+ "                 stored (default: result)\n"
 						+ "                 stored (default: result)\n"
 						+ " -bc <dir>       Name of the directory which contains the basecode (common framework)\n"
 						+ " -bc <dir>       Name of the directory which contains the basecode (common framework)\n"
+						+ " -c [files]      Compare a list of files. Should be the last one.\n"
 						+ " -l <language>   (Language) Supported Languages:\n                 ");
 						+ " -l <language>   (Language) Supported Languages:\n                 ");
 		for (int i = 0; i < languages.length - 2; i += 2)
 		for (int i = 0; i < languages.length - 2; i += 2)
 			System.out.print(languages[i] + (i == 0 ? " (default), " : ", "));
 			System.out.print(languages[i] + (i == 0 ? " (default), " : ", "));