From 47b825f5ce812e2563c2e613ba39dca0d69516d1 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Wed, 11 Sep 2019 16:53:54 +0200 Subject: Bump Gradle to 4.10.3 --- gradlew | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'gradlew') diff --git a/gradlew b/gradlew index cccdd3d5..83f2acfd 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -109,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` -- cgit From e99be615ce7c2c2b5c3ee5e3f8941c41c1e7a944 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Fri, 31 Jan 2020 00:37:29 +0100 Subject: Bump Gradle version, migrate to Kotlin DSL, refactor publishing --- build.gradle | 120 --------------- build.gradle.kts | 43 ++++++ buildSrc/build.gradle | 10 -- buildSrc/build.gradle.kts | 14 ++ .../org/jetbrains/CorrectShadowPublishing.groovy | 40 ----- .../org/jetbrains/DependenciesVersionGetter.groovy | 14 -- .../org/jetbrains/PluginXmlTransformer.groovy | 71 --------- .../main/kotlin/org/jetbrains/BintrayPublishing.kt | 29 ++++ .../kotlin/org/jetbrains/DistMavenPublishing.kt | 28 ++++ .../src/main/kotlin/org/jetbrains/DokkaVersion.kt | 19 +++ core/build.gradle | 72 --------- core/build.gradle.kts | 49 +++++++ core/src/main/kotlin/DokkaBootstrap.kt | 10 ++ core/src/main/kotlin/Java/JavadocParser.kt | 4 - core/src/main/kotlin/configuration.kt | 98 +++++++++++++ core/src/main/kotlin/defaultConfiguration.kt | 74 ++++++++++ .../kotlin/multiplatform/BasicMultiplatformTest.kt | 2 +- coreDependencies/build.gradle | 45 ------ coreDependencies/build.gradle.kts | 43 ++++++ gradle.properties | 9 +- gradle/wrapper/gradle-wrapper.jar | Bin 55616 -> 58695 bytes gradle/wrapper/gradle-wrapper.properties | 4 +- gradlew | 29 ++-- integration-tests/build.gradle | 7 - integration-tests/build.gradle.kts | 0 .../gradle-integration-tests/build.gradle | 60 -------- .../gradle-integration-tests/build.gradle.kts | 52 +++++++ integration/build.gradle | 25 ---- .../kotlin/org/jetbrains/dokka/DokkaBootstrap.kt | 10 -- .../main/kotlin/org/jetbrains/dokka/ReflectDsl.kt | 72 --------- .../kotlin/org/jetbrains/dokka/configuration.kt | 98 ------------- .../org/jetbrains/dokka/defaultConfiguration.kt | 74 ---------- plugins/build.gradle | 25 ---- plugins/build.gradle.kts | 11 ++ plugins/mathjax/build.gradle | 17 --- plugins/mathjax/build.gradle.kts | 8 + plugins/xml/build.gradle | 17 --- plugins/xml/build.gradle.kts | 8 + runners/build.gradle | 7 - runners/build.gradle.kts | 6 + runners/cli/build.gradle | 16 -- runners/cli/build.gradle.kts | 37 +++++ runners/fatjar/build.gradle | 78 ---------- runners/gradle-plugin/build.gradle | 108 -------------- runners/gradle-plugin/build.gradle.kts | 74 ++++++++++ .../kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt | 10 +- .../org/jetbrains/dokka/gradle/ReflectDsl.kt | 72 +++++++++ .../main/kotlin/org/jetbrains/dokka/gradle/main.kt | 2 +- runners/maven-plugin/build.gradle | 161 --------------------- runners/maven-plugin/build.gradle.kts | 115 +++++++++++++++ runners/maven-plugin/src/main/kotlin/DokkaMojo.kt | 3 +- .../src/main/kotlin/MavenDokkaLogger.kt | 6 +- settings.gradle | 16 -- settings.gradle.kts | 29 ++++ testApi/build.gradle | 12 -- testApi/build.gradle.kts | 29 ++++ 56 files changed, 873 insertions(+), 1219 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 buildSrc/build.gradle create mode 100644 buildSrc/build.gradle.kts delete mode 100644 buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy delete mode 100644 buildSrc/src/main/groovy/org/jetbrains/DependenciesVersionGetter.groovy delete mode 100644 buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy create mode 100644 buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt create mode 100644 buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt create mode 100644 buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt delete mode 100644 core/build.gradle create mode 100644 core/build.gradle.kts create mode 100644 core/src/main/kotlin/DokkaBootstrap.kt create mode 100644 core/src/main/kotlin/configuration.kt create mode 100644 core/src/main/kotlin/defaultConfiguration.kt delete mode 100644 coreDependencies/build.gradle create mode 100644 coreDependencies/build.gradle.kts delete mode 100644 integration-tests/build.gradle create mode 100644 integration-tests/build.gradle.kts delete mode 100644 integration-tests/gradle-integration-tests/build.gradle create mode 100644 integration-tests/gradle-integration-tests/build.gradle.kts delete mode 100644 integration/build.gradle delete mode 100644 integration/src/main/kotlin/org/jetbrains/dokka/DokkaBootstrap.kt delete mode 100644 integration/src/main/kotlin/org/jetbrains/dokka/ReflectDsl.kt delete mode 100644 integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt delete mode 100644 integration/src/main/kotlin/org/jetbrains/dokka/defaultConfiguration.kt delete mode 100644 plugins/build.gradle create mode 100644 plugins/build.gradle.kts delete mode 100644 plugins/mathjax/build.gradle create mode 100644 plugins/mathjax/build.gradle.kts delete mode 100644 plugins/xml/build.gradle create mode 100644 plugins/xml/build.gradle.kts delete mode 100644 runners/build.gradle create mode 100644 runners/build.gradle.kts delete mode 100644 runners/cli/build.gradle create mode 100644 runners/cli/build.gradle.kts delete mode 100644 runners/fatjar/build.gradle delete mode 100644 runners/gradle-plugin/build.gradle create mode 100644 runners/gradle-plugin/build.gradle.kts create mode 100644 runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ReflectDsl.kt delete mode 100644 runners/maven-plugin/build.gradle create mode 100644 runners/maven-plugin/build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts delete mode 100644 testApi/build.gradle create mode 100644 testApi/build.gradle.kts (limited to 'gradlew') diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 35fa8667..00000000 --- a/build.gradle +++ /dev/null @@ -1,120 +0,0 @@ -allprojects { - ext { - if (!project.findProperty("dokka_version")) { - final String buildNumber = System.getenv("BUILD_NUMBER") - dokka_version = dokka_version_base + (buildNumber == null || System.getenv("FORCE_SNAPSHOT") != null ? "-SNAPSHOT" : "-$buildNumber") - } - } - - if (project == rootProject) { - println "Publication version: $dokka_version" - } - - group 'org.jetbrains.dokka' - version dokka_version - - - buildscript { - repositories { - mavenCentral() - maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } - maven { url "https://plugins.gradle.org/m2/" } - } - dependencies { - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' - classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1' - - classpath "com.gradle.publish:plugin-publish-plugin:0.9.10" - } - } - - repositories { - jcenter() - mavenCentral() - mavenLocal() - maven { url 'https://kotlin.bintray.com/kotlin-plugin' } - maven { url 'https://www.jetbrains.com/intellij-repository/releases' } - maven { url "https://dl.bintray.com/jetbrains/markdown" } - maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } - maven { url "https://teamcity.jetbrains.com/guestAuth/repository/download/Kotlin_dev_CompilerAllPlugins/$bundled_kotlin_compiler_version/maven" } - maven { url "https://kotlin.bintray.com/kotlinx" } - maven { url "https://dl.bintray.com/kotlin/kotlinx" } - maven { url "https://dl.bintray.com/orangy/maven" } // TODO: remove this repository when kotlinx.cli is available in maven - } -} - - -def bintrayPublication(project, List _publications) { - configure(project, { - apply plugin: 'com.jfrog.bintray' - - bintray { - user = System.getenv('BINTRAY_USER') - key = System.getenv('BINTRAY_KEY') - - pkg { - repo = dokka_publication_channel - name = 'dokka' - userOrg = 'kotlin' - desc = 'Dokka, the Kotlin documentation tool' - vcsUrl = 'https://github.com/kotlin/dokka.git' - licenses = ['Apache-2.0'] - version { - name = dokka_version - } - } - - publications = _publications - } - }) -} - - -configurations { - ideaIC - intellijCore -} - -repositories { - maven { url 'https://kotlin.bintray.com/kotlin-plugin' } - maven { url 'https://www.jetbrains.com/intellij-repository/snapshots' } - maven { url 'https://www.jetbrains.com/intellij-repository/releases' } -} - -dependencies { - intellijCore "com.jetbrains.intellij.idea:intellij-core:$idea_version" - ideaIC "com.jetbrains.intellij.idea:ideaIC:$idea_version" -} - -def ideaRT() { - return zipTree(project.configurations.ideaIC.singleFile).matching ({ - include("lib/idea_rt.jar") - }) -} - -def repoLocation = uri(file("$buildDir/dist-maven")) - -allprojects { - - task publishToDistMaven { - group "publishing" - description "Publishes all Maven publications to Maven repository 'distMaven'." - dependsOn tasks.withType(PublishToMavenRepository).matching { - it.repository == publishing.repositories.distMaven - } - } - - plugins.withType(MavenPublishPlugin) { - publishing { - repositories { - maven { - name 'distMaven' - url repoLocation - } - } - } - - } -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..5540184a --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,43 @@ +import org.jetbrains.configureDistMaven +import org.jetbrains.configureDokkaVersion + +plugins { + kotlin("jvm") apply false + id("com.jfrog.bintray") apply false +} + +allprojects { + configureDokkaVersion() + val dokka_version: String by this + + if (this == rootProject) { + println("Publication version: $dokka_version") + } + group = "org.jetbrains.dokka" + version = dokka_version + + val language_version: String by project + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class).all { + kotlinOptions { + freeCompilerArgs += "-Xjsr305=strict" + languageVersion = language_version + apiVersion = language_version + jvmTarget = "1.8" + } + } + + repositories { + jcenter() + mavenCentral() + mavenLocal() + maven(url = "https://dl.bintray.com/jetbrains/markdown/") + } + + configureDistMaven() +} + +subprojects { + apply { + plugin("org.jetbrains.kotlin.jvm") + } +} \ No newline at end of file diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle deleted file mode 100644 index b62b4150..00000000 --- a/buildSrc/build.gradle +++ /dev/null @@ -1,10 +0,0 @@ -apply plugin: 'groovy' -repositories { - mavenCentral() - jcenter() - maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } - maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } -} -dependencies { - compile 'com.github.jengelman.gradle.plugins:shadow:2.0.4' -} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 00000000..aeec9540 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + `kotlin-dsl` + groovy +} + +repositories { + mavenCentral() + jcenter() +} + +dependencies { + implementation("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4") + implementation("com.github.jengelman.gradle.plugins:shadow:2.0.4") +} diff --git a/buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy b/buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy deleted file mode 100644 index 62cc3d3c..00000000 --- a/buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy +++ /dev/null @@ -1,40 +0,0 @@ -package org.jetbrains - -import org.gradle.api.Project -import org.gradle.api.artifacts.ModuleVersionIdentifier -import org.gradle.api.artifacts.ProjectDependency -import org.gradle.api.artifacts.SelfResolvingDependency -import org.gradle.api.internal.artifacts.ivyservice.projectmodule.ProjectDependencyPublicationResolver -import org.gradle.api.publish.maven.MavenPom -import org.gradle.api.publish.maven.MavenPublication - -//https://github.com/johnrengelman/shadow/issues/334 -static void configure(MavenPublication publication, Project project) { - publication.artifact(project.tasks.shadowJar) - - - publication.pom { MavenPom pom -> - pom.withXml { xml -> - def dependenciesNode = xml.asNode().appendNode('dependencies') - - project.configurations.shadow.allDependencies.each { - if (it instanceof ProjectDependency) { - final ProjectDependencyPublicationResolver projectDependencyResolver = project.gradle.services.get(ProjectDependencyPublicationResolver) - final ModuleVersionIdentifier identifier = projectDependencyResolver.resolve(ModuleVersionIdentifier, it) - addDependency(dependenciesNode, identifier) - } else if (!(it instanceof SelfResolvingDependency)) { - addDependency(dependenciesNode, it) - } - - } - } - } -} - -private static void addDependency(Node dependenciesNode, dep) { - def dependencyNode = dependenciesNode.appendNode('dependency') - dependencyNode.appendNode('groupId', dep.group) - dependencyNode.appendNode('artifactId', dep.name) - dependencyNode.appendNode('version', dep.version) - dependencyNode.appendNode('scope', 'compile') -} diff --git a/buildSrc/src/main/groovy/org/jetbrains/DependenciesVersionGetter.groovy b/buildSrc/src/main/groovy/org/jetbrains/DependenciesVersionGetter.groovy deleted file mode 100644 index 194f11af..00000000 --- a/buildSrc/src/main/groovy/org/jetbrains/DependenciesVersionGetter.groovy +++ /dev/null @@ -1,14 +0,0 @@ -package org.jetbrains - -import org.gradle.api.Project - -class DependenciesVersionGetter { - static Properties getVersions(Project project, String artifactVersionSelector) { - def dep = project.dependencies.create(group: 'teamcity', name: 'dependencies', version: artifactVersionSelector, ext: 'properties') - def file = project.configurations.detachedConfiguration(dep).resolve().first() - - def prop = new Properties() - prop.load(new FileReader(file)) - return prop - } -} diff --git a/buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy b/buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy deleted file mode 100644 index e711388f..00000000 --- a/buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy +++ /dev/null @@ -1,71 +0,0 @@ -package org.jetbrains - -import com.github.jengelman.gradle.plugins.shadow.relocation.RelocateClassContext -import com.github.jengelman.gradle.plugins.shadow.relocation.Relocator -import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer -import com.github.jengelman.gradle.plugins.shadow.transformers.TransformerContext -import groovy.xml.XmlUtil -import org.gradle.api.file.FileTreeElement -import shadow.org.apache.tools.zip.ZipEntry -import shadow.org.apache.tools.zip.ZipOutputStream - -public class PluginXmlTransformer implements Transformer { - private Map transformedPluginXmlFiles = new HashMap<>(); - - @Override - boolean canTransformResource(FileTreeElement fileTreeElement) { - return fileTreeElement.relativePath.segments.contains("META-INF") && fileTreeElement.name.endsWith(".xml") - } - - @Override - void transform(TransformerContext context) { - def path = context.path - def inputStream = context.is - System.out.println(path) - Node node = new XmlParser().parse(inputStream) - relocateXml(node, context) - transformedPluginXmlFiles.put(path, node) - } - - @Override - boolean hasTransformedResource() { - return !transformedPluginXmlFiles.isEmpty() - } - - @Override - void modifyOutputStream(ZipOutputStream zipOutputStream) { - for (Map.Entry entry : transformedPluginXmlFiles.entrySet()) { - zipOutputStream.putNextEntry(new ZipEntry(entry.key)) - XmlUtil.serialize(entry.value, zipOutputStream) - } - } - - private static void relocateXml(Node node, TransformerContext context) { - Map attributes = node.attributes() - RelocateClassContext relocateClassContext = new RelocateClassContext() - relocateClassContext.stats = context.stats - for (Map.Entry entry : attributes.entrySet()) { - relocateClassContext.setClassName((String) entry.getValue()) - entry.setValue(relocateClassName(relocateClassContext, context)) - } - List localText = node.localText() - if (localText.size() == 1) { - relocateClassContext.setClassName(localText[0]) - node.setValue(relocateClassName(relocateClassContext, context)) - } - node.children().each { - if (it instanceof Node) { - relocateXml((Node) it, context) - } - } - } - - private static String relocateClassName(RelocateClassContext relocateContext, TransformerContext context) { - for (Relocator relocator : context.relocators) { - if (relocator.canRelocateClass(relocateContext)) { - return relocator.relocateClass(relocateContext) - } - } - return relocateContext.className - } -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt b/buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt new file mode 100644 index 00000000..19e032a8 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt @@ -0,0 +1,29 @@ +package org.jetbrains + +import com.jfrog.bintray.gradle.BintrayExtension +import org.gradle.api.Project +import org.gradle.kotlin.dsl.provideDelegate + +fun Project.configureBintrayPublication(publication: String) = configureBintrayPublication(listOf(publication)) + +fun Project.configureBintrayPublication(publications: List) { + val dokka_version: String by this + val dokka_publication_channel: String by this + extensions.configure("bintray") { + user = System.getenv("BINTRAY_USER") + key = System.getenv("BINTRAY_KEY") + + pkg = PackageConfig().apply { + repo = dokka_publication_channel + name = "dokka" + userOrg = "kotlin" + desc = "Dokka, the Kotlin documentation tool" + vcsUrl = "https://github.com/kotlin/dokka.git" + setLicenses("Apache-2.0") + version = VersionConfig().apply { + name = dokka_version + } + } + setPublications(*publications.toTypedArray()) + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt b/buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt new file mode 100644 index 00000000..ec536bd7 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt @@ -0,0 +1,28 @@ +package org.jetbrains + +import org.gradle.api.Project +import org.gradle.api.artifacts.repositories.MavenArtifactRepository +import org.gradle.api.publish.PublishingExtension +import org.gradle.api.publish.maven.tasks.PublishToMavenRepository + +fun Project.configureDistMaven() { // TODO: This can probably be written cleaner + val repoLocation = uri(file("${rootProject.buildDir}/dist-maven")) + var distMaven: MavenArtifactRepository? = null + pluginManager.withPlugin("maven-publish") { + this@configureDistMaven.extensions.findByType(PublishingExtension::class.java)?.let { + it.repositories { + distMaven = maven { + name = "distMaven" + url = repoLocation + } + } + } + } + tasks.register("publishToDistMaven") { + group = "publishing" + description = "Publishes all Maven publications to Maven repository 'distMaven'" + dependsOn(tasks.withType(PublishToMavenRepository::class.java).matching { + it.repository == distMaven + }) + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt b/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt new file mode 100644 index 00000000..5bd35415 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt @@ -0,0 +1,19 @@ +package org.jetbrains + +import org.gradle.api.Project +import org.gradle.kotlin.dsl.extra +import org.gradle.kotlin.dsl.provideDelegate + +fun Project.configureDokkaVersion(): String { + var dokka_version: String? by this.extra + if (dokka_version == null) { + val buildNumber = System.getenv("BUILD_NUMBER") + val dokka_version_base: String by this + dokka_version = dokka_version_base + if (buildNumber == null || System.getenv("FORCE_SNAPSHOT") != null) { + "-SNAPSHOT" + } else { + "-$buildNumber" + } + } + return dokka_version!! +} \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle deleted file mode 100644 index a7379595..00000000 --- a/core/build.gradle +++ /dev/null @@ -1,72 +0,0 @@ -import javax.tools.ToolProvider - -buildscript { - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -allprojects { - 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 { - testCompile project(':testApi') - compile project(":integration") - compile project(path: ":coreDependencies", configuration: "shadow") - - compile "org.jetbrains.kotlin:kotlin-stdlib:$bundled_kotlin_compiler_version" - compile "org.jetbrains.kotlin:kotlin-reflect:$bundled_kotlin_compiler_version" - - compile group: 'com.google.inject', name: 'guice', version: '3.0' - implementation "org.jsoup:jsoup:1.12.1" - - compile "org.jetbrains.kotlin:kotlin-compiler:$bundled_kotlin_compiler_version" - compile "org.jetbrains.kotlin:kotlin-script-runtime:$bundled_kotlin_compiler_version" - - compile "org.jetbrains:markdown:0.1.41" - - compile 'org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.10' - - - //tools.jar -// def toolsJar = files(((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs().findAll { it.path.endsWith("jar") }) -// compileOnly toolsJar -// testCompile toolsJar - - - testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit', version: kotlin_version - testCompile "com.nhaarman:mockito-kotlin-kt1.1:1.5.0" - implementation "com.google.code.gson:gson:$gson_version" - - testImplementation "org.jetbrains.kotlin:kotlin-stdlib-js:$bundled_kotlin_compiler_version" - testImplementation "org.jetbrains.kotlin:kotlin-stdlib-common:$bundled_kotlin_compiler_version" -// testImplementation project(":core:testApi") - - testCompile ideaRT() -} - -apply plugin: 'maven-publish' - -publishing { - publications { - dokkaCore(MavenPublication) { publication -> - artifactId = 'dokka-core' - - from components.java - } - } -} - -bintrayPublication(project, ["dokkaCore"]) diff --git a/core/build.gradle.kts b/core/build.gradle.kts new file mode 100644 index 00000000..06610a38 --- /dev/null +++ b/core/build.gradle.kts @@ -0,0 +1,49 @@ +import org.jetbrains.configureBintrayPublication + +plugins { + id("com.github.johnrengelman.shadow") + `maven-publish` + id("com.jfrog.bintray") +} + +dependencies { + implementation(project(":coreDependencies", configuration = "shadow")) + + val kotlin_version: String by project + implementation("org.jetbrains.kotlin:kotlin-compiler:$kotlin_version") + implementation("org.jetbrains.kotlin:kotlin-script-runtime:$kotlin_version") + implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version") + implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version") + implementation("org.jsoup:jsoup:1.12.1") + implementation("com.google.code.gson:gson:2.8.5") + implementation("org.jetbrains:markdown:0.1.40") + implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.10") + + testImplementation(project(":testApi")) + testImplementation("junit:junit:4.13") +} + +tasks { + shadowJar { + val dokka_version: String by project + archiveFileName.set("dokka-core-$dokka_version.jar") + archiveClassifier.set("") + } +} + +val sourceJar by tasks.registering(Jar::class) { + archiveClassifier.set("sources") + from(sourceSets["main"].allSource) +} + +publishing { + publications { + register("dokkaCore") { + artifactId = "dokka-core" + project.shadow.component(this) + artifact(sourceJar.get()) + } + } +} + +configureBintrayPublication("dokkaCore") diff --git a/core/src/main/kotlin/DokkaBootstrap.kt b/core/src/main/kotlin/DokkaBootstrap.kt new file mode 100644 index 00000000..b78eb9c6 --- /dev/null +++ b/core/src/main/kotlin/DokkaBootstrap.kt @@ -0,0 +1,10 @@ +package org.jetbrains.dokka + +import java.util.function.BiConsumer + +interface DokkaBootstrap { + + fun configure(logger: BiConsumer, serializedConfigurationJSON: String) + + fun generate() +} \ No newline at end of file diff --git a/core/src/main/kotlin/Java/JavadocParser.kt b/core/src/main/kotlin/Java/JavadocParser.kt index 5058634a..856cfa04 100644 --- a/core/src/main/kotlin/Java/JavadocParser.kt +++ b/core/src/main/kotlin/Java/JavadocParser.kt @@ -4,16 +4,12 @@ import com.intellij.psi.* import com.intellij.psi.impl.source.tree.JavaDocElementType import com.intellij.psi.javadoc.* import com.intellij.psi.util.PsiTreeUtil -import com.intellij.util.containers.isNullOrEmpty -import kotlinx.html.P import org.jetbrains.dokka.model.doc.* import org.jetbrains.dokka.utilities.DokkaLogger -import org.jetbrains.kotlin.utils.keysToMap import org.jsoup.Jsoup import org.jsoup.nodes.Element import org.jsoup.nodes.Node import org.jsoup.nodes.TextNode -import java.net.URI interface JavaDocumentationParser { fun parseDocumentation(element: PsiNamedElement): DocumentationNode diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt new file mode 100644 index 00000000..8c6d35e8 --- /dev/null +++ b/core/src/main/kotlin/configuration.kt @@ -0,0 +1,98 @@ +package org.jetbrains.dokka + +import java.io.File +import java.net.URL + +enum class Platform(val key: String) { + jvm("jvm"), + js("js"), + native("native"), + common("common"); + + companion object { + val DEFAULT = jvm + + fun fromString(key: String): Platform { + return when (key.toLowerCase()) { + jvm.key -> jvm + js.key -> js + native.key -> native + common.key -> common + else -> throw IllegalArgumentException("Unrecognized platform: $key") + } + } + } +} + +interface DokkaConfiguration { + val outputDir: String + val format: String + val generateIndexPages: Boolean + val cacheRoot: String? + val passesConfigurations: List + val impliedPlatforms: List + var pluginsClasspath: List + + interface PassConfiguration { + val moduleName: String + val classpath: List + val sourceRoots: List + val samples: List + val includes: List + val includeNonPublic: Boolean + val includeRootPackage: Boolean + val reportUndocumented: Boolean + val skipEmptyPackages: Boolean + val skipDeprecated: Boolean + val jdkVersion: Int + val sourceLinks: List + val perPackageOptions: List + val externalDocumentationLinks: List + val languageVersion: String? + val apiVersion: String? + val noStdlibLink: Boolean + val noJdkLink: Boolean + val suppressedFiles: List + val collectInheritedExtensionsFromLibraries: Boolean + val analysisPlatform: Platform + val targets: List + val sinceKotlin: String? + } + + interface SourceRoot { + val path: String + } + + interface SourceLinkDefinition { + val path: String + val url: String + val lineSuffix: String? + } + + interface PackageOptions { + val prefix: String + val includeNonPublic: Boolean + val reportUndocumented: Boolean + val skipDeprecated: Boolean + val suppress: Boolean + } + + interface ExternalDocumentationLink { + val url: URL + val packageListUrl: URL + + 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) }) + + fun build(): ExternalDocumentationLink = + if (packageListUrl != null && url != null) + ExternalDocumentationLinkImpl(url!!, packageListUrl!!) + else if (url != null) + ExternalDocumentationLinkImpl(url!!, URL(url!!, "package-list")) + else + throw IllegalArgumentException("url or url && packageListUrl must not be null for external documentation link") + } + } +} diff --git a/core/src/main/kotlin/defaultConfiguration.kt b/core/src/main/kotlin/defaultConfiguration.kt new file mode 100644 index 00000000..6c797fcd --- /dev/null +++ b/core/src/main/kotlin/defaultConfiguration.kt @@ -0,0 +1,74 @@ +package org.jetbrains.dokka + +import java.io.File +import java.net.URL + +data class DokkaConfigurationImpl( + override val outputDir: String, + override val format: String, + override val generateIndexPages: Boolean, + override val cacheRoot: String?, + override val impliedPlatforms: List, + override val passesConfigurations: List, + override var pluginsClasspath: List +) : DokkaConfiguration + +data class PassConfigurationImpl ( + override val moduleName: String, + override val classpath: List, + override val sourceRoots: List, + override val samples: List, + override val includes: List, + override val includeNonPublic: Boolean, + override val includeRootPackage: Boolean, + override val reportUndocumented: Boolean, + override val skipEmptyPackages: Boolean, + override val skipDeprecated: Boolean, + override val jdkVersion: Int, + override val sourceLinks: List, + override val perPackageOptions: List, + override var externalDocumentationLinks: List, + override val languageVersion: String?, + override val apiVersion: String?, + override val noStdlibLink: Boolean, + override val noJdkLink: Boolean, + override val suppressedFiles: List, + override val collectInheritedExtensionsFromLibraries: Boolean, + override val analysisPlatform: Platform, + override val targets: List, + override val sinceKotlin: String? +) : DokkaConfiguration.PassConfiguration + + +data class SourceRootImpl( + override val path: String +): DokkaConfiguration.SourceRoot + +data class SourceLinkDefinitionImpl( + override val path: String, + override val url: String, + override val lineSuffix: String? +): DokkaConfiguration.SourceLinkDefinition { + companion object { + fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinitionImpl { + val (path, urlAndLine) = srcLink.split('=') + return SourceLinkDefinitionImpl( + File(path).canonicalPath, + urlAndLine.substringBefore("#"), + urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#$it" }) + } + } +} + +data class PackageOptionsImpl( + override val prefix: String, + override val includeNonPublic: Boolean, + override val reportUndocumented: Boolean, + override val skipDeprecated: Boolean, + override val suppress: Boolean +): DokkaConfiguration.PackageOptions + + +data class ExternalDocumentationLinkImpl(override val url: URL, + override val packageListUrl: URL +) : DokkaConfiguration.ExternalDocumentationLink \ No newline at end of file diff --git a/core/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt b/core/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt index ad165cdb..f9431bbb 100644 --- a/core/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt +++ b/core/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt @@ -1,8 +1,8 @@ package multiplatform +import org.junit.Assert.assertEquals import org.junit.Test import testApi.testRunner.AbstractCoreTest -import kotlin.test.assertEquals class BasicMultiplatformTest : AbstractCoreTest() { diff --git a/coreDependencies/build.gradle b/coreDependencies/build.gradle deleted file mode 100644 index 2b166a93..00000000 --- a/coreDependencies/build.gradle +++ /dev/null @@ -1,45 +0,0 @@ -def intellijCoreAnalysis() { - return zipTree(project(":").configurations.intellijCore.singleFile).matching ({ - include("intellij-core-analysis.jar") - }) -} - -apply plugin: 'java' -apply plugin: 'com.github.johnrengelman.shadow' - -dependencies { - compile intellijCoreAnalysis() - compile "org.jetbrains.kotlin:kotlin-plugin-ij193:$kotlin_plugin_version" //TODO: parametrize ij version after 1.3.70 -} - -shadowJar { - baseName = 'dokka-dependencies' - classifier = '' - - configurations { - exclude compileOnly - } - - - exclude 'colorScheme/**' - exclude 'fileTemplates/**' - exclude 'inspectionDescriptions/**' - exclude 'intentionDescriptions/**' - exclude 'tips/**' - exclude 'messages/**' - - exclude 'src/**' -} - -apply plugin: 'maven-publish' - -publishing { - publications { - dokkaDependencies(MavenPublication) { publication -> - artifactId = 'dokka-dependencies' - project.shadow.component(publication) - } - } -} - -bintrayPublication(project, ["dokkaDependencies"]) \ No newline at end of file diff --git a/coreDependencies/build.gradle.kts b/coreDependencies/build.gradle.kts new file mode 100644 index 00000000..514c7ae1 --- /dev/null +++ b/coreDependencies/build.gradle.kts @@ -0,0 +1,43 @@ +plugins { + id("com.github.johnrengelman.shadow") + `maven-publish` +} + +val intellijCore: Configuration by configurations.creating + +repositories { + maven(url = "https://www.jetbrains.com/intellij-repository/snapshots") + maven(url = "https://www.jetbrains.com/intellij-repository/releases") + maven(url = "https://kotlin.bintray.com/kotlin-plugin") +} + +fun intellijCoreAnalysis() = zipTree(intellijCore.singleFile).matching { + include("intellij-core-analysis.jar") +} + +dependencies { + val idea_version: String by project + intellijCore("com.jetbrains.intellij.idea:intellij-core:$idea_version") + val kotlin_plugin_version: String by project + implementation(intellijCoreAnalysis()) + implementation("org.jetbrains.kotlin:kotlin-plugin-ij193:$kotlin_plugin_version") { + //TODO: parametrize ij version after 1.3.70 + isTransitive = false + } +} + +tasks { + shadowJar { + val dokka_version: String by project + archiveFileName.set("dokka-dependencies-$dokka_version.jar") + archiveClassifier.set("") + + exclude("colorScheme/**") + exclude("fileTemplates/**") + exclude("inspectionDescriptions/**") + exclude("intentionDescriptions/**") + exclude("tips/**") + exclude("messages/**") + exclude("src/**") + } +} diff --git a/gradle.properties b/gradle.properties index b0c74348..57ddc095 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,11 +2,9 @@ dokka_version_base=0.11.0 dokka_publication_channel=dokka # Kotlin compiler and plugin -bundled_kotlin_compiler_version=1.3.61 kotlin_version=1.3.61 kotlin_plugin_version=1.3.61-release-180 idea_version=192.5728.98 -kotlin_for_gradle_runtime_version=1.3.61 language_version=1.3 ant_version=1.9.6 @@ -14,12 +12,7 @@ ant_version=1.9.6 # Maven plugin dependencies maven_version=3.5.0 maven_archiver_version=2.5 -plexus_utils_version=3.0.22 -plexus_archiver_version=3.4 maven_plugin_tools_version=3.5.2 # For CI -mvn=mvn - -# For serialization -gson_version=2.8.5 \ No newline at end of file +mvn=mvn \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf0..f3d88b1c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f9fe22d1..a869af2d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ -#Wed Sep 18 14:13:14 CEST 2019 -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip +#Wed Jan 29 14:26:26 CET 2020 +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 83f2acfd..2fe81a7d 100755 --- a/gradlew +++ b/gradlew @@ -154,19 +154,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -175,14 +175,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/integration-tests/build.gradle b/integration-tests/build.gradle deleted file mode 100644 index 23d232d2..00000000 --- a/integration-tests/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/integration-tests/build.gradle.kts b/integration-tests/build.gradle.kts new file mode 100644 index 00000000..e69de29b diff --git a/integration-tests/gradle-integration-tests/build.gradle b/integration-tests/gradle-integration-tests/build.gradle deleted file mode 100644 index 70213d8b..00000000 --- a/integration-tests/gradle-integration-tests/build.gradle +++ /dev/null @@ -1,60 +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").getTasksByName("shadowJar", true) -testClasses.dependsOn project(":runners:fatjar").shadowJar -testClasses.dependsOn createClasspathManifest - -test { - systemProperty "android.licenses.overwrite", project.findProperty("android.licenses.overwrite") ?: "" - inputs.dir(file('testData')) - exclude '*' // TODO: Remove this exclude when tests are migrated -} \ No newline at end of file diff --git a/integration-tests/gradle-integration-tests/build.gradle.kts b/integration-tests/gradle-integration-tests/build.gradle.kts new file mode 100644 index 00000000..6a3fc690 --- /dev/null +++ b/integration-tests/gradle-integration-tests/build.gradle.kts @@ -0,0 +1,52 @@ +val dokkaPlugin by configurations.creating +val dokkaCore by configurations.creating +val kotlinGradle by configurations.creating + +dependencies { + val kotlin_version: String by project + testCompileOnly(group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version = kotlin_version) + testImplementation( + group = "org.jetbrains.kotlin", + name = "kotlin-test-junit", + version = kotlin_version + ) + testImplementation(project(":coreDependencies")) + dokkaPlugin(project(path = ":runners:gradle-plugin")) + dokkaCore(project(path = ":core", configuration = "shadow")) + + kotlinGradle("org.jetbrains.kotlin:kotlin-gradle-plugin") + + testImplementation(group = "junit", name = "junit", version = "4.13") + testImplementation(gradleTestKit()) +} + + +val createClasspathManifest by tasks.registering { + dependsOn(project(":core").getTasksByName("shadowJar", true)) + + val outputDir = file("$buildDir/$name") + inputs.files(dokkaPlugin + dokkaCore) + outputs.dir(outputDir) + + doLast { + outputDir.mkdirs() + file("$outputDir/dokka-plugin-classpath.txt").writeText(dokkaPlugin.joinToString("\n")) + file("$outputDir/fatjar.txt").writeText(dokkaCore.joinToString("\n")) + file("$outputDir/kotlin-gradle.txt").writeText(kotlinGradle.joinToString("\n")) + } +} + +val testClasses by tasks.getting + +testClasses.dependsOn(project(":core").getTasksByName("shadowJar", true)) +testClasses.dependsOn(createClasspathManifest) + +tasks { + test { + systemProperty("android.licenses.overwrite", project.findProperty("android.licenses.overwrite") ?: "") + inputs.dir(file("testData")) + exclude("*") // TODO: Remove this exclude when tests are migrated + } +} + +// TODO: see if this file makes any sense \ No newline at end of file diff --git a/integration/build.gradle b/integration/build.gradle deleted file mode 100644 index ce25d9bf..00000000 --- a/integration/build.gradle +++ /dev/null @@ -1,25 +0,0 @@ -buildscript { - repositories { jcenter() } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -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 { - compileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_for_gradle_runtime_version - compileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_for_gradle_runtime_version - implementation "com.google.code.gson:gson:$gson_version" -} \ No newline at end of file diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/DokkaBootstrap.kt b/integration/src/main/kotlin/org/jetbrains/dokka/DokkaBootstrap.kt deleted file mode 100644 index b78eb9c6..00000000 --- a/integration/src/main/kotlin/org/jetbrains/dokka/DokkaBootstrap.kt +++ /dev/null @@ -1,10 +0,0 @@ -package org.jetbrains.dokka - -import java.util.function.BiConsumer - -interface DokkaBootstrap { - - fun configure(logger: BiConsumer, serializedConfigurationJSON: String) - - fun generate() -} \ No newline at end of file diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/ReflectDsl.kt b/integration/src/main/kotlin/org/jetbrains/dokka/ReflectDsl.kt deleted file mode 100644 index 1984a3e5..00000000 --- a/integration/src/main/kotlin/org/jetbrains/dokka/ReflectDsl.kt +++ /dev/null @@ -1,72 +0,0 @@ -package org.jetbrains.dokka - -import kotlin.reflect.* -import kotlin.reflect.full.memberFunctions -import kotlin.reflect.full.memberProperties -import kotlin.reflect.jvm.isAccessible - -object ReflectDsl { - - class CallOrPropAccess(private val receiver: Any?, - private val clz: KClass<*>, - private val selector: String) { - - @Suppress("UNCHECKED_CAST") - operator fun invoke(vararg a: Any?): T { - return func!!.call(receiver, *a) as T - } - - operator fun get(s: String): CallOrPropAccess { - return v()!![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 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/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt deleted file mode 100644 index 8c6d35e8..00000000 --- a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt +++ /dev/null @@ -1,98 +0,0 @@ -package org.jetbrains.dokka - -import java.io.File -import java.net.URL - -enum class Platform(val key: String) { - jvm("jvm"), - js("js"), - native("native"), - common("common"); - - companion object { - val DEFAULT = jvm - - fun fromString(key: String): Platform { - return when (key.toLowerCase()) { - jvm.key -> jvm - js.key -> js - native.key -> native - common.key -> common - else -> throw IllegalArgumentException("Unrecognized platform: $key") - } - } - } -} - -interface DokkaConfiguration { - val outputDir: String - val format: String - val generateIndexPages: Boolean - val cacheRoot: String? - val passesConfigurations: List - val impliedPlatforms: List - var pluginsClasspath: List - - interface PassConfiguration { - val moduleName: String - val classpath: List - val sourceRoots: List - val samples: List - val includes: List - val includeNonPublic: Boolean - val includeRootPackage: Boolean - val reportUndocumented: Boolean - val skipEmptyPackages: Boolean - val skipDeprecated: Boolean - val jdkVersion: Int - val sourceLinks: List - val perPackageOptions: List - val externalDocumentationLinks: List - val languageVersion: String? - val apiVersion: String? - val noStdlibLink: Boolean - val noJdkLink: Boolean - val suppressedFiles: List - val collectInheritedExtensionsFromLibraries: Boolean - val analysisPlatform: Platform - val targets: List - val sinceKotlin: String? - } - - interface SourceRoot { - val path: String - } - - interface SourceLinkDefinition { - val path: String - val url: String - val lineSuffix: String? - } - - interface PackageOptions { - val prefix: String - val includeNonPublic: Boolean - val reportUndocumented: Boolean - val skipDeprecated: Boolean - val suppress: Boolean - } - - interface ExternalDocumentationLink { - val url: URL - val packageListUrl: URL - - 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) }) - - fun build(): ExternalDocumentationLink = - if (packageListUrl != null && url != null) - ExternalDocumentationLinkImpl(url!!, packageListUrl!!) - else if (url != null) - ExternalDocumentationLinkImpl(url!!, URL(url!!, "package-list")) - else - throw IllegalArgumentException("url or url && packageListUrl must not be null for external documentation link") - } - } -} diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/defaultConfiguration.kt b/integration/src/main/kotlin/org/jetbrains/dokka/defaultConfiguration.kt deleted file mode 100644 index 6c797fcd..00000000 --- a/integration/src/main/kotlin/org/jetbrains/dokka/defaultConfiguration.kt +++ /dev/null @@ -1,74 +0,0 @@ -package org.jetbrains.dokka - -import java.io.File -import java.net.URL - -data class DokkaConfigurationImpl( - override val outputDir: String, - override val format: String, - override val generateIndexPages: Boolean, - override val cacheRoot: String?, - override val impliedPlatforms: List, - override val passesConfigurations: List, - override var pluginsClasspath: List -) : DokkaConfiguration - -data class PassConfigurationImpl ( - override val moduleName: String, - override val classpath: List, - override val sourceRoots: List, - override val samples: List, - override val includes: List, - override val includeNonPublic: Boolean, - override val includeRootPackage: Boolean, - override val reportUndocumented: Boolean, - override val skipEmptyPackages: Boolean, - override val skipDeprecated: Boolean, - override val jdkVersion: Int, - override val sourceLinks: List, - override val perPackageOptions: List, - override var externalDocumentationLinks: List, - override val languageVersion: String?, - override val apiVersion: String?, - override val noStdlibLink: Boolean, - override val noJdkLink: Boolean, - override val suppressedFiles: List, - override val collectInheritedExtensionsFromLibraries: Boolean, - override val analysisPlatform: Platform, - override val targets: List, - override val sinceKotlin: String? -) : DokkaConfiguration.PassConfiguration - - -data class SourceRootImpl( - override val path: String -): DokkaConfiguration.SourceRoot - -data class SourceLinkDefinitionImpl( - override val path: String, - override val url: String, - override val lineSuffix: String? -): DokkaConfiguration.SourceLinkDefinition { - companion object { - fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinitionImpl { - val (path, urlAndLine) = srcLink.split('=') - return SourceLinkDefinitionImpl( - File(path).canonicalPath, - urlAndLine.substringBefore("#"), - urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#$it" }) - } - } -} - -data class PackageOptionsImpl( - override val prefix: String, - override val includeNonPublic: Boolean, - override val reportUndocumented: Boolean, - override val skipDeprecated: Boolean, - override val suppress: Boolean -): DokkaConfiguration.PackageOptions - - -data class ExternalDocumentationLinkImpl(override val url: URL, - override val packageListUrl: URL -) : DokkaConfiguration.ExternalDocumentationLink \ No newline at end of file diff --git a/plugins/build.gradle b/plugins/build.gradle deleted file mode 100644 index a0bc5ee1..00000000 --- a/plugins/build.gradle +++ /dev/null @@ -1,25 +0,0 @@ -buildscript { - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -allprojects { - 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" - } - } -} - -subprojects { - dependencies { - testCompile project(':testApi') - } -} \ No newline at end of file diff --git a/plugins/build.gradle.kts b/plugins/build.gradle.kts new file mode 100644 index 00000000..5f2f6dcb --- /dev/null +++ b/plugins/build.gradle.kts @@ -0,0 +1,11 @@ +subprojects { + apply { + plugin("maven-publish") + } + + dependencies { + compileOnly(project(":core")) + compileOnly(kotlin("stdlib-jdk8")) + testImplementation(project(":testApi")) + } +} \ No newline at end of file diff --git a/plugins/mathjax/build.gradle b/plugins/mathjax/build.gradle deleted file mode 100644 index 6578ff45..00000000 --- a/plugins/mathjax/build.gradle +++ /dev/null @@ -1,17 +0,0 @@ -import javax.tools.ToolProvider - -apply plugin: 'maven-publish' - -dependencies { - compileOnly project(':core') -} - -publishing { - publications { - dokkaCore(MavenPublication) { publication -> - artifactId = 'mathjax-plugin' - - from components.java - } - } -} \ No newline at end of file diff --git a/plugins/mathjax/build.gradle.kts b/plugins/mathjax/build.gradle.kts new file mode 100644 index 00000000..0e9a16d0 --- /dev/null +++ b/plugins/mathjax/build.gradle.kts @@ -0,0 +1,8 @@ +publishing { + publications { + register("mathjaxPlugin") { + artifactId = "mathjax-plugin" + from(components["java"]) + } + } +} \ No newline at end of file diff --git a/plugins/xml/build.gradle b/plugins/xml/build.gradle deleted file mode 100644 index ed4adb92..00000000 --- a/plugins/xml/build.gradle +++ /dev/null @@ -1,17 +0,0 @@ -import javax.tools.ToolProvider - -apply plugin: 'maven-publish' - -dependencies { - compileOnly project(':core') -} - -publishing { - publications { - dokkaCore(MavenPublication) { publication -> - artifactId = 'xml-plugin' - - from components.java - } - } -} \ No newline at end of file diff --git a/plugins/xml/build.gradle.kts b/plugins/xml/build.gradle.kts new file mode 100644 index 00000000..cd65cfe4 --- /dev/null +++ b/plugins/xml/build.gradle.kts @@ -0,0 +1,8 @@ +publishing { + publications { + register("xmlPlugin") { + artifactId = "xml-plugin" + from(components["java"]) + } + } +} \ No newline at end of file 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..4b39d64c --- /dev/null +++ b/runners/cli/build.gradle.kts @@ -0,0 +1,37 @@ +import org.jetbrains.configureBintrayPublication + +plugins { + id("com.github.johnrengelman.shadow") +} + +repositories { + maven(url = "https://dl.bintray.com/orangy/maven") +} + +dependencies { + implementation("org.jetbrains.kotlinx:kotlinx-cli-jvm:0.1.0-dev-3") + implementation(project(":core")) +} + + +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") + } + } +} + +publishing { + publications { + register("dokkaCli") { + artifactId = "dokka-cli" + project.shadow.component(this) + } + } +} + +configureBintrayPublication("dokkaCli") \ No newline at end of file diff --git a/runners/fatjar/build.gradle b/runners/fatjar/build.gradle deleted file mode 100644 index cab64c0f..00000000 --- a/runners/fatjar/build.gradle +++ /dev/null @@ -1,78 +0,0 @@ -import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer -import org.jetbrains.PluginXmlTransformer -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar - -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') -} - -task apiShadow(type: ShadowJar) { - baseName = 'dokka-fatapi' - classifier = '' - - configurations = [project.configurations.compile] - configurations { - exclude compileOnly - } - - transform(ServiceFileTransformer) - transform(PluginXmlTransformer) - - exclude 'kotlin/**' - 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) - } - - dokkaFatApi(MavenPublication) {publication -> - artifactId = 'dokka-fatapi' - publication.artifact(project.tasks.apiShadow) - } - } -} - -bintrayPublication(project, ["dokkaFatJar"]) \ 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("", 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 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..0d68a525 --- /dev/null +++ b/runners/gradle-plugin/build.gradle.kts @@ -0,0 +1,74 @@ +import org.jetbrains.configureBintrayPublication + +plugins { + id("com.gradle.plugin-publish") +} + +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()) + 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") + } + } +} + +tasks { + processResources { + val dokka_version: String by project + eachFile { + if (name == "org.jetbrains.dokka.properties") { + filter { line -> + line.replace("", dokka_version) + } + } + } + } +} + +val sourceJar by tasks.registering(Jar::class) { + archiveClassifier.set("sources") + from(sourceSets["main"].allSource) +} + +publishing { + publications { + register("dokkaGradlePlugin") { + artifactId = "dokka-gradle-plugin" + from(components["java"]) + artifact(sourceJar.get()) + } + } +} + +configureBintrayPublication("dokkaGradlePlugin") // TODO check if this publishes correctly + +pluginBundle { + // TODO check if this publishes correctly + website = "https://www.kotlinlang.org/" + vcsUrl = "https://github.com/kotlin/dokka.git" + description = "Dokka, the Kotlin documentation tool" + tags = listOf("dokka", "kotlin", "kdoc", "android") + + plugins { + create("dokkaGradlePlugin") { + id = "org.jetbrains.dokka" + displayName = "Dokka plugin" + } + } + + mavenCoordinates { + groupId = "org.jetbrains.dokka" + artifactId = "dokka-gradle-plugin" + } +} \ No newline at end of file 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 940c496e..65b0f4b3 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 @@ -89,17 +89,9 @@ open class DokkaTask : DefaultTask() { private var outputDiagnosticInfo: Boolean = false // Workaround for Gradle, which fires some methods (like collectConfigurations()) multiple times in its lifecycle - private fun tryResolveFatJar(configuration: Configuration?): Set { - return try { - configuration!!.resolve() - } catch (e: Exception) { - project.parent?.let { tryResolveFatJar(configuration) } ?: throw e - } - } - private fun loadFatJar() { if (ClassloaderContainer.fatJarClassLoader == null) { - val jars = tryResolveFatJar(dokkaRuntime).toList() + val jars = dokkaRuntime!!.resolve() ClassloaderContainer.fatJarClassLoader = URLClassLoader(jars.map { it.toURI().toURL() }.toTypedArray(), ClassLoader.getSystemClassLoader().parent) } } 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..1984a3e5 --- /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 + +object ReflectDsl { + + class CallOrPropAccess(private val receiver: Any?, + private val clz: KClass<*>, + private val selector: String) { + + @Suppress("UNCHECKED_CAST") + operator fun invoke(vararg a: Any?): T { + return func!!.call(receiver, *a) as T + } + + operator fun get(s: String): CallOrPropAccess { + return v()!![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 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/main.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt index d75d3b21..71a02843 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 @@ -25,7 +25,7 @@ open class DokkaPlugin : Plugin { private fun addConfiguration(project: Project) = project.configurations.create("dokkaRuntime").apply { - defaultDependencies{ dependencies -> dependencies.add(project.dependencies.create("org.jetbrains.dokka:dokka-fatjar:${DokkaVersion.version}")) } + defaultDependencies{ dependencies -> dependencies.add(project.dependencies.create("org.jetbrains.dokka:dokka-core:${DokkaVersion.version}")) } } private fun addTasks( 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("dokka_version", "$dokka_version") - .replace("", "$maven_version") - .replace("maven-plugin-plugin", "$maven_plugin_tools_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..2dffd71c --- /dev/null +++ b/runners/maven-plugin/build.gradle.kts @@ -0,0 +1,115 @@ +import org.jetbrains.configureBintrayPublication + +/** + * [mavenBin] configuration is used to download Maven Plugin Plugin + * for generating plugin-help.xml and plugin.xml files + */ +val mavenBin: Configuration by configurations.creating + +val maven_version: String by project + +dependencies { + implementation(project(":core")) + implementation("org.apache.maven:maven-core:$maven_version") + implementation("org.apache.maven:maven-plugin-api:$maven_version") + val maven_plugin_tools_version: String by project + implementation("org.apache.maven.plugin-tools:maven-plugin-annotations:$maven_plugin_tools_version") + val maven_archiver_version: String by project + implementation("org.apache.maven:maven-archiver:$maven_archiver_version") + + mavenBin(group = "org.apache.maven", name = "apache-maven", version = maven_version, classifier = "bin", ext = "zip") + compileOnly(kotlin("stdlib-jdk8")) +} + +val mavenBinDir = "$buildDir/maven-bin" +val mavenBuildDir = "$buildDir/maven" +val mvn = File(mavenBinDir, "apache-maven-$maven_version/bin/mvn") + +tasks.named("clean") { + delete(mavenBinDir) +} + +/** + * Copy Maven Plugin Plugin to [mavenBinDir] directory + */ +val setupMaven by tasks.registering(Sync::class) { + from(mavenBin.map { zipTree(it) }) + into(mavenBinDir) +} + +/** + * Generate pom.xml for Maven Plugin Plugin + */ +val generatePom by tasks.registering(Copy::class) { + val dokka_version: String by project + val maven_plugin_tools_version: String by project + + from("$projectDir/pom.tpl.xml") { + rename("(.*).tpl.xml", "$1.xml") + } + into(mavenBuildDir) + + eachFile { + filter { line -> + line.replace("", "$maven_version") + } + filter { line -> + line.replace("dokka_version", "$dokka_version") + } + filter { line -> + line.replace("maven-plugin-plugin", "$maven_plugin_tools_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("$mavenBuildDir/classes/java") + + preserve { + include("**/*.class") + } +} + +val helpMojo by tasks.registering(org.jetbrains.CrossPlatformExec::class) { + dependsOn(setupMaven, generatePom, syncClasses) + workingDir(mavenBuildDir) + commandLine(mvn, "-e", "-B", "org.apache.maven.plugins:maven-plugin-plugin:helpmojo") +} + +val pluginDescriptor by tasks.registering(org.jetbrains.CrossPlatformExec::class) { + dependsOn(setupMaven, generatePom, syncClasses) + workingDir(mavenBuildDir) + commandLine(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") { + dependsOn(pluginDescriptor, helpMojo) + metaInf { + from("$mavenBuildDir/classes/java/main/META-INF") + } + manifest { + attributes("Class-Path" to configurations.runtimeClasspath.get().files.joinToString(" ") { it.name }) + } +} + +publishing { + publications { + register("dokkaMavenPlugin") { + artifactId = "dokka-maven-plugin" + from(components["java"]) + artifact(sourceJar.get()) + } + } +} + +configureBintrayPublication("dokkaMavenPlugin") diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index fb11ecac..67188325 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -189,7 +189,8 @@ abstract class AbstractDokkaMojo : AbstractMojo() { impliedPlatforms = impliedPlatforms, cacheRoot = cacheRoot, passesConfigurations = listOf(passConfiguration), - generateIndexPages = generateIndexPages + generateIndexPages = generateIndexPages, + pluginsClasspath = emptyList() //TODO fix this ) val gen = DokkaGenerator(configuration, MavenDokkaLogger(log)) diff --git a/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt b/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt index a535c807..950af3e0 100644 --- a/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt +++ b/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt @@ -1,17 +1,21 @@ 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 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) } diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 323af4b9..00000000 --- a/settings.gradle +++ /dev/null @@ -1,16 +0,0 @@ -rootProject.name = "dokka" - -include 'core', -// 'core:testApi', - 'coreDependencies', - 'integration', - 'runners:gradle-integration-tests', - 'runners:fatjar', - 'runners:ant', - 'runners:cli', -// 'runners:maven-plugin', - 'runners:gradle-plugin', -// 'plugins:javadoc8' - 'plugins:mathjax', - 'plugins:xml', - 'testApi' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..364a96ad --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,29 @@ +rootProject.name = "dokka" + +include("core") +include("coreDependencies") +include("testApi") +include("runners:gradle-plugin") +include("runners:cli") +include("runners:maven-plugin") +include("plugins:xml") +include("plugins:mathjax") +//include("integration-tests:gradle-integration-tests") + + +pluginManagement { + val kotlin_version: String by settings + plugins { + id("org.jetbrains.kotlin.jvm") version kotlin_version + id("com.github.johnrengelman.shadow") version "5.2.0" + id("com.jfrog.bintray") version "1.8.4" + id("com.gradle.plugin-publish") version "0.10.1" + } + + repositories { + mavenLocal() + mavenCentral() + jcenter() + gradlePluginPortal() + } +} \ No newline at end of file diff --git a/testApi/build.gradle b/testApi/build.gradle deleted file mode 100644 index 5425b7bc..00000000 --- a/testApi/build.gradle +++ /dev/null @@ -1,12 +0,0 @@ -buildscript { - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} -apply plugin: 'kotlin' - -dependencies { - implementation project(':core') - implementation group: 'junit', name: 'junit', version: '4.12' - implementation group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit', version: kotlin_version -} \ No newline at end of file diff --git a/testApi/build.gradle.kts b/testApi/build.gradle.kts new file mode 100644 index 00000000..db861b90 --- /dev/null +++ b/testApi/build.gradle.kts @@ -0,0 +1,29 @@ +import org.jetbrains.configureBintrayPublication + +plugins { + `maven-publish` + id("com.jfrog.bintray") +} + +dependencies { + implementation(project(":core")) + implementation("junit:junit:4.13") // TODO: remove dependency to junit + implementation(kotlin("stdlib")) +} + +val sourceJar by tasks.registering(Jar::class) { + archiveClassifier.set("sources") + from(sourceSets["main"].allSource) +} + +publishing { + publications { + register("dokkaTestAPI") { + artifactId = "dokka-test-api" + components["java"] + artifact(sourceJar.get()) + } + } +} + +configureBintrayPublication("dokkaTestAPI") \ No newline at end of file -- cgit