diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2020-07-17 16:36:09 +0200 |
---|---|---|
committer | Paweł Marks <pmarks@virtuslab.com> | 2020-07-17 16:36:09 +0200 |
commit | 6996b1135f61c7d2cb60b0652c6a2691dda31990 (patch) | |
tree | d568096c25e31c28d14d518a63458b5a7526b896 /runners | |
parent | de56cab76f556e5b4af0b8c8cb08d8b482b86d0a (diff) | |
parent | 1c3530dcbb50c347f80bef694829dbefe89eca77 (diff) | |
download | dokka-6996b1135f61c7d2cb60b0652c6a2691dda31990.tar.gz dokka-6996b1135f61c7d2cb60b0652c6a2691dda31990.tar.bz2 dokka-6996b1135f61c7d2cb60b0652c6a2691dda31990.zip |
Merge branch 'dev-0.11.0'
Diffstat (limited to 'runners')
139 files changed, 1713 insertions, 3811 deletions
diff --git a/runners/ant/build.gradle b/runners/ant/build.gradle deleted file mode 100644 index 216420c6..00000000 --- a/runners/ant/build.gradle +++ /dev/null @@ -1,18 +0,0 @@ -apply plugin: 'kotlin' - -sourceCompatibility = 1.8 - -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { - kotlinOptions { - freeCompilerArgs += "-Xjsr305=strict" - languageVersion = language_version - apiVersion = language_version - jvmTarget = "1.8" - } -} - -dependencies { - compile project(":core") - compileOnly group: 'org.apache.ant', name: 'ant', version: ant_version -} - diff --git a/runners/ant/src/main/kotlin/ant/dokka.kt b/runners/ant/src/main/kotlin/ant/dokka.kt deleted file mode 100644 index 3ecc7b94..00000000 --- a/runners/ant/src/main/kotlin/ant/dokka.kt +++ /dev/null @@ -1,192 +0,0 @@ -package org.jetbrains.dokka.ant - -import org.apache.tools.ant.BuildException -import org.apache.tools.ant.Project -import org.apache.tools.ant.Task -import org.apache.tools.ant.types.Path -import org.apache.tools.ant.types.Reference -import org.jetbrains.dokka.* -import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink -import java.io.File - -class AntLogger(val task: Task): DokkaLogger { - override fun info(message: String) = task.log(message, Project.MSG_INFO) - override fun warn(message: String) = task.log(message, Project.MSG_WARN) - override fun error(message: String) = task.log(message, Project.MSG_ERR) -} - -class AntSourceLinkDefinition(var path: String? = null, var url: String? = null, var lineSuffix: String? = null) - -class AntSourceRoot(var path: String? = null) { - fun toSourceRoot(): SourceRootImpl? = path?.let { path -> - SourceRootImpl(path) - } -} - -class TextProperty(var value: String = "") - -class AntPassConfig(task: Task) : DokkaConfiguration.PassConfiguration { - override var moduleName: String = "" - override val classpath: List<String> - get() = buildClassPath.list().toList() - - override val sourceRoots: List<DokkaConfiguration.SourceRoot> - get() = sourcePath.list().map { SourceRootImpl(it) } + antSourceRoots.mapNotNull { it.toSourceRoot() } - - override val samples: List<String> - get() = samplesPath.list().toList() - override val includes: List<String> - get() = includesPath.list().toList() - override var includeNonPublic: Boolean = false - override var includeRootPackage: Boolean = true - override var reportUndocumented: Boolean = false - override var skipEmptyPackages: Boolean = true - override var skipDeprecated: Boolean = false - override var jdkVersion: Int = 6 - override val sourceLinks: List<DokkaConfiguration.SourceLinkDefinition> - get() = antSourceLinkDefinition.map { - val path = it.path!! - val url = it.url!! - SourceLinkDefinitionImpl(File(path).canonicalFile.absolutePath, url, it.lineSuffix) - } - override val perPackageOptions: MutableList<DokkaConfiguration.PackageOptions> = mutableListOf() - override val externalDocumentationLinks: List<ExternalDocumentationLink> - get() = buildExternalLinksBuilders.map { it.build() } + defaultExternalDocumentationLinks - - override var languageVersion: String? = null - override var apiVersion: String? = null - override var noStdlibLink: Boolean = false - override var noJdkLink: Boolean = false - override var suppressedFiles: MutableList<String> = mutableListOf() - override var collectInheritedExtensionsFromLibraries: Boolean = false - override var analysisPlatform: Platform = Platform.DEFAULT - override var targets: List<String> = listOf() - get() = buildTargets.filter { it.value != "" } - .map { it.value } - - override var sinceKotlin: String? = null - - private val samplesPath: Path by lazy { Path(task.project) } - private val includesPath: Path by lazy { Path(task.project) } - private val buildClassPath: Path by lazy { Path(task.project) } - val sourcePath: Path by lazy { Path(task.project) } - val antSourceRoots: MutableList<AntSourceRoot> = mutableListOf() - - private val buildTargets: MutableList<TextProperty> = mutableListOf() - private val buildExternalLinksBuilders: MutableList<ExternalDocumentationLink.Builder> = mutableListOf() - val antSourceLinkDefinition: MutableList<AntSourceLinkDefinition> = mutableListOf() - - private val defaultExternalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink> - get() { - val links = mutableListOf<DokkaConfiguration.ExternalDocumentationLink>() - if (!noJdkLink) - links += DokkaConfiguration.ExternalDocumentationLink.Builder("https://docs.oracle.com/javase/$jdkVersion/docs/api/").build() - - if (!noStdlibLink) - links += DokkaConfiguration.ExternalDocumentationLink.Builder("https://kotlinlang.org/api/latest/jvm/stdlib/").build() - return links - } - - - fun setSamples(ref: Path) { - samplesPath.append(ref) - } - - fun setSamplesRef(ref: Reference) { - samplesPath.createPath().refid = ref - } - - fun setInclude(ref: Path) { - includesPath.append(ref) - } - - fun setClasspath(classpath: Path) { - buildClassPath.append(classpath) - } - - fun createPackageOptions(): AntPackageOptions = AntPackageOptions().apply { perPackageOptions.add(this) } - - fun createSourceRoot(): AntSourceRoot = AntSourceRoot().apply { antSourceRoots.add(this) } - - fun createTarget(): TextProperty = TextProperty().apply { - buildTargets.add(this) - } - - fun setClasspathRef(ref: Reference) { - buildClassPath.createPath().refid = ref - } - - fun setSrc(src: Path) { - sourcePath.append(src) - } - - fun setSrcRef(ref: Reference) { - sourcePath.createPath().refid = ref - } - - fun createSourceLink(): AntSourceLinkDefinition { - val def = AntSourceLinkDefinition() - antSourceLinkDefinition.add(def) - return def - } - - fun createExternalDocumentationLink() = - ExternalDocumentationLink.Builder().apply { buildExternalLinksBuilders.add(this) } - -} - -class AntPackageOptions( - override var prefix: String = "", - override var includeNonPublic: Boolean = false, - override var reportUndocumented: Boolean = true, - override var skipDeprecated: Boolean = false, - override var suppress: Boolean = false) : DokkaConfiguration.PackageOptions - -class DokkaAntTask: Task(), DokkaConfiguration { - - override var format: String = "html" - override var generateIndexPages: Boolean = false - override var outputDir: String = "" - override var impliedPlatforms: List<String> = listOf() - get() = buildImpliedPlatforms.map { it.value }.toList() - private val buildImpliedPlatforms: MutableList<TextProperty> = mutableListOf() - - override var cacheRoot: String? = null - override val passesConfigurations: MutableList<AntPassConfig> = mutableListOf() - - fun createPassConfig() = AntPassConfig(this).apply { passesConfigurations.add(this) } - fun createImpliedPlatform(): TextProperty = TextProperty().apply { buildImpliedPlatforms.add(this) } - - - override fun execute() { - for (passConfig in passesConfigurations) { - if (passConfig.sourcePath.list().isEmpty() && passConfig.antSourceRoots.isEmpty()) { - throw BuildException("At least one source path needs to be specified") - } - - if (passConfig.moduleName == "") { - throw BuildException("Module name needs to be specified and not empty") - } - - for (sourceLink in passConfig.antSourceLinkDefinition) { - if (sourceLink.path == null) { - throw BuildException("'path' attribute of a <sourceLink> element is required") - } - if (sourceLink.path!!.contains("\\")) { - throw BuildException("'dir' attribute of a <sourceLink> - incorrect value, only Unix based path allowed") - } - - if (sourceLink.url == null) { - throw BuildException("'url' attribute of a <sourceLink> element is required") - } - } - } - - if (outputDir == "") { - throw BuildException("Output directory needs to be specified and not empty") - } - - val generator = DokkaGenerator(this, AntLogger(this)) - generator.generate() - } -}
\ No newline at end of file diff --git a/runners/ant/src/main/resources/dokka-antlib.xml b/runners/ant/src/main/resources/dokka-antlib.xml deleted file mode 100644 index 9c3373d5..00000000 --- a/runners/ant/src/main/resources/dokka-antlib.xml +++ /dev/null @@ -1,3 +0,0 @@ -<antlib> - <taskdef name="dokka" classname="org.jetbrains.dokka.ant.DokkaAntTask"/> -</antlib> diff --git a/runners/build.gradle b/runners/build.gradle deleted file mode 100644 index 23d232d2..00000000 --- a/runners/build.gradle +++ /dev/null @@ -1,7 +0,0 @@ -subprojects { - buildscript { - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } - } -}
\ No newline at end of file diff --git a/runners/build.gradle.kts b/runners/build.gradle.kts new file mode 100644 index 00000000..57081149 --- /dev/null +++ b/runners/build.gradle.kts @@ -0,0 +1,6 @@ +subprojects { + apply { + plugin("maven-publish") + plugin("com.jfrog.bintray") + } +}
\ No newline at end of file diff --git a/runners/cli/build.gradle b/runners/cli/build.gradle deleted file mode 100644 index 24db0b1e..00000000 --- a/runners/cli/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -apply plugin: 'kotlin' - -sourceCompatibility = 1.8 - -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { - kotlinOptions { - languageVersion = language_version - apiVersion = language_version - jvmTarget = "1.8" - } -} - -dependencies { - implementation "org.jetbrains.kotlinx:kotlinx-cli-jvm:0.1.0-dev-3" - implementation project(":core") -} diff --git a/runners/cli/build.gradle.kts b/runners/cli/build.gradle.kts new file mode 100644 index 00000000..4ad34192 --- /dev/null +++ b/runners/cli/build.gradle.kts @@ -0,0 +1,34 @@ +import org.jetbrains.DokkaPublicationBuilder.Component.Shadow +import org.jetbrains.registerDokkaArtifactPublication + +plugins { + id("com.github.johnrengelman.shadow") + id("com.jfrog.bintray") +} + +repositories { + maven(url = "https://dl.bintray.com/kotlin/kotlinx") +} + +dependencies { + implementation("org.jetbrains.kotlinx:kotlinx-cli-jvm:0.2.1") + implementation(project(":core")) + implementation(kotlin("stdlib")) +} + +tasks { + shadowJar { + val dokka_version: String by project + archiveFileName.set("dokka-cli-$dokka_version.jar") + archiveClassifier.set("") + manifest { + attributes("Main-Class" to "org.jetbrains.dokka.MainKt") + } + } +} + +registerDokkaArtifactPublication("dokkaCli"){ + artifactId = "dokka-cli" + component = Shadow +} + diff --git a/runners/cli/src/main/kotlin/cli/DokkaArgumentsParser.kt b/runners/cli/src/main/kotlin/cli/DokkaArgumentsParser.kt deleted file mode 100644 index 5d795da7..00000000 --- a/runners/cli/src/main/kotlin/cli/DokkaArgumentsParser.kt +++ /dev/null @@ -1,185 +0,0 @@ -package org.jetbrains.dokka - -import kotlinx.cli.* -import kotlin.reflect.KProperty - -class ParseContext(val cli: CommandLineInterface = CommandLineInterface("dokka")) { - private val transformActions = mutableMapOf<KProperty<*>, (String) -> Unit>() - private val flagActions = mutableMapOf<KProperty<*>, () -> Unit>() - - fun registerFlagAction( - keys: List<String>, - help: String, - property: KProperty<*>, - invoke: () -> Unit - ) { - if (property !in flagActions.keys) { - cli.flagAction(keys, help) { - flagActions[property]!!() - } - } - flagActions[property] = invoke - - } - - fun registerSingleOption( - keys: List<String>, - help: String, - property: KProperty<*>, - invoke: (String) -> Unit - ) { - if (property !in transformActions.keys) { - cli.singleAction(keys, help) { - transformActions[property]!!(it) - } - } - transformActions[property] = invoke - } - - fun registerRepeatableOption( - keys: List<String>, - help: String, - property: KProperty<*>, - invoke: (String) -> Unit - ) { - if (property !in transformActions.keys) { - cli.repeatingAction(keys, help) { - transformActions[property]!!(it) - } - } - transformActions[property] = invoke - } - - fun parse(args: Array<String>) { - cli.parseArgs(*args) - } - -} - -fun CommandLineInterface.singleAction( - keys: List<String>, - help: String, - invoke: (String) -> Unit -) = registerAction( - object : FlagActionBase(keys, help) { - override fun invoke(arguments: ListIterator<String>) { - if (arguments.hasNext()) { - val msg = arguments.next() - invoke(msg) - } - } - - override fun invoke() { - error("should be never called") - } - } -) - -fun CommandLineInterface.repeatingAction( - keys: List<String>, - help: String, - invoke: (String) -> Unit -) = registerAction( - object : FlagActionBase(keys, help) { - override fun invoke(arguments: ListIterator<String>) { - while (arguments.hasNext()) { - val message = arguments.next() - - if (this@repeatingAction.getFlagAction(message) != null) { - arguments.previous() - break - } - invoke(message) - } - } - - override fun invoke() { - error("should be never called") - } - } - -) - - -class DokkaArgumentsParser(val args: Array<String>, val parseContext: ParseContext) { - class OptionDelegate<T>( - var value: T, - private val action: (delegate: OptionDelegate<T>, property: KProperty<*>) -> Unit - ) { - operator fun getValue(thisRef: Any?, property: KProperty<*>): T = value - operator fun provideDelegate(thisRef: Any, property: KProperty<*>): OptionDelegate<T> { - action(this, property) - return this - } - } - - fun <T> parseInto(dest: T): T { - // TODO: constructor: (DokkaArgumentsParser) -> T - parseContext.parse(args) - return dest - } - - fun <T> repeatableOption( - keys: List<String>, - help: String, - transform: (String) -> T - ) = OptionDelegate(mutableListOf<T>()) { delegate, property -> - parseContext.registerRepeatableOption(keys, help, property) { - delegate.value.add(transform(it)) - } - } - - fun <T : String?> repeatableOption( - keys: List<String>, - help: String - ) = repeatableOption(keys, help) { it as T } - - fun <T> repeatableFlag( - keys: List<String>, - help: String, - initElement: (ParseContext) -> T - ) = OptionDelegate(mutableListOf<T>()) { delegate, property -> - parseContext.registerFlagAction(keys, help, property) { - delegate.value.add(initElement(parseContext)) - } - } - - fun <T> singleFlag( - keys: List<String>, - help: String, - initElement: (ParseContext) -> T, - transform: () -> T - ) = OptionDelegate(initElement(parseContext)) { delegate, property -> - parseContext.registerFlagAction(keys, help, property) { - delegate.value = transform() - } - } - - fun singleFlag( - keys: List<String>, - help: String - ) = singleFlag(keys, help, { false }, { true }) - - fun <T : String?> stringOption( - keys: List<String>, - help: String, - defaultValue: T - ) = singleOption(keys, help, { it as T }, { defaultValue }) - - fun <T> singleOption( - keys: List<String>, - help: String, - transform: (String) -> T, - initElement: (ParseContext) -> T - ) = OptionDelegate(initElement(parseContext)) { delegate, property -> - parseContext.registerSingleOption(keys, help, property) { - val toAdd = transform(it) - delegate.value = toAdd - } - } -} - - -//`(-perPackage fqName [-include-non-public] [...other flags])*` (edited) -//`(-sourceLink dir url [-urlSuffix value])*` -//`(-extLink url [packageListUrl])*`
\ No newline at end of file diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index 55601b21..989a45a1 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -1,278 +1,350 @@ package org.jetbrains.dokka +import kotlinx.cli.* import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink -import org.jetbrains.dokka.Utilities.defaultLinks -import java.io.File +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet.* +import org.jetbrains.dokka.utilities.DokkaConsoleLogger +import org.jetbrains.dokka.utilities.cast +import java.io.* import java.net.MalformedURLException import java.net.URL -import java.net.URLClassLoader - -open class GlobalArguments(parser: DokkaArgumentsParser) : DokkaConfiguration { - override val outputDir: String by parser.stringOption( - listOf("-output"), - "Output directory path", - "") - - override val format: String by parser.stringOption( - listOf("-format"), - "Output format (text, html, markdown, jekyll, kotlin-website)", - "") - - override val generateIndexPages: Boolean by parser.singleFlag( - listOf("-generateIndexPages"), - "Generate index page" - ) +import java.nio.file.Files +import java.nio.file.Paths - override val cacheRoot: String? by parser.stringOption( - listOf("-cacheRoot"), - "Path to cache folder, or 'default' to use ~/.cache/dokka, if not provided caching is disabled", - null) +class GlobalArguments(args: Array<String>) : DokkaConfiguration { - override val impliedPlatforms: List<String> = emptyList() + val parser = ArgParser("globalArguments", prefixStyle = ArgParser.OptionPrefixStyle.JVM) - override val passesConfigurations: List<Arguments> by parser.repeatableFlag( - listOf("-pass"), - "Single dokka pass" - ) { - Arguments(parser) - } -} + val json: String? by parser.argument(ArgType.String, description = "Json file name").optional() -class Arguments(val parser: DokkaArgumentsParser) : DokkaConfiguration.PassConfiguration { - override val moduleName: String by parser.stringOption( - listOf("-module"), - "Name of the documentation module", - "") + override val outputDir by parser.option(ArgType.String, description = "Output directory path") + .default(DokkaDefaults.outputDir) - override val classpath: List<String> by parser.repeatableOption( - listOf("-classpath"), - "Classpath for symbol resolution" + override val cacheRoot by parser.option( + ArgType.String, + description = "Path to cache folder, or 'default' to use ~/.cache/dokka, if not provided caching is disabled" ) - override val sourceRoots: List<DokkaConfiguration.SourceRoot> by parser.repeatableOption( - listOf("-src"), - "Source file or directory (allows many paths separated by the system path separator)" - ) { SourceRootImpl(it) } - - override val samples: List<String> by parser.repeatableOption( - listOf("-sample"), - "Source root for samples" + override val sourceSets by parser.option( + ArgTypeArgument, + description = "Single dokka source set", + fullName = "sourceSet" + ).multiple() + + override val pluginsConfiguration by parser.option( + ArgTypePlugin, + description = "Configuration for plugins in format fqPluginName=json^^fqPluginName=json..." + ).default(emptyMap()) + + override val pluginsClasspath by parser.option( + ArgTypeFile, + description = "List of jars with dokka plugins (allows many paths separated by the semicolon `;`)" + ).delimiter(";") + + + override val offlineMode by parser.option( + ArgType.Boolean, + "Offline mode (do not download package lists from the Internet)" + ).default(DokkaDefaults.offlineMode) + + override val failOnWarning by parser.option( + ArgType.Boolean, + "Throw an exception if the generation exited with warnings" + ).default(DokkaDefaults.failOnWarning) + + val globalPackageOptions by parser.option( + ArgType.String, + description = "List of package source sets in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" " + ).delimiter(";") + + val globalLinks by parser.option( + ArgType.String, + description = "External documentation links in format url^packageListUrl^^url2..." + ).delimiter("^^") + + val globalSrcLink by parser.option( + ArgType.String, + description = "Mapping between a source directory and a Web site for browsing the code (allows many paths separated by the semicolon `;`)" + ).delimiter(";") + + val helpSourceSet by parser.option( + ArgTypeHelpSourceSet, + description = "Prints help for single -sourceSet" ) - override val includes: List<String> by parser.repeatableOption( - listOf("-include"), - "Markdown files to load (allows many paths separated by the system path separator)" - ) - - override val includeNonPublic: Boolean by parser.singleFlag( - listOf("-includeNonPublic"), - "Include non public") - - override val includeRootPackage: Boolean by parser.singleFlag( - listOf("-includeRootPackage"), - "Include root package") + override val modules: List<DokkaConfiguration.DokkaModuleDescription> = emptyList() - override val reportUndocumented: Boolean by parser.singleFlag( - listOf("-reportUndocumented"), - "Report undocumented members") + init { + parser.parse(args) - override val skipEmptyPackages: Boolean by parser.singleFlag( - listOf("-skipEmptyPackages"), - "Do not create index pages for empty packages") - - override val skipDeprecated: Boolean by parser.singleFlag( - listOf("-skipDeprecated"), - "Do not output deprecated members") - - override val jdkVersion: Int by parser.singleOption( - listOf("-jdkVersion"), - "Version of JDK to use for linking to JDK JavaDoc", - { it.toInt() }, - { 6 } - ) - - override val languageVersion: String? by parser.stringOption( - listOf("-languageVersion"), - "Language Version to pass to Kotlin Analysis", - null) - - override val apiVersion: String? by parser.stringOption( - listOf("-apiVersion"), - "Kotlin Api Version to pass to Kotlin Analysis", - null - ) + sourceSets.all { + it.perPackageOptions.cast<MutableList<DokkaConfiguration.PackageOptions>>() + .addAll(parsePerPackageOptions(globalPackageOptions)) + } - override val noStdlibLink: Boolean by parser.singleFlag( - listOf("-noStdlibLink"), - "Disable documentation link to stdlib") + sourceSets.all { + it.externalDocumentationLinks.cast<MutableList<ExternalDocumentationLink>>().addAll(parseLinks(globalLinks)) + } - override val noJdkLink: Boolean by parser.singleFlag( - listOf("-noJdkLink"), - "Disable documentation link to JDK") + globalSrcLink.forEach { + if (it.isNotEmpty() && it.contains("=")) + sourceSets.all { sourceSet -> + sourceSet.sourceLinks.cast<MutableList<SourceLinkDefinitionImpl>>() + .add(SourceLinkDefinitionImpl.parseSourceLinkDefinition(it)) + } + else { + DokkaConsoleLogger.warn("Invalid -srcLink syntax. Expected: <path>=<url>[#lineSuffix]. No source links will be generated.") + } + } - override val suppressedFiles: List<String> by parser.repeatableOption( - listOf("-suppressedFile"), - "" - ) + sourceSets.forEach { + it.externalDocumentationLinks.cast<MutableList<ExternalDocumentationLink>>().addAll(defaultLinks(it)) + it.externalDocumentationLinks.cast<MutableList<ExternalDocumentationLink>>().replaceAll { link -> + ExternalDocumentationLink.Builder(link.url, link.packageListUrl).build() + } + } + } +} - override val sinceKotlin: String? by parser.stringOption( - listOf("-sinceKotlin"), - "Kotlin Api version to use as base version, if none specified", - null - ) +private fun parseSourceSet(args: Array<String>): DokkaConfiguration.DokkaSourceSet { - override val collectInheritedExtensionsFromLibraries: Boolean by parser.singleFlag( - listOf("-collectInheritedExtensionsFromLibraries"), - "Search for applicable extensions in libraries") + val parser = ArgParser("sourceSet", prefixStyle = ArgParser.OptionPrefixStyle.JVM) - override val analysisPlatform: Platform by parser.singleOption( - listOf("-analysisPlatform"), - "Platform for analysis", - { Platform.fromString(it) }, - { Platform.DEFAULT } - ) + val moduleName by parser.option( + ArgType.String, + description = "Name of the documentation module", + fullName = "moduleName" + ).required() - override val targets: List<String> by parser.repeatableOption( - listOf("-target"), - "Generation targets" + val moduleDisplayName by parser.option( + ArgType.String, + description = "Name of the documentation module" ) - override val perPackageOptions: MutableList<DokkaConfiguration.PackageOptions> by parser.singleOption( - listOf("-packageOptions"), - "List of package passConfiguration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" ", - { parsePerPackageOptions(it).toMutableList() }, - { mutableListOf() } + val sourceSetName by parser.option( + ArgType.String, + description = "Name of the source set" + ).default("main") + + val displayName by parser.option( + ArgType.String, + description = "Displayed name of the source set" + ).default("JVM") + + val classpath by parser.option( + ArgType.String, + description = "Classpath for symbol resolution (allows many paths separated by the semicolon `;`)" + ).delimiter(";") + + val sourceRoots by parser.option( + ArgType.String, + description = "Source file or directory (allows many paths separated by the semicolon `;`)", + fullName = "src" + ).delimiter(";") + + val dependentSourceSets by parser.option( + ArgType.String, + description = "Names of dependent source sets in format \"moduleName/sourceSetName\" (allows many paths separated by the semicolon `;`)" + ).delimiter(";") + + val samples by parser.option( + ArgType.String, + description = "Source root for samples (allows many paths separated by the semicolon `;`)" + ).delimiter(";") + + val includes by parser.option( + ArgType.String, + description = "Markdown files to load (allows many paths separated by the semicolon `;`)" + ).delimiter(";") + + val includeNonPublic: Boolean by parser.option(ArgType.Boolean, description = "Include non public") + .default(DokkaDefaults.includeNonPublic) + + val includeRootPackage by parser.option(ArgType.Boolean, description = "Include root package") + .default(DokkaDefaults.includeRootPackage) + + val reportUndocumented by parser.option(ArgType.Boolean, description = "Report undocumented members") + .default(DokkaDefaults.reportUndocumented) + + val skipEmptyPackages by parser.option( + ArgType.Boolean, + description = "Do not create index pages for empty packages" + ).default(DokkaDefaults.skipEmptyPackages) + + val skipDeprecated by parser.option(ArgType.Boolean, description = "Do not output deprecated members") + .default(DokkaDefaults.skipDeprecated) + + val jdkVersion by parser.option( + ArgType.Int, + description = "Version of JDK to use for linking to JDK JavaDoc" + ).default(DokkaDefaults.jdkVersion) + + val languageVersion by parser.option( + ArgType.String, + description = "Language Version to pass to Kotlin analysis" ) - override val externalDocumentationLinks: MutableList<DokkaConfiguration.ExternalDocumentationLink> by parser.singleOption( - listOf("-links"), - "External documentation links in format url^packageListUrl^^url2...", - { MainKt.parseLinks(it).toMutableList() }, - { mutableListOf() } + val apiVersion by parser.option( + ArgType.String, + description = "Kotlin Api Version to pass to Kotlin analysis" ) - override val sourceLinks: MutableList<DokkaConfiguration.SourceLinkDefinition> by parser.repeatableOption( - listOf("-srcLink"), - "Mapping between a source directory and a Web site for browsing the code" - ) { - if (it.isNotEmpty() && it.contains("=")) - SourceLinkDefinitionImpl.parseSourceLinkDefinition(it) - else { - throw IllegalArgumentException("Warning: Invalid -srcLink syntax. Expected: <path>=<url>[#lineSuffix]. No source links will be generated.") - } + val noStdlibLink by parser.option(ArgType.Boolean, description = "Disable documentation link to stdlib") + .default(DokkaDefaults.noStdlibLink) + + val noJdkLink by parser.option(ArgType.Boolean, description = "Disable documentation link to JDK") + .default(DokkaDefaults.noJdkLink) + + val suppressedFiles by parser.option( + ArgType.String, + description = "Paths to files to be suppressed (allows many paths separated by the semicolon `;`)" + ).delimiter(";") + + val analysisPlatform: Platform by parser.option( + ArgTypePlatform, + description = "Platform for analysis" + ).default(DokkaDefaults.analysisPlatform) + + val perPackageOptions by parser.option( + ArgType.String, + description = "List of package source set configuration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" " + ).delimiter(";") + + val externalDocumentationLinks by parser.option( + ArgType.String, + description = "External documentation links in format url^packageListUrl^^url2..." + ).delimiter("^^") + + val sourceLinks by parser.option( + ArgTypeSourceLinkDefinition, + description = "Mapping between a source directory and a Web site for browsing the code (allows many paths separated by the semicolon `;`)", + fullName = "srcLink" + ).delimiter(";") + + parser.parse(args) + + return object : DokkaConfiguration.DokkaSourceSet { + override val moduleDisplayName = moduleDisplayName ?: moduleName + override val displayName = displayName + override val sourceSetID = DokkaSourceSetID(moduleName, sourceSetName) + override val classpath = classpath + override val sourceRoots = sourceRoots.map { SourceRootImpl(it.toAbsolutePath()) } + override val dependentSourceSets: Set<DokkaSourceSetID> = dependentSourceSets + .map { dependentSourceSetName -> dependentSourceSetName.split('/').let { DokkaSourceSetID(it[0], it[1]) } } + .toSet() + override val samples = samples.map { it.toAbsolutePath() } + override val includes = includes.map { it.toAbsolutePath() } + override val includeNonPublic = includeNonPublic + override val includeRootPackage = includeRootPackage + override val reportUndocumented = reportUndocumented + override val skipEmptyPackages = skipEmptyPackages + override val skipDeprecated = skipDeprecated + override val jdkVersion = jdkVersion + override val sourceLinks = sourceLinks + override val analysisPlatform = analysisPlatform + override val perPackageOptions = parsePerPackageOptions(perPackageOptions) + override val externalDocumentationLinks = parseLinks(externalDocumentationLinks) + override val languageVersion = languageVersion + override val apiVersion = apiVersion + override val noStdlibLink = noStdlibLink + override val noJdkLink = noJdkLink + override val suppressedFiles = suppressedFiles } } -object MainKt { - fun parseLinks(links: String): List<ExternalDocumentationLink> { - val (parsedLinks, parsedOfflineLinks) = links.split("^^") - .map { it.split("^").map { it.trim() }.filter { it.isNotBlank() } } - .filter { it.isNotEmpty() } - .partition { it.size == 1 } - - return parsedLinks.map { (root) -> ExternalDocumentationLink.Builder(root).build() } + - parsedOfflineLinks.map { (root, packageList) -> - val rootUrl = URL(root) - val packageListUrl = - try { - URL(packageList) - } catch (ex: MalformedURLException) { - File(packageList).toURI().toURL() - } - ExternalDocumentationLink.Builder(rootUrl, packageListUrl).build() - } - } +object ArgTypeFile : ArgType<File>(true) { + override fun convert(value: kotlin.String, name: kotlin.String): File = File(value) + override val description: kotlin.String + get() = "{ String that points to file path }" +} - @JvmStatic - fun entry(configuration: DokkaConfiguration) { - val generator = DokkaGenerator(configuration, DokkaConsoleLogger) - generator.generate() - DokkaConsoleLogger.report() - } +object ArgTypePlatform : ArgType<Platform>(true) { + override fun convert(value: kotlin.String, name: kotlin.String): Platform = Platform.fromString(value) + override val description: kotlin.String + get() = "{ String thar represents paltform }" +} - fun findToolsJar(): File { - val javaHome = System.getProperty("java.home") - val default = File(javaHome, "../lib/tools.jar") - val mac = File(javaHome, "../Classes/classes.jar") - when { - default.exists() -> return default - mac.exists() -> return mac - else -> { - throw Exception("tools.jar not found, please check it, also you can provide it manually, using -cp") +object ArgTypePlugin : ArgType<Map<String, String>>(true) { + override fun convert(value: kotlin.String, name: kotlin.String): Map<kotlin.String, kotlin.String> = + value.split("^^").map { + it.split("=").let { + it[0] to it[1] } - } - } + }.toMap() - fun createClassLoaderWithTools(): ClassLoader { - val toolsJar = findToolsJar().canonicalFile.toURI().toURL() - val originalUrls = (javaClass.classLoader as? URLClassLoader)?.urLs - val dokkaJar = javaClass.protectionDomain.codeSource.location - val urls = if (originalUrls != null) arrayOf(toolsJar, *originalUrls) else arrayOf(toolsJar, dokkaJar) - return URLClassLoader(urls, ClassLoader.getSystemClassLoader().parent) - } + override val description: kotlin.String + get() = "{ String fqName=json, remember to escape `\"` inside json }" +} - fun startWithToolsJar(configuration: DokkaConfiguration) { - try { - javaClass.classLoader.loadClass("com.sun.tools.doclets.formats.html.HtmlDoclet") - entry(configuration) - } catch (e: ClassNotFoundException) { - val classLoader = createClassLoaderWithTools() - classLoader.loadClass("org.jetbrains.dokka.MainKt") - .methods.find { it.name == "entry" }!! - .invoke(null, configuration) +object ArgTypeSourceLinkDefinition : ArgType<DokkaConfiguration.SourceLinkDefinition>(true) { + override fun convert(value: kotlin.String, name: kotlin.String): DokkaConfiguration.SourceLinkDefinition = + if (value.isNotEmpty() && value.contains("=")) + SourceLinkDefinitionImpl.parseSourceLinkDefinition(value) + else { + throw IllegalArgumentException("Warning: Invalid -srcLink syntax. Expected: <path>=<url>[#lineSuffix]. No source links will be generated.") } - } - fun createConfiguration(args: Array<String>): GlobalArguments { - val parseContext = ParseContext() - val parser = DokkaArgumentsParser(args, parseContext) - val configuration = GlobalArguments(parser) + override val description: kotlin.String + get() = "{ String that represent source links }" +} - parseContext.cli.singleAction( - listOf("-globalPackageOptions"), - "List of package passConfiguration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" " - ) { link -> - configuration.passesConfigurations.all { it.perPackageOptions.addAll(parsePerPackageOptions(link)) } - } +object ArgTypeArgument : ArgType<DokkaConfiguration.DokkaSourceSet>(true) { + override fun convert(value: kotlin.String, name: kotlin.String): DokkaConfiguration.DokkaSourceSet = + parseSourceSet(value.split(" ").filter { it.isNotBlank() }.toTypedArray()) - parseContext.cli.singleAction( - listOf("-globalLinks"), - "External documentation links in format url^packageListUrl^^url2..." - ) { link -> - configuration.passesConfigurations.all { it.externalDocumentationLinks.addAll(parseLinks(link)) } - } + override val description: kotlin.String + get() = "" +} - parseContext.cli.repeatingAction( - listOf("-globalSrcLink"), - "Mapping between a source directory and a Web site for browsing the code" - ) { - val newSourceLinks = if (it.isNotEmpty() && it.contains("=")) - listOf(SourceLinkDefinitionImpl.parseSourceLinkDefinition(it)) - else { - if (it.isNotEmpty()) { - println("Warning: Invalid -srcLink syntax. Expected: <path>=<url>[#lineSuffix]. No source links will be generated.") - } - listOf() - } +// Workaround for printing nested parsers help +object ArgTypeHelpSourceSet : ArgType<Any>(false) { + override fun convert(value: kotlin.String, name: kotlin.String): Any = Any().also { parseSourceSet(arrayOf("-h")) } - configuration.passesConfigurations.all { it.sourceLinks.addAll(newSourceLinks) } - } + override val description: kotlin.String + get() = "" +} - parser.parseInto(configuration) - return configuration +fun defaultLinks(config: DokkaConfiguration.DokkaSourceSet): MutableList<ExternalDocumentationLink> = + mutableListOf<ExternalDocumentationLink>().apply { + if (!config.noJdkLink) + this += DokkaConfiguration.ExternalDocumentationLink + .Builder("https://docs.oracle.com/javase/${config.jdkVersion}/docs/api/") + .build() + + if (!config.noStdlibLink) + this += ExternalDocumentationLink + .Builder("https://kotlinlang.org/api/latest/jvm/stdlib/") + .build() } - fun GlobalArguments.addDefaultLinks() = passesConfigurations.forEach { it.externalDocumentationLinks += it.defaultLinks() } - - @JvmStatic - fun main(args: Array<String>) { - val configuration = createConfiguration(args).apply { addDefaultLinks() } - if (configuration.format.toLowerCase() == "javadoc") - startWithToolsJar(configuration) - else - entry(configuration) - } +private fun String.toAbsolutePath() = Paths.get(this).toAbsolutePath().toString() + +fun parseLinks(links: List<String>): List<ExternalDocumentationLink> { + val (parsedLinks, parsedOfflineLinks) = links + .map { it.split("^").map { it.trim() }.filter { it.isNotBlank() } } + .filter { it.isNotEmpty() } + .partition { it.size == 1 } + + return parsedLinks.map { (root) -> ExternalDocumentationLink.Builder(root).build() } + + parsedOfflineLinks.map { (root, packageList) -> + val rootUrl = URL(root) + val packageListUrl = + try { + URL(packageList) + } catch (ex: MalformedURLException) { + File(packageList).toURI().toURL() + } + ExternalDocumentationLink.Builder(rootUrl, packageListUrl).build() + } } - - +fun main(args: Array<String>) { + val globalArguments = GlobalArguments(args) + val configuration = if (globalArguments.json != null) + DokkaConfigurationImpl( + Paths.get(checkNotNull(globalArguments.json)).toFile().readText() + ) + else + globalArguments + DokkaGenerator(configuration, DokkaConsoleLogger).generate() +} diff --git a/runners/fatjar/build.gradle b/runners/fatjar/build.gradle deleted file mode 100644 index 4ce0416c..00000000 --- a/runners/fatjar/build.gradle +++ /dev/null @@ -1,50 +0,0 @@ -import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer -import org.jetbrains.PluginXmlTransformer - -apply plugin: 'java' -apply plugin: 'com.github.johnrengelman.shadow' - -dependencies { - compile project(":runners:cli") - compile project(":runners:ant") -} - -jar { - manifest { - attributes 'Main-Class': 'org.jetbrains.dokka.MainKt' - } -} - -shadowJar { - baseName = 'dokka-fatjar' - classifier = '' - - configurations { - exclude compileOnly - } - - transform(ServiceFileTransformer) - transform(PluginXmlTransformer) - - exclude 'colorScheme/**' - exclude 'fileTemplates/**' - exclude 'inspectionDescriptions/**' - exclude 'intentionDescriptions/**' - - exclude 'src/**' - - relocate('kotlin.reflect.full', 'kotlin.reflect') -} - -apply plugin: 'maven-publish' - -publishing { - publications { - dokkaFatJar(MavenPublication) { publication -> - artifactId = 'dokka-fatjar' - project.shadow.component(publication) - } - } -} - -bintrayPublication(project, ["dokkaFatJar"])
\ No newline at end of file diff --git a/runners/gradle-integration-tests/android-licenses/android-sdk-license b/runners/gradle-integration-tests/android-licenses/android-sdk-license deleted file mode 100644 index c311cf48..00000000 --- a/runners/gradle-integration-tests/android-licenses/android-sdk-license +++ /dev/null @@ -1,2 +0,0 @@ - -d56f5187479451eabf01fb78af6dfcb131a6481e
\ No newline at end of file diff --git a/runners/gradle-integration-tests/android-licenses/android-sdk-preview-license b/runners/gradle-integration-tests/android-licenses/android-sdk-preview-license deleted file mode 100644 index da4552d2..00000000 --- a/runners/gradle-integration-tests/android-licenses/android-sdk-preview-license +++ /dev/null @@ -1,2 +0,0 @@ - -84831b9409646a918e30573bab4c9c91346d8abd
\ No newline at end of file diff --git a/runners/gradle-integration-tests/build.gradle b/runners/gradle-integration-tests/build.gradle deleted file mode 100644 index 2430d46b..00000000 --- a/runners/gradle-integration-tests/build.gradle +++ /dev/null @@ -1,59 +0,0 @@ -apply plugin: 'kotlin' - -sourceCompatibility = 1.8 - -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { - kotlinOptions { - freeCompilerArgs += "-Xjsr305=strict" - languageVersion = language_version - apiVersion = language_version - jvmTarget = "1.8" - } -} - -configurations { - dokkaPlugin - dokkaFatJar - kotlinGradle -} - -dependencies { - - testCompileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_for_gradle_runtime_version - testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit', version: kotlin_for_gradle_runtime_version - testCompile ideaRT() - - dokkaPlugin project(path: ':runners:gradle-plugin', configuration: 'shadow') - dokkaFatJar project(path: ":runners:fatjar", configuration: 'shadow') - - kotlinGradle "org.jetbrains.kotlin:kotlin-gradle-plugin" - - testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile gradleTestKit() -} - - - -task createClasspathManifest { - def outputDir = file("$buildDir/$name") - - inputs.files(configurations.dokkaPlugin + configurations.dokkaFatJar) - outputs.dir outputDir - - doLast { - outputDir.mkdirs() - file("$outputDir/dokka-plugin-classpath.txt").text = configurations.dokkaPlugin.join("\n") - file("$outputDir/fatjar.txt").text = configurations.dokkaFatJar.join("\n") - file("$outputDir/kotlin-gradle.txt").text = configurations.kotlinGradle.join("\n") - } -} - - -createClasspathManifest.mustRunAfter project(":runners:fatjar").shadowJar -testClasses.dependsOn project(":runners:fatjar").shadowJar -testClasses.dependsOn createClasspathManifest - -test { - systemProperty "android.licenses.overwrite", project.findProperty("android.licenses.overwrite") ?: "" - inputs.dir(file('testData')) -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractAndroidAppTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractAndroidAppTest.kt deleted file mode 100644 index c3fe2ea9..00000000 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractAndroidAppTest.kt +++ /dev/null @@ -1,51 +0,0 @@ -package org.jetbrains.dokka.gradle - -import org.gradle.testkit.runner.TaskOutcome -import kotlin.test.assertEquals - -abstract class AbstractAndroidAppTest(val testDataRootPath: String) : AbstractDokkaAndroidGradleTest() { - - fun prepareTestData() { - val testDataRoot = testDataFolder.resolve(testDataRootPath) - val tmpRoot = testProjectDir.root.toPath() - - testDataRoot.resolve("app").copy(tmpRoot.resolve("app")) - testDataRoot.resolve("build.gradle").copy(tmpRoot.resolve("build.gradle")) - testDataRoot.resolve("settings.gradle").copy(tmpRoot.resolve("settings.gradle")) - - androidLocalProperties?.copy(tmpRoot.resolve("local.properties")) - } - - - data class AndroidPluginParams(val pluginVersion: String, val buildToolsVersion: String, val compileSdk: Int) { - fun asArguments(): List<String> = listOf( - "-Pabt_plugin_version=$pluginVersion", - "-Pabt_version=$buildToolsVersion", - "-Psdk_version=$compileSdk" - ) - } - - - protected fun doTest(gradleVersion: String, kotlinVersion: String, androidPluginParams: AndroidPluginParams) { - prepareTestData() - - val result = configure(gradleVersion, kotlinVersion, - arguments = arrayOf("dokka", "--stacktrace") + androidPluginParams.asArguments()) - .build() - - println(result.output) - - assertEquals(TaskOutcome.SUCCESS, result.task(":app:dokka")?.outcome) - - val docsOutput = "app/build/dokka" - - checkOutputStructure("$testDataRootPath/fileTree.txt", docsOutput) - - checkNoErrorClasses(docsOutput) - checkNoUnresolvedLinks(docsOutput) - - checkExternalLink(docsOutput, "<span class=\"identifier\">Activity</span>", - """<a href="https://developer.android.com/reference/android/app/Activity.html"><span class="identifier">Activity</span></a>""") - } - -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaAndroidGradleTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaAndroidGradleTest.kt deleted file mode 100644 index 334fc7c8..00000000 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaAndroidGradleTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -package org.jetbrains.dokka.gradle - -import org.junit.BeforeClass -import java.io.File - -abstract class AbstractDokkaAndroidGradleTest : AbstractDokkaGradleTest() { - - override val pluginClasspath: List<File> = pluginClasspathData.toFile().readLines().map { File(it) } - - companion object { - - @JvmStatic - @BeforeClass - fun acceptAndroidSdkLicenses() { - val sdkDir = androidLocalProperties?.toFile()?.let { - val lines = it.readLines().map { it.trim() } - val sdkDirLine = lines.firstOrNull { "sdk.dir" in it } - sdkDirLine?.substringAfter("=")?.trim() - } ?: System.getenv("ANDROID_HOME") - - if (sdkDir == null || sdkDir.isEmpty()) { - error("Android SDK home not set, " + - "try setting \$ANDROID_HOME " + - "or sdk.dir in runners/gradle-integration-tests/testData/android.local.properties") - } - val sdkDirFile = File(sdkDir) - if (!sdkDirFile.exists()) error("\$ANDROID_HOME and android.local.properties points to non-existing location") - val sdkLicensesDir = sdkDirFile.resolve("licenses") - - val acceptedLicenses = File("android-licenses") - acceptedLicenses.listFiles().forEach { licenseFile -> - val target = sdkLicensesDir.resolve(licenseFile.name) - if(!target.exists() || target.readText() != licenseFile.readText()) { - val overwrite = System.getProperty("android.licenses.overwrite", "false")!!.toBoolean() - if (!target.exists() || overwrite) { - licenseFile.copyTo(target, true) - println("Accepted ${licenseFile.name}, by copying $licenseFile to $target") - } - } - - } - } - - } -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaGradleTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaGradleTest.kt deleted file mode 100644 index 4814e707..00000000 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaGradleTest.kt +++ /dev/null @@ -1,108 +0,0 @@ -package org.jetbrains.dokka.gradle - - -import com.intellij.rt.execution.junit.FileComparisonFailure -import org.gradle.testkit.runner.GradleRunner -import org.junit.Rule -import org.junit.rules.TemporaryFolder -import java.io.File -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths - - -val testDataFolder: Path = Paths.get("testData") - -val pluginClasspathData: Path = Paths.get("build", "createClasspathManifest", "dokka-plugin-classpath.txt") - -val dokkaFatJarPathData: Path = pluginClasspathData.resolveSibling("fatjar.txt") - -val androidLocalProperties = testDataFolder.resolve("android.local.properties").let { if (Files.exists(it)) it else null } - -abstract class AbstractDokkaGradleTest { - @get:Rule val testProjectDir = TemporaryFolder() - - open val pluginClasspath: List<File> = pluginClasspathData.toFile().readLines().map { File(it) } - - fun checkOutputStructure(expected: String, actualSubpath: String) { - val expectedPath = testDataFolder.resolve(expected) - val actualPath = testProjectDir.root.toPath().resolve(actualSubpath).normalize() - - assertEqualsIgnoringSeparators(expectedPath.toFile(), buildString { - actualPath.toFile().writeStructure(this, File(actualPath.toFile(), ".")) - }) - } - - fun checkNoErrorClasses(actualSubpath: String, extension: String = "html", errorClassMarker: String = "ERROR CLASS") { - val actualPath = testProjectDir.root.toPath().resolve(actualSubpath).normalize() - var checked = 0 - Files.walk(actualPath).filter { Files.isRegularFile(it) && it.fileName.toString().endsWith(".$extension") }.forEach { - val text = it.toFile().readText() - - val noErrorClasses = text.replace(errorClassMarker, "?!") - - if (noErrorClasses != text) { - throw FileComparisonFailure("", noErrorClasses, text, null) - } - - checked++ - } - println("$checked files checked for error classes") - } - - fun checkNoUnresolvedLinks(actualSubpath: String, extension: String = "html", marker: Regex = "[\"']#[\"']".toRegex()) { - val actualPath = testProjectDir.root.toPath().resolve(actualSubpath).normalize() - var checked = 0 - Files.walk(actualPath).filter { Files.isRegularFile(it) && it.fileName.toString().endsWith(".$extension") }.forEach { - val text = it.toFile().readText() - - val noErrorClasses = text.replace(marker, "?!") - - if (noErrorClasses != text) { - throw FileComparisonFailure("", noErrorClasses, text, null) - } - - checked++ - } - println("$checked files checked for unresolved links") - } - - fun checkExternalLink(actualSubpath: String, linkBody: String, fullLink: String, extension: String = "html") { - val match = "!!match!!" - val notMatch = "!!not-match!!" - - val actualPath = testProjectDir.root.toPath().resolve(actualSubpath).normalize() - var checked = 0 - var totalEntries = 0 - Files.walk(actualPath).filter { Files.isRegularFile(it) && it.fileName.toString().endsWith(".$extension") }.forEach { - val text = it.toFile().readText() - - val textWithoutMatches = text.replace(fullLink, match) - - val textWithoutNonMatches = textWithoutMatches.replace(linkBody, notMatch) - - if (textWithoutNonMatches != textWithoutMatches) { - - val expected = textWithoutNonMatches.replace(notMatch, fullLink).replace(match, fullLink) - val actual = textWithoutMatches.replace(match, fullLink) - - throw FileComparisonFailure("", expected, actual, null) - } - if (text != textWithoutMatches) - totalEntries++ - - checked++ - } - println("$checked files checked for valid external links '$linkBody', found $totalEntries links") - } - - fun configure(gradleVersion: String = "3.5", kotlinVersion: String = "1.1.2", arguments: Array<String>): GradleRunner { - val fatjar = dokkaFatJarPathData.toFile().readText() - - return GradleRunner.create().withProjectDir(testProjectDir.root) - .withArguments("-Pdokka_fatjar=$fatjar", "-Ptest_kotlin_version=$kotlinVersion", *arguments) - .withPluginClasspath(pluginClasspath) - .withGradleVersion(gradleVersion) - .withDebug(true) - } -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt deleted file mode 100644 index bbb63909..00000000 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt +++ /dev/null @@ -1,25 +0,0 @@ -package org.jetbrains.dokka.gradle - -import org.junit.Test - -class AndroidAppTest : AbstractAndroidAppTest("androidApp") { - @Test - fun `test kotlin 1_1_2-5 and gradle 4_0 and abt 3_0_0-alpha3`() { - doTest("4.0", "1.1.2-5", AndroidPluginParams("3.0.0-alpha3", "25.0.2", 25)) - } - - @Test - fun `test kotlin 1_1_2 and gradle 3_5 and abt 2_3_0`() { - doTest("3.5", "1.1.2", AndroidPluginParams("2.3.0", "25.0.0", 24)) - } - - @Test - fun `test kotlin 1_0_7 and gradle 2_14_1 and abt 2_2_3`() { - doTest("2.14.1", "1.0.7", AndroidPluginParams("2.2.3", "25.0.0", 24)) - } - - @Test - fun `test kotlin 1_2_20 and gradle 4_5 and abt 3_0_1`() { - doTest("4.5", "1.2.20", AndroidPluginParams("3.0.1", "27.0.0", 27)) - } -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidLibDependsOnJavaLibTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidLibDependsOnJavaLibTest.kt deleted file mode 100644 index 9bc52273..00000000 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidLibDependsOnJavaLibTest.kt +++ /dev/null @@ -1,48 +0,0 @@ -package org.jetbrains.dokka.gradle - -import org.gradle.testkit.runner.TaskOutcome -import org.junit.Test -import kotlin.test.assertEquals - -class AndroidLibDependsOnJavaLibTest: AbstractDokkaAndroidGradleTest() { - - private val testDataRootPath = "androidLibDependsOnJavaLib" - - private fun prepareTestData() { - val testDataRoot = testDataFolder.resolve(testDataRootPath) - val tmpRoot = testProjectDir.root.toPath() - - testDataRoot.copy(tmpRoot) - - androidLocalProperties?.copy(tmpRoot.resolve("local.properties")) - } - - - private fun doTest(gradleVersion: String, kotlinVersion: String, androidPluginParams: AbstractAndroidAppTest.AndroidPluginParams) { - prepareTestData() - - val result = configure(gradleVersion, kotlinVersion, - arguments = arrayOf("dokka", "--stacktrace") + androidPluginParams.asArguments()) - .build() - - println(result.output) - - assertEquals(TaskOutcome.SUCCESS, result.task(":lib:dokka")?.outcome) - - val docsOutput = "lib/build/dokka" - - checkOutputStructure("$testDataRootPath/fileTree.txt", docsOutput) - - checkNoErrorClasses(docsOutput) - checkNoUnresolvedLinks(docsOutput) - - checkExternalLink(docsOutput, "<span class=\"identifier\">LibClz</span>", - """<a href="https://example.com/example/jlib/LibClz.html"><span class="identifier">LibClz</span></a>""") - } - - - @Test - fun `test kotlin 1_2_20 and gradle 4_5 and abt 3_0_1`() { - doTest("4.5", "1.2.20", AbstractAndroidAppTest.AndroidPluginParams("3.0.1", "27.0.0", 27)) - } -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt deleted file mode 100644 index ef1b94d8..00000000 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt +++ /dev/null @@ -1,60 +0,0 @@ -package org.jetbrains.dokka.gradle - -import org.gradle.testkit.runner.TaskOutcome -import org.jetbrains.dokka.gradle.AbstractAndroidAppTest.AndroidPluginParams -import org.junit.Test -import kotlin.test.assertEquals - -class AndroidMultiFlavourAppTest : AbstractDokkaAndroidGradleTest() { - - fun prepareTestData(testDataRootPath: String) { - val testDataRoot = testDataFolder.resolve(testDataRootPath) - val tmpRoot = testProjectDir.root.toPath() - - testDataRoot.resolve("app").copy(tmpRoot.resolve("app")) - testDataRoot.resolve("build.gradle").copy(tmpRoot.resolve("build.gradle")) - testDataRoot.resolve("settings.gradle").copy(tmpRoot.resolve("settings.gradle")) - - androidLocalProperties?.copy(tmpRoot.resolve("local.properties")) - } - - private fun doTest(gradleVersion: String, kotlinVersion: String, androidPluginParams: AndroidPluginParams) { - prepareTestData("androidMultiFlavourApp") - - val result = configure(gradleVersion, kotlinVersion, - arguments = arrayOf("dokka", "dokkaFullFlavourOnly", "--stacktrace") + androidPluginParams.asArguments()) - .build() - - println(result.output) - - assertEquals(TaskOutcome.SUCCESS, result.task(":app:dokka")?.outcome) - assertEquals(TaskOutcome.SUCCESS, result.task(":app:dokkaFullFlavourOnly")?.outcome) - - val docsOutput = "app/build/dokka" - - checkOutputStructure("androidMultiFlavourApp/fileTree.txt", docsOutput) - - checkNoErrorClasses(docsOutput) - checkNoUnresolvedLinks(docsOutput) - - checkExternalLink(docsOutput, "<span class=\"identifier\">Activity</span>", - """<a href="https://developer.android.com/reference/android/app/Activity.html"><span class="identifier">Activity</span></a>""") - } - - @Test fun `test kotlin 1_1_2-5 and gradle 4_0 and abt 3_0_0-alpha3`() { - doTest("4.0", "1.1.2-5", AndroidPluginParams("3.0.0-alpha3", "25.0.2", 25)) - } - - @Test fun `test kotlin 1_1_2 and gradle 3_5 and abt 2_3_0`() { - doTest("3.5", "1.1.2", AndroidPluginParams("2.3.0", "25.0.0", 24)) - } - - @Test fun `test kotlin 1_0_7 and gradle 2_14_1 and abt 2_2_3`() { - doTest("2.14.1", "1.0.7", AndroidPluginParams("2.2.3", "25.0.0", 24)) - } - - @Test fun `test kotlin 1_2_20 and gradle 4_5 and abt 3_0_1`() { - doTest("4.5", "1.2.20", AndroidPluginParams("3.0.1", "27.0.0", 27)) - } - -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/BasicTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/BasicTest.kt deleted file mode 100644 index 2e1a0d41..00000000 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/BasicTest.kt +++ /dev/null @@ -1,51 +0,0 @@ -package org.jetbrains.dokka.gradle - -import org.gradle.testkit.runner.TaskOutcome -import org.junit.Test -import kotlin.test.assertEquals - -class BasicTest : AbstractDokkaGradleTest() { - - fun prepareTestData(testDataRootPath: String) { - val testDataRoot = testDataFolder.resolve(testDataRootPath) - val tmpRoot = testProjectDir.root.toPath() - - testDataRoot.resolve("src").copy(tmpRoot.resolve("src")) - testDataRoot.resolve("classDir").copy(tmpRoot.resolve("classDir")) - testDataRoot.resolve("build.gradle").copy(tmpRoot.resolve("build.gradle")) - testDataRoot.resolve("settings.gradle").copy(tmpRoot.resolve("settings.gradle")) - } - - private fun doTest(gradleVersion: String, kotlinVersion: String) { - - prepareTestData("basic") - - val result = configure(gradleVersion, kotlinVersion, arguments = arrayOf("dokka", "--stacktrace")).build() - - println(result.output) - - assertEquals(TaskOutcome.SUCCESS, result.task(":dokka")?.outcome) - - val docsOutput = "build/dokka" - - checkOutputStructure("basic/fileTree.txt", docsOutput) - - checkNoErrorClasses(docsOutput) - checkNoUnresolvedLinks(docsOutput) - - checkExternalLink(docsOutput, "<span class=\"identifier\">String</span>", - """<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html"><span class="identifier">String</span></a>""") - } - - @Test fun `test kotlin 1_0_7 and gradle 2_14_1`() { - doTest("2.14.1", "1.0.7") - } - - @Test fun `test kotlin 1_1_2 and gradle 4_0`() { - doTest("4.0", "1.1.2") - } - - @Test fun `test kotlin 1_2_20 and gradle 4_5`() { - doTest("4.5", "1.2.20") - } -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/JavadocRSuppressionTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/JavadocRSuppressionTest.kt deleted file mode 100644 index 3a4d08b8..00000000 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/JavadocRSuppressionTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package org.jetbrains.dokka.gradle - -import org.junit.Test - -class JavadocRSuppressionTest : AbstractAndroidAppTest("androidAppJavadoc") { - @Test - fun `test kotlin 1_1_2-5 and gradle 4_0 and abt 3_0_0-alpha3`() { - doTest("4.0", "1.1.2-5", AndroidPluginParams("3.0.0-alpha3", "25.0.2", 25)) - } - - @Test - fun `test kotlin 1_1_2 and gradle 3_5 and abt 2_3_0`() { - doTest("3.5", "1.1.2", AndroidPluginParams("2.3.0", "25.0.0", 24)) - } - - @Test - fun `test kotlin 1_0_7 and gradle 2_14_1 and abt 2_2_3`() { - doTest("2.14.1", "1.0.7", AndroidPluginParams("2.2.3", "25.0.0", 24)) - } - - @Test fun `test kotlin 1_2_20 and gradle 4_5 and abt 3_0_1`() { - doTest("4.5", "1.2.20", AndroidPluginParams("3.0.1", "27.0.0", 27)) - } -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/MultiProjectSingleOutTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/MultiProjectSingleOutTest.kt deleted file mode 100644 index 9458528c..00000000 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/MultiProjectSingleOutTest.kt +++ /dev/null @@ -1,57 +0,0 @@ -package org.jetbrains.dokka.gradle - -import org.gradle.testkit.runner.TaskOutcome -import org.junit.Test -import kotlin.test.assertEquals - -class MultiProjectSingleOutTest : AbstractDokkaGradleTest() { - - fun prepareTestData(testDataRootPath: String) { - val testDataRoot = testDataFolder.resolve(testDataRootPath) - val tmpRoot = testProjectDir.root.toPath() - - testDataRoot.apply { - resolve("build.gradle").copy(tmpRoot.resolve("build.gradle")) - resolve("settings.gradle").copy(tmpRoot.resolve("settings.gradle")) - resolve("subA").copy(tmpRoot.resolve("subA")) - resolve("subB").copy(tmpRoot.resolve("subB")) - } - } - - private fun doTest(gradleVersion: String, kotlinVersion: String) { - - prepareTestData("multiProjectSingleOut") - - val result = configure(gradleVersion, kotlinVersion, arguments = arrayOf("dokka", "--stacktrace")).build() - - println(result.output) - - assertEquals(TaskOutcome.SUCCESS, result.task(":dokka")?.outcome) - - val docsOutput = "build/dokka" - - checkOutputStructure("multiProjectSingleOut/fileTree.txt", docsOutput) - - checkNoErrorClasses(docsOutput) - checkNoUnresolvedLinks(docsOutput) - - checkExternalLink(docsOutput, "<span class=\"identifier\">String</span>", - """<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html"><span class="identifier">String</span></a>""") - } - - @Test fun `test kotlin 1_1_2 and gradle 3_5`() { - doTest("3.5", "1.1.2") - } - - @Test fun `test kotlin 1_0_7 and gradle 2_14_1`() { - doTest("2.14.1", "1.0.7") - } - - @Test fun `test kotlin 1_1_2 and gradle 4_0`() { - doTest("4.0", "1.1.2") - } - - @Test fun `test kotlin 1_2_20 and gradle 4_5`() { - doTest("4.5", "1.2.20") - } -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/MultiplatformProjectTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/MultiplatformProjectTest.kt deleted file mode 100644 index 6ab9fd52..00000000 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/MultiplatformProjectTest.kt +++ /dev/null @@ -1,54 +0,0 @@ -package org.jetbrains.dokka.gradle - -import org.gradle.testkit.runner.TaskOutcome -import org.junit.Test -import java.io.File -import kotlin.test.assertEquals - -class MultiplatformProjectTest : AbstractDokkaGradleTest() { - - fun prepareTestData(testDataRootPath: String) { - val testDataRoot = testDataFolder.resolve(testDataRootPath) - val tmpRoot = testProjectDir.root.toPath() - - testDataRoot.apply { - resolve("build.gradle").copy(tmpRoot.resolve("build.gradle")) - resolve("settings.gradle").copy(tmpRoot.resolve("settings.gradle")) - resolve("src").copy(tmpRoot.resolve("src")) - } - } - - private fun doTest(gradleVersion: String, kotlinVersion: String) { - val kotlinGradlePlugin = pluginClasspathData.resolveSibling("kotlin-gradle.txt").toFile().readLines().map { File(it) } - prepareTestData("multiplatformProject") - - // Remove withDebug(false) when https://github.com/gradle/gradle/issues/6862 is solved - val result = configure(gradleVersion, kotlinVersion, arguments = arrayOf("dokka", "--stacktrace")) - .withDebug(false) - .withPluginClasspath(pluginClasspath.union(kotlinGradlePlugin)) - .build() - - println(result.output) - - assertEquals(TaskOutcome.SUCCESS, result.task(":dokka")?.outcome) - - val docsOutput = "build/dokka" - - checkOutputStructure("multiplatformProject/fileTree.txt", docsOutput) - - checkNoErrorClasses(docsOutput) - checkNoUnresolvedLinks(docsOutput) - } - - @Test fun `test kotlin 1_3_30 and gradle 4_9`() { - doTest("4.9", "1.3.30") - } - - @Test fun `test kotlin 1_3_40 and gradle 4_10_3`() { - doTest("4.10.3", "1.3.40") - } - - @Test fun `test kotlin 1_3_40 and gradle 5_6_1`() { - doTest("5.6.1", "1.3.50") - } -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt deleted file mode 100644 index 8b2db560..00000000 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt +++ /dev/null @@ -1,74 +0,0 @@ -package org.jetbrains.dokka.gradle - -import org.gradle.testkit.runner.TaskOutcome -import org.junit.Test -import java.nio.file.Path -import kotlin.test.assertEquals - -class RebuildAfterSourceChangeTest : AbstractDokkaGradleTest() { - - fun prepareTestData(testDataRootPath: String): Pair<Path, Path> { - val testDataRoot = testDataFolder.resolve(testDataRootPath) - val tmpRoot = testProjectDir.root.toPath() - - testDataRoot.resolve("src").copy(tmpRoot.resolve("src")) - testDataRoot.resolve("build.gradle").copy(tmpRoot.resolve("build.gradle")) - testDataRoot.resolve("settings.gradle").copy(tmpRoot.resolve("settings.gradle")) - - return testDataRoot to tmpRoot - } - - private fun doTest(gradleVersion: String, kotlinVersion: String) { - - val (testDataRoot, tmpRoot) = prepareTestData("sourcesChange") - val docsOutput = "build/dokka" - - configure(gradleVersion, kotlinVersion, arguments = arrayOf("dokka", "--stacktrace")).build().let { result -> - println(result.output) - - assertEquals(TaskOutcome.SUCCESS, result.task(":dokka")?.outcome) - } - - - configure(gradleVersion, kotlinVersion, arguments = arrayOf("dokka", "-i", "--stacktrace")).build().let { result -> - println(result.output) - - assertEquals(TaskOutcome.UP_TO_DATE, result.task(":dokka")?.outcome) - } - - checkOutputStructure("sourcesChange/fileTree.txt", docsOutput) - - testDataRoot.resolve("src1").copy(tmpRoot.resolve("src")) - - configure(gradleVersion, kotlinVersion, arguments = arrayOf("dokka", "--stacktrace")).build().let { result -> - println(result.output) - - assertEquals(TaskOutcome.SUCCESS, result.task(":dokka")?.outcome) - } - - - checkOutputStructure("sourcesChange/fileTree1.txt", docsOutput) - - } - - - @Test - fun `test kotlin 1_0_7 and gradle 2_14_1`() { - doTest("2.14.1", "1.0.7") - } - - @Test - fun `test kotlin 1_1_2 and gradle 3_5`() { - doTest("3.5", "1.1.2") - } - - @Test - fun `test kotlin 1_1_2 and gradle 4_0`() { - doTest("4.0", "1.1.2") - } - - @Test - fun `test kotlin 1_2_20 and gradle 4_5`() { - doTest("4.5", "1.2.20") - } -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/TypeSafeConfigurationTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/TypeSafeConfigurationTest.kt deleted file mode 100644 index 7b179e92..00000000 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/TypeSafeConfigurationTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -package org.jetbrains.dokka.gradle - -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.Parameterized - -@RunWith(Parameterized::class) -class TypeSafeConfigurationTest(private val testCase: TestCase) : AbstractDokkaGradleTest() { - - data class TestCase(val gradleVersion: String, val kotlinVersion: String) { - override fun toString(): String = "Gradle $gradleVersion and Kotlin $kotlinVersion" - } - - companion object { - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun testCases() = listOf( - TestCase("4.0", "1.1.2"), - TestCase("4.5", "1.2.20"), - TestCase("4.10.1", "1.2.60") - ) - } - - @Test - fun test() { - - testDataFolder.resolve("typeSafeConfiguration").toFile() - .copyRecursively(testProjectDir.root) - - configure( - testCase.gradleVersion, - testCase.kotlinVersion, - arguments = arrayOf("help", "-s") - ).build() - } -} diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/Utils.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/Utils.kt deleted file mode 100644 index 6f17af22..00000000 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/Utils.kt +++ /dev/null @@ -1,56 +0,0 @@ -package org.jetbrains.dokka.gradle - -import com.intellij.rt.execution.junit.FileComparisonFailure -import java.io.File -import java.io.IOException -import java.nio.file.* -import java.nio.file.attribute.BasicFileAttributes - - -fun File.writeStructure(builder: StringBuilder, relativeTo: File = this, spaces: Int = 0) { - builder.append(" ".repeat(spaces)) - val out = if (this != relativeTo) this.relativeTo(relativeTo) else this - - builder.append(out) - if (this.isDirectory) { - builder.appendln("/") - this.listFiles().sortedBy { it.name }.forEach { it.writeStructure(builder, this, spaces + 4) } - } else { - builder.appendln() - } -} - -fun assertEqualsIgnoringSeparators(expectedFile: File, output: String) { - if (!expectedFile.exists()) expectedFile.createNewFile() - val expectedText = expectedFile.readText().replace("\r\n", "\n") - val actualText = output.replace("\r\n", "\n") - - if (expectedText != actualText) - throw FileComparisonFailure("", expectedText, actualText, expectedFile.canonicalPath) -} - -class CopyFileVisitor(private var sourcePath: Path?, private val targetPath: Path) : SimpleFileVisitor<Path>() { - - @Throws(IOException::class) - override fun preVisitDirectory(dir: Path, - attrs: BasicFileAttributes): FileVisitResult { - if (sourcePath == null) { - sourcePath = dir - } else { - Files.createDirectories(targetPath.resolve(sourcePath?.relativize(dir))) - } - return FileVisitResult.CONTINUE - } - - @Throws(IOException::class) - override fun visitFile(file: Path, - attrs: BasicFileAttributes): FileVisitResult { - Files.copy(file, targetPath.resolve(sourcePath?.relativize(file)), StandardCopyOption.REPLACE_EXISTING) - return FileVisitResult.CONTINUE - } -} - -fun Path.copy(to: Path) { - Files.walkFileTree(this, CopyFileVisitor(this, to)) -} - diff --git a/runners/gradle-integration-tests/testData/androidApp/app/build.gradle b/runners/gradle-integration-tests/testData/androidApp/app/build.gradle deleted file mode 100644 index 2420107c..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/app/build.gradle +++ /dev/null @@ -1,45 +0,0 @@ -buildscript { - repositories { - jcenter() - mavenLocal() - } - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$test_kotlin_version" - } -} - -plugins { - id 'org.jetbrains.dokka' -} - - -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' - -android { - compileSdkVersion Integer.parseInt(sdk_version) - buildToolsVersion abt_version - - defaultConfig { - applicationId "org.example.kotlin.mixed" - minSdkVersion 14 - targetSdkVersion Integer.parseInt(sdk_version) - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt') - } - } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } -} - -dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$test_kotlin_version" - dokkaRuntime files(dokka_fatjar) -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/androidApp/app/src/main/AndroidManifest.xml b/runners/gradle-integration-tests/testData/androidApp/app/src/main/AndroidManifest.xml deleted file mode 100644 index b4e1a892..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="org.example.kotlin.mixed" > - - <application - android:allowBackup="true" - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" - android:theme="@style/AppTheme" > - - <activity - android:name=".JavaActivity" - android:label="@string/title_activity_main_activity1" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - - <activity - android:name=".KotlinActivity" - android:label="@string/title_activity_main_activity2" /> - - </application> - -</manifest> diff --git a/runners/gradle-integration-tests/testData/androidApp/app/src/main/java/org/example/kotlin/mixed/JavaActivity.java b/runners/gradle-integration-tests/testData/androidApp/app/src/main/java/org/example/kotlin/mixed/JavaActivity.java deleted file mode 100644 index 3668c594..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/app/src/main/java/org/example/kotlin/mixed/JavaActivity.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.example.kotlin.mixed; - -import android.content.Intent; -import android.os.Bundle; -import android.app.Activity; -import android.view.Menu; -import android.view.View; -import android.widget.Button; - -public class JavaActivity extends Activity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Button next = (Button) findViewById(R.id.Button01); - next.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - Intent myIntent = new Intent(view.getContext(), KotlinActivity.class); - startActivityForResult(myIntent, 0); - } - }); - } - - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.main, menu); - return true; - } - -} diff --git a/runners/gradle-integration-tests/testData/androidApp/app/src/main/kotlin/org/example/kotlin/mixed/KotlinActivity.kt b/runners/gradle-integration-tests/testData/androidApp/app/src/main/kotlin/org/example/kotlin/mixed/KotlinActivity.kt deleted file mode 100644 index ca2f27b0..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/app/src/main/kotlin/org/example/kotlin/mixed/KotlinActivity.kt +++ /dev/null @@ -1,28 +0,0 @@ -package org.example.kotlin.mixed - -import android.content.Intent -import android.os.Bundle -import android.app.Activity -import android.view.Menu -import android.widget.Button - -class KotlinActivity : Activity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main2) - - val next = findViewById(R.id.Button02) as Button - next.setOnClickListener { - val intent: Intent = Intent() - setResult(RESULT_OK, intent) - finish() - } - } - - override fun onCreateOptionsMenu(menu: Menu?): Boolean { - // Inflate the menu; this adds items to the action bar if it is present. - menuInflater.inflate(R.menu.main_activity2, menu) - return true - } -} diff --git a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/drawable-hdpi/ic_launcher.png b/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/drawable-hdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 96a442e5..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/drawable-hdpi/ic_launcher.png +++ /dev/null diff --git a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/drawable-mdpi/ic_launcher.png b/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/drawable-mdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 359047df..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/drawable-mdpi/ic_launcher.png +++ /dev/null diff --git a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/drawable-xhdpi/ic_launcher.png b/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/drawable-xhdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 71c6d760..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/drawable-xhdpi/ic_launcher.png +++ /dev/null diff --git a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/layout/activity_main.xml b/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index ede57c39..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,24 +0,0 @@ -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" - android:paddingBottom="@dimen/activity_vertical_margin" - tools:context=".MainActivity"> - - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="Activity 1" /> - - <Button android:text="Next" - android:id="@+id/Button01" - android:layout_width="250px" - android:textSize="18px" - android:layout_height="55px"> - </Button> - -</LinearLayout> diff --git a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/layout/activity_main2.xml b/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/layout/activity_main2.xml deleted file mode 100644 index d707536a..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/layout/activity_main2.xml +++ /dev/null @@ -1,24 +0,0 @@ -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" - android:paddingBottom="@dimen/activity_vertical_margin" - tools:context=".MainActivity"> - - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="Activity 2" /> - - <Button android:text="Next" - android:id="@+id/Button02" - android:layout_width="250px" - android:textSize="18px" - android:layout_height="55px"> - </Button> - -</LinearLayout> diff --git a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/menu/main.xml b/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/menu/main.xml deleted file mode 100644 index f3b10b6c..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/menu/main.xml +++ /dev/null @@ -1,6 +0,0 @@ -<menu xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:id="@+id/action_settings" - android:title="@string/action_settings" - android:orderInCategory="100" - android:showAsAction="never" /> -</menu> diff --git a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/menu/main_activity2.xml b/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/menu/main_activity2.xml deleted file mode 100644 index f3b10b6c..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/menu/main_activity2.xml +++ /dev/null @@ -1,6 +0,0 @@ -<menu xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:id="@+id/action_settings" - android:title="@string/action_settings" - android:orderInCategory="100" - android:showAsAction="never" /> -</menu> diff --git a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/values/dimens.xml b/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/values/dimens.xml deleted file mode 100644 index 47c82246..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/values/dimens.xml +++ /dev/null @@ -1,5 +0,0 @@ -<resources> - <!-- Default screen margins, per the Android Design guidelines. --> - <dimen name="activity_horizontal_margin">16dp</dimen> - <dimen name="activity_vertical_margin">16dp</dimen> -</resources> diff --git a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/values/strings.xml b/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/values/strings.xml deleted file mode 100644 index d8f08bc2..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - - <string name="app_name">AndroidSample</string> - <string name="action_settings">Settings</string> - <string name="hello_world">Hello world!</string> - <string name="title_activity_main_activity1">JavaActivity</string> - <string name="title_activity_main_activity2">KotlinActivity</string> - -</resources> diff --git a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/values/styles.xml b/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/values/styles.xml deleted file mode 100644 index 6ce89c7b..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,20 +0,0 @@ -<resources> - - <!-- - Base application theme, dependent on API level. This theme is replaced - by AppBaseTheme from res/values-vXX/styles.xml on newer devices. - --> - <style name="AppBaseTheme" parent="android:Theme.Light"> - <!-- - Theme customizations available in newer API levels can go in - res/values-vXX/styles.xml, while customizations related to - backward-compatibility can go here. - --> - </style> - - <!-- Application theme. --> - <style name="AppTheme" parent="AppBaseTheme"> - <!-- All customizations that are NOT specific to a particular API-level can go here. --> - </style> - -</resources> diff --git a/runners/gradle-integration-tests/testData/androidApp/build.gradle b/runners/gradle-integration-tests/testData/androidApp/build.gradle deleted file mode 100644 index 35356b90..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/build.gradle +++ /dev/null @@ -1,21 +0,0 @@ -buildscript { - repositories { - mavenCentral() - jcenter() - maven { url 'https://maven.google.com' } - maven { url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } - } - dependencies { - classpath "com.android.tools.build:gradle:$abt_plugin_version" - } -} - -allprojects { - repositories { - mavenCentral() - jcenter() - maven { url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } - } -} diff --git a/runners/gradle-integration-tests/testData/androidApp/fileTree.txt b/runners/gradle-integration-tests/testData/androidApp/fileTree.txt deleted file mode 100644 index f66c79e3..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/fileTree.txt +++ /dev/null @@ -1,20 +0,0 @@ -/ - app/ - alltypes/ - index.html - index-outline.html - index.html - org.example.kotlin.mixed/ - -java-activity/ - -init-.html - index.html - on-create-options-menu.html - on-create.html - -kotlin-activity/ - -init-.html - index.html - on-create-options-menu.html - on-create.html - index.html - package-list - style.css diff --git a/runners/gradle-integration-tests/testData/androidApp/settings.gradle b/runners/gradle-integration-tests/testData/androidApp/settings.gradle deleted file mode 100644 index 1feb2867..00000000 --- a/runners/gradle-integration-tests/testData/androidApp/settings.gradle +++ /dev/null @@ -1,3 +0,0 @@ -rootProject.name = "androidApp" - -include ':app'
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/build.gradle b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/build.gradle deleted file mode 100644 index 66421f52..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/build.gradle +++ /dev/null @@ -1,49 +0,0 @@ -buildscript { - repositories { - jcenter() - mavenLocal() - } - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$test_kotlin_version" - } -} - -plugins { - id 'org.jetbrains.dokka' -} - - -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' - -android { - compileSdkVersion Integer.parseInt(sdk_version) - buildToolsVersion abt_version - - defaultConfig { - applicationId "org.example.kotlin.mixed" - minSdkVersion 14 - targetSdkVersion Integer.parseInt(sdk_version) - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt') - } - } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } -} - -dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$test_kotlin_version" - dokkaRuntime files(dokka_fatjar) -} - - -dokka { - outputFormat = "javadoc" -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/AndroidManifest.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/AndroidManifest.xml deleted file mode 100644 index b4e1a892..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="org.example.kotlin.mixed" > - - <application - android:allowBackup="true" - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" - android:theme="@style/AppTheme" > - - <activity - android:name=".JavaActivity" - android:label="@string/title_activity_main_activity1" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - - <activity - android:name=".KotlinActivity" - android:label="@string/title_activity_main_activity2" /> - - </application> - -</manifest> diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/java/org/example/kotlin/mixed/JavaActivity.java b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/java/org/example/kotlin/mixed/JavaActivity.java deleted file mode 100644 index 3668c594..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/java/org/example/kotlin/mixed/JavaActivity.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.example.kotlin.mixed; - -import android.content.Intent; -import android.os.Bundle; -import android.app.Activity; -import android.view.Menu; -import android.view.View; -import android.widget.Button; - -public class JavaActivity extends Activity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Button next = (Button) findViewById(R.id.Button01); - next.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - Intent myIntent = new Intent(view.getContext(), KotlinActivity.class); - startActivityForResult(myIntent, 0); - } - }); - } - - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.main, menu); - return true; - } - -} diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/kotlin/org/example/kotlin/mixed/KotlinActivity.kt b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/kotlin/org/example/kotlin/mixed/KotlinActivity.kt deleted file mode 100644 index ca2f27b0..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/kotlin/org/example/kotlin/mixed/KotlinActivity.kt +++ /dev/null @@ -1,28 +0,0 @@ -package org.example.kotlin.mixed - -import android.content.Intent -import android.os.Bundle -import android.app.Activity -import android.view.Menu -import android.widget.Button - -class KotlinActivity : Activity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main2) - - val next = findViewById(R.id.Button02) as Button - next.setOnClickListener { - val intent: Intent = Intent() - setResult(RESULT_OK, intent) - finish() - } - } - - override fun onCreateOptionsMenu(menu: Menu?): Boolean { - // Inflate the menu; this adds items to the action bar if it is present. - menuInflater.inflate(R.menu.main_activity2, menu) - return true - } -} diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-hdpi/ic_launcher.png b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-hdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 96a442e5..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-hdpi/ic_launcher.png +++ /dev/null diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-mdpi/ic_launcher.png b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-mdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 359047df..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-mdpi/ic_launcher.png +++ /dev/null diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-xhdpi/ic_launcher.png b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-xhdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 71c6d760..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-xhdpi/ic_launcher.png +++ /dev/null diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/layout/activity_main.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index ede57c39..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,24 +0,0 @@ -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" - android:paddingBottom="@dimen/activity_vertical_margin" - tools:context=".MainActivity"> - - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="Activity 1" /> - - <Button android:text="Next" - android:id="@+id/Button01" - android:layout_width="250px" - android:textSize="18px" - android:layout_height="55px"> - </Button> - -</LinearLayout> diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/layout/activity_main2.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/layout/activity_main2.xml deleted file mode 100644 index d707536a..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/layout/activity_main2.xml +++ /dev/null @@ -1,24 +0,0 @@ -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" - android:paddingBottom="@dimen/activity_vertical_margin" - tools:context=".MainActivity"> - - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="Activity 2" /> - - <Button android:text="Next" - android:id="@+id/Button02" - android:layout_width="250px" - android:textSize="18px" - android:layout_height="55px"> - </Button> - -</LinearLayout> diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/menu/main.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/menu/main.xml deleted file mode 100644 index f3b10b6c..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/menu/main.xml +++ /dev/null @@ -1,6 +0,0 @@ -<menu xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:id="@+id/action_settings" - android:title="@string/action_settings" - android:orderInCategory="100" - android:showAsAction="never" /> -</menu> diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/menu/main_activity2.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/menu/main_activity2.xml deleted file mode 100644 index f3b10b6c..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/menu/main_activity2.xml +++ /dev/null @@ -1,6 +0,0 @@ -<menu xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:id="@+id/action_settings" - android:title="@string/action_settings" - android:orderInCategory="100" - android:showAsAction="never" /> -</menu> diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/dimens.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/dimens.xml deleted file mode 100644 index 47c82246..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/dimens.xml +++ /dev/null @@ -1,5 +0,0 @@ -<resources> - <!-- Default screen margins, per the Android Design guidelines. --> - <dimen name="activity_horizontal_margin">16dp</dimen> - <dimen name="activity_vertical_margin">16dp</dimen> -</resources> diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/strings.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/strings.xml deleted file mode 100644 index d8f08bc2..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - - <string name="app_name">AndroidSample</string> - <string name="action_settings">Settings</string> - <string name="hello_world">Hello world!</string> - <string name="title_activity_main_activity1">JavaActivity</string> - <string name="title_activity_main_activity2">KotlinActivity</string> - -</resources> diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/styles.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/styles.xml deleted file mode 100644 index 6ce89c7b..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,20 +0,0 @@ -<resources> - - <!-- - Base application theme, dependent on API level. This theme is replaced - by AppBaseTheme from res/values-vXX/styles.xml on newer devices. - --> - <style name="AppBaseTheme" parent="android:Theme.Light"> - <!-- - Theme customizations available in newer API levels can go in - res/values-vXX/styles.xml, while customizations related to - backward-compatibility can go here. - --> - </style> - - <!-- Application theme. --> - <style name="AppTheme" parent="AppBaseTheme"> - <!-- All customizations that are NOT specific to a particular API-level can go here. --> - </style> - -</resources> diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/build.gradle b/runners/gradle-integration-tests/testData/androidAppJavadoc/build.gradle deleted file mode 100644 index 35356b90..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/build.gradle +++ /dev/null @@ -1,21 +0,0 @@ -buildscript { - repositories { - mavenCentral() - jcenter() - maven { url 'https://maven.google.com' } - maven { url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } - } - dependencies { - classpath "com.android.tools.build:gradle:$abt_plugin_version" - } -} - -allprojects { - repositories { - mavenCentral() - jcenter() - maven { url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } - } -} diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/fileTree.txt b/runners/gradle-integration-tests/testData/androidAppJavadoc/fileTree.txt deleted file mode 100644 index c5e79eba..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/fileTree.txt +++ /dev/null @@ -1,21 +0,0 @@ -/ - allclasses-frame.html - allclasses-noframe.html - constant-values.html - deprecated-list.html - help-doc.html - index-all.html - index.html - org/ - example/ - kotlin/ - mixed/ - JavaActivity.html - KotlinActivity.html - package-frame.html - package-summary.html - package-tree.html - overview-tree.html - package-list - script.js - stylesheet.css diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/settings.gradle b/runners/gradle-integration-tests/testData/androidAppJavadoc/settings.gradle deleted file mode 100644 index a4e67fea..00000000 --- a/runners/gradle-integration-tests/testData/androidAppJavadoc/settings.gradle +++ /dev/null @@ -1,3 +0,0 @@ -rootProject.name = "androidAppJavadoc" - -include ':app'
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/build.gradle b/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/build.gradle deleted file mode 100644 index 736668ab..00000000 --- a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/build.gradle +++ /dev/null @@ -1,20 +0,0 @@ -subprojects { - buildscript { - repositories { - mavenCentral() - jcenter() - maven { url 'https://maven.google.com' } - maven { url "https://dl.bintray.com/kotlin/kotlin-eap/" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } - } - - } - - repositories { - mavenCentral() - jcenter() - maven { url 'https://maven.google.com' } - maven { url "https://dl.bintray.com/kotlin/kotlin-eap/" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } - } -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/fileTree.txt b/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/fileTree.txt deleted file mode 100644 index 6c96a01c..00000000 --- a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/fileTree.txt +++ /dev/null @@ -1,14 +0,0 @@ -/ - lib/ - alltypes/ - index.html - example/ - -lib-clz-use/ - -init-.html - f.html - index.html - index.html - index-outline.html - index.html - package-list - style.css diff --git a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/jlib/build.gradle b/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/jlib/build.gradle deleted file mode 100644 index bbfeb03c..00000000 --- a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/jlib/build.gradle +++ /dev/null @@ -1 +0,0 @@ -apply plugin: 'java' diff --git a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/jlib/src/main/java/example/jlib/LibClz.java b/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/jlib/src/main/java/example/jlib/LibClz.java deleted file mode 100644 index 1d9a6fb2..00000000 --- a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/jlib/src/main/java/example/jlib/LibClz.java +++ /dev/null @@ -1,5 +0,0 @@ -package example.jlib; - -public class LibClz { - -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/lib/build.gradle b/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/lib/build.gradle deleted file mode 100644 index b1ee52ab..00000000 --- a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/lib/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -buildscript { - dependencies { - classpath "com.android.tools.build:gradle:$abt_plugin_version" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$test_kotlin_version" - } -} - - -plugins { - id 'org.jetbrains.dokka' -} - - -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' - - -android { - compileSdkVersion Integer.parseInt(sdk_version) - buildToolsVersion abt_version - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } -} - -dependencies { - api(project(":jlib")) - dokkaRuntime files(dokka_fatjar) -} - -dokka { - configuration { - externalDocumentationLink { - url = new URL("https://example.com") - packageListUrl = file("$rootDir/package-list").toURI().toURL() - } - } -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/lib/src/main/AndroidManifest.xml b/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/lib/src/main/AndroidManifest.xml deleted file mode 100644 index 267f6efd..00000000 --- a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/lib/src/main/AndroidManifest.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="example"> -</manifest> diff --git a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/lib/src/main/kotlin/example/LibClzUse.kt b/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/lib/src/main/kotlin/example/LibClzUse.kt deleted file mode 100644 index d034a3a9..00000000 --- a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/lib/src/main/kotlin/example/LibClzUse.kt +++ /dev/null @@ -1,13 +0,0 @@ -package example - -import example.jlib.LibClz - -/** - * Uses jlib - */ -class LibClzUse { - /** - * Returns LibClz - */ - fun f(): LibClz = LibClz() -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/package-list b/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/package-list deleted file mode 100644 index bf76058e..00000000 --- a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/package-list +++ /dev/null @@ -1 +0,0 @@ -example.jlib
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/settings.gradle b/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/settings.gradle deleted file mode 100644 index 5b4250a0..00000000 --- a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/settings.gradle +++ /dev/null @@ -1,5 +0,0 @@ -rootProject.name = "androidLibDependsOnJavaLib" - - -include(":lib") -include(":jlib")
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/build.gradle b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/build.gradle deleted file mode 100644 index 660257ab..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/build.gradle +++ /dev/null @@ -1,75 +0,0 @@ -buildscript { - repositories { - jcenter() - mavenLocal() - } - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$test_kotlin_version" - } -} - -plugins { - id 'org.jetbrains.dokka' -} - - -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' - -android { - compileSdkVersion Integer.parseInt(sdk_version) - buildToolsVersion abt_version - - defaultConfig { - applicationId "org.example.kotlin.mixed" - minSdkVersion 14 - targetSdkVersion Integer.parseInt(sdk_version) - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt') - } - } - - flavorDimensions "mode" - productFlavors { - free { - dimension "mode" - applicationIdSuffix ".free" - versionNameSuffix "-free" - } - full { - dimension "mode" - applicationIdSuffix ".full" - versionNameSuffix "-full" - } - } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - free.java.srcDirs += 'src/free/kotlin' - } -} - -dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$test_kotlin_version" - dokkaRuntime files(dokka_fatjar) -} - - -dokka { - outputDirectory = "$buildDir/dokka/all" -} - -task dokkaFullFlavourOnly(type: org.jetbrains.dokka.gradle.DokkaTask) { - outputDirectory = "$buildDir/dokka/fullOnly" - configuration { - moduleName = "full" - kotlinTasks { - ["compileFullReleaseKotlin"] - } - } -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/free/AndroidManifest.xml b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/free/AndroidManifest.xml deleted file mode 100644 index 3ecbcd3a..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/free/AndroidManifest.xml +++ /dev/null @@ -1,9 +0,0 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android"> - - <application> - <activity - android:name="org.example.kotlin.mixed.free.AdActivity" - android:label="@string/title_activity_ad" - android:theme="@style/AppTheme"></activity> - </application> -</manifest> diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/free/kotlin/org/example/kotlin/mixed/free/AdActivity.kt b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/free/kotlin/org/example/kotlin/mixed/free/AdActivity.kt deleted file mode 100644 index b0b980fd..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/free/kotlin/org/example/kotlin/mixed/free/AdActivity.kt +++ /dev/null @@ -1,14 +0,0 @@ -package org.example.kotlin.mixed.free - -import android.os.Bundle -import android.app.Activity -import org.example.kotlin.mixed.R - -class AdActivity : Activity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_ad) - } - -} diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/free/res/layout/activity_ad.xml b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/free/res/layout/activity_ad.xml deleted file mode 100644 index e6443d05..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/free/res/layout/activity_ad.xml +++ /dev/null @@ -1,24 +0,0 @@ -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" - android:paddingBottom="@dimen/activity_vertical_margin" - tools:context=".free.AdActivity"> - - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="Advertisment" /> - - <Button android:text="Next" - android:id="@+id/Button02" - android:layout_width="250px" - android:textSize="18px" - android:layout_height="55px"> - </Button> - -</LinearLayout> diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/free/res/values/strings.xml b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/free/res/values/strings.xml deleted file mode 100644 index bbdf2d06..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/free/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ -<resources> - <string name="title_activity_ad">AdActivity</string> -</resources> diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/AndroidManifest.xml b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/AndroidManifest.xml deleted file mode 100644 index b4e1a892..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="org.example.kotlin.mixed" > - - <application - android:allowBackup="true" - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" - android:theme="@style/AppTheme" > - - <activity - android:name=".JavaActivity" - android:label="@string/title_activity_main_activity1" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - - <activity - android:name=".KotlinActivity" - android:label="@string/title_activity_main_activity2" /> - - </application> - -</manifest> diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/java/org/example/kotlin/mixed/JavaActivity.java b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/java/org/example/kotlin/mixed/JavaActivity.java deleted file mode 100644 index 3668c594..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/java/org/example/kotlin/mixed/JavaActivity.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.example.kotlin.mixed; - -import android.content.Intent; -import android.os.Bundle; -import android.app.Activity; -import android.view.Menu; -import android.view.View; -import android.widget.Button; - -public class JavaActivity extends Activity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Button next = (Button) findViewById(R.id.Button01); - next.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - Intent myIntent = new Intent(view.getContext(), KotlinActivity.class); - startActivityForResult(myIntent, 0); - } - }); - } - - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.main, menu); - return true; - } - -} diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/kotlin/org/example/kotlin/mixed/KotlinActivity.kt b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/kotlin/org/example/kotlin/mixed/KotlinActivity.kt deleted file mode 100644 index ca2f27b0..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/kotlin/org/example/kotlin/mixed/KotlinActivity.kt +++ /dev/null @@ -1,28 +0,0 @@ -package org.example.kotlin.mixed - -import android.content.Intent -import android.os.Bundle -import android.app.Activity -import android.view.Menu -import android.widget.Button - -class KotlinActivity : Activity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main2) - - val next = findViewById(R.id.Button02) as Button - next.setOnClickListener { - val intent: Intent = Intent() - setResult(RESULT_OK, intent) - finish() - } - } - - override fun onCreateOptionsMenu(menu: Menu?): Boolean { - // Inflate the menu; this adds items to the action bar if it is present. - menuInflater.inflate(R.menu.main_activity2, menu) - return true - } -} diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/drawable-hdpi/ic_launcher.png b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/drawable-hdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 96a442e5..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/drawable-hdpi/ic_launcher.png +++ /dev/null diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/drawable-mdpi/ic_launcher.png b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/drawable-mdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 359047df..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/drawable-mdpi/ic_launcher.png +++ /dev/null diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/drawable-xhdpi/ic_launcher.png b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/drawable-xhdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 71c6d760..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/drawable-xhdpi/ic_launcher.png +++ /dev/null diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/layout/activity_main.xml b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index ede57c39..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,24 +0,0 @@ -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" - android:paddingBottom="@dimen/activity_vertical_margin" - tools:context=".MainActivity"> - - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="Activity 1" /> - - <Button android:text="Next" - android:id="@+id/Button01" - android:layout_width="250px" - android:textSize="18px" - android:layout_height="55px"> - </Button> - -</LinearLayout> diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/layout/activity_main2.xml b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/layout/activity_main2.xml deleted file mode 100644 index d707536a..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/layout/activity_main2.xml +++ /dev/null @@ -1,24 +0,0 @@ -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" - android:paddingBottom="@dimen/activity_vertical_margin" - tools:context=".MainActivity"> - - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="Activity 2" /> - - <Button android:text="Next" - android:id="@+id/Button02" - android:layout_width="250px" - android:textSize="18px" - android:layout_height="55px"> - </Button> - -</LinearLayout> diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/menu/main.xml b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/menu/main.xml deleted file mode 100644 index f3b10b6c..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/menu/main.xml +++ /dev/null @@ -1,6 +0,0 @@ -<menu xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:id="@+id/action_settings" - android:title="@string/action_settings" - android:orderInCategory="100" - android:showAsAction="never" /> -</menu> diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/menu/main_activity2.xml b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/menu/main_activity2.xml deleted file mode 100644 index f3b10b6c..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/menu/main_activity2.xml +++ /dev/null @@ -1,6 +0,0 @@ -<menu xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:id="@+id/action_settings" - android:title="@string/action_settings" - android:orderInCategory="100" - android:showAsAction="never" /> -</menu> diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/values/dimens.xml b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/values/dimens.xml deleted file mode 100644 index 47c82246..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/values/dimens.xml +++ /dev/null @@ -1,5 +0,0 @@ -<resources> - <!-- Default screen margins, per the Android Design guidelines. --> - <dimen name="activity_horizontal_margin">16dp</dimen> - <dimen name="activity_vertical_margin">16dp</dimen> -</resources> diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/values/strings.xml b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/values/strings.xml deleted file mode 100644 index d8f08bc2..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - - <string name="app_name">AndroidSample</string> - <string name="action_settings">Settings</string> - <string name="hello_world">Hello world!</string> - <string name="title_activity_main_activity1">JavaActivity</string> - <string name="title_activity_main_activity2">KotlinActivity</string> - -</resources> diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/values/styles.xml b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/values/styles.xml deleted file mode 100644 index 6ce89c7b..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,20 +0,0 @@ -<resources> - - <!-- - Base application theme, dependent on API level. This theme is replaced - by AppBaseTheme from res/values-vXX/styles.xml on newer devices. - --> - <style name="AppBaseTheme" parent="android:Theme.Light"> - <!-- - Theme customizations available in newer API levels can go in - res/values-vXX/styles.xml, while customizations related to - backward-compatibility can go here. - --> - </style> - - <!-- Application theme. --> - <style name="AppTheme" parent="AppBaseTheme"> - <!-- All customizations that are NOT specific to a particular API-level can go here. --> - </style> - -</resources> diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/build.gradle b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/build.gradle deleted file mode 100644 index 35356b90..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/build.gradle +++ /dev/null @@ -1,21 +0,0 @@ -buildscript { - repositories { - mavenCentral() - jcenter() - maven { url 'https://maven.google.com' } - maven { url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } - } - dependencies { - classpath "com.android.tools.build:gradle:$abt_plugin_version" - } -} - -allprojects { - repositories { - mavenCentral() - jcenter() - maven { url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } - } -} diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/fileTree.txt b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/fileTree.txt deleted file mode 100644 index 77b563b2..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/fileTree.txt +++ /dev/null @@ -1,47 +0,0 @@ -/ - all/ - app/ - alltypes/ - index.html - index-outline.html - index.html - org.example.kotlin.mixed/ - -java-activity/ - -init-.html - index.html - on-create-options-menu.html - on-create.html - -kotlin-activity/ - -init-.html - index.html - on-create-options-menu.html - on-create.html - index.html - org.example.kotlin.mixed.free/ - -ad-activity/ - -init-.html - index.html - on-create.html - index.html - package-list - style.css - fullOnly/ - full/ - alltypes/ - index.html - index-outline.html - index.html - org.example.kotlin.mixed/ - -java-activity/ - -init-.html - index.html - on-create-options-menu.html - on-create.html - -kotlin-activity/ - -init-.html - index.html - on-create-options-menu.html - on-create.html - index.html - package-list - style.css diff --git a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/settings.gradle b/runners/gradle-integration-tests/testData/androidMultiFlavourApp/settings.gradle deleted file mode 100644 index 1feb2867..00000000 --- a/runners/gradle-integration-tests/testData/androidMultiFlavourApp/settings.gradle +++ /dev/null @@ -1,3 +0,0 @@ -rootProject.name = "androidApp" - -include ':app'
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/basic/build.gradle b/runners/gradle-integration-tests/testData/basic/build.gradle deleted file mode 100644 index 79645204..00000000 --- a/runners/gradle-integration-tests/testData/basic/build.gradle +++ /dev/null @@ -1,42 +0,0 @@ -buildscript { - repositories { - mavenCentral() - jcenter() - maven { url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } - } - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$test_kotlin_version" - } -} - -plugins { - id 'org.jetbrains.dokka' -} - -apply plugin: 'kotlin' -apply plugin: 'org.jetbrains.dokka' - -repositories { - mavenCentral() - jcenter() - maven { - url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" - } - maven { - url "https://dl.bintray.com/kotlin/kotlin-dev" - } -} - -dependencies { - dokkaRuntime files(dokka_fatjar) - compile group: 'org.jetbrains.kotlin', name: 'kotlin-runtime', version: test_kotlin_version - compile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: test_kotlin_version -} - - -dokka { - configuration { - classpath += "$projectDir/classDir" - } -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/basic/classDir/p1/MyBinaryClass.class b/runners/gradle-integration-tests/testData/basic/classDir/p1/MyBinaryClass.class Binary files differdeleted file mode 100644 index ccfff300..00000000 --- a/runners/gradle-integration-tests/testData/basic/classDir/p1/MyBinaryClass.class +++ /dev/null diff --git a/runners/gradle-integration-tests/testData/basic/fileTree.txt b/runners/gradle-integration-tests/testData/basic/fileTree.txt deleted file mode 100644 index 2ceae371..00000000 --- a/runners/gradle-integration-tests/testData/basic/fileTree.txt +++ /dev/null @@ -1,33 +0,0 @@ -/ - basic/ - alltypes/ - index.html - demo/ - -a/ - -init-.html - index.html - p.html - -greeter/ - -init-.html - greet.html - index.html - name.html - -some-interface.html - -some-sub-type/ - -init-.html - index.html - -some-type/ - -init-.html - index.html - constructor.html - index.html - main.html - p1.-my-binary-class/ - index.html - test.html - str.html - x.html - index-outline.html - index.html - package-list - style.css diff --git a/runners/gradle-integration-tests/testData/basic/settings.gradle b/runners/gradle-integration-tests/testData/basic/settings.gradle deleted file mode 100644 index c36a146c..00000000 --- a/runners/gradle-integration-tests/testData/basic/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = "basic"
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/basic/src/main/kotlin/demo/HelloWorld.kt b/runners/gradle-integration-tests/testData/basic/src/main/kotlin/demo/HelloWorld.kt deleted file mode 100644 index 3d7bcb51..00000000 --- a/runners/gradle-integration-tests/testData/basic/src/main/kotlin/demo/HelloWorld.kt +++ /dev/null @@ -1,45 +0,0 @@ -package demo - -import p1.MyBinaryClass - -/** - * This class supports greeting people by name. - * - * @property name The name of the person to be greeted. - */ -class Greeter(val name: String) { - - /** - * Prints the greeting to the standard output. - */ - fun greet() { - println("Hello $name!") - } -} - -fun main(args: Array<String>) { - Greeter(args[0]).greet() -} - -val str = "Hello! ".repeat(4) -val x: (a: String, b: Int) -> Int = { a, b -> 0 } - -interface SomeInterface -private class SomeImpl : SomeInterface - -fun SomeInterface.constructor(): SomeInterface { - return SomeImpl() -} - -open class SomeType -class SomeSubType : SomeType() - -fun SomeType.constructor(): SomeType { - return SomeSubType() -} - - -annotation class A(val p: String) - -val MyBinaryClass.test get() = s() - diff --git a/runners/gradle-integration-tests/testData/multiProjectSingleOut/build.gradle b/runners/gradle-integration-tests/testData/multiProjectSingleOut/build.gradle deleted file mode 100644 index 0ea86d4c..00000000 --- a/runners/gradle-integration-tests/testData/multiProjectSingleOut/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -plugins { - id 'org.jetbrains.dokka' -} - -subprojects { - buildscript { - repositories { - mavenCentral() - jcenter() - maven { url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } - } - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$test_kotlin_version" - } - } - repositories { - mavenCentral() - jcenter() - maven { url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } - } -} - -dependencies { - dokkaRuntime files(dokka_fatjar) -} - -apply plugin: 'org.jetbrains.dokka' - -dokka { - configuration { - kotlinTasks { - [":subA:compileKotlin", ":subB:compileKotlin"] - } - } -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/multiProjectSingleOut/fileTree.txt b/runners/gradle-integration-tests/testData/multiProjectSingleOut/fileTree.txt deleted file mode 100644 index 5624fca6..00000000 --- a/runners/gradle-integration-tests/testData/multiProjectSingleOut/fileTree.txt +++ /dev/null @@ -1,33 +0,0 @@ -/ - multi-project-root/ - alltypes/ - index.html - index-outline.html - index.html - package-list - s1/ - -my-class/ - -init-.html - index.html - otherworks.html - -super/ - -init-.html - bar.html - foo.html - index.html - index.html - some-cool-thing.html - s2/ - -cooler/ - -init-.html - a.html - coolest.html - index.html - my-class.html - -superful/ - -init-.html - bar.html - index.html - index.html - main.html - style.css diff --git a/runners/gradle-integration-tests/testData/multiProjectSingleOut/settings.gradle b/runners/gradle-integration-tests/testData/multiProjectSingleOut/settings.gradle deleted file mode 100644 index 283cc526..00000000 --- a/runners/gradle-integration-tests/testData/multiProjectSingleOut/settings.gradle +++ /dev/null @@ -1,3 +0,0 @@ -rootProject.name = "multiProjectRoot" - -include 'subA', 'subB'
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/multiProjectSingleOut/subA/build.gradle b/runners/gradle-integration-tests/testData/multiProjectSingleOut/subA/build.gradle deleted file mode 100644 index 0600411e..00000000 --- a/runners/gradle-integration-tests/testData/multiProjectSingleOut/subA/build.gradle +++ /dev/null @@ -1,6 +0,0 @@ -apply plugin: 'kotlin' - -dependencies { - compile group: 'org.jetbrains.kotlin', name: 'kotlin-runtime', version: test_kotlin_version - compile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: test_kotlin_version -} diff --git a/runners/gradle-integration-tests/testData/multiProjectSingleOut/subA/src/main/kotlin/module.kt b/runners/gradle-integration-tests/testData/multiProjectSingleOut/subA/src/main/kotlin/module.kt deleted file mode 100644 index 126d7f3e..00000000 --- a/runners/gradle-integration-tests/testData/multiProjectSingleOut/subA/src/main/kotlin/module.kt +++ /dev/null @@ -1,31 +0,0 @@ -package s1 - -/** - * Coolest one - */ -fun someCoolThing(s: String) = s.repeat(2) - -/** - * Just a class - */ -class MyClass { - /** - * Ultimate answer to all questions - */ - fun otherworks(): Int = 42 -} - -/** - * Just a SUPER class - */ -open class Super { - /** - * Same as [MyClass.otherworks] - */ - fun foo(i: Int = 21) = i * 2 - - /** - * magic - */ - open fun bar() = foo() -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/multiProjectSingleOut/subB/build.gradle b/runners/gradle-integration-tests/testData/multiProjectSingleOut/subB/build.gradle deleted file mode 100644 index 7b8ff9f3..00000000 --- a/runners/gradle-integration-tests/testData/multiProjectSingleOut/subB/build.gradle +++ /dev/null @@ -1,7 +0,0 @@ -apply plugin: 'kotlin' - -dependencies { - compile group: 'org.jetbrains.kotlin', name: 'kotlin-runtime', version: test_kotlin_version - compile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: test_kotlin_version - compile project(":subA") -} diff --git a/runners/gradle-integration-tests/testData/multiProjectSingleOut/subB/src/main/kotlin/module.kt b/runners/gradle-integration-tests/testData/multiProjectSingleOut/subB/src/main/kotlin/module.kt deleted file mode 100644 index 8a87590a..00000000 --- a/runners/gradle-integration-tests/testData/multiProjectSingleOut/subB/src/main/kotlin/module.kt +++ /dev/null @@ -1,31 +0,0 @@ -package s2 - -import s1.Super -import s1.MyClass -import s1.someCoolThing - -/** - * Just an entry-point - */ -fun main(args: Array<String>) { - -} - -/** - * Take a glass of hot water - */ -class Cooler { - val myClass = MyClass() - val a = myClass.otherworks() - val coolest = someCoolThing() -} - -/** - * Powerful - */ -class Superful : Super() { - /** - * Overriden magic - */ - override fun bar() = foo(20) * 2 -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/multiplatformProject/build.gradle b/runners/gradle-integration-tests/testData/multiplatformProject/build.gradle deleted file mode 100644 index b5454c55..00000000 --- a/runners/gradle-integration-tests/testData/multiplatformProject/build.gradle +++ /dev/null @@ -1,60 +0,0 @@ -buildscript { - repositories { - mavenCentral() - jcenter() - maven { url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } - } - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$test_kotlin_version" - } -} - -plugins { - id 'org.jetbrains.dokka' -} - -repositories { - jcenter() - mavenLocal() -} - -group 'org.test' -version '1.0-SNAPSHOT' - -apply plugin: "org.jetbrains.kotlin.multiplatform" - -kotlin { - jvm() // Create a JVM target with the default name 'jvm' - js() - sourceSets { - jsMain { - dependencies{ - implementation "org.jetbrains.kotlin:kotlin-stdlib-js" - } - } - jvmMain { - dependencies { - implementation kotlin('stdlib-jdk8') - } - } - } -} - -dependencies { - dokkaRuntime files(dokka_fatjar) -} - -apply plugin: 'org.jetbrains.dokka' - -dokka { - - multiplatform { - javascript { - targets = ["js"] - platform = "js" - kotlinTasks { [tasks.getByPath(":compileKotlinJs")] } - } - jvm {} - } -} diff --git a/runners/gradle-integration-tests/testData/multiplatformProject/fileTree.txt b/runners/gradle-integration-tests/testData/multiplatformProject/fileTree.txt deleted file mode 100644 index e9cc847c..00000000 --- a/runners/gradle-integration-tests/testData/multiplatformProject/fileTree.txt +++ /dev/null @@ -1,18 +0,0 @@ -/ - multiplatform-project-root/ - alltypes/ - index.html - index-outline.html - index.html - org.kotlintestmpp/ - get-current-date.html - index.html - js.html - jvm.html - kotlin.-string/ - index.html - my-extension.html - main.html - shared.html - package-list - style.css diff --git a/runners/gradle-integration-tests/testData/multiplatformProject/settings.gradle b/runners/gradle-integration-tests/testData/multiplatformProject/settings.gradle deleted file mode 100644 index 0bb1e91b..00000000 --- a/runners/gradle-integration-tests/testData/multiplatformProject/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = "multiplatformProjectRoot" diff --git a/runners/gradle-integration-tests/testData/multiplatformProject/src/jsMain/kotlin/org/kotlintestmpp/main.kt b/runners/gradle-integration-tests/testData/multiplatformProject/src/jsMain/kotlin/org/kotlintestmpp/main.kt deleted file mode 100644 index a77b50f9..00000000 --- a/runners/gradle-integration-tests/testData/multiplatformProject/src/jsMain/kotlin/org/kotlintestmpp/main.kt +++ /dev/null @@ -1,14 +0,0 @@ -package org.kotlintestmpp - -fun main(args : Array<String>) { - console.log("Hello, world!") -} - -fun js(){} -fun shared(){} - -fun getCurrentDate(): String { - return "test" -} - -fun String.myExtension() = println("test")
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/multiplatformProject/src/jvmMain/kotlin/org/kotlintestmpp/main.kt b/runners/gradle-integration-tests/testData/multiplatformProject/src/jvmMain/kotlin/org/kotlintestmpp/main.kt deleted file mode 100644 index 96d725fc..00000000 --- a/runners/gradle-integration-tests/testData/multiplatformProject/src/jvmMain/kotlin/org/kotlintestmpp/main.kt +++ /dev/null @@ -1,20 +0,0 @@ -package org.kotlintestmpp - - -fun main(args : Array<String>) { - println("Hello, world!") -} - -/** - * comment for this class - */ -fun jvm(){} -fun shared(){} - -fun getCurrentDate(): String { - return "test" -} - -fun String.myExtension() = println("test2") - - diff --git a/runners/gradle-integration-tests/testData/sourcesChange/build.gradle b/runners/gradle-integration-tests/testData/sourcesChange/build.gradle deleted file mode 100644 index a6270e23..00000000 --- a/runners/gradle-integration-tests/testData/sourcesChange/build.gradle +++ /dev/null @@ -1,35 +0,0 @@ -buildscript { - repositories { - mavenCentral() - jcenter() - maven { url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } - } - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$test_kotlin_version" - } -} - -plugins { - id 'org.jetbrains.dokka' -} - -apply plugin: 'kotlin' -apply plugin: 'org.jetbrains.dokka' - -repositories { - mavenCentral() - jcenter() - maven { - url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" - } - maven { - url "https://dl.bintray.com/kotlin/kotlin-dev" - } -} - -dependencies { - dokkaRuntime files(dokka_fatjar) - compile group: 'org.jetbrains.kotlin', name: 'kotlin-runtime', version: test_kotlin_version - compile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: test_kotlin_version -}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/sourcesChange/fileTree.txt b/runners/gradle-integration-tests/testData/sourcesChange/fileTree.txt deleted file mode 100644 index 09f3724b..00000000 --- a/runners/gradle-integration-tests/testData/sourcesChange/fileTree.txt +++ /dev/null @@ -1,10 +0,0 @@ -/ - sources-change/ - alltypes.html - demo/ - hello.html - index.html - index-outline.html - index.html - package-list - style.css diff --git a/runners/gradle-integration-tests/testData/sourcesChange/fileTree1.txt b/runners/gradle-integration-tests/testData/sourcesChange/fileTree1.txt deleted file mode 100644 index eeb377f7..00000000 --- a/runners/gradle-integration-tests/testData/sourcesChange/fileTree1.txt +++ /dev/null @@ -1,11 +0,0 @@ -/ - sources-change/ - alltypes.html - demo/ - hello.html - index.html - world.html - index-outline.html - index.html - package-list - style.css diff --git a/runners/gradle-integration-tests/testData/sourcesChange/settings.gradle b/runners/gradle-integration-tests/testData/sourcesChange/settings.gradle deleted file mode 100644 index 3fb032bf..00000000 --- a/runners/gradle-integration-tests/testData/sourcesChange/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = "sourcesChange"
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/sourcesChange/src/main/kotlin/demo/HelloWorld.kt b/runners/gradle-integration-tests/testData/sourcesChange/src/main/kotlin/demo/HelloWorld.kt deleted file mode 100644 index c54dea50..00000000 --- a/runners/gradle-integration-tests/testData/sourcesChange/src/main/kotlin/demo/HelloWorld.kt +++ /dev/null @@ -1,6 +0,0 @@ -package demo - -/** - * @return Hello - */ -fun hello(): String = "Hello"
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/sourcesChange/src1/main/kotlin/demo/HelloWorld.kt b/runners/gradle-integration-tests/testData/sourcesChange/src1/main/kotlin/demo/HelloWorld.kt deleted file mode 100644 index 53f22ff5..00000000 --- a/runners/gradle-integration-tests/testData/sourcesChange/src1/main/kotlin/demo/HelloWorld.kt +++ /dev/null @@ -1,11 +0,0 @@ -package demo - -/** - * @return Hello - */ -fun hello(): String = "Hello" - -/** - * @return World - */ -fun world(): String = "World"
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/typeSafeConfiguration/build.gradle b/runners/gradle-integration-tests/testData/typeSafeConfiguration/build.gradle deleted file mode 100644 index 444d2ab3..00000000 --- a/runners/gradle-integration-tests/testData/typeSafeConfiguration/build.gradle +++ /dev/null @@ -1,74 +0,0 @@ -import org.jetbrains.dokka.* -import org.jetbrains.dokka.gradle.* -import org.jetbrains.kotlin.gradle.tasks.* - -import groovy.transform.CompileStatic -import java.util.concurrent.Callable - -buildscript { - repositories { - jcenter() - mavenLocal() - } - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$test_kotlin_version" - } -} - -plugins { - id 'org.jetbrains.dokka' -} - -apply plugin: 'kotlin' - -@CompileStatic -def configureDokkaTypeSafely(DokkaTask dokka) { - dokka.with { - outputFormat = "some String" - outputDirectory = "some String" - cacheRoot = null as String - impliedPlatforms = new ArrayList<String>() - } - dokka.configuration.with { - moduleName = "some String" - classpath = Arrays.asList("someClassDir") - includes = Collections.<String> emptyList() - samples = Collections.<String> emptyList() - jdkVersion = 6 - sourceRoots = new ArrayList<GradleSourceRootImpl>() as List<DokkaConfiguration.SourceRoot> - - includeNonPublic = false - skipDeprecated = false - skipEmptyPackages = true - reportUndocumented = true - perPackageOptions = new ArrayList<GradlePackageOptionsImpl>() as List<DokkaConfiguration.PackageOptions> - externalDocumentationLinks = new ArrayList<DokkaConfiguration.ExternalDocumentationLink>() - noStdlibLink = false - languageVersion = null as String - apiVersion = null as String - sourceRoot(new Action<GradleSourceRootImpl>() { - @Override - void execute(GradleSourceRootImpl sourceRoot) { - sourceRoot.path = "some String" - } - }) - externalDocumentationLink(new Action<GradleExternalDocumentationLinkImpl.Builder>() { - @Override - void execute(GradleExternalDocumentationLinkImpl.Builder builder) { - builder.url = uri("some URI").toURL() - builder.packageListUrl = uri("some URI").toURL() - builder.build() - } - }) - kotlinTasks(new Callable<List<Object>>() { - @Override - List<Object> call() { - return defaultKotlinTasks() - } - }) - } -} - -project.tasks.withType(DokkaTask) { dokka -> - configureDokkaTypeSafely(dokka) -} diff --git a/runners/gradle-integration-tests/testData/typeSafeConfiguration/settings.gradle b/runners/gradle-integration-tests/testData/typeSafeConfiguration/settings.gradle deleted file mode 100644 index be82e328..00000000 --- a/runners/gradle-integration-tests/testData/typeSafeConfiguration/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = "type-safe-configuration"
\ No newline at end of file diff --git a/runners/gradle-plugin/build.gradle b/runners/gradle-plugin/build.gradle deleted file mode 100644 index ceb03bae..00000000 --- a/runners/gradle-plugin/build.gradle +++ /dev/null @@ -1,108 +0,0 @@ -import com.gradle.publish.DependenciesBuilder - -apply plugin: 'java' -apply plugin: 'kotlin' - - -apply plugin: 'com.github.johnrengelman.shadow' -apply plugin: "com.gradle.plugin-publish" - -sourceCompatibility = 1.8 - -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { - kotlinOptions { - freeCompilerArgs += "-Xjsr305=strict" - languageVersion = language_version - apiVersion = language_version - jvmTarget = "1.8" - } -} - -repositories { - jcenter() - google() -} - -dependencies { - testCompile group: 'junit', name: 'junit', version: '4.12' - - shadow group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_for_gradle_runtime_version - shadow group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_for_gradle_runtime_version - - compile project(":integration") - - compileOnly "org.jetbrains.kotlin:kotlin-gradle-plugin" - compileOnly("com.android.tools.build:gradle:3.0.0") - compileOnly("com.android.tools.build:gradle-core:3.0.0") - compileOnly("com.android.tools.build:builder-model:3.0.0") - compileOnly gradleApi() - compileOnly localGroovy() - implementation "com.google.code.gson:gson:$gson_version" -} - -task sourceJar(type: Jar) { - from sourceSets.main.allSource -} - -processResources { - eachFile { - if (it.name == "org.jetbrains.dokka.properties") { - it.filter { line -> - line.replace("<version>", dokka_version) - } - } - } -} - -shadowJar { - baseName = 'dokka-gradle-plugin' - classifier = '' -} - -apply plugin: 'maven-publish' - -publishing { - publications { - dokkaGradlePlugin(MavenPublication) { publication -> - artifactId = 'dokka-gradle-plugin' - - artifact sourceJar { - classifier "sources" - } - - project.shadow.component(publication) - } - } -} - -bintrayPublication(project, ['dokkaGradlePlugin']) - -configurations.archives.artifacts.clear() -artifacts { - archives shadowJar -} - -pluginBundle { - website = 'https://www.kotlinlang.org/' - vcsUrl = 'https://github.com/kotlin/dokka.git' - description = 'Dokka, the Kotlin documentation tool' - tags = ['dokka', 'kotlin', 'kdoc', 'android'] - - plugins { - dokkaGradlePlugin { - id = 'org.jetbrains.dokka' - displayName = 'Dokka plugin' - } - } - - withDependencies { List<Dependency> list -> - list.clear() - def builder = new DependenciesBuilder() - builder.addUniqueScopedDependencies(list, configurations.shadow, "compile") - } - - mavenCoordinates { - groupId = "org.jetbrains.dokka" - artifactId = "dokka-gradle-plugin" - } -}
\ No newline at end of file diff --git a/runners/gradle-plugin/build.gradle.kts b/runners/gradle-plugin/build.gradle.kts new file mode 100644 index 00000000..0222f5e0 --- /dev/null +++ b/runners/gradle-plugin/build.gradle.kts @@ -0,0 +1,63 @@ +import org.jetbrains.configureBintrayPublication +import org.jetbrains.dokkaVersion + +plugins { + `java-gradle-plugin` +} + +repositories { + google() +} + +dependencies { + implementation(project(":core")) + compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin") + compileOnly("com.android.tools.build:gradle:3.0.0") + compileOnly("com.android.tools.build:gradle-core:3.0.0") + compileOnly("com.android.tools.build:builder-model:3.0.0") + compileOnly(gradleApi()) + compileOnly(gradleKotlinDsl()) + testImplementation(gradleApi()) + testImplementation(gradleKotlinDsl()) + testImplementation(kotlin("test-junit")) + testImplementation("org.jetbrains.kotlin:kotlin-gradle-plugin") + + constraints { + val kotlin_version: String by project + compileOnly("org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}") { + because("kotlin-gradle-plugin and :core both depend on this") + } + } +} + +val sourceJar by tasks.registering(Jar::class) { + archiveClassifier.set("sources") + from(sourceSets["main"].allSource) +} + +gradlePlugin { + plugins { + create("dokkaGradlePlugin") { + id = "org.jetbrains.dokka" + implementationClass = "org.jetbrains.dokka.gradle.DokkaPlugin" + version = dokkaVersion + } + } +} + +publishing { + publications { + register<MavenPublication>("pluginMaven") { + artifactId = "dokka-gradle-plugin" + } + + register<MavenPublication>("dokkaGradlePluginForIntegrationTests") { + artifactId = "dokka-gradle-plugin" + from(components["java"]) + version = "for-integration-tests-SNAPSHOT" + } + } +} + + +configureBintrayPublication("dokkaGradlePluginPluginMarkerMaven", "pluginMaven") diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt new file mode 100644 index 00000000..846f021c --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt @@ -0,0 +1,45 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.api.DefaultTask +import org.gradle.api.Project +import org.gradle.api.artifacts.Configuration +import org.gradle.api.attributes.Usage +import org.gradle.api.tasks.Classpath +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.TaskAction +import org.gradle.kotlin.dsl.dependencies +import org.jetbrains.dokka.DokkaBootstrap +import org.jetbrains.dokka.plugability.Configurable + + +abstract class AbstractDokkaTask : DefaultTask(), Configurable { + @Input + var outputDirectory: String = defaultDokkaOutputDirectory().absolutePath + + @Input + override val pluginsConfiguration: Map<String, String> = mutableMapOf() + + @Classpath + val plugins: Configuration = project.maybeCreateDokkaPluginConfiguration(name) + + @Classpath + val runtime: Configuration = project.maybeCreateDokkaRuntimeConfiguration(name) + + @TaskAction + protected fun run() { + val kotlinColorsEnabledBefore = System.getProperty(DokkaTask.COLORS_ENABLED_PROPERTY) ?: "false" + System.setProperty(DokkaTask.COLORS_ENABLED_PROPERTY, "false") + try { + generate() + } finally { + System.setProperty(DokkaTask.COLORS_ENABLED_PROPERTY, kotlinColorsEnabledBefore) + } + } + + protected abstract fun generate() + + protected fun DokkaBootstrap(bootstrapClassFQName: String): DokkaBootstrap { + return DokkaBootstrap(runtime, bootstrapClassFQName) + } +} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt index 39672b9a..1bfd2c78 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt @@ -1,9 +1,5 @@ package org.jetbrains.dokka.gradle -import com.android.build.gradle.* -import com.android.build.gradle.api.BaseVariant -import com.android.builder.core.BuilderConstants -import org.gradle.api.NamedDomainObjectCollection import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.UnknownDomainObjectException @@ -13,90 +9,71 @@ import org.gradle.api.plugins.JavaPluginConvention import org.gradle.api.tasks.SourceSet import org.gradle.api.tasks.compile.AbstractCompile import org.jetbrains.dokka.ReflectDsl -import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinSingleTargetExtension import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation -import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType -import org.jetbrains.kotlin.gradle.plugin.KotlinTarget +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult import java.io.File import java.io.Serializable class ConfigurationExtractor(private val project: Project) { - - fun extractConfiguration(targetName: String, variantNames: List<String>) = - if (project.isMultiplatformProject()) { - extractFromMultiPlatform(targetName, variantNames) - } else { - extractFromSinglePlatform(variantNames) + fun extractConfiguration(sourceSetName: String): PlatformData? { + val projectExtension = project.extensions.findByType(KotlinProjectExtension::class.java) ?: run { + project.logger.error("Missing kotlin project extension") + return null } - private fun extractFromSinglePlatform(variantNames: List<String>): PlatformData? { - val target: KotlinTarget - try { - target = project.extensions.getByType(KotlinSingleTargetExtension::class.java).target - } catch (e: Throwable) { - when (e) { - is UnknownDomainObjectException, is NoClassDefFoundError, is ClassNotFoundException -> - return null - else -> throw e - } + val sourceSet = projectExtension.sourceSets.findByName(sourceSetName) ?: run { + project.logger.error("No source set with name '$sourceSetName' found") + return null } - return try { - PlatformData( - null, - accumulateClassPaths(variantNames, target), - accumulateSourceSets(variantNames, target), - getPlatformName(target.platformType) - ) - } catch (e: NoSuchMethodError) { + val compilation = try { + when (projectExtension) { + is KotlinMultiplatformExtension -> { + val targets = projectExtension.targets.flatMap { it.compilations } + targets.find { it.name == sourceSetName } + ?: targets.find { it.kotlinSourceSets.contains(sourceSet) } + } + is KotlinSingleTargetExtension -> projectExtension.target.compilations.find { + it.kotlinSourceSets.contains(sourceSet) + } + else -> null + } + } catch (e: NoClassDefFoundError) { // Old Kotlin plugin versions null } + + val sourceRoots = sourceSet.sourceFiles + val classpath = compilation?.classpath + ?: sourceRoots + sourceSet.allParentSourceFiles() + + return PlatformData( + sourceSetName, + classpath.filter { it.exists() }, + sourceRoots, + sourceSet.dependsOn.map { it.name }, + compilation?.target?.platformType?.name ?: "common" + ) } - private fun extractFromMultiPlatform(targetName: String, variantNames: List<String>): PlatformData? = - try { - project.extensions.getByType(KotlinMultiplatformExtension::class.java).targets - } catch (e: Throwable) { - when (e) { - is UnknownDomainObjectException, is NoClassDefFoundError, is ClassNotFoundException -> - null - else -> throw e - } - }?.let { - val fixedName = if (targetName.toLowerCase() == "common") "metadata" else targetName.toLowerCase() - it.find { target -> target.name.toLowerCase() == fixedName }?.let { target -> - PlatformData( - fixedName, - accumulateClassPaths(variantNames, target), - accumulateSourceSets(variantNames, target), - target.platformType.toString() - ) - } - } + private fun KotlinSourceSet.allParentSourceFiles(): List<File> = + sourceFiles + dependsOn.flatMap { it.allParentSourceFiles() } fun extractFromJavaPlugin(): PlatformData? = project.convention.findPlugin(JavaPluginConvention::class.java) ?.run { sourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME)?.allSource?.srcDirs } - ?.let { PlatformData(null, emptyList(), it.toList(), "") } + ?.let { PlatformData(null, emptyList(), it.toList(), emptyList(), "") } - fun extractFromKotlinTasks(kotlinTasks: List<Task>): PlatformData? = + fun extractFromKotlinTasks(kotlinTasks: List<Task>): List<PlatformData> = try { - kotlinTasks.map { extractFromKotlinTask(it) }.let { platformDataList -> - PlatformData( - null, - platformDataList.flatMap { it.classpath }, - platformDataList.flatMap { it.sourceRoots }, - "" - ) - } + kotlinTasks.map { extractFromKotlinTask(it) } } catch (e: Throwable) { when (e) { is UnknownDomainObjectException, is NoClassDefFoundError, is ClassNotFoundException -> - extractFromKotlinTasksTheHardWay(kotlinTasks) + listOfNotNull(extractFromKotlinTasksTheHardWay(kotlinTasks)) else -> throw e } } @@ -110,10 +87,18 @@ class ConfigurationExtractor(private val project: Project) { when (e) { is UnknownDomainObjectException, is NoClassDefFoundError, is ClassNotFoundException -> project.extensions.getByType(KotlinMultiplatformExtension::class.java).targets - .firstNotNullResult { target -> target.compilations.find { it.compileKotlinTask == task } } + .flatMap { it.compilations }.firstOrNull { it.compileKotlinTask == task } else -> throw e } - }.let { PlatformData(task.name, getClasspath(it), getSourceSet(it), it?.platformType?.toString() ?: "") } + }.let { compilation -> + PlatformData( + task.name, + compilation?.classpath.orEmpty(), + compilation?.sourceFiles.orEmpty(), + compilation?.dependentSourceSets?.map { it.name }.orEmpty(), + compilation?.platformType?.toString() ?: "" + ) + } private fun extractFromKotlinTasksTheHardWay(kotlinTasks: List<Task>): PlatformData? { val allClasspath = mutableSetOf<File>() @@ -134,8 +119,8 @@ class ConfigurationExtractor(private val project: Project) { val taskClasspath: Iterable<File> = (it["getClasspath", AbstractCompile::class].takeIfIsFunc()?.invoke() - ?: it["compileClasspath", abstractKotlinCompileClz].takeIfIsProp()?.v() - ?: it["getClasspath", abstractKotlinCompileClz]()) + ?: it["compileClasspath", abstractKotlinCompileClz].takeIfIsProp()?.v() + ?: it["getClasspath", abstractKotlinCompileClz]()) if (taskClasspath is FileCollection) { allClasspathFileCollection += taskClasspath @@ -152,97 +137,42 @@ class ConfigurationExtractor(private val project: Project) { } classpath.addAll(project.files(allClasspath).toList()) - return PlatformData(null, classpath, allSourceRoots.toList(), "") + return PlatformData(null, classpath, allSourceRoots.toList(), emptyList(), "") } - private fun getSourceSet(target: KotlinTarget, variantName: String): List<File> = - if (target.isAndroidTarget()) - getSourceSet(getCompilation(target, variantName)) - else - getSourceSet(getMainCompilation(target)) - - private fun getClasspath(target: KotlinTarget, variantName: String): List<File> = - if (target.isAndroidTarget()) - getClasspathFromAndroidTask(getCompilation(target, variantName)) - else - getClasspath(getMainCompilation(target)) - - private fun getSourceSet(compilation: KotlinCompilation<*>?): List<File> = compilation - ?.allKotlinSourceSets - ?.flatMap { it.kotlin.sourceDirectories } - ?.filter { it.exists() } - .orEmpty() - - private fun getClasspath(compilation: KotlinCompilation<*>?): List<File> = compilation - ?.compileDependencyFiles - ?.files - ?.toList() - ?.filter { it.exists() } - .orEmpty() - - // This is a workaround for KT-33893 - private fun getClasspathFromAndroidTask(compilation: KotlinCompilation<*>): List<File> = (compilation - .compileKotlinTask as? KotlinCompile) - ?.classpath?.files?.toList() ?: getClasspath(compilation) - - private fun getMainCompilation(target: KotlinTarget) = - getCompilation(target, getMainCompilationName(target)) - - private fun getCompilation(target: KotlinTarget, name: String) = - target.compilations.getByName(name) - - private fun getMainCompilationName(target: KotlinTarget) = if (target.isAndroidTarget()) - getVariants(project).filter { it.buildType.name == BuilderConstants.RELEASE }.map { it.name }.first() - else - KotlinCompilation.MAIN_COMPILATION_NAME - - private fun getVariants(project: Project): Set<BaseVariant> { - val androidExtension = project.extensions.getByName("android") - val baseVariants = when (androidExtension) { - is AppExtension -> androidExtension.applicationVariants.toSet() - is LibraryExtension -> { - androidExtension.libraryVariants.toSet() + - if (androidExtension is FeatureExtension) { - androidExtension.featureVariants.toSet() - } else { - emptySet<BaseVariant>() - } - } - is TestExtension -> androidExtension.applicationVariants.toSet() - else -> emptySet() - } - val testVariants = if (androidExtension is TestedExtension) { - androidExtension.testVariants.toSet() + androidExtension.unitTestVariants.toSet() - } else { - emptySet<BaseVariant>() - } + private val KotlinCompilation<*>.sourceFiles: List<File> + get() = kotlinSourceSets.flatMap { it.sourceFiles } - return baseVariants + testVariants - } + private val KotlinSourceSet.sourceFiles: List<File> + get() = kotlin.sourceDirectories.filter { it.exists() }.toList() - private fun getPlatformName(platform: KotlinPlatformType): String = - if (platform == KotlinPlatformType.androidJvm) KotlinPlatformType.jvm.toString() else platform.toString() + private val KotlinCompilation<*>.dependentSourceSets: Set<KotlinSourceSet> + get() = (allKotlinSourceSets - kotlinSourceSets) - private fun accumulateClassPaths(variantNames: List<String>, target: KotlinTarget) = - if (variantNames.isNotEmpty()) { - variantNames.flatMap { getClasspath(target, it) }.distinct() + private val KotlinCompilation<*>.classpath: List<File> + get() = if (target.isAndroidTarget()) { + getClasspathFromAndroidTask(this) } else { - if (target.isAndroidTarget()) - getClasspathFromAndroidTask(getMainCompilation(target)) - else - getClasspath(getMainCompilation(target)) + getClasspathFromRegularTask(this) } - private fun accumulateSourceSets(variantNames: List<String>, target: KotlinTarget) = - if (variantNames.isNotEmpty()) - variantNames.flatMap { getSourceSet(target, it) }.distinct() - else - getSourceSet(getMainCompilation(target)) + // This is a workaround for KT-33893 + private fun getClasspathFromAndroidTask(compilation: KotlinCompilation<*>): List<File> = (compilation + .compileKotlinTask as? KotlinCompile) + ?.classpath?.files?.toList() ?: getClasspathFromRegularTask(compilation) + + private fun getClasspathFromRegularTask(compilation: KotlinCompilation<*>): List<File> = + compilation + .compileDependencyFiles + .files + .toList() + .filter { it.exists() } data class PlatformData( val name: String?, val classpath: List<File>, val sourceRoots: List<File>, + val dependentSourceSets: List<String>, val platform: String ) : Serializable -}
\ No newline at end of file +} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaArtifacts.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaArtifacts.kt new file mode 100644 index 00000000..90d51015 --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaArtifacts.kt @@ -0,0 +1,17 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.api.Project +import org.jetbrains.dokka.DokkaVersion + +internal val Project.dokkaArtifacts get() = DokkaArtifacts(this) + +internal class DokkaArtifacts(private val project: Project) { + private fun fromModuleName(name: String) = + project.dependencies.create("org.jetbrains.dokka:$name:${DokkaVersion.version}") + + val dokkaCore get() = fromModuleName("dokka-core") + val dokkaBase get() = fromModuleName("dokka-base") + val javadocPlugin get() = fromModuleName("javadoc-plugin") + val gfmPlugin get() = fromModuleName("gfm-plugin") + val jekyllPlugin get() = fromModuleName("jekyll-plugin") +} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaBootstrapFactory.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaBootstrapFactory.kt new file mode 100644 index 00000000..df29c19b --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaBootstrapFactory.kt @@ -0,0 +1,18 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.api.artifacts.Configuration +import org.jetbrains.dokka.DokkaBootstrap +import java.net.URLClassLoader + + +fun DokkaBootstrap(configuration: Configuration, bootstrapClassFQName: String): DokkaBootstrap { + val runtimeJars = configuration.resolve() + val runtimeClassLoader = URLClassLoader( + runtimeJars.map { it.toURI().toURL() }.toTypedArray(), + ClassLoader.getSystemClassLoader().parent + ) + + val bootstrapClass = runtimeClassLoader.loadClass(bootstrapClassFQName) + val bootstrapInstance = bootstrapClass.constructors.first().newInstance() + return automagicTypedProxy(DokkaPlugin::class.java.classLoader, bootstrapInstance) +} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt new file mode 100644 index 00000000..37952ea8 --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt @@ -0,0 +1,58 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.api.DefaultTask +import org.gradle.api.plugins.JavaBasePlugin +import org.gradle.api.plugins.JavaBasePlugin.DOCUMENTATION_GROUP +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.TaskAction +import java.lang.IllegalStateException + +open class DokkaCollectorTask : DefaultTask() { + + @Input + var modules: List<String> = emptyList() + + @Input + var outputDirectory: String = defaultDokkaOutputDirectory().absolutePath + + private lateinit var configuration: GradleDokkaConfigurationImpl + + @Input + var dokkaTaskNames: Set<String> = setOf() + + @TaskAction + fun collect() { + val configurations = project.subprojects + .filter { subProject -> subProject.name in modules } + .flatMap { subProject -> dokkaTaskNames.mapNotNull(subProject.tasks::findByName) } + .filterIsInstance<DokkaTask>() + .mapNotNull { dokkaTask -> dokkaTask.getConfigurationOrNull() } + + + val initial = GradleDokkaConfigurationImpl().apply { + outputDir = outputDirectory + cacheRoot = configurations.first().cacheRoot + } + + // TODO this certainly not the ideal solution + configuration = configurations.fold(initial) { acc, it: GradleDokkaConfigurationImpl -> + if (acc.cacheRoot != it.cacheRoot) + throw IllegalStateException("Dokka task configurations differ on core argument cacheRoot") + acc.sourceSets = acc.sourceSets + it.sourceSets + acc.pluginsClasspath = (acc.pluginsClasspath + it.pluginsClasspath).distinct() + acc + } + project.tasks.withType(DokkaTask::class.java).configureEach { it.enforcedConfiguration = configuration } + } + + init { + // TODO: This this certainly not the ideal solution + dokkaTaskNames.forEach { dokkaTaskName -> + finalizedBy(dokkaTaskName) + } + + group = DOCUMENTATION_GROUP + } + + +} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultimoduleTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultimoduleTask.kt new file mode 100644 index 00000000..6fd58afe --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultimoduleTask.kt @@ -0,0 +1,68 @@ +package org.jetbrains.dokka.gradle + +import com.google.gson.GsonBuilder +import org.gradle.api.plugins.JavaBasePlugin +import org.gradle.api.plugins.JavaBasePlugin.DOCUMENTATION_GROUP +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Internal +import org.jetbrains.dokka.plugability.Configurable + +open class DokkaMultimoduleTask : AbstractDokkaTask(), Configurable { + + @Input + var documentationFileName: String = "README.md" + + + @Input + var dokkaTaskNames: Set<String> = setOf() + set(value) { + field = value.toSet() + setDependsOn(getSubprojectDokkaTasks(value)) + } + + + override fun generate() { + val bootstrap = DokkaBootstrap("org.jetbrains.dokka.DokkaMultimoduleBootstrapImpl") + val gson = GsonBuilder().setPrettyPrinting().create() + val configuration = getConfiguration() + bootstrap.configure(gson.toJson(configuration)) { level, message -> + when (level) { + "debug" -> logger.debug(message) + "info" -> logger.info(message) + "progress" -> logger.lifecycle(message) + "warn" -> logger.warn(message) + "error" -> logger.error(message) + } + } + bootstrap.generate() + } + + @Internal + internal fun getConfiguration(): GradleDokkaConfigurationImpl = + GradleDokkaConfigurationImpl().apply { + outputDir = project.file(outputDirectory).absolutePath + pluginsClasspath = plugins.resolve().toList() + pluginsConfiguration = this@DokkaMultimoduleTask.pluginsConfiguration + modules = getSubprojectDokkaTasks(dokkaTaskNames).map { dokkaTask -> + GradleDokkaModuleDescription().apply { + name = dokkaTask.project.name + path = dokkaTask.project.projectDir.resolve(dokkaTask.outputDirectory) + .toRelativeString(project.file(outputDirectory)) + docFile = dokkaTask.project.projectDir.resolve(documentationFileName).absolutePath + } + } + } + + private fun getSubprojectDokkaTasks(dokkaTaskName: String): List<DokkaTask> { + return project.subprojects + .mapNotNull { subproject -> subproject.tasks.findByName(dokkaTaskName) as? DokkaTask } + } + + private fun getSubprojectDokkaTasks(dokkaTaskNames: Set<String>): List<DokkaTask> { + return dokkaTaskNames.flatMap { dokkaTaskName -> getSubprojectDokkaTasks(dokkaTaskName) } + } + + init { + group = DOCUMENTATION_GROUP + } +} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaSourceSetIDFactory.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaSourceSetIDFactory.kt new file mode 100644 index 00000000..3fadb4fd --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaSourceSetIDFactory.kt @@ -0,0 +1,10 @@ +@file:Suppress("FunctionName") + +package org.jetbrains.dokka.gradle + +import org.gradle.api.Project +import org.jetbrains.dokka.DokkaSourceSetID + +internal fun DokkaSourceSetID(project: Project, sourceSetName: String): DokkaSourceSetID { + return DokkaSourceSetID(moduleName = project.path, sourceSetName = sourceSetName) +} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt index bafe657e..0d7e74a3 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt @@ -1,28 +1,26 @@ package org.jetbrains.dokka.gradle import com.google.gson.GsonBuilder -import org.gradle.api.* -import org.gradle.api.artifacts.Configuration +import org.gradle.api.NamedDomainObjectContainer +import org.gradle.api.Project +import org.gradle.api.Task import org.gradle.api.file.FileCollection import org.gradle.api.internal.plugins.DslObject import org.gradle.api.plugins.JavaBasePlugin import org.gradle.api.tasks.* -import org.jetbrains.dokka.DokkaBootstrap import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink.Builder import org.jetbrains.dokka.DokkaConfiguration.SourceRoot +import org.jetbrains.dokka.DokkaException import org.jetbrains.dokka.Platform import org.jetbrains.dokka.ReflectDsl import org.jetbrains.dokka.ReflectDsl.isNotInstance import org.jetbrains.dokka.gradle.ConfigurationExtractor.PlatformData -import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType import java.io.File -import java.net.URLClassLoader import java.util.concurrent.Callable -import java.util.function.BiConsumer -open class DokkaTask : DefaultTask() { +open class DokkaTask : AbstractDokkaTask() { private val ANDROID_REFERENCE_URL = Builder("https://developer.android.com/reference/").build() - private val GLOBAL_PLATFORM_NAME = "global" // Used for copying perPackageOptions to other platforms + private val configExtractor = ConfigurationExtractor(project) @Suppress("MemberVisibilityCanBePrivate") fun defaultKotlinTasks(): List<Task> = with(ReflectDsl) { @@ -44,60 +42,50 @@ open class DokkaTask : DefaultTask() { dependsOn(Callable { kotlinTasks.map { it.taskDependencies } }) } - @Input - var outputFormat: String = "html" - - @Input - var outputDirectory: String = "" - - var dokkaRuntime: Configuration? = null - - @Input - var subProjects: List<String> = emptyList() - - @Input - var impliedPlatforms: MutableList<String> = arrayListOf() - @Optional @Input var cacheRoot: String? = null - var multiplatform: NamedDomainObjectContainer<GradlePassConfigurationImpl> - @Suppress("UNCHECKED_CAST") - @Nested get() = (DslObject(this).extensions.getByName(MULTIPLATFORM_EXTENSION_NAME) as NamedDomainObjectContainer<GradlePassConfigurationImpl>) - internal set(value) = DslObject(this).extensions.add(MULTIPLATFORM_EXTENSION_NAME, value) - var configuration: GradlePassConfigurationImpl - @Suppress("UNCHECKED_CAST") - @Nested get() = DslObject(this).extensions.getByType(GradlePassConfigurationImpl::class.java) - internal set(value) = DslObject(this).extensions.add(CONFIGURATION_EXTENSION_NAME, value) + /** + * Hack used by DokkaCollector to enforce a different configuration to be used. + */ + @get:Internal + internal var enforcedConfiguration: GradleDokkaConfigurationImpl? = null - // Configure Dokka with closure in Gradle Kotlin DSL - fun configuration(action: Action<in GradlePassConfigurationImpl>) = action.execute(configuration) + @get:Nested + val dokkaSourceSets: NamedDomainObjectContainer<GradleDokkaSourceSet> = + project.container(GradleDokkaSourceSet::class.java) { name -> GradleDokkaSourceSet(name, project) } + .also { container -> DslObject(this).extensions.add("dokkaSourceSets", container) } - private val kotlinTasks: List<Task> by lazy { extractKotlinCompileTasks(configuration.collectKotlinTasks ?: { defaultKotlinTasks() }) } - private val configExtractor = ConfigurationExtractor(project) + private val kotlinTasks: List<Task> by lazy { + extractKotlinCompileTasks( + dokkaSourceSets.mapNotNull { + it.collectKotlinTasks?.invoke() + }.takeIf { it.isNotEmpty() }?.flatten() ?: defaultKotlinTasks() + ) + } @Input var disableAutoconfiguration: Boolean = false - private var outputDiagnosticInfo: Boolean = false // Workaround for Gradle, which fires some methods (like collectConfigurations()) multiple times in its lifecycle + @Input + var failOnWarning: Boolean = false - private fun loadFatJar() { - if (ClassloaderContainer.fatJarClassLoader == null) { - val jars = dokkaRuntime!!.resolve().toList() - ClassloaderContainer.fatJarClassLoader = URLClassLoader(jars.map { it.toURI().toURL() }.toTypedArray(), ClassLoader.getSystemClassLoader().parent) - } - } + @Input + var offlineMode: Boolean = false - private fun extractKotlinCompileTasks(collectTasks: () -> List<Any?>?): List<Task> { - val inputList = (collectTasks.invoke() ?: emptyList()).filterNotNull() - val (paths, other) = inputList.partition { it is String } + private var outputDiagnosticInfo: Boolean = + false // Workaround for Gradle, which fires some methods (like collectConfigurations()) multiple times in its lifecycle - val taskContainer = project.tasks + protected fun extractKotlinCompileTasks(collectTasks: List<Any?>?): List<Task> { + val inputList = (collectTasks ?: emptyList()).filterNotNull() + val (paths, other) = inputList.partition { it is String } - val tasksByPath = paths.map { taskContainer.findByPath(it as String) ?: throw IllegalArgumentException("Task with path '$it' not found") } + val tasksByPath = paths.map { + project.tasks.findByPath(it as String) ?: throw IllegalArgumentException("Task with path '$it' not found") + } other .filter { it !is Task || it isNotInstance getAbstractKotlinCompileFor(it) } @@ -111,11 +99,14 @@ open class DokkaTask : DefaultTask() { return (tasksByPath + other) as List<Task> } - private fun Iterable<File>.toSourceRoots(): List<GradleSourceRootImpl> = this.filter { it.exists() }.map { GradleSourceRootImpl().apply { path = it.path } } - private fun Iterable<String>.toProjects(): List<Project> = project.subprojects.toList().filter { this.contains(it.name) } + private fun Iterable<File>.toSourceRoots(): List<GradleSourceRootImpl> = + this.filter { it.exists() }.map { GradleSourceRootImpl().apply { path = it.path } } + + private fun Iterable<String>.toProjects(): List<Project> = + project.subprojects.toList().filter { this.contains(it.name) } protected open fun collectSuppressedFiles(sourceRoots: List<SourceRoot>) = - if(project.isAndroidProject()) { + if (project.isAndroidProject()) { val generatedRoot = project.buildDir.resolve("generated").absoluteFile sourceRoots .map { File(it.path) } @@ -126,153 +117,152 @@ open class DokkaTask : DefaultTask() { emptyList() } - @TaskAction - fun generate() { + override fun generate() = enforcedConfiguration?.let { generate(it) } ?: generate(getConfigurationOrThrow()) + + protected open fun generate(configuration: GradleDokkaConfigurationImpl) { outputDiagnosticInfo = true - val kotlinColorsEnabledBefore = System.getProperty(COLORS_ENABLED_PROPERTY) ?: "false" - System.setProperty(COLORS_ENABLED_PROPERTY, "false") - try { - loadFatJar() - - val bootstrapClass = ClassloaderContainer.fatJarClassLoader!!.loadClass("org.jetbrains.dokka.DokkaBootstrapImpl") - val bootstrapInstance = bootstrapClass.constructors.first().newInstance() - val bootstrapProxy: DokkaBootstrap = - automagicTypedProxy(javaClass.classLoader, bootstrapInstance) - - val gson = GsonBuilder().setPrettyPrinting().create() - - val globalConfig = multiplatform.toList().find { it.name.toLowerCase() == GLOBAL_PLATFORM_NAME } - val passConfigurationList = collectConfigurations() - .map { defaultPassConfiguration(it, globalConfig) } - - val configuration = GradleDokkaConfigurationImpl() - configuration.outputDir = outputDirectory - configuration.format = outputFormat - configuration.generateIndexPages = true - configuration.cacheRoot = cacheRoot - configuration.impliedPlatforms = impliedPlatforms - configuration.passesConfigurations = passConfigurationList - - if(passConfigurationList.isEmpty() || passConfigurationList == listOf(globalConfig)) { - println("No pass configurations for generation detected!") - return + val bootstrap = DokkaBootstrap("org.jetbrains.dokka.DokkaBootstrapImpl") + + bootstrap.configure( + GsonBuilder().setPrettyPrinting().create().toJson(configuration) + ) { level, message -> + when (level) { + "debug" -> logger.debug(message) + "info" -> logger.info(message) + "progress" -> logger.lifecycle(message) + "warn" -> logger.warn(message) + "error" -> logger.error(message) } + } + bootstrap.generate() + } - bootstrapProxy.configure( - BiConsumer { level, message -> - when (level) { - "info" -> logger.info(message) - "warn" -> logger.warn(message) - "error" -> logger.error(message) - } - }, - gson.toJson(configuration) - ) - bootstrapProxy.generate() + @Internal + internal fun getConfigurationOrNull(): GradleDokkaConfigurationImpl? { + val defaultModulesConfiguration = configuredDokkaSourceSets + .map { configureDefault(it) }.takeIf { it.isNotEmpty() } + ?: listOf( + configureDefault(configureDokkaSourceSet(dokkaSourceSets.create("main"))) + ).takeIf { project.isNotMultiplatformProject() } ?: emptyList() - } finally { - System.setProperty(COLORS_ENABLED_PROPERTY, kotlinColorsEnabledBefore) + if (defaultModulesConfiguration.isEmpty()) { + return null } - } - protected open fun collectConfigurations() = - if (this.isMultiplatformProject()) collectMultiplatform() else listOf(collectSinglePlatform(configuration)) + return GradleDokkaConfigurationImpl().apply { + outputDir = project.file(outputDirectory).absolutePath + cacheRoot = this@DokkaTask.cacheRoot + offlineMode = this@DokkaTask.offlineMode + sourceSets = defaultModulesConfiguration + pluginsClasspath = plugins.resolve().toList() + pluginsConfiguration = this@DokkaTask.pluginsConfiguration + failOnWarning = this@DokkaTask.failOnWarning + } + } - protected open fun collectMultiplatform() = multiplatform - .filterNot { it.name.toLowerCase() == GLOBAL_PLATFORM_NAME } - .map { collectSinglePlatform(it) } + @Internal + internal fun getConfigurationOrThrow(): GradleDokkaConfigurationImpl { + return getConfigurationOrNull() ?: throw DokkaException( + """ + No source sets to document found. + Make source to configure at least one source set e.g. + + dokka { + dokkaSourceSets { + create("commonMain") { + displayName = "common" + platform = "common" + } + } + } + """ + ) + } - protected open fun collectSinglePlatform(config: GradlePassConfigurationImpl): GradlePassConfigurationImpl { - val userConfig = config.let { - if (it.collectKotlinTasks != null) { - configExtractor.extractFromKotlinTasks(extractKotlinCompileTasks(it.collectKotlinTasks!!)) - ?.let { platformData -> mergeUserConfigurationAndPlatformData(it, platformData) } ?: it - } else { - it + @get:Internal + protected val configuredDokkaSourceSets: List<GradleDokkaSourceSet> + get() = dokkaSourceSets.map { configureDokkaSourceSet(it) } + + private fun configureDokkaSourceSet(config: GradleDokkaSourceSet): GradleDokkaSourceSet { + val userConfig = config + .apply { + collectKotlinTasks?.let { + configExtractor.extractFromKotlinTasks(extractKotlinCompileTasks(it())) + .fold(this) { config, platformData -> + mergeUserConfigurationAndPlatformData(config, platformData) + } + } } - } if (disableAutoconfiguration) return userConfig - val baseConfig = configExtractor.extractConfiguration(userConfig.name, userConfig.androidVariants) + return configExtractor.extractConfiguration(userConfig.name) ?.let { mergeUserConfigurationAndPlatformData(userConfig, it) } - ?: if (this.isMultiplatformProject()) { - if (outputDiagnosticInfo) - logger.warn("Could not find target with name: ${userConfig.name} in Kotlin Gradle Plugin, " + - "using only user provided configuration for this target") - userConfig - } else { - logger.warn("Could not find target with name: ${userConfig.name} in Kotlin Gradle Plugin") - collectFromSinglePlatformOldPlugin() - } - - return if (subProjects.isNotEmpty()) { - try { - subProjects.toProjects().fold(baseConfig) { config, subProject -> - mergeUserConfigurationAndPlatformData( - config, - ConfigurationExtractor(subProject).extractConfiguration(config.name, config.androidVariants)!! + ?: if (this.dokkaSourceSets.isNotEmpty()) { + if (outputDiagnosticInfo) + logger.warn( + "Could not find source set with name: ${userConfig.name} in Kotlin Gradle Plugin, " + + "using only user provided configuration for this source set" ) - } - } catch(e: NullPointerException) { - logger.warn("Cannot extract sources from subProjects. Do you have the Kotlin plugin in version 1.3.30+ " + - "and the Kotlin plugin applied in the root project?") - baseConfig + userConfig + } else { + if (outputDiagnosticInfo) + logger.warn("Could not find source set with name: ${userConfig.name} in Kotlin Gradle Plugin") + collectFromSinglePlatformOldPlugin(userConfig.name, userConfig) } - } else { - baseConfig - } } - protected open fun collectFromSinglePlatformOldPlugin() = - configExtractor.extractFromKotlinTasks(kotlinTasks) - ?.let { mergeUserConfigurationAndPlatformData(configuration, it) } - ?: configExtractor.extractFromJavaPlugin() - ?.let { mergeUserConfigurationAndPlatformData(configuration, it) } - ?: configuration - - protected open fun mergeUserConfigurationAndPlatformData(userConfig: GradlePassConfigurationImpl, autoConfig: PlatformData) = - userConfig.copy().apply { - sourceRoots.addAll(userConfig.sourceRoots.union(autoConfig.sourceRoots.toSourceRoots()).distinct()) - classpath = userConfig.classpath.union(autoConfig.classpath.map { it.absolutePath }).distinct() - if (userConfig.platform == null && autoConfig.platform != "") - platform = autoConfig.platform + private fun collectFromSinglePlatformOldPlugin(name: String, userConfig: GradleDokkaSourceSet) = + kotlinTasks.find { it.name == name } + ?.let { configExtractor.extractFromKotlinTasks(listOf(it)) } + ?.singleOrNull() + ?.let { mergeUserConfigurationAndPlatformData(userConfig, it) } + ?: configExtractor.extractFromJavaPlugin() + ?.let { mergeUserConfigurationAndPlatformData(userConfig, it) } + ?: userConfig + + private fun mergeUserConfigurationAndPlatformData( + userConfig: GradleDokkaSourceSet, + autoConfig: PlatformData + ) = userConfig.copy().apply { + sourceRoots.addAll(userConfig.sourceRoots.union(autoConfig.sourceRoots.toSourceRoots()).distinct()) + dependentSourceSets.addAll(userConfig.dependentSourceSets) + dependentSourceSets.addAll(autoConfig.dependentSourceSets.map { DokkaSourceSetID(project, it) }) + classpath = userConfig.classpath.union(autoConfig.classpath.map { it.absolutePath }).distinct() + if (userConfig.platform == null && autoConfig.platform != "") + platform = autoConfig.platform + } + + private fun configureDefault(config: GradleDokkaSourceSet): GradleDokkaSourceSet { + if (config.moduleDisplayName.isBlank()) { + config.moduleDisplayName = project.name } - protected open fun defaultPassConfiguration( - config: GradlePassConfigurationImpl, - globalConfig: GradlePassConfigurationImpl? - ): GradlePassConfigurationImpl { - if (config.moduleName == "") { - config.moduleName = project.name + if (config.displayName.isBlank()) { + config.displayName = config.name.substringBeforeLast("Main", config.platform.toString()) } - if (config.targets.isEmpty() && multiplatform.isNotEmpty()){ - config.targets = listOf(config.name) + + if (project.isAndroidProject() && !config.noAndroidSdkLink) { + config.externalDocumentationLinks.add(ANDROID_REFERENCE_URL) + } + + if (config.platform?.isNotBlank() == true) { + config.analysisPlatform = dokkaPlatformFromString(config.platform.toString()) } - config.classpath = (config.classpath as List<Any>).map { it.toString() }.distinct() // Workaround for Groovy's GStringImpl + + // Workaround for Groovy's GStringImpl + config.classpath = (config.classpath as List<Any>).map { it.toString() }.distinct() config.sourceRoots = config.sourceRoots.distinct().toMutableList() config.samples = config.samples.map { project.file(it).absolutePath } config.includes = config.includes.map { project.file(it).absolutePath } config.suppressedFiles += collectSuppressedFiles(config.sourceRoots) - if (project.isAndroidProject() && !config.noAndroidSdkLink) { // TODO: introduce Android as a separate Dokka platform? - config.externalDocumentationLinks.add(ANDROID_REFERENCE_URL) - } - if (config.platform != null && config.platform.toString().isNotEmpty()) { - config.analysisPlatform = dokkaPlatformFromString(config.platform.toString()) - } - if (globalConfig != null) { - config.perPackageOptions.addAll(globalConfig.perPackageOptions) - config.externalDocumentationLinks.addAll(globalConfig.externalDocumentationLinks) - config.sourceLinks.addAll(globalConfig.sourceLinks) - config.samples += globalConfig.samples.map { project.file(it).absolutePath } - config.includes += globalConfig.includes.map { project.file(it).absolutePath } - } + return config } private fun dokkaPlatformFromString(platform: String) = when (platform.toLowerCase()) { - KotlinPlatformType.androidJvm.toString().toLowerCase(), "androidjvm", "android" -> Platform.jvm + "androidjvm", "android" -> Platform.jvm "metadata" -> Platform.common else -> Platform.fromString(platform) } @@ -283,16 +273,16 @@ open class DokkaTask : DefaultTask() { // Needed for Gradle incremental build @InputFiles - fun getInputFiles(): FileCollection { - val config = collectConfigurations() - return project.files(config.flatMap { it.sourceRoots }.map { project.fileTree(File(it.path)) }) + + fun getInputFiles(): FileCollection = configuredDokkaSourceSets.let { config -> + project.files(config.flatMap { it.sourceRoots }.map { project.fileTree(File(it.path)) }) + project.files(config.flatMap { it.includes }) + project.files(config.flatMap { it.samples }.map { project.fileTree(File(it)) }) } @Classpath fun getInputClasspath(): FileCollection = - project.files((collectConfigurations().flatMap { it.classpath } as List<Any>).map { project.fileTree(File(it.toString())) }) + project.files((configuredDokkaSourceSets.flatMap { it.classpath } as List<Any>) + .map { project.fileTree(File(it.toString())) }) companion object { const val COLORS_ENABLED_PROPERTY = "kotlin.colors.enabled" diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ProxyUtils.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ProxyUtils.kt index f8965993..468f597f 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ProxyUtils.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ProxyUtils.kt @@ -1,9 +1,6 @@ package org.jetbrains.dokka.gradle -import java.lang.reflect.InvocationHandler -import java.lang.reflect.InvocationTargetException -import java.lang.reflect.Method -import java.lang.reflect.Proxy +import java.lang.reflect.* /** @@ -13,8 +10,8 @@ import java.lang.reflect.Proxy * to create access proxy for [delegate] into [targetClassLoader]. */ @Suppress("UNCHECKED_CAST") -inline fun <reified T : Any> automagicTypedProxy(targetClassLoader: ClassLoader, delegate: Any): T = - automagicProxy(targetClassLoader, T::class.java, delegate) as T +internal inline fun <reified T : Any> automagicTypedProxy(targetClassLoader: ClassLoader, delegate: Any): T = + automagicProxy(targetClassLoader, T::class.java, delegate) as T /** @@ -24,14 +21,14 @@ inline fun <reified T : Any> automagicTypedProxy(targetClassLoader: ClassLoader, * to create access proxy for [delegate] into [targetClassLoader]. * */ -fun automagicProxy(targetClassLoader: ClassLoader, targetType: Class<*>, delegate: Any): Any = - Proxy.newProxyInstance( - targetClassLoader, - arrayOf(targetType), - DelegatedInvocationHandler(delegate) - ) +internal fun automagicProxy(targetClassLoader: ClassLoader, targetType: Class<*>, delegate: Any): Any = + Proxy.newProxyInstance( + targetClassLoader, + arrayOf(targetType), + DelegatedInvocationHandler(delegate) + ) -class DelegatedInvocationHandler(private val delegate: Any) : InvocationHandler { +internal class DelegatedInvocationHandler(private val delegate: Any) : InvocationHandler { @Throws(Throwable::class) override fun invoke(proxy: Any, method: Method, args: Array<Any?>?): Any? { diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ReflectDsl.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ReflectDsl.kt new file mode 100644 index 00000000..4b511022 --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ReflectDsl.kt @@ -0,0 +1,72 @@ +package org.jetbrains.dokka + +import kotlin.reflect.* +import kotlin.reflect.full.memberFunctions +import kotlin.reflect.full.memberProperties +import kotlin.reflect.jvm.isAccessible + +internal object ReflectDsl { + + class CallOrPropAccess(private val receiver: Any?, + private val clz: KClass<*>, + private val selector: String) { + + @Suppress("UNCHECKED_CAST") + operator fun <T : Any?> invoke(vararg a: Any?): T { + return func!!.call(receiver, *a) as T + } + + operator fun get(s: String): CallOrPropAccess { + return v<Any?>()!![s] + } + + val func: KFunction<*>? by lazy { clz.memberFunctions.find { it.name == selector } } + val prop: KProperty<*>? by lazy { clz.memberProperties.find { it.name == selector } } + + fun takeIfIsFunc(): CallOrPropAccess? = if (func != null) this else null + + fun takeIfIsProp(): CallOrPropAccess? = if (prop != null) this else null + + @Suppress("UNCHECKED_CAST") + fun <T : Any?> v(): T { + val prop = prop!! + return try { + prop.getter.apply { isAccessible = true }.call(receiver) as T + } catch (e: KotlinNullPointerException) { + // Hack around kotlin-reflect bug KT-18480 + val jclass = clz.java + val customGetterName = prop.getter.name + val getterName = if (customGetterName.startsWith("<")) "get" + prop.name.capitalize() else customGetterName + val getter = jclass.getDeclaredMethod(getterName) + getter.isAccessible = true + + getter.invoke(receiver) as T + + } + } + + @Suppress("UNCHECKED_CAST") + fun v(x: Any?) { + (prop as KMutableProperty).setter.apply { isAccessible = true }.call(receiver, x) + } + + + } + + operator fun Any.get(s: String): CallOrPropAccess { + val clz = this.javaClass.kotlin + return CallOrPropAccess(this, clz, s) + } + + operator fun Any.get(s: String, clz: Class<*>): CallOrPropAccess { + val kclz = clz.kotlin + return CallOrPropAccess(this, kclz, s) + } + + operator fun Any.get(s: String, clz: KClass<*>): CallOrPropAccess { + return CallOrPropAccess(this, clz, s) + } + + inline infix fun Any.isInstance(clz: Class<*>?): Boolean = clz != null && clz.isAssignableFrom(this.javaClass) + inline infix fun Any.isNotInstance(clz: Class<*>?): Boolean = !(this isInstance clz) +}
\ No newline at end of file diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt index 65afad04..b6b8399c 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt @@ -1,12 +1,19 @@ +@file:Suppress("FunctionName") + package org.jetbrains.dokka.gradle +import com.android.build.gradle.api.AndroidSourceSet import groovy.lang.Closure import org.gradle.api.Action +import org.gradle.api.Project import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Internal import org.gradle.api.tasks.Optional import org.gradle.util.ConfigureUtil import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.DokkaConfiguration.* +import org.jetbrains.dokka.DokkaDefaults +import org.jetbrains.dokka.DokkaSourceSetID import org.jetbrains.dokka.Platform import java.io.File import java.io.Serializable @@ -14,8 +21,10 @@ import java.net.URL import java.util.concurrent.Callable import kotlin.reflect.KMutableProperty import kotlin.reflect.full.memberProperties +import org.gradle.api.tasks.SourceSet as GradleSourceSet +import org.jetbrains.kotlin.gradle.model.SourceSet as KotlinSourceSet -class GradleSourceRootImpl: SourceRoot, Serializable { +class GradleSourceRootImpl : SourceRoot, Serializable { override var path: String = "" set(value) { field = File(value).absolutePath @@ -24,34 +33,113 @@ class GradleSourceRootImpl: SourceRoot, Serializable { override fun toString(): String = path } -open class GradlePassConfigurationImpl(@Transient val name: String = ""): PassConfiguration { - @Input @Optional override var classpath: List<String> = emptyList() - @Input override var moduleName: String = "" - @Input override var sourceRoots: MutableList<SourceRoot> = mutableListOf() - @Input override var samples: List<String> = emptyList() - @Input override var includes: List<String> = emptyList() - @Input override var includeNonPublic: Boolean = false - @Input override var includeRootPackage: Boolean = false - @Input override var reportUndocumented: Boolean = false - @Input override var skipEmptyPackages: Boolean = true - @Input override var skipDeprecated: Boolean = false - @Input override var jdkVersion: Int = 6 - @Input override var sourceLinks: MutableList<SourceLinkDefinition> = mutableListOf() - @Input override var perPackageOptions: MutableList<PackageOptions> = mutableListOf() - @Input override var externalDocumentationLinks: MutableList<ExternalDocumentationLink> = mutableListOf() - @Input @Optional override var languageVersion: String? = null - @Input @Optional override var apiVersion: String? = null - @Input override var noStdlibLink: Boolean = false - @Input override var noJdkLink: Boolean = false - @Input var noAndroidSdkLink: Boolean = false - @Input override var suppressedFiles: List<String> = emptyList() - @Input override var collectInheritedExtensionsFromLibraries: Boolean = false - @Input override var analysisPlatform: Platform = Platform.DEFAULT - @Input @Optional var platform: String? = null - @Input override var targets: List<String> = emptyList() - @Input @Optional override var sinceKotlin: String? = null - @Transient var collectKotlinTasks: (() -> List<Any?>?)? = null - @Input @Transient var androidVariants: List<String> = emptyList() +open class GradleDokkaSourceSet constructor( + @Transient @get:Input val name: String, + @Transient @get:Internal internal val project: Project +) : DokkaSourceSet { + + @Input + @Optional + override var classpath: List<String> = emptyList() + + @Input + override var moduleDisplayName: String = "" + + @Input + override var displayName: String = "" + + @get:Internal + override val sourceSetID: DokkaSourceSetID = DokkaSourceSetID(project, name) + + @Input + override var sourceRoots: MutableList<SourceRoot> = mutableListOf() + + @Input + override var dependentSourceSets: MutableSet<DokkaSourceSetID> = mutableSetOf() + + @Input + override var samples: List<String> = emptyList() + + @Input + override var includes: List<String> = emptyList() + + @Input + override var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic + + @Input + override var includeRootPackage: Boolean = DokkaDefaults.includeRootPackage + + @Input + override var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented + + @Input + override var skipEmptyPackages: Boolean = DokkaDefaults.skipEmptyPackages + + @Input + override var skipDeprecated: Boolean = DokkaDefaults.skipDeprecated + + @Input + override var jdkVersion: Int = DokkaDefaults.jdkVersion + + @Input + override var sourceLinks: MutableList<SourceLinkDefinition> = mutableListOf() + + @Input + override var perPackageOptions: MutableList<PackageOptions> = mutableListOf() + + @Input + override var externalDocumentationLinks: MutableList<ExternalDocumentationLink> = mutableListOf() + + @Input + @Optional + override var languageVersion: String? = null + + @Input + @Optional + override var apiVersion: String? = null + + @Input + override var noStdlibLink: Boolean = DokkaDefaults.noStdlibLink + + @Input + override var noJdkLink: Boolean = DokkaDefaults.noJdkLink + + @Input + var noAndroidSdkLink: Boolean = false + + @Input + override var suppressedFiles: List<String> = emptyList() + + @Input + override var analysisPlatform: Platform = DokkaDefaults.analysisPlatform + + @Input + @Optional + var platform: String? = null + + @Internal + @Transient + var collectKotlinTasks: (() -> List<Any?>?)? = null + + fun DokkaSourceSetID(sourceSetName: String): DokkaSourceSetID { + return DokkaSourceSetID(project, sourceSetName) + } + + fun dependsOn(sourceSet: GradleSourceSet) { + dependsOn(DokkaSourceSetID(sourceSet.name)) + } + + fun dependsOn(sourceSet: DokkaSourceSet) { + dependsOn(sourceSet.sourceSetID) + } + + fun dependsOn(sourceSetName: String) { + dependsOn(DokkaSourceSetID(sourceSetName)) + } + + fun dependsOn(sourceSetID: DokkaSourceSetID) { + dependentSourceSets.add(sourceSetID) + } fun kotlinTasks(taskSupplier: Callable<List<Any>>) { collectKotlinTasks = { taskSupplier.call() } @@ -95,70 +183,76 @@ open class GradlePassConfigurationImpl(@Transient val name: String = ""): PassCo } fun externalDocumentationLink(c: Closure<Unit>) { - val builder = ConfigureUtil.configure(c, GradleExternalDocumentationLinkImpl.Builder()) - externalDocumentationLinks.add(builder.build()) + val link = ConfigureUtil.configure(c, GradleExternalDocumentationLinkImpl()) + externalDocumentationLinks.add(ExternalDocumentationLink.Builder(link.url, link.packageListUrl).build()) } - fun externalDocumentationLink(action: Action<in GradleExternalDocumentationLinkImpl.Builder>) { - val builder = GradleExternalDocumentationLinkImpl.Builder() - action.execute(builder) - externalDocumentationLinks.add(builder.build()) + fun externalDocumentationLink(action: Action<in GradleExternalDocumentationLinkImpl>) { + val link = GradleExternalDocumentationLinkImpl() + action.execute(link) + externalDocumentationLinks.add(ExternalDocumentationLink.Builder(link.url, link.packageListUrl).build()) } } +fun GradleDokkaSourceSet.dependsOn(sourceSet: KotlinSourceSet) { + dependsOn(DokkaSourceSetID(sourceSet.name)) +} + +fun GradleDokkaSourceSet.dependsOn(sourceSet: org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet) { + dependsOn(DokkaSourceSetID(sourceSet.name)) +} + +fun GradleDokkaSourceSet.dependsOn(sourceSet: AndroidSourceSet) { + dependsOn(DokkaSourceSetID(sourceSet.name)) +} + class GradleSourceLinkDefinitionImpl : SourceLinkDefinition, Serializable { override var path: String = "" override var url: String = "" override var lineSuffix: String? = null } -class GradleExternalDocumentationLinkImpl( - override val url: URL, - override val packageListUrl: URL -): ExternalDocumentationLink, Serializable { - open class Builder(open var url: URL? = null, - open var packageListUrl: URL? = null) { - - constructor(root: String, packageList: String? = null) : this(URL(root), packageList?.let { URL(it) }) +class GradleExternalDocumentationLinkImpl : ExternalDocumentationLink, Serializable { + override var url: URL = URL("http://") + override var packageListUrl: URL = URL("http://") +} - fun build(): ExternalDocumentationLink = - if (packageListUrl != null && url != null) - GradleExternalDocumentationLinkImpl(url!!, packageListUrl!!) - else if (url != null) - GradleExternalDocumentationLinkImpl(url!!, URL(url!!, "package-list")) - else - throw IllegalArgumentException("url or url && packageListUrl must not be null for external documentation link") - } +class GradleDokkaModuleDescription : DokkaModuleDescription { + override var name: String = "" + override var path: String = "" + override var docFile: String = "" } -class GradleDokkaConfigurationImpl: DokkaConfiguration { +class GradleDokkaConfigurationImpl : DokkaConfiguration { override var outputDir: String = "" - override var format: String = "html" - override var generateIndexPages: Boolean = false - override var cacheRoot: String? = null - override var impliedPlatforms: List<String> = emptyList() - override var passesConfigurations: List<GradlePassConfigurationImpl> = emptyList() + override var cacheRoot: String? = DokkaDefaults.cacheRoot + override var offlineMode: Boolean = DokkaDefaults.offlineMode + override var failOnWarning: Boolean = DokkaDefaults.failOnWarning + override var sourceSets: List<GradleDokkaSourceSet> = emptyList() + override var pluginsClasspath: List<File> = emptyList() + override var pluginsConfiguration: Map<String, String> = mutableMapOf() + override var modules: List<GradleDokkaModuleDescription> = emptyList() } -class GradlePackageOptionsImpl: PackageOptions, Serializable { +class GradlePackageOptionsImpl : PackageOptions, Serializable { override var prefix: String = "" - override var includeNonPublic: Boolean = false - override var reportUndocumented: Boolean = false - override var skipDeprecated: Boolean = false - override var suppress: Boolean = false + override var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic + override var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented + override var skipDeprecated: Boolean = DokkaDefaults.skipDeprecated + override var suppress: Boolean = DokkaDefaults.suppress } -fun GradlePassConfigurationImpl.copy(): GradlePassConfigurationImpl { - val newObj = GradlePassConfigurationImpl(this.name) +internal fun GradleDokkaSourceSet.copy(): GradleDokkaSourceSet { + val newObj = GradleDokkaSourceSet(this.name, this.project) this::class.memberProperties.forEach { field -> if (field is KMutableProperty<*>) { - val value = field.getter.call(this) - if (value is Collection<*>) { - field.setter.call(newObj, value.toMutableList()) - } else { - field.setter.call(newObj, field.getter.call(this)) + when (val value = field.getter.call(this)) { + is List<*> -> field.setter.call(newObj, value.toMutableList()) + is Set<*> -> field.setter.call(newObj, value.toMutableSet()) + else -> field.setter.call(newObj, field.getter.call(this)) } + } } return newObj -}
\ No newline at end of file +} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/defaultDokkaOutputDirectory.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/defaultDokkaOutputDirectory.kt new file mode 100644 index 00000000..0a7ab534 --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/defaultDokkaOutputDirectory.kt @@ -0,0 +1,13 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.api.Task +import java.io.File + +internal fun Task.defaultDokkaOutputDirectory(): File { + return defaultDokkaOutputDirectory(project.buildDir, name) +} + +internal fun defaultDokkaOutputDirectory(buildDir: File, taskName: String): File { + val formatClassifier = taskName.removePrefix("dokka").decapitalize() + return File(buildDir, "dokka${File.separator}$formatClassifier") +} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaConfigurations.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaConfigurations.kt new file mode 100644 index 00000000..20f54cc5 --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaConfigurations.kt @@ -0,0 +1,41 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.api.Project +import org.gradle.api.artifacts.Configuration +import org.gradle.api.attributes.Usage + +internal fun Project.maybeCreateDokkaDefaultPluginConfiguration(): Configuration { + return configurations.maybeCreate("dokkaPlugin") { + attributes.attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, "java-runtime")) + isCanBeConsumed = false + } +} + +internal fun Project.maybeCreateDokkaDefaultRuntimeConfiguration(): Configuration { + return configurations.maybeCreate("dokkaRuntime") { + attributes.attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, "java-runtime")) + isCanBeConsumed = false + } +} + +internal fun Project.maybeCreateDokkaPluginConfiguration(dokkaTaskName: String): Configuration { + return project.configurations.maybeCreate("${dokkaTaskName}Plugin") { + extendsFrom(maybeCreateDokkaDefaultPluginConfiguration()) + attributes.attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, "java-runtime")) + isCanBeConsumed = false + defaultDependencies { dependencies -> + dependencies.add(project.dokkaArtifacts.dokkaBase) + } + } +} + +internal fun Project.maybeCreateDokkaRuntimeConfiguration(dokkaTaskName: String): Configuration { + return project.configurations.maybeCreate("${dokkaTaskName}Runtime") { + extendsFrom(maybeCreateDokkaDefaultRuntimeConfiguration()) + attributes.attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, "java-runtime")) + isCanBeConsumed = false + defaultDependencies { dependencies -> + dependencies.add(project.dokkaArtifacts.dokkaCore) + } + } +} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt index 7ed29c58..d70448f1 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt @@ -2,57 +2,49 @@ package org.jetbrains.dokka.gradle import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.artifacts.Configuration -import org.gradle.util.GradleVersion -import java.io.File -import java.io.InputStream -import java.util.* - -internal const val CONFIGURATION_EXTENSION_NAME = "configuration" -internal const val MULTIPLATFORM_EXTENSION_NAME = "multiplatform" +import org.gradle.kotlin.dsl.register open class DokkaPlugin : Plugin<Project> { - private val taskName = "dokka" - override fun apply(project: Project) { - loadDokkaVersion() - val dokkaRuntimeConfiguration = addConfiguration(project) - addTasks(project, dokkaRuntimeConfiguration, DokkaTask::class.java) - } - private fun loadDokkaVersion() = DokkaVersion.loadFrom(javaClass.getResourceAsStream("/META-INF/gradle-plugins/org.jetbrains.dokka.properties")) + project.setupDokkaTasks("dokkaHtml") - private fun addConfiguration(project: Project) = - project.configurations.create("dokkaRuntime").apply { - defaultDependencies{ dependencies -> dependencies.add(project.dependencies.create("org.jetbrains.dokka:dokka-fatjar:${DokkaVersion.version}")) } + project.setupDokkaTasks("dokkaJavadoc") { + plugins.dependencies.add(project.dokkaArtifacts.javadocPlugin) } - protected open fun addTasks(project: Project, runtimeConfiguration: Configuration, taskClass: Class<out DokkaTask>) { - if(GradleVersion.current() >= GradleVersion.version("4.10")) { - project.tasks.register(taskName, taskClass) - } else { - project.tasks.create(taskName, taskClass) + project.setupDokkaTasks("dokkaGfm") { + plugins.dependencies.add(project.dokkaArtifacts.gfmPlugin) } - project.tasks.withType(taskClass) { task -> - task.multiplatform = project.container(GradlePassConfigurationImpl::class.java) - task.configuration = GradlePassConfigurationImpl() - task.dokkaRuntime = runtimeConfiguration - task.outputDirectory = File(project.buildDir, taskName).absolutePath + + project.setupDokkaTasks("dokkaJekyll") { + plugins.dependencies.add(project.dokkaArtifacts.jekyllPlugin) } } -} -object DokkaVersion { - var version: String? = null + /** + * Creates [DokkaTask], [DokkaMultimoduleTask] and [DokkaCollectorTask] for the given + * name and configuration. + */ + private fun Project.setupDokkaTasks(name: String, configuration: AbstractDokkaTask.() -> Unit = {}) { + project.maybeCreateDokkaPluginConfiguration(name) + project.maybeCreateDokkaRuntimeConfiguration(name) + project.tasks.register<DokkaTask>(name) { + configuration() + } - fun loadFrom(stream: InputStream) { - version = Properties().apply { - load(stream) - }.getProperty("dokka-version") + if (project.subprojects.isNotEmpty()) { + val multimoduleName = "${name}Multimodule" + project.maybeCreateDokkaPluginConfiguration(multimoduleName) + project.maybeCreateDokkaRuntimeConfiguration(multimoduleName) + project.tasks.register<DokkaMultimoduleTask>(multimoduleName) { + dokkaTaskNames = dokkaTaskNames + name + configuration() + } + + project.tasks.register<DokkaCollectorTask>("${name}Collector") { + dokkaTaskNames = dokkaTaskNames + name + } + } } } - -object ClassloaderContainer { - @JvmField - var fatJarClassLoader: ClassLoader? = null -}
\ No newline at end of file diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt index 31892e8e..b6c5cbd8 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka.gradle +import org.gradle.api.NamedDomainObjectContainer import org.gradle.api.Project import org.gradle.api.UnknownDomainObjectException import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension @@ -7,25 +8,30 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType import org.jetbrains.kotlin.gradle.plugin.KotlinTarget -fun Project.isAndroidProject() = try { +internal fun Project.isAndroidProject() = try { project.extensions.getByName("android") true -} catch(e: UnknownDomainObjectException) { +} catch (e: UnknownDomainObjectException) { false -} catch(e: ClassNotFoundException) { +} catch (e: ClassNotFoundException) { false } -fun Project.isMultiplatformProject() = try { +internal fun Project.isNotMultiplatformProject() = !isMultiplatformProject() + +internal fun Project.isMultiplatformProject() = try { project.extensions.getByType(KotlinMultiplatformExtension::class.java) true -} catch(e: UnknownDomainObjectException) { +} catch (e: UnknownDomainObjectException) { false -} catch (e: NoClassDefFoundError){ +} catch (e: NoClassDefFoundError) { false -} catch(e: ClassNotFoundException) { +} catch (e: ClassNotFoundException) { false } -fun KotlinTarget.isAndroidTarget() = this.platformType == KotlinPlatformType.androidJvm -fun DokkaTask.isMultiplatformProject() = this.multiplatform.isNotEmpty()
\ No newline at end of file +internal fun KotlinTarget.isAndroidTarget() = this.platformType == KotlinPlatformType.androidJvm + +internal fun <T : Any> NamedDomainObjectContainer<T>.maybeCreate(name: String, configuration: T.() -> Unit): T { + return findByName(name) ?: create(name, configuration) +} diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AutomagicProxyTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AutomagicProxyTest.kt new file mode 100644 index 00000000..e981d6fe --- /dev/null +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AutomagicProxyTest.kt @@ -0,0 +1,48 @@ +package org.jetbrains.dokka.gradle + +import org.jetbrains.dokka.DokkaBootstrap +import org.jetbrains.dokka.gradle.AutomagicProxyTest.TestInterface +import java.util.function.BiConsumer +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + + +class AutomagicProxyTest { + + private class TestException(message: String, cause: Throwable?) : Exception(message, cause) + + private fun interface TestInterface { + @Throws(Throwable::class) + operator fun invoke(): Int + } + + @Test + fun `simple method invocation`() { + val instance = TestInterface { 0 } + val proxy = automagicTypedProxy<TestInterface>(instance.javaClass.classLoader, instance) + assertEquals(0, proxy()) + } + + @Test + fun `exception throw in DokkaBootstrap is not wrapped inside UndeclaredThrowableException`() { + val instanceThrowingTestException = object : DokkaBootstrap { + override fun configure(serializedConfigurationJSON: String, logger: BiConsumer<String, String>) = Unit + override fun generate() { + throw TestException("Test Exception Message", Exception("Cause Exception Message")) + } + } + + val proxy = automagicTypedProxy<DokkaBootstrap>( + instanceThrowingTestException.javaClass.classLoader, + instanceThrowingTestException + ) + + val exception = assertFailsWith<TestException> { + proxy.generate() + } + + assertEquals("Test Exception Message", exception.message) + assertEquals("Cause Exception Message", exception.cause?.message) + } +} diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaTasksTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaTasksTest.kt new file mode 100644 index 00000000..b948c540 --- /dev/null +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaTasksTest.kt @@ -0,0 +1,65 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.api.plugins.JavaBasePlugin +import org.gradle.kotlin.dsl.withType +import org.gradle.testfixtures.ProjectBuilder +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertSame +import kotlin.test.assertTrue + +class DokkaTasksTest { + + @Test + fun `one task per format is registered`() { + val project = ProjectBuilder.builder().build() + project.plugins.apply("org.jetbrains.dokka") + + assertTrue( + project.tasks.findByName("dokkaHtml") is DokkaTask, + "Expected DokkaTask: dokkaHtml" + ) + + assertTrue( + project.tasks.findByName("dokkaGfm") is DokkaTask, + "Expected DokkaTask: dokkaGfm" + ) + + assertTrue( + project.tasks.findByName("dokkaJekyll") is DokkaTask, + "Expected DokkaTask: dokkaJekyll" + ) + + assertTrue( + project.tasks.findByName("dokkaJavadoc") is DokkaTask, + "Expected DokkaTask: dokkaJavadoc" + ) + } + + @Test + fun `dokka plugin configurations extend dokkaPlugin`() { + val project = ProjectBuilder.builder().build() + project.plugins.apply("org.jetbrains.dokka") + + val dokkaPluginsConfiguration = project.maybeCreateDokkaDefaultPluginConfiguration() + + project.tasks.withType<DokkaTask>().forEach { dokkaTask -> + assertSame( + dokkaTask.plugins.extendsFrom.single(), dokkaPluginsConfiguration, + "Expected dokka plugins configuration to extend default ${dokkaPluginsConfiguration.name} configuration" + ) + } + } + + @Test + fun `all dokka tasks are part of the documentation group`() { + val project = ProjectBuilder.builder().build() + project.plugins.apply("org.jetbrains.dokka") + project.tasks.filter { "dokka" in it.name.toLowerCase() }.forEach { dokkaTask -> + assertEquals( + JavaBasePlugin.DOCUMENTATION_GROUP, dokkaTask.group, + "Expected task: ${dokkaTask.path} group to be ${JavaBasePlugin.DOCUMENTATION_GROUP}" + ) + } + } +} diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt new file mode 100644 index 00000000..7b78fb55 --- /dev/null +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt @@ -0,0 +1,97 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.testfixtures.ProjectBuilder +import org.jetbrains.dokka.DokkaSourceSetID +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension +import kotlin.test.Test +import kotlin.test.assertEquals + +class KotlinDslDokkaTaskConfigurationTest { + + @Test + fun `configure project using dokka extension function`() { + val project = ProjectBuilder.builder().build() + project.plugins.apply("org.jetbrains.dokka") + project.tasks.withType(DokkaTask::class.java).forEach { dokkaTask -> + dokkaTask.outputDirectory = "test" + } + + project.tasks.withType(DokkaTask::class.java).forEach { dokkaTask -> + assertEquals("test", dokkaTask.outputDirectory) + } + } + + @Test + fun `sourceSet dependsOn by String`() { + val project = ProjectBuilder.builder().build() + project.plugins.apply("org.jetbrains.dokka") + + project.tasks.withType(DokkaTask::class.java).forEach { dokkaTask -> + dokkaTask.dokkaSourceSets.run { + val commonMain = create("commonMain") + val jvmMain = create("jvmMain") { + it.dependsOn("commonMain") + } + + assertEquals( + 0, commonMain.dependentSourceSets.size, + "Expected no dependent source set in commonMain" + ) + + assertEquals( + 1, jvmMain.dependentSourceSets.size, + "Expected only one dependent source set in jvmMain" + ) + + assertEquals( + commonMain.sourceSetID, jvmMain.dependentSourceSets.single(), + "Expected jvmMain to depend on commonMain" + ) + + assertEquals( + DokkaSourceSetID(project.path, "commonMain"), commonMain.sourceSetID + ) + } + } + } + + @Test + fun `sourceSet dependsOn by DokkaSourceSet`() { + val project = ProjectBuilder.builder().build() + project.plugins.apply("org.jetbrains.dokka") + + project.tasks.withType(DokkaTask::class.java).first().run { + dokkaSourceSets.run { + val commonMain = create("commonMain") + val jvmMain = create("jvmMain") { + it.dependsOn(commonMain) + } + + assertEquals( + commonMain.sourceSetID, jvmMain.dependentSourceSets.single() + ) + } + } + } + + @Test + fun `sourceSet dependsOn by KotlinSourceSet`() { + val project = ProjectBuilder.builder().build() + project.plugins.apply("org.jetbrains.dokka") + project.plugins.apply("org.jetbrains.kotlin.jvm") + + val kotlin = project.extensions.getByName("kotlin") as KotlinJvmProjectExtension + + project.tasks.withType(DokkaTask::class.java).first().run { + dokkaSourceSets.run { + val special = create("special") { + it.dependsOn(kotlin.sourceSets.getByName("main")) + } + + assertEquals( + DokkaSourceSetID(project, "main"), special.dependentSourceSets.single() + ) + } + } + } +} diff --git a/runners/maven-plugin/build.gradle b/runners/maven-plugin/build.gradle deleted file mode 100644 index 76fab68d..00000000 --- a/runners/maven-plugin/build.gradle +++ /dev/null @@ -1,161 +0,0 @@ -import groovy.io.FileType -import org.jetbrains.CorrectShadowPublishing -import org.jetbrains.CrossPlatformExec - -import java.nio.file.Files -import java.nio.file.StandardCopyOption - -apply plugin: 'kotlin' -apply plugin: 'com.github.johnrengelman.shadow' - -sourceCompatibility = 1.8 - -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { - kotlinOptions { - freeCompilerArgs += "-Xjsr305=strict" - languageVersion = "1.2" - apiVersion = languageVersion - jvmTarget = "1.8" - } -} - -configurations { - maven -} - -dependencies { - maven group: "org.apache.maven", name: 'apache-maven', version: maven_version, classifier: 'bin', ext: 'zip' - - shadow project(":runners:fatjar") - shadow "org.apache.maven:maven-core:$maven_version" - shadow "org.apache.maven:maven-model:$maven_version" - shadow "org.apache.maven:maven-plugin-api:$maven_version" - shadow "org.apache.maven:maven-archiver:$maven_archiver_version" - shadow "org.codehaus.plexus:plexus-utils:$plexus_utils_version" - shadow "org.codehaus.plexus:plexus-archiver:$plexus_archiver_version" - shadow "org.apache.maven.plugin-tools:maven-plugin-annotations:$maven_plugin_tools_version" - shadow "com.github.olivergondza:maven-jdk-tools-wrapper:0.1" -} - -final File mavenHome = new File(buildDir, "maven-bin") -final File mvn = new File(mavenHome, "apache-maven-$maven_version/bin/mvn") - -tasks.clean.doLast { - delete mavenHome -} - -task setupMaven(type: Sync) { - from configurations.maven.collect{ zipTree(it) } - into "$buildDir/maven-bin" -} - -def mavenBuildDir = "$buildDir/maven" - - -sourceSets.main.resources { - srcDirs += "$mavenBuildDir/classes/java/main" - exclude "**/*.class" -} - -task generatePom() { - inputs.file(new File(projectDir, "pom.tpl.xml")) - outputs.file(new File(mavenBuildDir, "pom.xml")) - doLast { - final pomTemplate = new File(projectDir, "pom.tpl.xml") - final pom = new File(mavenBuildDir, "pom.xml") - pom.parentFile.mkdirs() - pom.text = pomTemplate.text.replace("<version>dokka_version</version>", "<version>$dokka_version</version>") - .replace("<maven.version></maven.version>", "<maven.version>$maven_version</maven.version>") - .replace("<version>maven-plugin-plugin</version>", "<version>$maven_plugin_tools_version</version>") - } -} -// -//task mergeClassOutputs doLast { -// def sourceDir = new File(buildDir, "classes/kotlin") -// def targetDir = new File(buildDir, "classes/java") -// -// sourceDir.eachFileRecurse FileType.ANY, { -// def filePath = it.toPath() -// def targetFilePath = targetDir.toPath().resolve(sourceDir.toPath().relativize(filePath)) -// if (it.isFile()) { -// Files.move(filePath, targetFilePath, StandardCopyOption.REPLACE_EXISTING) -// } else if (it.isDirectory()) { -// targetFilePath.toFile().mkdirs() -// } -// } -//} - - - -task syncKotlinClasses(type: Sync, dependsOn: compileKotlin) { - from "$buildDir/classes/kotlin" - into "$mavenBuildDir/classes/java" - - preserve { - include '**/*.class' - } -} - -task syncJavaClasses(type: Sync, dependsOn: compileJava) { - from "$buildDir/classes/java" - into "$mavenBuildDir/classes/java" - - preserve { - include '**/*.class' - } -} - -task helpMojo(type: CrossPlatformExec, dependsOn: setupMaven) { - workingDir mavenBuildDir - commandLine mvn, '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:helpmojo' - - dependsOn syncKotlinClasses -} - - -task pluginDescriptor(type: CrossPlatformExec, dependsOn: setupMaven) { - workingDir mavenBuildDir - commandLine mvn, '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:descriptor' - - dependsOn syncJavaClasses -} - - -//mergeClassOutputs.dependsOn compileKotlin -//helpMojo.dependsOn mergeClassOutputs -helpMojo.dependsOn generatePom -sourceSets.main.java.srcDir("$buildDir/maven/generated-sources/plugin") -compileJava.dependsOn helpMojo -processResources.dependsOn pluginDescriptor - -pluginDescriptor.dependsOn generatePom - -shadowJar { - baseName = 'dokka-maven-plugin' - classifier = '' -} - -shadowJar.dependsOn pluginDescriptor - - -task sourceJar(type: Jar) { - from sourceSets.main.allSource -} - -apply plugin: 'maven-publish' - -publishing { - publications { - dokkaMavenPlugin(MavenPublication) { MavenPublication publication -> - artifactId = 'dokka-maven-plugin' - - artifact sourceJar { - classifier "sources" - } - - CorrectShadowPublishing.configure(publication, project) - } - } -} - -bintrayPublication(project, ['dokkaMavenPlugin']) diff --git a/runners/maven-plugin/build.gradle.kts b/runners/maven-plugin/build.gradle.kts new file mode 100644 index 00000000..fbd2b48a --- /dev/null +++ b/runners/maven-plugin/build.gradle.kts @@ -0,0 +1,98 @@ +import org.jetbrains.CrossPlatformExec +import org.jetbrains.SetupMaven +import org.jetbrains.registerDokkaArtifactPublication + +val setupMaven by tasks.register<SetupMaven>("setupMaven") + +dependencies { + implementation(project(":core")) + implementation("org.apache.maven:maven-core:${setupMaven.mavenVersion}") + implementation("org.apache.maven:maven-plugin-api:${setupMaven.mavenVersion}") + implementation("org.apache.maven.plugin-tools:maven-plugin-annotations:${setupMaven.mavenPluginToolsVersion}") + implementation("org.apache.maven:maven-archiver:2.5") + implementation(kotlin("stdlib-jdk8")) + implementation("org.eclipse.aether:aether-api:${setupMaven.aetherVersion}") + implementation("org.eclipse.aether:aether-spi:${setupMaven.aetherVersion}") + implementation("org.eclipse.aether:aether-impl:${setupMaven.aetherVersion}") + implementation("org.eclipse.aether:aether-connector-basic:${setupMaven.aetherVersion}") + implementation("org.eclipse.aether:aether-transport-file:${setupMaven.aetherVersion}") + implementation("org.eclipse.aether:aether-transport-http:${setupMaven.aetherVersion}") + implementation("org.apache.maven:maven-aether-provider:3.3.3") +} + +tasks.named<Delete>("clean") { + delete(setupMaven.mavenBuildDir) + delete(setupMaven.mavenBinDir) +} + +/** + * Generate pom.xml for Maven Plugin Plugin + */ +val generatePom by tasks.registering(Copy::class) { + val dokka_version: String by project + inputs.property("dokka_version", dokka_version) + + from("$projectDir/pom.tpl.xml") { + rename("(.*).tpl.xml", "$1.xml") + } + into(setupMaven.mavenBuildDir) + + eachFile { + filter { line -> + line.replace("<maven.version></maven.version>", "<maven.version>${setupMaven.mavenVersion}</maven.version>") + } + filter { line -> + line.replace("<version>dokka_version</version>", "<version>$dokka_version</version>") + } + filter { line -> + line.replace( + "<version>maven-plugin-plugin</version>", + "<version>${setupMaven.mavenPluginToolsVersion}</version>" + ) + } + } +} + +/** + * Copy compiled classes to [mavenBuildDir] for Maven Plugin Plugin + */ +val syncClasses by tasks.registering(Sync::class) { + dependsOn(tasks.compileKotlin, tasks.compileJava) + from("$buildDir/classes/kotlin", "$buildDir/classes/java") + into("${setupMaven.mavenBuildDir}/classes/java") + + preserve { + include("**/*.class") + } +} + +val helpMojo by tasks.registering(CrossPlatformExec::class) { + dependsOn(setupMaven, generatePom, syncClasses) + workingDir(setupMaven.mavenBuildDir) + commandLine(setupMaven.mvn, "-e", "-B", "org.apache.maven.plugins:maven-plugin-plugin:helpmojo") +} + +val pluginDescriptor by tasks.registering(CrossPlatformExec::class) { + dependsOn(setupMaven, generatePom, syncClasses) + workingDir(setupMaven.mavenBuildDir) + commandLine(setupMaven.mvn, "-e", "-B", "org.apache.maven.plugins:maven-plugin-plugin:descriptor") +} + +val sourceJar by tasks.registering(Jar::class) { + archiveClassifier.set("sources") + from(sourceSets["main"].allSource) +} + +tasks.named<Jar>("jar") { + dependsOn(pluginDescriptor, helpMojo) + metaInf { + from("${setupMaven.mavenBuildDir}/classes/java/main/META-INF") + } + manifest { + attributes("Class-Path" to configurations.runtimeClasspath.get().files.joinToString(" ") { it.name }) + } +} + +registerDokkaArtifactPublication("dokkaMavenPlugin") { + artifactId = "dokka-maven-plugin" +} diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index 1cbe39f3..514df151 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -3,15 +3,32 @@ package org.jetbrains.dokka.maven import org.apache.maven.archiver.MavenArchiveConfiguration import org.apache.maven.archiver.MavenArchiver import org.apache.maven.execution.MavenSession +import org.apache.maven.model.Dependency import org.apache.maven.plugin.AbstractMojo import org.apache.maven.plugin.MojoExecutionException import org.apache.maven.plugins.annotations.* import org.apache.maven.project.MavenProject import org.apache.maven.project.MavenProjectHelper +import org.apache.maven.repository.internal.MavenRepositorySystemUtils import org.codehaus.plexus.archiver.Archiver import org.codehaus.plexus.archiver.jar.JarArchiver +import org.eclipse.aether.DefaultRepositorySystemSession +import org.eclipse.aether.RepositorySystem +import org.eclipse.aether.RepositorySystemSession +import org.eclipse.aether.artifact.DefaultArtifact +import org.eclipse.aether.collection.CollectRequest +import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory +import org.eclipse.aether.graph.DependencyNode +import org.eclipse.aether.impl.DefaultServiceLocator +import org.eclipse.aether.repository.LocalRepository +import org.eclipse.aether.repository.RemoteRepository +import org.eclipse.aether.resolution.DependencyRequest +import org.eclipse.aether.spi.connector.RepositoryConnectorFactory +import org.eclipse.aether.spi.connector.transport.TransporterFactory +import org.eclipse.aether.transport.file.FileTransporterFactory +import org.eclipse.aether.transport.http.HttpTransporterFactory +import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator import org.jetbrains.dokka.* -import org.jetbrains.dokka.Utilities.defaultLinks import java.io.File import java.net.URL @@ -30,36 +47,47 @@ class ExternalDocumentationLinkBuilder : DokkaConfiguration.ExternalDocumentatio @Parameter(name = "url", required = true) override var url: URL? = null + @Parameter(name = "packageListUrl", required = true) override var packageListUrl: URL? = null } -abstract class AbstractDokkaMojo : AbstractMojo() { +abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List<Dependency>) : AbstractMojo() { class SourceRoot : DokkaConfiguration.SourceRoot { @Parameter(required = true) override var path: String = "" } + @Parameter(defaultValue = "\${project}", readonly = true) + private var mavenProject: MavenProject? = null + + @Parameter() + private var session: RepositorySystemSession? = null + class PackageOptions : DokkaConfiguration.PackageOptions { @Parameter override var prefix: String = "" + @Parameter - override var includeNonPublic: Boolean = false + override var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic + @Parameter - override var reportUndocumented: Boolean = true + override var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented + @Parameter - override var skipDeprecated: Boolean = false + override var skipDeprecated: Boolean = DokkaDefaults.skipDeprecated + @Parameter - override var suppress: Boolean = false + override var suppress: Boolean = DokkaDefaults.suppress } + @Parameter + var sourceSetName: String = "JVM" + @Parameter(required = true, defaultValue = "\${project.compileSourceRoots}") var sourceDirectories: List<String> = emptyList() @Parameter - var sourceRoots: List<SourceRoot> = emptyList() - - @Parameter var samples: List<String> = emptyList() @Parameter @@ -74,18 +102,23 @@ abstract class AbstractDokkaMojo : AbstractMojo() { @Parameter(required = true, defaultValue = "\${project.artifactId}") var moduleName: String = "" + @Parameter + var moduleDisplayName: String = "" + @Parameter(required = false, defaultValue = "false") var skip: Boolean = false - @Parameter(required = false, defaultValue = "6") - var jdkVersion: Int = 6 + @Parameter(required = false, defaultValue = "${DokkaDefaults.jdkVersion}") + var jdkVersion: Int = DokkaDefaults.jdkVersion @Parameter - var skipDeprecated: Boolean = false + var skipDeprecated: Boolean = DokkaDefaults.skipDeprecated + @Parameter - var skipEmptyPackages: Boolean = true + var skipEmptyPackages: Boolean = DokkaDefaults.skipEmptyPackages + @Parameter - var reportUndocumented: Boolean = true + var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented @Parameter var impliedPlatforms: List<String> = emptyList() @@ -96,15 +129,21 @@ abstract class AbstractDokkaMojo : AbstractMojo() { @Parameter var externalDocumentationLinks: List<ExternalDocumentationLinkBuilder> = emptyList() - @Parameter(defaultValue = "false") - var noStdlibLink: Boolean = false + @Parameter(defaultValue = "${DokkaDefaults.noStdlibLink}") + var noStdlibLink: Boolean = DokkaDefaults.noStdlibLink - @Parameter(defaultValue = "false") - var noJdkLink: Boolean = false + @Parameter(defaultValue = "${DokkaDefaults.noJdkLink}") + var noJdkLink: Boolean = DokkaDefaults.noJdkLink @Parameter var cacheRoot: String? = null + @Parameter(defaultValue = "JVM") + var displayName: String = "JVM" + + @Parameter(defaultValue = "${DokkaDefaults.offlineMode}") + var offlineMode: Boolean = DokkaDefaults.offlineMode + @Parameter var languageVersion: String? = null @@ -112,33 +151,26 @@ abstract class AbstractDokkaMojo : AbstractMojo() { var apiVersion: String? = null @Parameter - var includeRootPackage: Boolean = false - - @Parameter - var suppressedFiles: List<String> = emptyList() + var includeRootPackage: Boolean = DokkaDefaults.includeRootPackage @Parameter - var collectInheritedExtensionsFromLibraries: Boolean = false + var suppressedFiles: List<String> = emptyList() @Parameter var platform: String = "" @Parameter - var targets: List<String> = emptyList() + var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic @Parameter - var sinceKotlin: String? = null + var failOnWarning: Boolean = DokkaDefaults.failOnWarning @Parameter - var includeNonPublic: Boolean = false - - @Parameter - var generateIndexPages: Boolean = false + var dokkaPlugins: List<Dependency> = emptyList() + get() = field + defaultDokkaPlugins protected abstract fun getOutDir(): String - protected abstract fun getOutFormat(): String - override fun execute() { if (skip) { log.info("Dokka skip parameter is true so no dokka output will be produced") @@ -150,18 +182,36 @@ abstract class AbstractDokkaMojo : AbstractMojo() { throw MojoExecutionException("Incorrect path property, only Unix based path allowed.") } } + fun defaultLinks(config: DokkaSourceSetImpl): List<ExternalDocumentationLinkImpl> { + val links = mutableListOf<ExternalDocumentationLinkImpl>() + if (!config.noJdkLink) + links += DokkaConfiguration.ExternalDocumentationLink + .Builder("https://docs.oracle.com/javase/${config.jdkVersion}/docs/api/") + .build() as ExternalDocumentationLinkImpl + + if (!config.noStdlibLink) + links += DokkaConfiguration.ExternalDocumentationLink + .Builder("https://kotlinlang.org/api/latest/jvm/stdlib/") + .build() as ExternalDocumentationLinkImpl + return links + } - val passConfiguration = PassConfigurationImpl( + val sourceSet = DokkaSourceSetImpl( + moduleDisplayName = moduleDisplayName.takeIf(String::isNotBlank) ?: moduleName, + displayName = displayName, + sourceSetID = DokkaSourceSetID(moduleName, sourceSetName), classpath = classpath, - sourceRoots = sourceDirectories.map { SourceRootImpl(it) } + sourceRoots.map { SourceRootImpl(path = it.path) }, + sourceRoots = sourceDirectories.map { SourceRootImpl(it) }, + dependentSourceSets = emptySet(), samples = samples, includes = includes, - collectInheritedExtensionsFromLibraries = collectInheritedExtensionsFromLibraries, // TODO: Should we implement this? - sourceLinks = sourceLinks.map { SourceLinkDefinitionImpl(it.path, it.url, it.lineSuffix) }, - jdkVersion = jdkVersion, - skipDeprecated = skipDeprecated, - skipEmptyPackages = skipEmptyPackages, + includeNonPublic = includeNonPublic, + includeRootPackage = includeRootPackage, reportUndocumented = reportUndocumented, + skipEmptyPackages = skipEmptyPackages, + skipDeprecated = skipDeprecated, + jdkVersion = jdkVersion, + sourceLinks = sourceLinks.map { SourceLinkDefinitionImpl(it.path, it.url, it.lineSuffix) }, perPackageOptions = perPackageOptions.map { PackageOptionsImpl( prefix = it.prefix, @@ -169,61 +219,132 @@ abstract class AbstractDokkaMojo : AbstractMojo() { reportUndocumented = it.reportUndocumented, skipDeprecated = it.skipDeprecated, suppress = it.suppress - )}, + ) + }, externalDocumentationLinks = externalDocumentationLinks.map { it.build() as ExternalDocumentationLinkImpl }, - noStdlibLink = noStdlibLink, - noJdkLink = noJdkLink, languageVersion = languageVersion, apiVersion = apiVersion, - moduleName = moduleName, + noStdlibLink = noStdlibLink, + noJdkLink = noJdkLink, suppressedFiles = suppressedFiles, - sinceKotlin = sinceKotlin, - analysisPlatform = if (platform.isNotEmpty()) Platform.fromString(platform) else Platform.DEFAULT, - targets = targets, - includeNonPublic = includeNonPublic, - includeRootPackage = includeRootPackage - ) + analysisPlatform = if (platform.isNotEmpty()) Platform.fromString(platform) else Platform.DEFAULT + ).let { + it.copy( + externalDocumentationLinks = defaultLinks(it) + it.externalDocumentationLinks + ) + } - passConfiguration.externalDocumentationLinks += passConfiguration.defaultLinks() + val logger = MavenDokkaLogger(log) val configuration = DokkaConfigurationImpl( outputDir = getOutDir(), - format = getOutFormat(), - impliedPlatforms = impliedPlatforms, + offlineMode = offlineMode, cacheRoot = cacheRoot, - passesConfigurations = listOf(passConfiguration), - generateIndexPages = generateIndexPages + sourceSets = listOf(sourceSet).also { + if (sourceSet.moduleDisplayName.isEmpty()) logger.warn("Not specified module name. It can result in unexpected behaviour while including documentation for module") + }, + pluginsClasspath = getArtifactByAether("org.jetbrains.dokka", "dokka-base", dokkaVersion) + + dokkaPlugins.map { getArtifactByAether(it.groupId, it.artifactId, it.version ?: dokkaVersion) }.flatten(), + pluginsConfiguration = mutableMapOf(), //TODO implement as it is in Gradle + modules = emptyList(), + failOnWarning = failOnWarning ) - val gen = DokkaGenerator(configuration, MavenDokkaLogger(log)) + val gen = DokkaGenerator(configuration, logger) gen.generate() } -} -@Mojo(name = "dokka", defaultPhase = LifecyclePhase.PRE_SITE, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true) -class DokkaMojo : AbstractDokkaMojo() { - @Parameter(required = true, defaultValue = "html") - var outputFormat: String = "html" + private fun newRepositorySystem(): RepositorySystem { + val locator: DefaultServiceLocator = MavenRepositorySystemUtils.newServiceLocator() + locator.addService(RepositoryConnectorFactory::class.java, BasicRepositoryConnectorFactory::class.java) + locator.addService(TransporterFactory::class.java, FileTransporterFactory::class.java) + locator.addService(TransporterFactory::class.java, HttpTransporterFactory::class.java) + return locator.getService(RepositorySystem::class.java) + } + + private fun newSession(system: RepositorySystem): RepositorySystemSession { + val session: DefaultRepositorySystemSession = + MavenRepositorySystemUtils.newSession() + val localRepo = LocalRepository(System.getProperty("user.home") + "/.m2/repository") + session.localRepositoryManager = system.newLocalRepositoryManager(session, localRepo) + return session + } + + private fun getArtifactByAether( + groupId: String, + artifactId: String, + version: String + ): List<File> { + val repoSystem: RepositorySystem = newRepositorySystem() + val session: RepositorySystemSession = newSession(repoSystem) + val dependency = + org.eclipse.aether.graph.Dependency(DefaultArtifact("$groupId:$artifactId:$version"), "compile") + val collectRequest = CollectRequest() + collectRequest.root = dependency + val repositories: List<RemoteRepository> = + (mavenProject?.remoteProjectRepositories?.plus(mavenProject?.remotePluginRepositories ?: emptyList()) + ?: mavenProject?.remotePluginRepositories ?: emptyList()) + repositories.forEach { + collectRequest.addRepository( + RemoteRepository.Builder( + "repo", + "default", + it.url + ).build() + ) + } + val node: DependencyNode = repoSystem.collectDependencies(session, collectRequest).root + val dependencyRequest = DependencyRequest() + dependencyRequest.root = node + repoSystem.resolveDependencies(session, dependencyRequest) + val nlg = PreorderNodeListGenerator() + node.accept(nlg) + return nlg.files + } + + private val dokkaVersion: String by lazy { + mavenProject?.pluginArtifacts?.filter { it.groupId == "org.jetbrains.dokka" && it.artifactId == "dokka-maven-plugin" } + ?.firstOrNull()?.version ?: throw IllegalStateException("Not found dokka plugin") + } +} +@Mojo( + name = "dokka", + defaultPhase = LifecyclePhase.PRE_SITE, + threadSafe = true, + requiresDependencyResolution = ResolutionScope.COMPILE, + requiresProject = true +) +class DokkaMojo : AbstractDokkaMojo(emptyList()) { @Parameter(required = true, defaultValue = "\${project.basedir}/target/dokka") var outputDir: String = "" - override fun getOutFormat() = outputFormat override fun getOutDir() = outputDir } -@Mojo(name = "javadoc", defaultPhase = LifecyclePhase.PRE_SITE, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true) -class DokkaJavadocMojo : AbstractDokkaMojo() { +@Mojo( + name = "javadoc", + defaultPhase = LifecyclePhase.PRE_SITE, + threadSafe = true, + requiresDependencyResolution = ResolutionScope.COMPILE, + requiresProject = true +) +class DokkaJavadocMojo : AbstractDokkaMojo(listOf(javadocDependency)) { @Parameter(required = true, defaultValue = "\${project.basedir}/target/dokkaJavadoc") var outputDir: String = "" - override fun getOutFormat() = "javadoc" override fun getOutDir() = outputDir } -@Mojo(name = "javadocJar", defaultPhase = LifecyclePhase.PRE_SITE, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true) -class DokkaJavadocJarMojo : AbstractDokkaMojo() { +@Mojo( + name = "javadocJar", + defaultPhase = LifecyclePhase.PRE_SITE, + threadSafe = true, + requiresDependencyResolution = ResolutionScope.COMPILE, + requiresProject = true +) +class DokkaJavadocJarMojo : AbstractDokkaMojo(listOf(javadocDependency)) { @Parameter(required = true, defaultValue = "\${project.basedir}/target/dokkaJavadocJar") var outputDir: String = "" @@ -268,12 +389,11 @@ class DokkaJavadocJarMojo : AbstractDokkaMojo() { @Component(role = Archiver::class, hint = "jar") private var jarArchiver: JarArchiver? = null - override fun getOutFormat() = "javadoc" override fun getOutDir() = outputDir override fun execute() { super.execute() - if(!File(outputDir).exists()) { + if (!File(outputDir).exists()) { log.warn("No javadoc generated so no javadoc jar will be generated") return } @@ -298,3 +418,7 @@ class DokkaJavadocJarMojo : AbstractDokkaMojo() { } } +private val javadocDependency = Dependency().apply { + groupId = "org.jetbrains.dokka" + artifactId = "javadoc-plugin" +} diff --git a/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt b/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt index a535c807..4b5f4fa9 100644 --- a/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt +++ b/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt @@ -1,18 +1,15 @@ package org.jetbrains.dokka.maven import org.apache.maven.plugin.logging.Log -import org.jetbrains.dokka.DokkaLogger +import org.jetbrains.dokka.utilities.DokkaLogger class MavenDokkaLogger(val log: Log) : DokkaLogger { - override fun error(message: String) { - log.error(message) - } - - override fun info(message: String) { - log.info(message) - } - - override fun warn(message: String) { - log.warn(message) - } -}
\ No newline at end of file + override var warningsCount: Int = 0 + override var errorsCount: Int = 0 + + override fun debug(message: String) = log.debug(message) + override fun info(message: String) = log.info(message) + override fun progress(message: String) = log.info(message) + override fun warn(message: String) = log.warn(message).also { warningsCount++ } + override fun error(message: String) = log.error(message).also { errorsCount++ } +} |