aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author2017398956 <2017398956@qq.com>2022-08-11 18:41:02 +0800
committerGitHub <noreply@github.com>2022-08-11 12:41:02 +0200
commita7c3113b2249a0fa1631dbc0e4bb85d75a12b25a (patch)
tree4af69aaaee90fdb69cfc2c0e1a638169870e39a2
parent732f8aac1eb6b2c137fdf81d9d670a30d0f8b9ea (diff)
downloaddokka-a7c3113b2249a0fa1631dbc0e4bb85d75a12b25a.tar.gz
dokka-a7c3113b2249a0fa1631dbc0e4bb85d75a12b25a.tar.bz2
dokka-a7c3113b2249a0fa1631dbc0e4bb85d75a12b25a.zip
Fixed Java file extension spelling error and add a test (#2604)
Co-authored-by: nfl <fuli.niu@zealcomm.cn>
-rw-r--r--kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt2
-rw-r--r--plugins/base/src/test/kotlin/filter/JavaFileFilterTest.kt37
2 files changed, 38 insertions, 1 deletions
diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt
index 9efa66fb..37381b0f 100644
--- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt
+++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt
@@ -571,7 +571,7 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl
fun addSources(sourceDirectories: Iterable<File>) {
sourceDirectories.forEach { directory ->
configuration.addKotlinSourceRoot(directory.path)
- if (directory.isDirectory || directory.extension == ".java") {
+ if (directory.isDirectory || directory.extension == "java") {
configuration.addJavaSourceRoot(directory)
}
}
diff --git a/plugins/base/src/test/kotlin/filter/JavaFileFilterTest.kt b/plugins/base/src/test/kotlin/filter/JavaFileFilterTest.kt
new file mode 100644
index 00000000..f618292c
--- /dev/null
+++ b/plugins/base/src/test/kotlin/filter/JavaFileFilterTest.kt
@@ -0,0 +1,37 @@
+package filter
+
+import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
+import org.junit.jupiter.api.Assertions
+import org.junit.jupiter.api.Test
+import kotlin.test.assertEquals
+
+class JavaFileFilterTest : BaseAbstractTest() {
+ @Test
+ fun `java file should be included`() {
+ val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ skipEmptyPackages = false
+ sourceRoots = listOf("src/main/java/basic/Test.java")
+ }
+ }
+ }
+
+ testInline(
+ """
+ |/src/main/java/basic/Test.java
+ |package example;
+ |
+ |
+ |
+ """.trimMargin(),
+ configuration
+ ) {
+ preMergeDocumentablesTransformationStage = {
+ Assertions.assertTrue(
+ it.first().packages.isNotEmpty()
+ )
+ }
+ }
+ }
+}