remove KDoc support in Kotlin Gradle plugin
This commit is contained in:
@@ -52,11 +52,6 @@
|
||||
<artifactId>kotlin-jdk-annotations</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kdoc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
|
||||
-63
@@ -284,69 +284,6 @@ public open class Kotlin2JsCompile() : AbstractKotlinCompile<K2JSCompilerArgumen
|
||||
}
|
||||
}
|
||||
|
||||
public open class KDoc() : SourceTask() {
|
||||
|
||||
private val logger = Logging.getLogger(this.javaClass)
|
||||
override fun getLogger() = logger
|
||||
|
||||
public var kdocArgs: KDocArguments = KDocArguments()
|
||||
|
||||
public var destinationDir: File? = null
|
||||
|
||||
init {
|
||||
// by default, output dir is not defined in options
|
||||
kdocArgs.docConfig.docOutputDir = ""
|
||||
}
|
||||
|
||||
TaskAction fun generateDocs() {
|
||||
val args = KDocArguments()
|
||||
val cfg = args.docConfig
|
||||
|
||||
val kdocOptions = kdocArgs.docConfig
|
||||
|
||||
cfg.docOutputDir = if ((kdocOptions.docOutputDir.length() == 0) && (destinationDir != null)) {
|
||||
destinationDir!!.path
|
||||
} else {
|
||||
kdocOptions.docOutputDir
|
||||
}
|
||||
cfg.title = kdocOptions.title
|
||||
cfg.sourceRootHref = kdocOptions.sourceRootHref
|
||||
cfg.projectRootDir = kdocOptions.projectRootDir
|
||||
cfg.warnNoComments = kdocOptions.warnNoComments
|
||||
|
||||
cfg.packagePrefixToUrls.putAll(kdocOptions.packagePrefixToUrls)
|
||||
cfg.ignorePackages.addAll(kdocOptions.ignorePackages)
|
||||
cfg.packageDescriptionFiles.putAll(kdocOptions.packageDescriptionFiles)
|
||||
cfg.packageSummaryText.putAll(kdocOptions.packageSummaryText)
|
||||
|
||||
// KDoc compiler does not accept list of files as input. Try to pass directories instead.
|
||||
args.freeArgs = getSource().map { it.getParentFile()!!.getAbsolutePath() }
|
||||
// Drop compiled sources to temp. Why KDoc compiles anything after all?!
|
||||
args.destination = getTemporaryDir()?.getAbsolutePath()
|
||||
|
||||
getLogger().warn(args.freeArgs.toString())
|
||||
val embeddedAnnotations = getAnnotations(getProject(), getLogger())
|
||||
val userAnnotations = (kdocArgs.annotations ?: "").split(File.pathSeparatorChar).toList()
|
||||
val allAnnotations = if (kdocArgs.noJdkAnnotations) userAnnotations else userAnnotations.plus(embeddedAnnotations.map { it.getPath() })
|
||||
args.annotations = allAnnotations.joinToString(File.pathSeparator)
|
||||
|
||||
args.noStdlib = true
|
||||
args.noJdkAnnotations = true
|
||||
|
||||
|
||||
val compiler = KDocCompiler()
|
||||
|
||||
val messageCollector = GradleMessageCollector(getLogger())
|
||||
val exitCode = compiler.exec(messageCollector, Services.EMPTY, args)
|
||||
|
||||
when (exitCode) {
|
||||
ExitCode.COMPILATION_ERROR -> throw GradleException("Failed to generate kdoc. See log for more details")
|
||||
ExitCode.INTERNAL_ERROR -> throw GradleException("Internal generation error. See log for more details")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun <T: Any> ExtraPropertiesExtension.getOrNull(id: String): T? {
|
||||
try {
|
||||
@suppress("UNCHECKED_CAST")
|
||||
|
||||
@@ -37,12 +37,6 @@
|
||||
<version>2.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kdoc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-gradle-plugin-core</artifactId>
|
||||
|
||||
-18
@@ -247,7 +247,6 @@ abstract class AbstractKotlinPlugin @Inject constructor(val scriptHandler: Scrip
|
||||
project.getPlugins().apply(javaClass<JavaPlugin>())
|
||||
|
||||
configureSourceSetDefaults(project as ProjectInternal, javaBasePlugin, javaPluginConvention)
|
||||
configureKDoc(project, javaPluginConvention)
|
||||
|
||||
val gradleUtils = GradleUtils(scriptHandler, project)
|
||||
project.getExtensions().add(DEFAULT_ANNOTATIONS, gradleUtils.resolveKotlinPluginDependency("kotlin-jdk-annotations"))
|
||||
@@ -262,23 +261,6 @@ abstract class AbstractKotlinPlugin @Inject constructor(val scriptHandler: Scrip
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
open protected fun configureKDoc(project: Project, javaPluginConvention: JavaPluginConvention) {
|
||||
val mainSourceSet = javaPluginConvention.getSourceSets()?.findByName(SourceSet.MAIN_SOURCE_SET_NAME) as HasConvention?
|
||||
|
||||
if (mainSourceSet != null) {
|
||||
|
||||
val kdoc = tasksProvider.createKDocTask(project, KDOC_TASK_NAME)
|
||||
|
||||
kdoc.setDescription("Generates KDoc API documentation for the main source code.")
|
||||
kdoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP)
|
||||
kdoc.setSource(mainSourceSet.getConvention().getExtensionsAsDynamicObject().getProperty("kotlin"))
|
||||
}
|
||||
|
||||
project.getTasks().withType(tasksProvider.kDocTaskClass) { it!!.setProperty("destinationDir", File(javaPluginConvention.getDocsDir(), "kdoc")) }
|
||||
}
|
||||
|
||||
public val KDOC_TASK_NAME: String = "kdoc"
|
||||
}
|
||||
|
||||
|
||||
|
||||
-7
@@ -19,9 +19,6 @@ public open class KotlinTasksProvider(val tasksLoader: ClassLoader) {
|
||||
val kotlinJSCompileTaskClass: Class<AbstractCompile> =
|
||||
tasksLoader.loadClass("org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile") as Class<AbstractCompile>
|
||||
|
||||
val kDocTaskClass: Class<SourceTask> =
|
||||
tasksLoader.loadClass("org.jetbrains.kotlin.gradle.tasks.KDoc") as Class<SourceTask>
|
||||
|
||||
val kotlinJVMOptionsClass: Class<Any> =
|
||||
tasksLoader.loadClass("org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments") as Class<Any>
|
||||
|
||||
@@ -33,8 +30,4 @@ public open class KotlinTasksProvider(val tasksLoader: ClassLoader) {
|
||||
public fun createKotlinJSTask(project: Project, name: String): AbstractCompile {
|
||||
return project.getTasks().create(name, kotlinJSCompileTaskClass)
|
||||
}
|
||||
|
||||
public fun createKDocTask(project: Project, name: String): SourceTask {
|
||||
return project.getTasks().create(name, kDocTaskClass)
|
||||
}
|
||||
}
|
||||
|
||||
-8
@@ -66,14 +66,6 @@ class SimpleKotlinGradleIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
Test fun testSimpleKDoc() {
|
||||
Project("kdocProject", "1.6").build("kdoc") {
|
||||
assertSuccessful()
|
||||
assertReportExists("build/docs/kdoc/demo/MyClass.html")
|
||||
assertContains(":kdoc", "Generating kdoc to")
|
||||
}
|
||||
}
|
||||
|
||||
Test fun testKotlinExtraJavaSrc() {
|
||||
Project("additionalJavaSrc", "1.6").build("build") {
|
||||
assertSuccessful()
|
||||
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url 'file://' + pathToKotlinPlugin
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:0.1-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
apply plugin: "kotlin"
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url 'file://' + pathToKotlinPlugin
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile 'org.testng:testng:6.8'
|
||||
compile 'org.jetbrains.kotlin:kotlin-stdlib:0.1-SNAPSHOT'
|
||||
}
|
||||
|
||||
test {
|
||||
useTestNG()
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.annotations = "externalAnnotations"
|
||||
}
|
||||
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion="1.4"
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<root>
|
||||
<item name='com.google.common.base.Joiner com.google.common.base.Joiner on(java.lang.String)'>
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name='com.google.common.base.Joiner com.google.common.base.Joiner.MapJoiner withKeyValueSeparator(java.lang.String)'>
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name='com.google.common.base.Joiner com.google.common.base.Joiner skipNulls()'>
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
</root>
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package demo
|
||||
|
||||
/**
|
||||
* This is **bold**
|
||||
*
|
||||
* New paragraph using newlines.
|
||||
*
|
||||
* We can also support wiki links notation
|
||||
* for example [[List]] and [[Collection]] and [[java.util.Collection.size()]] will
|
||||
* generate hypertext links to classes
|
||||
*/
|
||||
public class MyClass() {
|
||||
val i: Int = 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user