From a38fee022dc5b2ff546a6d69169848138bb37108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20St=C3=A4ding?= Date: Fri, 9 Jun 2023 20:27:51 +0200 Subject: [PATCH] Start separating modules in submission artifact --- .../gradle/extension/ProjectSourceSetTuple.kt | 23 +++++++++++-- .../task/submission/SubmissionBuildTask.kt | 34 +++++++++++++++++-- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/launcher/gradle-plugin/src/jvmMain/kotlin/org/sourcegrade/jagr/gradle/extension/ProjectSourceSetTuple.kt b/launcher/gradle-plugin/src/jvmMain/kotlin/org/sourcegrade/jagr/gradle/extension/ProjectSourceSetTuple.kt index 357a4071..59f2263c 100644 --- a/launcher/gradle-plugin/src/jvmMain/kotlin/org/sourcegrade/jagr/gradle/extension/ProjectSourceSetTuple.kt +++ b/launcher/gradle-plugin/src/jvmMain/kotlin/org/sourcegrade/jagr/gradle/extension/ProjectSourceSetTuple.kt @@ -1,3 +1,22 @@ +/* + * Jagr - SourceGrade.org + * Copyright (C) 2021-2023 Alexander Städing + * Copyright (C) 2021-2023 Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + package org.sourcegrade.jagr.gradle.extension import org.gradle.api.Project @@ -11,10 +30,10 @@ data class ProjectSourceSetTuple( val sourceSetName: String, ) : Serializable { companion object { - fun fromSourceSetNames(projectPath: String, sourceSetNames: Sequence) = + fun fromSourceSetNames(projectPath: String, sourceSetNames: Sequence): Set = sourceSetNames.map { ProjectSourceSetTuple(projectPath, it) }.toSet() - fun fromSourceSetNames(projectPath: String, sourceSetNames: Iterable) = + fun fromSourceSetNames(projectPath: String, sourceSetNames: Iterable): Set = fromSourceSetNames(projectPath, sourceSetNames.asSequence()) } } diff --git a/launcher/gradle-plugin/src/jvmMain/kotlin/org/sourcegrade/jagr/gradle/task/submission/SubmissionBuildTask.kt b/launcher/gradle-plugin/src/jvmMain/kotlin/org/sourcegrade/jagr/gradle/task/submission/SubmissionBuildTask.kt index 484afef1..4123aa51 100644 --- a/launcher/gradle-plugin/src/jvmMain/kotlin/org/sourcegrade/jagr/gradle/task/submission/SubmissionBuildTask.kt +++ b/launcher/gradle-plugin/src/jvmMain/kotlin/org/sourcegrade/jagr/gradle/task/submission/SubmissionBuildTask.kt @@ -1,10 +1,28 @@ +/* + * Jagr - SourceGrade.org + * Copyright (C) 2021-2023 Alexander Städing + * Copyright (C) 2021-2023 Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + package org.sourcegrade.jagr.gradle.task.submission import org.gradle.api.Project import org.gradle.api.provider.Property import org.gradle.api.tasks.InputFile import org.gradle.jvm.tasks.Jar -import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.property import org.sourcegrade.jagr.gradle.extension.SubmissionConfiguration import org.sourcegrade.jagr.gradle.extension.getSourceSet @@ -22,7 +40,19 @@ abstract class SubmissionBuildTask : Jar(), SubmissionTask { group = "build" dependsOn(configurationName.map(SubmissionWriteInfoTask.Factory::determineTaskName)) from(submissionInfoFile) - from(sourceSetNames.map { all -> all.map { it.getSourceSet(project).allSource } }) + + project.subprojects.forEach { subproject -> + from( + sourceSetNames.map { all -> + all + .filter { it.projectPath == subproject.path } + .map { it.getSourceSet(project).allSource } + }, + ) { copy -> + copy.into(subproject.path) + } + } + archiveFileName.set( assignmentId.zip(studentId) { assignmentId, studentId -> "$assignmentId-$studentId"