Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Dealing with packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
gchallen committed Apr 2, 2018
1 parent 3a8ee5e commit 36a143a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/main/groovy/edu/illinois/cs/cs125/gradle/GradeTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ class GradeTask extends DefaultTask {
*/

def testOutputDirectories = []
def packagePath = ""
if (gradeConfiguration.package) {
packagePath = gradeConfiguration.package.replace(".", File.separator)
}
gradeConfiguration.files.each{info ->
def compile, testCompile, test, name
try {
Expand All @@ -287,8 +291,12 @@ class GradeTask extends DefaultTask {
name = info
}
try {
def sources = project.sourceSets.main.java.srcDirs
if (gradeConfiguration.package) {
sources = sources.collect { new File(it, packagePath ) }
}
def compileTask = project.tasks.create(name: "compile" + name, type: JavaCompile) {
source = project.sourceSets.main.java.srcDirs
source = sources
include compile
classpath = project.sourceSets.main.compileClasspath
destinationDir = project.sourceSets.main.java.outputDir
Expand All @@ -298,9 +306,14 @@ class GradeTask extends DefaultTask {
} catch (Exception e) {
return
}

try {
def sources = project.sourceSets.test.java.srcDirs
if (gradeConfiguration.package) {
sources = sources.collect { new File(it, packagePath ) }
}
def testCompileTask = project.tasks.create(name: "compileTest" + name, type: JavaCompile) {
source = project.sourceSets.test.java.srcDirs
source = sources
include testCompile
classpath = project.sourceSets.test.compileClasspath
destinationDir = project.sourceSets.test.java.outputDir
Expand All @@ -310,6 +323,7 @@ class GradeTask extends DefaultTask {
} catch (Exception e) {
return
}

try {
def showStreams = false
if (gradeConfiguration.showStreams) {
Expand All @@ -319,7 +333,7 @@ class GradeTask extends DefaultTask {
useTestNG() { useDefaultListeners = true }
testLogging.showStandardStreams = showStreams
reports.html.enabled = false
include "**" + test + "**"
include "**" + packagePath + test + "**"
}
addListener(testTask, listener)
if (project.hasProperty("grade.secure") && gradeConfiguration.secure) {
Expand Down

0 comments on commit 36a143a

Please sign in to comment.