Skip to content

Commit c17bcd0

Browse files
move setting of default values (#373)
* move setting of default values * correct default values * move layout --------- Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
1 parent 5ec848f commit c17bcd0

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

paperweight-core/src/main/kotlin/io/papermc/paperweight/checkstyle/PaperCheckstyle.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,19 @@ import io.papermc.paperweight.checkstyle.tasks.PaperCheckstyleTask
2727
import io.papermc.paperweight.util.*
2828
import io.papermc.paperweight.util.constants.*
2929
import io.papermc.paperweight.util.path
30+
import javax.inject.Inject
3031
import kotlin.io.path.readText
3132
import org.gradle.api.Plugin
3233
import org.gradle.api.Project
34+
import org.gradle.api.file.ProjectLayout
3335
import org.gradle.api.plugins.quality.CheckstyleExtension
3436
import org.gradle.kotlin.dsl.*
3537

3638
abstract class PaperCheckstyle : Plugin<Project> {
3739

40+
@get:Inject
41+
abstract val layout: ProjectLayout
42+
3843
override fun apply(target: Project) {
3944
val ext = target.extensions.create<PaperCheckstyleExt>(PAPER_CHECKSTYLE_EXTENSION)
4045
target.plugins.apply(PaperCheckstylePlugin::class.java)
@@ -46,11 +51,15 @@ abstract class PaperCheckstyle : Plugin<Project> {
4651
val mergeCheckstyleConfigs by target.tasks.registering<MergeCheckstyleConfigs>()
4752

4853
target.tasks.withType(PaperCheckstyleTask::class.java).configureEach {
49-
rootPath.convention(project.rootDir.path)
54+
rootPath.convention(layout.settingsDirectory.asFile.path)
5055
directoriesToSkip.convention(ext.directoriesToSkipFile.map { it.path.readText().trim().split("\n").toSet() })
5156
typeUseAnnotations.convention(ext.typeUseAnnotationsFile.map { it.path.readText().trim().split("\n") })
5257
customJavadocTags.convention(ext.customJavadocTags)
5358
configOverride.convention(mergeCheckstyleConfigs.flatMap { it.mergedConfigFile })
59+
reports.xml.required.convention(true)
60+
reports.html.required.convention(true)
61+
maxHeapSize.convention("2g")
62+
configDirectory.convention(layout.settingsDirectory.dir(".checkstyle"))
5463
}
5564
}
5665
}

paperweight-core/src/main/kotlin/io/papermc/paperweight/checkstyle/tasks/PaperCheckstyleTask.kt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ package io.papermc.paperweight.checkstyle.tasks
2525
import io.papermc.paperweight.checkstyle.JavadocTag
2626
import io.papermc.paperweight.util.*
2727
import java.nio.file.Paths
28-
import javax.inject.Inject
2928
import kotlin.io.path.*
30-
import org.gradle.api.file.ProjectLayout
3129
import org.gradle.api.file.RegularFileProperty
3230
import org.gradle.api.internal.file.FileOperations
3331
import org.gradle.api.plugins.quality.Checkstyle
@@ -59,16 +57,6 @@ abstract class PaperCheckstyleTask : Checkstyle() {
5957
@get:Optional
6058
abstract val configOverride: RegularFileProperty
6159

62-
@get:Inject
63-
abstract val layout: ProjectLayout
64-
65-
init {
66-
reports.xml.required.convention(true)
67-
reports.html.required.convention(true)
68-
maxHeapSize.convention("2g")
69-
configDirectory.convention(layout.settingsDirectory.dir(".checkstyle"))
70-
}
71-
7260
@TaskAction
7361
override fun run() {
7462
if (configOverride.isPresent && configOverride.path.exists()) {

0 commit comments

Comments
 (0)