diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index c03c14f..b44ce03 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -9,11 +9,12 @@ plugins { } group = "com.github.cs125-illinois" -version = "2021.10.5" +version = "2021.10.6" dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib:1.5.31") implementation("org.jetbrains.kotlin:kotlin-reflect:1.5.31") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31") implementation(gradleApi()) implementation("com.google.code.gson:gson:2.8.8") implementation("org.apache.httpcomponents:httpclient:4.5.13") @@ -50,3 +51,6 @@ tasks.withType().configureEach { languageVersion = "1.4" } } +tasks.shadowJar { + isZip64 = true +} \ No newline at end of file diff --git a/plugin/src/main/java/edu/illinois/cs/cs125/gradlegrader/plugin/GradeTask.kt b/plugin/src/main/java/edu/illinois/cs/cs125/gradlegrader/plugin/GradeTask.kt index cd7f5da..05c04f2 100644 --- a/plugin/src/main/java/edu/illinois/cs/cs125/gradlegrader/plugin/GradeTask.kt +++ b/plugin/src/main/java/edu/illinois/cs/cs125/gradlegrader/plugin/GradeTask.kt @@ -188,14 +188,22 @@ open class GradeTask : DefaultTask() { pointsEarned += if (passed) gradedAnnotation.points else 0 } } + + val testingSucceeded = project.tasks.getByName("grade").state.executed + gradedTests.forEach { task -> // Process the report XML files with a class loader that can access test classes var compiled = false - @Suppress("DEPRECATION") - URLClassLoader(task.classpath.map { it.toURI().toURL() }.toTypedArray(), javaClass.classLoader).use { loader -> - task.reports.junitXml.destination.listFiles { _, name -> name.endsWith(".xml") }?.forEach { file -> - compiled = true - processTestFile(task, loader, file) + if (testingSucceeded) { + @Suppress("DEPRECATION") + URLClassLoader( + task.classpath.map { it.toURI().toURL() }.toTypedArray(), + javaClass.classLoader + ).use { loader -> + task.reports.junitXml.destination.listFiles { _, name -> name.endsWith(".xml") }?.forEach { file -> + compiled = true + processTestFile(task, loader, file) + } } } diff --git a/plugin/src/main/java/edu/illinois/cs/cs125/gradlegrader/plugin/GradleGraderPlugin.kt b/plugin/src/main/java/edu/illinois/cs/cs125/gradlegrader/plugin/GradleGraderPlugin.kt index f10085c..e8af409 100644 --- a/plugin/src/main/java/edu/illinois/cs/cs125/gradlegrader/plugin/GradleGraderPlugin.kt +++ b/plugin/src/main/java/edu/illinois/cs/cs125/gradlegrader/plugin/GradleGraderPlugin.kt @@ -19,6 +19,7 @@ import org.gradle.api.tasks.Delete import org.gradle.api.tasks.compile.JavaCompile import org.gradle.api.tasks.testing.Test import java.nio.file.Files +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile /** * The gradlegrader Gradle plugin. @@ -38,13 +39,19 @@ class GradleGraderPlugin : Plugin { return config.subprojects ?: listOf(project) } - val compileTasks = mutableSetOf() + val javaCompileTasks = mutableSetOf() + val kotlinCompileTasks = mutableSetOf() + val testTasks = mutableMapOf() var currentCheckpoint: String? = null val checkstyleTask = project.tasks.register("relentlessCheckstyle", RelentlessCheckstyle::class.java).get() val detektTask = project.tasks.register("ourDetekt", Detekt::class.java).get() - val gradeTask: GradeTask = project.tasks.register("grade", GradeTask::class.java).get() + + val targetTask = project.tasks.register("grade").get() + val gradeTask: GradeTask = project.tasks.register("score", GradeTask::class.java).get() + gradeTask.mustRunAfter(targetTask) + val reconfTask = project.task("prepareForGrading").doLast { // Check projects' test tasks findSubprojects().forEach { subproject -> @@ -146,11 +153,15 @@ class GradleGraderPlugin : Plugin { } // Configure compilation tasks - compileTasks.forEach { + javaCompileTasks.forEach { gradeTask.listenTo(it) it.options.isFailOnError = false it.outputs.upToDateWhen { false } } + kotlinCompileTasks.forEach { + gradeTask.listenTo(it) + it.outputs.upToDateWhen { false } + } } // Logic that depends on all projects having been evaluated @@ -158,21 +169,21 @@ class GradleGraderPlugin : Plugin { val cleanTasks = findSubprojects().map { it.tasks.getByName("clean") } if (config.forceClean) { // Require a clean first - gradeTask.dependsOn(cleanTasks) + targetTask.dependsOn(cleanTasks) } // Depend on checkstyle if (config.checkstyle.enabled) { checkstyleTask.mustRunAfter(reconfTask) checkstyleTask.mustRunAfter(cleanTasks) - gradeTask.dependsOn(checkstyleTask) + targetTask.dependsOn(checkstyleTask) gradeTask.gatherCheckstyleInfo(checkstyleTask) } if (config.detekt.enabled) { detektTask.mustRunAfter(reconfTask) detektTask.mustRunAfter(cleanTasks) - gradeTask.dependsOn(detektTask) + targetTask.dependsOn(detektTask) gradeTask.gatherDetektInfo(detektTask) } @@ -182,7 +193,12 @@ class GradleGraderPlugin : Plugin { subproject.tasks.withType(JavaCompile::class.java) { compile -> compile.mustRunAfter(cleanTasks) compile.mustRunAfter(reconfTask) - compileTasks.add(compile) + javaCompileTasks.add(compile) + } + subproject.tasks.withType(KotlinCompile::class.java) { compile -> + compile.mustRunAfter(cleanTasks) + compile.mustRunAfter(reconfTask) + kotlinCompileTasks.add(compile) } // Depend on tests @@ -191,7 +207,7 @@ class GradleGraderPlugin : Plugin { testTasks[subproject] = test test.mustRunAfter(cleanTasks) test.mustRunAfter(reconfTask) - gradeTask.dependsOn(test) + targetTask.dependsOn(test) } } }