Skip to content

Commit

Permalink
Allow subpackages (issue #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
espertus committed Aug 29, 2023
1 parent 13f085b commit bc68984
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main/java/com/spertus/jacquard/common/Target.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public final class Target {
// arguments are package and class
"src/main/java/%s/%s.java";

// This works on Windows, even though it's not the normal separator.
private static final char SEP = '/';

private final Path path;

private Target(final Path path) {
Expand Down Expand Up @@ -49,8 +52,7 @@ public static Target fromPathString(final String s) {

/**
* Creates a target from a class that the student is responsible for
* submitting. The class's package must not be a subpackage (contain a
* period) or be empty.
* submitting. The class's package must not be empty.
*
* @param targetClass the class
* @return the target
Expand All @@ -61,10 +63,9 @@ public static Target fromClass(Class<?> targetClass) {
if (pkgName.isEmpty()) {
throw new ClientException("Package name may not be empty.");
}
if (pkgName.contains(".")) {
throw new ClientException("Subpackages are not yet allowed.");
}
String pathString = String.format(SUBMISSION_PATH_TEMPLATE, pkgName, targetClass.getSimpleName());
String pathString = String.format(SUBMISSION_PATH_TEMPLATE,
pkgName.replace('.', SEP),
targetClass.getSimpleName());
return fromPathString(pathString);
}

Expand Down

0 comments on commit bc68984

Please sign in to comment.