Skip to content

Commit adf0ee8

Browse files
committed
made generatedSources sourceSet to simplify the process and have a linting task auto-generated.
1 parent 0bd1a91 commit adf0ee8

File tree

2 files changed

+37
-47
lines changed

2 files changed

+37
-47
lines changed

core/build.gradle.kts

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -171,30 +171,6 @@ tasks.withType<KorroTask> {
171171

172172
// region docPreprocessor
173173

174-
val ktlintCheckGeneratedSources by tasks.creating {
175-
doFirst {
176-
tasks.runKtlintCheckOverMainSourceSet.configure {
177-
source(generatedSourcesFolderName)
178-
}
179-
}
180-
finalizedBy(tasks.ktlintCheck)
181-
}
182-
183-
tasks.runKtlintFormatOverMainSourceSet {
184-
doFirst {
185-
println("running runKtlintFormatOverMainSourceSet on ${source.files}")
186-
}
187-
}
188-
189-
val ktlintFormatGeneratedSources by tasks.creating {
190-
doFirst {
191-
tasks.runKtlintFormatOverMainSourceSet.configure {
192-
source(generatedSourcesFolderName)
193-
}
194-
}
195-
finalizedBy(tasks.ktlintFormat)
196-
}
197-
198174
val generatedSourcesFolderName = "generated-sources"
199175

200176
// Backup the kotlin source files location
@@ -213,40 +189,34 @@ fun pathOf(vararg parts: String) = parts.joinToString(File.separator)
213189
val processKDocsMainSources = (kotlinMainSources + kotlinTestSources)
214190
.filterNot { pathOf("build", "generated") in it.path }
215191

216-
// Raw processKDocsMain output; includes both generated main and -test sources
217-
// Should be the same as processKDocsMain.targets after running it
218-
val processKDocsMainRawOutputs
219-
get() = processKDocsMainSources.map {
220-
projectDir
221-
.resolve(generatedSourcesFolderName)
222-
.resolve(it.relativeTo(projectDir))
223-
}
224-
225-
// processKDocsMain output files; can be used as source set to generate sources.jar (after running processKDocsMain).
226-
val processKDocsMainOutputs
227-
get() = processKDocsMainRawOutputs.filterNot {
228-
pathOf("src", "test", "kotlin") in it.path || pathOf("src", "test", "java") in it.path
229-
} + kotlinMainSources.filter {
230-
// Include generated sources (which were excluded above)
231-
pathOf("build", "generated") in it.path
192+
// sourceset of the generated sources as a result of `processKDocsMain`, this will create linter tasks
193+
val generatedSources by kotlin.sourceSets.creating {
194+
kotlin {
195+
setSrcDirs(
196+
listOf(
197+
"build/generated/ksp/main/kotlin/",
198+
"core/build/generatedSrc",
199+
"$generatedSourcesFolderName/src/main/kotlin",
200+
"$generatedSourcesFolderName/src/main/java",
201+
),
202+
)
232203
}
204+
}
233205

234206
// Task to generate the processed documentation
235207
val processKDocsMain by creatingProcessDocTask(processKDocsMainSources) {
236208
target = file(generatedSourcesFolderName)
237209
arguments += ARG_DOC_PROCESSOR_LOG_NOT_FOUND to false
238210

239-
// false, so ktlintFormatGeneratedSources can format the output
211+
// false, so `runKtlintFormatOverGeneratedSourcesSourceSet` can format the output
240212
outputReadOnly = false
241213

242214
exportAsHtml {
243215
dir = file("../docs/StardustDocs/snippets/kdocs")
244216
}
245217
task {
246218
group = "KDocs"
247-
// making sure it always runs, so targets is set
248-
outputs.upToDateWhen { false }
249-
finalizedBy(ktlintFormatGeneratedSources)
219+
finalizedBy("runKtlintFormatOverGeneratedSourcesSourceSet")
250220
}
251221
}
252222

@@ -271,11 +241,15 @@ val changeJarTask by tasks.creating {
271241
tasks.withType<Jar> {
272242
dependsOn(processKDocsMain)
273243
doFirst {
274-
require(processKDocsMainOutputs.toList().isNotEmpty()) {
275-
logger.error("`processKDocsMainOutputs` was empty, did `processKDocsMain` run before this task?")
244+
require(
245+
generatedSources.kotlin.srcDirs
246+
.toList()
247+
.isNotEmpty(),
248+
) {
249+
logger.error("`processKDocsMain`'s outputs are empty, did `processKDocsMain` run before this task?")
276250
}
277251
kotlin.sourceSets.main {
278-
kotlin.setSrcDirs(processKDocsMainOutputs)
252+
kotlin.setSrcDirs(generatedSources.kotlin.srcDirs)
279253
}
280254
logger.lifecycle("$this is run with modified sources: \"$generatedSourcesFolderName\"")
281255
}
@@ -360,6 +334,11 @@ tasks.runKtlintFormatOverTestSourceSet {
360334
dependsOn("kspTestKotlin")
361335
}
362336

337+
tasks.named("runKtlintFormatOverGeneratedSourcesSourceSet") {
338+
dependsOn(tasks.generateKeywordsSrc)
339+
dependsOn("kspKotlin")
340+
}
341+
363342
tasks.runKtlintCheckOverMainSourceSet {
364343
dependsOn(tasks.generateKeywordsSrc)
365344
dependsOn("kspKotlin")
@@ -370,6 +349,11 @@ tasks.runKtlintCheckOverTestSourceSet {
370349
dependsOn("kspTestKotlin")
371350
}
372351

352+
tasks.named("runKtlintCheckOverGeneratedSourcesSourceSet") {
353+
dependsOn(tasks.generateKeywordsSrc)
354+
dependsOn("kspKotlin")
355+
}
356+
373357
kotlin {
374358
explicitApi()
375359
}

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/columnNameFilters.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
88
import org.jetbrains.kotlinx.dataframe.columns.ColumnSet
99
import org.jetbrains.kotlinx.dataframe.columns.SingleColumn
1010
import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate
11+
import org.jetbrains.kotlinx.dataframe.documentation.ExcludeFromSources
1112
import org.jetbrains.kotlinx.dataframe.documentation.Indent
1213
import org.jetbrains.kotlinx.dataframe.documentation.LineBreak
1314
import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet
@@ -112,6 +113,7 @@ public interface ColumnNameFiltersColumnsSelectionDsl {
112113
* @see [nameStartsWith\]
113114
* {@set [ExtraParamsArg]}
114115
*/
116+
@ExcludeFromSources
115117
private interface CommonNameContainsDocs {
116118

117119
/* Example to give */
@@ -131,6 +133,7 @@ public interface ColumnNameFiltersColumnsSelectionDsl {
131133
* @param [ignoreCase\] `true` to ignore character case when comparing strings. By default `false`.
132134
* }
133135
*/
136+
@ExcludeFromSources
134137
private interface NameContainsTextDocs
135138

136139
/**
@@ -303,6 +306,7 @@ public interface ColumnNameFiltersColumnsSelectionDsl {
303306
* @return A [ColumnSet] containing
304307
* all columns {@get [CommonNameStartsEndsDocs.NounArg]} with {@get [CommonNameStartsEndsDocs.ArgumentArg]} in their name.
305308
*/
309+
@ExcludeFromSources
306310
private interface CommonNameStartsEndsDocs {
307311

308312
/* "Starts" or "Ends" */
@@ -340,6 +344,7 @@ public interface ColumnNameFiltersColumnsSelectionDsl {
340344
* @see [nameEndsWith\]
341345
* @see [nameContains\]
342346
*/
347+
@ExcludeFromSources
343348
private interface CommonNameStartsWithDocs
344349

345350
@Deprecated("Use nameStartsWith instead", ReplaceWith("this.nameStartsWith(prefix)"))
@@ -443,6 +448,7 @@ public interface ColumnNameFiltersColumnsSelectionDsl {
443448
* @see [nameStartsWith\]
444449
* @see [nameContains\]
445450
*/
451+
@ExcludeFromSources
446452
private interface CommonNameEndsWithDocs
447453

448454
@Deprecated("Use nameEndsWith instead", ReplaceWith("this.nameEndsWith(suffix)"))

0 commit comments

Comments
 (0)