|
@@ -2,18 +2,12 @@ package de.jplag;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.Arrays;
|
|
|
|
|
-import java.util.Collection;
|
|
|
|
|
-import java.util.Collections;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.HashSet;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.Optional;
|
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
|
|
|
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
+
|
|
|
import de.jplag.exceptions.BasecodeException;
|
|
import de.jplag.exceptions.BasecodeException;
|
|
|
import de.jplag.exceptions.ExitException;
|
|
import de.jplag.exceptions.ExitException;
|
|
|
import de.jplag.exceptions.RootDirectoryException;
|
|
import de.jplag.exceptions.RootDirectoryException;
|
|
@@ -26,6 +20,8 @@ import de.jplag.options.JPlagOptions;
|
|
|
*/
|
|
*/
|
|
|
public class SubmissionSetBuilder {
|
|
public class SubmissionSetBuilder {
|
|
|
|
|
|
|
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(SubmissionSetBuilder.class);
|
|
|
|
|
+
|
|
|
private final Language language;
|
|
private final Language language;
|
|
|
private final JPlagOptions options;
|
|
private final JPlagOptions options;
|
|
|
private final ErrorCollector errorCollector;
|
|
private final ErrorCollector errorCollector;
|
|
@@ -98,7 +94,7 @@ public class SubmissionSetBuilder {
|
|
|
rootDirectory = makeCanonical(rootDirectory, it -> new RootDirectoryException("Cannot read root directory: " + rootDirectoryName, it));
|
|
rootDirectory = makeCanonical(rootDirectory, it -> new RootDirectoryException("Cannot read root directory: " + rootDirectoryName, it));
|
|
|
if (!canonicalRootDirectories.add(rootDirectory)) {
|
|
if (!canonicalRootDirectories.add(rootDirectory)) {
|
|
|
// Root directory was already added, report a warning.
|
|
// Root directory was already added, report a warning.
|
|
|
- System.out.printf("Warning: Root directory \"%s\" was specified more than once, duplicates will be ignored.", rootDirectoryName);
|
|
|
|
|
|
|
+ logger.warn("Root directory \"{}\" was specified more than once, duplicates will be ignored.", rootDirectoryName);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return canonicalRootDirectories;
|
|
return canonicalRootDirectories;
|
|
@@ -119,7 +115,7 @@ public class SubmissionSetBuilder {
|
|
|
// former use can be removed without affecting the result of the checks.
|
|
// former use can be removed without affecting the result of the checks.
|
|
|
oldSubmissionDirectories.removeAll(commonRootdirectories);
|
|
oldSubmissionDirectories.removeAll(commonRootdirectories);
|
|
|
for (File rootDirectory : commonRootdirectories) {
|
|
for (File rootDirectory : commonRootdirectories) {
|
|
|
- System.out.println("Warning: Root directory \"" + rootDirectory.toString()
|
|
|
|
|
|
|
+ logger.warn("Root directory \"" + rootDirectory.toString()
|
|
|
+ "\" is specified both for plagiarism checking and for prior submissions, will perform plagiarism checking only.");
|
|
+ "\" is specified both for plagiarism checking and for prior submissions, will perform plagiarism checking only.");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -146,12 +142,12 @@ public class SubmissionSetBuilder {
|
|
|
}
|
|
}
|
|
|
// TODO Optional.of() will cause a NPTR-Exception of baseCode is null. Is this a bug?
|
|
// TODO Optional.of() will cause a NPTR-Exception of baseCode is null. Is this a bug?
|
|
|
baseCodeSubmission = Optional.of(baseCode);
|
|
baseCodeSubmission = Optional.of(baseCode);
|
|
|
- System.out.printf("Basecode directory \"%s\" will be used.%n", baseCode.getName());
|
|
|
|
|
|
|
+ logger.info("Basecode directory \"{}\" will be used.", baseCode.getName());
|
|
|
|
|
|
|
|
// Basecode may also be registered as a user submission. If so, remove the latter.
|
|
// Basecode may also be registered as a user submission. If so, remove the latter.
|
|
|
Submission removed = foundSubmissions.remove(baseCode.getRoot());
|
|
Submission removed = foundSubmissions.remove(baseCode.getRoot());
|
|
|
if (removed != null) {
|
|
if (removed != null) {
|
|
|
- System.out.printf("Submission \"%s\" is the specified basecode, it will be skipped during comparison.%n", removed.getName());
|
|
|
|
|
|
|
+ logger.info("Submission \"{}\" is the specified basecode, it will be skipped during comparison.", removed.getName());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return baseCodeSubmission;
|
|
return baseCodeSubmission;
|
|
@@ -216,7 +212,7 @@ public class SubmissionSetBuilder {
|
|
|
throw new BasecodeException(String.format("Basecode path \"%s\" relative to the working directory could not be found.", baseCodeName));
|
|
throw new BasecodeException(String.format("Basecode path \"%s\" relative to the working directory could not be found.", baseCodeName));
|
|
|
} else {
|
|
} else {
|
|
|
// Found a base code as a submission, report about legacy usage.
|
|
// Found a base code as a submission, report about legacy usage.
|
|
|
- System.out.println("Legacy use of the -bc option found, please specify the basecode by path instead of by name!");
|
|
|
|
|
|
|
+ logger.info("Legacy use of the -bc option found, please specify the basecode by path instead of by name!");
|
|
|
}
|
|
}
|
|
|
return baseCode;
|
|
return baseCode;
|
|
|
}
|
|
}
|
|
@@ -306,7 +302,7 @@ public class SubmissionSetBuilder {
|
|
|
Submission submission = processSubmission(submissionName, submissionFile, isNew);
|
|
Submission submission = processSubmission(submissionName, submissionFile, isNew);
|
|
|
foundSubmissions.put(submission.getRoot(), submission);
|
|
foundSubmissions.put(submission.getRoot(), submission);
|
|
|
} else {
|
|
} else {
|
|
|
- System.out.println(errorMessage);
|
|
|
|
|
|
|
+ logger.error(errorMessage);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|