├── .gitignore ├── README.md ├── build-with-core-plugins ├── build.gradle.kts └── settings.gradle.kts ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts └── src │ └── main │ └── kotlin │ ├── api │ ├── GradleApiSources.kt │ ├── GradleInstall.kt │ ├── GradleKotlinDslApiSources.kt │ └── GradlePluginsAccessors.kt │ └── git │ └── GitClone.kt ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts ├── src ├── dokka │ └── kotlin-dsl.md └── pages │ ├── index.html │ └── style.css └── update-wrapper.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build 3 | .idea 4 | *.iml 5 | build-with-core-plugins/buildSrc/src/gradle-kotlin-dsl 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gradle Kotlin DSL Documentation 2 | 3 | > [!CAUTION] 4 | > This repository is now obsolete. 5 | 6 | Up-to-date Kotlin DSL Reference docs for Gradle can be found [here](https://docs.gradle.org/current/kotlin-dsl/index.html). 7 | -------------------------------------------------------------------------------- /build-with-core-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | eclipse 3 | `eclipse-wtp` 4 | idea 5 | announce 6 | `build-announcements` 7 | antlr 8 | `compare-gradle-builds` 9 | `build-init` 10 | wrapper 11 | checkstyle 12 | codenarc 13 | findbugs 14 | jdepend 15 | pmd 16 | `help-tasks` 17 | `project-report` 18 | `project-reports` 19 | ear 20 | `visual-studio` 21 | xcode 22 | `play-ide` 23 | `ivy-publish` 24 | jacoco 25 | `coffeescript-base` 26 | envjs 27 | `javascript-base` 28 | jshint 29 | rhino 30 | `java-lang` 31 | `jvm-resources` 32 | `assembler-lang` 33 | assembler 34 | `c-lang` 35 | c 36 | // `cpp-application` 37 | `cpp-lang` 38 | // `cpp-library` 39 | cpp 40 | `objective-c-lang` 41 | `objective-c` 42 | `objective-cpp-lang` 43 | `objective-cpp` 44 | // `swift-application` 45 | // `swift-library` 46 | `windows-resource-script` 47 | `windows-resources` 48 | `scala-lang` 49 | `maven-publish` 50 | maven 51 | osgi 52 | `binary-base` 53 | `component-base` 54 | `component-model-base` 55 | `language-base` 56 | `lifecycle-base` 57 | `jvm-component` 58 | `clang-compiler` 59 | `gcc-compiler` 60 | `microsoft-visual-cpp-compiler` 61 | `native-component-model` 62 | `native-component` 63 | `standard-tool-chains` 64 | `play-application` 65 | `play-coffeescript` 66 | `play-javascript` 67 | play 68 | `java-gradle-plugin` 69 | application 70 | base 71 | distribution 72 | `groovy-base` 73 | groovy 74 | `java-base` 75 | `java-library-distribution` 76 | `java-library` 77 | java 78 | war 79 | publishing 80 | `build-dashboard` 81 | `reporting-base` 82 | `scala-base` 83 | scala 84 | signing 85 | `junit-test-suite` 86 | // `cpp-test-suite` 87 | `cunit-test-suite` 88 | cunit 89 | `google-test-test-suite` 90 | `google-test` 91 | // xctest 92 | } 93 | 94 | val clean: org.gradle.api.tasks.Delete by tasks 95 | clean.delete("buildSrc") 96 | -------------------------------------------------------------------------------- /build-with-core-plugins/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.buildFileName = "build.gradle.kts" -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.dokka.gradle.DokkaTask 2 | import java.net.URL 3 | 4 | 5 | plugins { 6 | base 7 | id("org.jetbrains.dokka") 8 | id("org.ajoberstar.github-pages") 9 | } 10 | 11 | buildscript { 12 | // dokka requires a repository from which to download dokka-fatjar on demand 13 | configure(listOf(repositories, project.repositories)) { 14 | jcenter() 15 | maven { url = uri("https://dl.bintray.com/kotlin/kotlin-dev") } 16 | } 17 | } 18 | 19 | 20 | // Sources sources 21 | // Uses local clones if available 22 | 23 | val gradleGitUseLocalClone = file("../gradle/.git").isDirectory 24 | val gradleGitUri = 25 | if (gradleGitUseLocalClone) file("../gradle").toURI().toString() 26 | else "https://github.com/gradle/gradle.git" 27 | val gradleGitRef = "kotlin-dsl-docs" 28 | 29 | val kotlinDslGitUseLocalClone = file("../kotlin-dsl/.git").isDirectory 30 | val kotlinDslGitUri = 31 | if (kotlinDslGitUseLocalClone) file("../kotlin-dsl").toURI().toString() 32 | else "https://github.com/gradle/kotlin-dsl.git" 33 | val kotlinDslGitRef = "v0.18.4" 34 | 35 | logger.lifecycle("Gradle sources for Kotlin DSL API\n uri = $gradleGitUri\n ref = $gradleGitRef\n") 36 | logger.lifecycle("Kotlin DSL sources for Kotlin DSL API\n uri = $kotlinDslGitUri\n ref = $kotlinDslGitRef\n") 37 | 38 | 39 | // Groovy and Kotlin versions 40 | // Required to be fetched at configuration time 41 | 42 | val groovyVersionSourceFilePath = "gradle/dependencies.gradle" 43 | val groovyVersion = 44 | if (gradleGitUseLocalClone) 45 | file("../gradle/$groovyVersionSourceFilePath").readLines().extractGroovyVersion() 46 | else 47 | URL("https://raw.githubusercontent.com/gradle/gradle/$gradleGitRef/$groovyVersionSourceFilePath") 48 | .openStream().bufferedReader().use { it.lineSequence().toList().extractGroovyVersion() } 49 | 50 | val kotlinVersionSourceFilePath = "kotlin-version.txt" 51 | val kotlinVersion = 52 | if (kotlinDslGitUseLocalClone) 53 | file("../kotlin-dsl/$kotlinVersionSourceFilePath").readLines().extractKotlinVersion() 54 | else 55 | URL("https://raw.githubusercontent.com/gradle/kotlin-dsl/$kotlinDslGitRef/$kotlinVersionSourceFilePath") 56 | .openStream().bufferedReader().use { it.lineSequence().toList().extractKotlinVersion() } 57 | 58 | fun List.extractGroovyVersion() = 59 | find { it.startsWith("libraries.groovy =") }!! 60 | .split("=").last().substringAfterLast("version: '").substringBeforeLast("'").trim() 61 | 62 | fun List.extractKotlinVersion() = 63 | first().trim() 64 | 65 | logger.lifecycle("Runtime versions for Kotlin DSL API\n Groovy $groovyVersion\n Kotlin $kotlinVersion\n") 66 | 67 | 68 | val dokkaDependencies by configurations.creating 69 | dependencies { 70 | dokkaDependencies("org.codehaus.groovy:groovy-all:$groovyVersion") 71 | dokkaDependencies("org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlinVersion") 72 | dokkaDependencies("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion") 73 | dokkaDependencies("org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion") 74 | } 75 | 76 | 77 | tasks { 78 | 79 | val cloningGroup = "cloning" 80 | val apiSourcesGroup = "API sources" 81 | 82 | 83 | // Gradle API sources extraction 84 | val cloneGradle by creating(git.GitClone::class) { 85 | group = cloningGroup 86 | description = "Clones Gradle sources." 87 | uri = gradleGitUri 88 | ref = gradleGitRef 89 | cloneDir = file("$buildDir/clones/gradle") 90 | } 91 | val gradleApiSources by creating(api.GradleApiSources::class) { 92 | group = apiSourcesGroup 93 | description = "Generates Gradle API sources." 94 | gradleClone = cloneGradle.cloneDir 95 | sourceDir = file("$buildDir/api-sources/gradle") 96 | dependsOn(cloneGradle) 97 | } 98 | 99 | 100 | // Gradle Kotlin DSL API sources extraction and generation 101 | val cloneKotlinDsl by tasks.creating(git.GitClone::class) { 102 | group = cloningGroup 103 | description = "Clones Gradle Kotlin DSL sources." 104 | uri = kotlinDslGitUri 105 | ref = kotlinDslGitRef 106 | cloneDir = file("$buildDir/clones/kotlin-dsl") 107 | } 108 | val generateKotlinDslExtensions by creating(GradleBuild::class) { 109 | dir = cloneKotlinDsl.cloneDir 110 | tasks = listOf(":provider:generateExtensions") 111 | dependsOn(cloneKotlinDsl) 112 | } 113 | val gradleKotlinDslApiSources by creating(api.GradleKotlinDslApiSources::class) { 114 | group = apiSourcesGroup 115 | description = "Generates Gradle Kotlin DSL API sources." 116 | kotlinDslClone = cloneKotlinDsl.cloneDir 117 | sourceDir = file("$buildDir/api-sources/gradle-kotlin-dsl") 118 | dependsOn(generateKotlinDslExtensions) 119 | } 120 | 121 | 122 | // Gradle built-in plugins accessors API generation 123 | val installGradle by creating(api.GradleInstall::class) { 124 | gradleClone = cloneGradle.cloneDir 125 | gradleInstall = file("$buildDir/install/gradle") 126 | dependsOn(cloneGradle) 127 | } 128 | val buildWithCorePluginsDir = file("build-with-core-plugins") 129 | val gradlePluginsAccessors by creating(api.GradlePluginsAccessors::class) { 130 | gradleInstall = installGradle.gradleInstall 131 | buildDirectory = buildWithCorePluginsDir 132 | accessorsDir = file("$buildDir/generated/gradle-plugins-accessors") 133 | dependsOn(installGradle) 134 | } 135 | 136 | 137 | // API docs generation using dokka 138 | val dokka by getting(DokkaTask::class) { 139 | dependsOn(gradleApiSources, gradleKotlinDslApiSources, gradlePluginsAccessors) 140 | group = "" 141 | moduleName = "api" 142 | outputDirectory = "$buildDir/docs/dokka" 143 | jdkVersion = 8 144 | classpath = dokkaDependencies 145 | sourceDirs = listOf( 146 | gradleKotlinDslApiSources.sourceDir, 147 | gradleApiSources.sourceDir, 148 | gradlePluginsAccessors.accessorsDir) 149 | includes = listOf("src/dokka/kotlin-dsl.md") 150 | doFirst { 151 | file(outputDirectory).deleteRecursively() 152 | } 153 | } 154 | val apiDocumentation by creating { 155 | group = "documentation" 156 | description = "Generates Gradle Kotlin DSL API documentation." 157 | dependsOn(dokka) 158 | } 159 | 160 | 161 | // Checks 162 | val checkApiDocumentation by creating { 163 | dependsOn(dokka) 164 | group = "verification" 165 | description = "Runs checks on the generated API documentation." 166 | val apiDocsRoot = file(dokka.outputDirectory) 167 | inputs.dir(apiDocsRoot) 168 | doLast { 169 | var gradleApiFound = false 170 | var gradleKotlinDslApiFound = false 171 | var gradleKotlinDslGeneratedApiFound = false 172 | var gradlePluginsBlockAccessorsFound = false 173 | var gradlePluginsAccessorsFound = false 174 | val filesWithErrorClass = mutableListOf() 175 | apiDocsRoot.walk().filter { it.isFile }.forEach { file -> 176 | val text = file.readText() 177 | if (text.contains("ERROR CLASS")) { 178 | filesWithErrorClass += file 179 | } 180 | if (!gradleApiFound && text.contains("id=\"org.gradle.api.Project\$task")) { 181 | gradleApiFound = true 182 | } 183 | if (!gradleKotlinDslApiFound && text.contains("id=\"org.gradle.kotlin.dsl.KotlinBuildScript")) { 184 | gradleKotlinDslApiFound = true 185 | } 186 | if (!gradleKotlinDslGeneratedApiFound && text.contains("embeddedKotlinVersion")) { 187 | gradleKotlinDslGeneratedApiFound = true 188 | } 189 | if (!gradlePluginsBlockAccessorsFound && text.contains("name=\"org.gradle.kotlin.dsl\$base#org.gradle.plugin.use.PluginDependenciesSpec\"")) { 190 | gradlePluginsBlockAccessorsFound = true 191 | } 192 | if (!gradlePluginsAccessorsFound && text.contains("name=\"org.gradle.kotlin.dsl\$checkstyle#org.gradle.api.Project")) { 193 | gradlePluginsAccessorsFound = true 194 | } 195 | } 196 | if (!gradleApiFound) { 197 | throw Exception("API documentation does not include Gradle API") 198 | } 199 | if (!gradleKotlinDslApiFound) { 200 | throw Exception("API documentation does not include Gradle Kotlin DSL") 201 | } 202 | if (!gradleKotlinDslGeneratedApiFound) { 203 | throw Exception("API documentation does not include *generated* Gradle Kotlin DSL") 204 | } 205 | if (!gradlePluginsBlockAccessorsFound) { 206 | throw Exception("API documentation does not include *generated* Gradle plugins { core } accessors") 207 | } 208 | if (!gradlePluginsAccessorsFound) { 209 | throw Exception("API documentation does not include *generated* Core Gradle Plugins extensions accessors") 210 | } 211 | if (filesWithErrorClass.isNotEmpty()) { 212 | throw Exception(" found in ${filesWithErrorClass.size} files:\n ${filesWithErrorClass.joinToString("\n ")}") 213 | } 214 | } 215 | } 216 | 217 | 218 | // Lifecycle 219 | val cleanBuildWithCorePlugins by creating(GradleBuild::class) { 220 | dir = buildWithCorePluginsDir 221 | tasks = listOf("clean") 222 | } 223 | "clean" { 224 | dependsOn(cleanBuildWithCorePlugins) 225 | } 226 | "assemble" { 227 | dependsOn(apiDocumentation) 228 | } 229 | "check" { 230 | dependsOn(checkApiDocumentation) 231 | } 232 | 233 | 234 | // Publishing 235 | githubPages { 236 | pages.apply { 237 | from("$buildDir/docs/dokka") 238 | from("$buildDir/docs/gradle") 239 | from("src/pages") 240 | } 241 | commitMessage = "Updating gh-pages" 242 | } 243 | "prepareGhPages" { 244 | description = "Stages documentation locally." 245 | dependsOn("assemble") 246 | } 247 | "publishGhPages" { 248 | description = "Publishes documentation to production." 249 | dependsOn("check") 250 | } 251 | 252 | 253 | // Global tasks configuration 254 | withType { 255 | startParameter.showStacktrace = ShowStacktrace.ALWAYS 256 | } 257 | } 258 | -------------------------------------------------------------------------------- /buildSrc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | repositories { 6 | jcenter() 7 | } 8 | 9 | dependencies { 10 | compile("org.ajoberstar:grgit:1.9.1") 11 | } 12 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/api/GradleApiSources.kt: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import java.io.File 4 | 5 | import org.gradle.api.* 6 | import org.gradle.api.tasks.* 7 | 8 | 9 | // TODO Gradle API definition extracted from gradle/gradle/build.gradle 10 | // and gradle/gradle/publicApi.gradle 11 | open class GradleApiSources : DefaultTask() { 12 | 13 | @get:InputDirectory 14 | lateinit var gradleClone: File 15 | 16 | @get:OutputDirectory 17 | lateinit var sourceDir: File 18 | 19 | @TaskAction 20 | fun copyGradleApiSources() { 21 | File(gradleClone, "subprojects").listFiles { file: File -> 22 | file.isDirectory() 23 | && !file.name.startsWith("internal") 24 | && file.name !in listOf("integTest", "distributions", "performance", "build-scan-performance", "distributions-dependencies") 25 | }.forEach { subprojectDir: File -> 26 | project.copy { 27 | from(File(subprojectDir, "src/main/java")) 28 | from(File(subprojectDir, "src/main/groovy")) 29 | from(File(subprojectDir, "src/main/kotlin")) 30 | include( 31 | "org/gradle/*", 32 | "org/gradle/api/**", 33 | "org/gradle/authentication/**", 34 | "org/gradle/buildinit/**", 35 | "org/gradle/caching/**", 36 | "org/gradle/concurrent/**", 37 | "org/gradle/deployment/**", 38 | "org/gradle/external/javadoc/**", 39 | "org/gradle/ide/**", 40 | "org/gradle/includedbuild/**", 41 | "org/gradle/ivy/**", 42 | "org/gradle/jvm/**", 43 | "org/gradle/language/**", 44 | "org/gradle/maven/**", 45 | "org/gradle/nativeplatform/**", 46 | "org/gradle/normalization/**", 47 | "org/gradle/platform/**", 48 | "org/gradle/play/**", 49 | "org/gradle/plugin/devel/**", 50 | "org/gradle/plugin/repository/*", 51 | "org/gradle/plugin/use/*", 52 | "org/gradle/plugin/management/*", 53 | "org/gradle/plugins/**", 54 | "org/gradle/process/**", 55 | "org/gradle/testfixtures/**", 56 | "org/gradle/testing/jacoco/**", 57 | "org/gradle/tooling/**", 58 | "org/gradle/swiftpm/**", 59 | "org/gradle/model/**", 60 | "org/gradle/testkit/**", 61 | "org/gradle/testing/**", 62 | "org/gradle/vcs/**", 63 | "org/gradle/workers/**") 64 | exclude("**/internal/**") 65 | into(sourceDir) 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/api/GradleInstall.kt: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import org.gradle.api.DefaultTask 4 | import org.gradle.api.tasks.InputDirectory 5 | import org.gradle.api.tasks.OutputDirectory 6 | import org.gradle.api.tasks.TaskAction 7 | import java.io.File 8 | 9 | open class GradleInstall : DefaultTask() { 10 | 11 | @get:InputDirectory 12 | lateinit var gradleClone: File 13 | 14 | @get:OutputDirectory 15 | lateinit var gradleInstall: File 16 | 17 | 18 | @TaskAction 19 | fun gradleInstall() { 20 | val buildDirectory = File(temporaryDir, "gradle") 21 | project.delete(buildDirectory) 22 | project.copy { 23 | from(gradleClone) 24 | into(buildDirectory) 25 | } 26 | project.delete(gradleInstall) 27 | val gradlew = File(buildDirectory, "gradlew") 28 | project.exec { 29 | commandLine = listOf( 30 | gradlew.absolutePath, "-q", "--no-scan", 31 | "-c", File(buildDirectory, "settings.gradle.kts").absolutePath, 32 | "-p", buildDirectory.absolutePath, 33 | "install", "-Pgradle_installPath=${gradleInstall.absolutePath}") 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/api/GradleKotlinDslApiSources.kt: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import java.io.File 4 | 5 | import org.gradle.api.* 6 | import org.gradle.api.tasks.* 7 | 8 | open class GradleKotlinDslApiSources : DefaultTask() { 9 | 10 | @get:InputDirectory 11 | lateinit var kotlinDslClone: File 12 | 13 | @get:OutputDirectory 14 | lateinit var sourceDir: File 15 | 16 | @TaskAction 17 | fun copyGradleScriptKotlinApiSources() { 18 | project.sync { 19 | from(File(kotlinDslClone, "subprojects/provider/src/main/kotlin")) 20 | from(File(kotlinDslClone, "subprojects/provider/src/generated/kotlin")) 21 | from(File(kotlinDslClone, "subprojects/plugins/src/main/kotlin")) 22 | from(File(kotlinDslClone, "subprojects/tooling-models/src/main/kotlin")) 23 | exclude("org/gradle/kotlin/dsl/accessors/**") 24 | exclude("org/gradle/kotlin/dsl/cache/**") 25 | exclude("org/gradle/kotlin/dsl/codegen/**") 26 | exclude("org/gradle/kotlin/dsl/concurrent/**") 27 | exclude("org/gradle/kotlin/dsl/execution/**") 28 | exclude("org/gradle/kotlin/dsl/precompile/**") 29 | exclude("org/gradle/kotlin/dsl/provider/**") 30 | exclude("org/gradle/kotlin/dsl/resolver/**") 31 | exclude("org/gradle/kotlin/dsl/services/**") 32 | exclude("org/gradle/kotlin/dsl/support/**") 33 | exclude("org/gradle/script/lang/kotlin/**") 34 | into(sourceDir) 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/api/GradlePluginsAccessors.kt: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import java.io.ByteArrayOutputStream 4 | import java.io.File 5 | 6 | import org.gradle.api.* 7 | import org.gradle.api.provider.* 8 | import org.gradle.api.tasks.* 9 | 10 | import java.util.jar.JarFile 11 | 12 | 13 | open class GradlePluginsAccessors : DefaultTask() { 14 | 15 | @get:InputDirectory 16 | lateinit var gradleInstall: File 17 | 18 | @get:Internal 19 | lateinit var buildDirectory: File 20 | 21 | @get:InputFile 22 | val buildScript: File 23 | get() = buildDirectory.resolve("build.gradle.kts") 24 | 25 | private 26 | val accessorsDirState = project.objects.property(File::class.java) 27 | 28 | @get:OutputDirectory 29 | var accessorsDir 30 | get() = accessorsDirState.get() 31 | set(value) = accessorsDirState.set(value) 32 | 33 | @get:Internal 34 | val accessorsDirProvider: Provider 35 | get() = accessorsDirState 36 | 37 | @TaskAction 38 | fun gradlePluginsAccessors() { 39 | accessorsDir.deleteRecursively() 40 | val gradleUserHomeDir = temporaryDir.resolve("guhd").also { it.deleteRecursively() } 41 | val baos = ByteArrayOutputStream() 42 | val gradlew = gradleInstall.resolve("bin/gradle") 43 | project.exec { 44 | commandLine = listOf( 45 | gradlew.absolutePath, "-q", "-s", 46 | "-g", gradleUserHomeDir.absolutePath, 47 | "-c", buildDirectory.resolve("settings.gradle.kts").absolutePath, 48 | "-p", buildDirectory.absolutePath, 49 | "kotlinDslAccessorsReport") 50 | standardOutput = baos 51 | } 52 | val output = baos.toString() 53 | extractGradleCorePluginsAccessors(output) 54 | extractGradleApiKotlinDslExtensions(gradleUserHomeDir) 55 | } 56 | 57 | fun extractGradleCorePluginsAccessors(output: String) { 58 | val corePluginsAccessorsSource = """ 59 | package org.gradle.kotlin.dsl 60 | 61 | import org.gradle.api.* 62 | import org.gradle.api.artifacts.* 63 | import org.gradle.api.artifacts.dsl.* 64 | 65 | $output 66 | """ 67 | val accessorsFile = accessorsDir.resolve("GradleCorePluginsAccessors.kt") 68 | accessorsFile.parentFile.mkdirs() 69 | accessorsFile.writeText(corePluginsAccessorsSource) 70 | } 71 | 72 | fun extractGradleApiKotlinDslExtensions(gradleUserHomeDir: File) { 73 | 74 | val generatedJar = gradleUserHomeDir.resolve("caches") 75 | .listFiles { f -> f.isDirectory && f.name[0].isDigit() } 76 | .single().resolve("generated-gradle-jars") 77 | .listFiles { f -> f.isFile && f.name.startsWith("gradle-kotlin-dsl-extensions-") } 78 | .single() 79 | 80 | JarFile(generatedJar).use { jar -> 81 | jar.entries().asSequence() 82 | .filter { !it.isDirectory && it.name.endsWith(".kt") } 83 | .forEach { sourceEntry -> 84 | val sourceFile = accessorsDir.resolve(sourceEntry.name) 85 | sourceFile.parentFile.mkdirs() 86 | jar.getInputStream(sourceEntry).use { input -> sourceFile.outputStream().use { output -> input.copyTo(output) } } 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/git/GitClone.kt: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import java.io.File 4 | import org.eclipse.jgit.api.Git 5 | import org.eclipse.jgit.api.LsRemoteCommand 6 | import org.eclipse.jgit.lib.Repository 7 | import org.eclipse.jgit.storage.file.FileRepositoryBuilder 8 | 9 | import org.gradle.api.* 10 | import org.gradle.api.tasks.* 11 | 12 | open class GitClone : DefaultTask() { 13 | 14 | @get:Input 15 | lateinit var uri: String 16 | 17 | @get:Internal 18 | lateinit var ref: String 19 | 20 | @get:OutputDirectory 21 | lateinit var cloneDir: File 22 | 23 | private 24 | val lastCommitHashFile: File = 25 | File(temporaryDir, "lastCommitHash") 26 | 27 | init { 28 | outputs.upToDateWhen { 29 | if (!lastCommitHashFile.isFile) { 30 | false 31 | } else { 32 | val remoteCommitHash = retrieveRemoteRefCommitHash() 33 | val lastCommitHash = lastCommitHashFile.readText() 34 | lastCommitHash == remoteCommitHash 35 | } 36 | } 37 | } 38 | 39 | @TaskAction 40 | fun gitClone(): Unit { 41 | cloneDir.deleteRecursively() 42 | var clone: Git? = null 43 | try { 44 | clone = Git.cloneRepository() 45 | .setURI(uri) 46 | .setDirectory(cloneDir) 47 | .setBranchesToClone(listOf(ref)) 48 | .setBranch(ref) 49 | .call() 50 | } finally { 51 | clone?.close() 52 | } 53 | lastCommitHashFile.writeText(readCloneCurrentCommitHash()) 54 | } 55 | 56 | private 57 | fun readCloneCurrentCommitHash(): String { 58 | var repo: Repository? = null 59 | try { 60 | repo = FileRepositoryBuilder().setWorkTree(cloneDir).build() 61 | return repo.findRef(ref)!!.objectId.name 62 | } finally { 63 | repo?.close() 64 | } 65 | } 66 | 67 | private 68 | fun retrieveRemoteRefCommitHash(): String = 69 | LsRemoteCommand(null) 70 | .setRemote(uri) 71 | .setHeads(true) 72 | .call().find { it.name.substringAfter("refs/heads/") == ref }?.objectId?.name ?: ref 73 | } 74 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/kotlin-dsl-docs/8b1d7feb20655d1ca5b60f0c9d1f6793381fa136/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="-Xms64m -Xmx64m -Dfile.encoding=UTF-8" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | jcenter() 5 | maven { url = uri("https://dl.bintray.com/kotlin/kotlin-dev") } 6 | } 7 | resolutionStrategy { 8 | eachPlugin { 9 | when (requested.id.id) { 10 | "org.jetbrains.dokka" -> useModule("org.jetbrains.dokka:dokka-gradle-plugin:0.9.17") 11 | "org.ajoberstar.github-pages" -> useModule("org.ajoberstar:gradle-git:1.7.1") 12 | } 13 | } 14 | } 15 | } 16 | 17 | rootProject.name = "gradle-kotlin-dsl-docs" 18 | -------------------------------------------------------------------------------- /src/dokka/kotlin-dsl.md: -------------------------------------------------------------------------------- 1 | # Module api 2 | 3 | ## Gradle Kotlin DSL 4 | 5 | See the [org.gradle.kotlin.dsl](org.gradle.kotlin.dsl/index.html) package. 6 | 7 | 8 | # Package org.gradle.kotlin.dsl 9 | 10 | The Gradle Kotlin DSL. 11 | 12 | 13 | # Package org.gradle.kotlin.dsl.plugins.embedded 14 | 15 | The `embedded-kotlin` plugin. 16 | 17 | 18 | # Package org.gradle.kotlin.dsl.plugins.dsl 19 | 20 | The `kotlin-dsl` plugin. 21 | 22 | 23 | # Package org.gradle.kotlin.dsl.tooling.models 24 | 25 | The Tooling API models for the Gradle Kotlin DSL. 26 | -------------------------------------------------------------------------------- /src/pages/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Gradle Kotlin DSL - Documentation 6 | 7 | 8 |

API

9 |

Migration Guide

10 |

Gradle User Manual

11 | 12 | 13 | -------------------------------------------------------------------------------- /src/pages/style.css: -------------------------------------------------------------------------------- 1 | @import url(https://fonts.googleapis.com/css?family=Open+Sans:300i,400,700); 2 | 3 | body, table { 4 | padding:50px; 5 | font:14px/1.5 'Open Sans', "Helvetica Neue", Helvetica, Arial, sans-serif; 6 | color:#555; 7 | font-weight:300; 8 | margin-left: auto; 9 | margin-right: auto; 10 | max-width: 1440px; 11 | } 12 | 13 | .keyword { 14 | color:black; 15 | font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; 16 | font-size:12px; 17 | } 18 | 19 | .symbol { 20 | font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; 21 | font-size:12px; 22 | } 23 | 24 | .identifier { 25 | color: darkblue; 26 | font-size:12px; 27 | font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; 28 | } 29 | 30 | h1, h2, h3, h4, h5, h6 { 31 | color:#222; 32 | margin:0 0 20px; 33 | } 34 | 35 | p, ul, ol, table, pre, dl { 36 | margin:0 0 20px; 37 | } 38 | 39 | h1, h2, h3 { 40 | line-height:1.1; 41 | } 42 | 43 | h1 { 44 | font-size:28px; 45 | } 46 | 47 | h2 { 48 | color:#393939; 49 | } 50 | 51 | h3, h4, h5, h6 { 52 | color:#494949; 53 | } 54 | 55 | a { 56 | color:#258aaf; 57 | font-weight:400; 58 | text-decoration:none; 59 | } 60 | 61 | a:hover { 62 | color: inherit; 63 | text-decoration:underline; 64 | } 65 | 66 | a small { 67 | font-size:11px; 68 | color:#555; 69 | margin-top:-0.6em; 70 | display:block; 71 | } 72 | 73 | .wrapper { 74 | width:860px; 75 | margin:0 auto; 76 | } 77 | 78 | blockquote { 79 | border-left:1px solid #e5e5e5; 80 | margin:0; 81 | padding:0 0 0 20px; 82 | font-style:italic; 83 | } 84 | 85 | code, pre { 86 | font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; 87 | color:#333; 88 | font-size:12px; 89 | } 90 | 91 | pre { 92 | display: block; 93 | /* 94 | padding:8px 8px; 95 | background: #f8f8f8; 96 | border-radius:5px; 97 | border:1px solid #e5e5e5; 98 | */ 99 | overflow-x: auto; 100 | } 101 | 102 | table { 103 | width:100%; 104 | border-collapse:collapse; 105 | } 106 | 107 | th, td { 108 | text-align:left; 109 | vertical-align: top; 110 | padding:5px 10px; 111 | } 112 | 113 | dt { 114 | color:#444; 115 | font-weight:700; 116 | } 117 | 118 | th { 119 | color:#444; 120 | } 121 | 122 | img { 123 | max-width:100%; 124 | } 125 | 126 | header { 127 | width:270px; 128 | float:left; 129 | position:fixed; 130 | } 131 | 132 | header ul { 133 | list-style:none; 134 | height:40px; 135 | 136 | padding:0; 137 | 138 | background: #eee; 139 | background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%); 140 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd)); 141 | background: -webkit-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); 142 | background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); 143 | background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); 144 | background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%); 145 | 146 | border-radius:5px; 147 | border:1px solid #d2d2d2; 148 | box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0; 149 | width:270px; 150 | } 151 | 152 | header li { 153 | width:89px; 154 | float:left; 155 | border-right:1px solid #d2d2d2; 156 | height:40px; 157 | } 158 | 159 | header ul a { 160 | line-height:1; 161 | font-size:11px; 162 | color:#999; 163 | display:block; 164 | text-align:center; 165 | padding-top:6px; 166 | height:40px; 167 | } 168 | 169 | strong { 170 | color:#222; 171 | font-weight:700; 172 | } 173 | 174 | header ul li + li { 175 | width:88px; 176 | border-left:1px solid #fff; 177 | } 178 | 179 | header ul li + li + li { 180 | border-right:none; 181 | width:89px; 182 | } 183 | 184 | header ul a strong { 185 | font-size:14px; 186 | display:block; 187 | color:#222; 188 | } 189 | 190 | section { 191 | width:500px; 192 | float:right; 193 | padding-bottom:50px; 194 | } 195 | 196 | small { 197 | font-size:11px; 198 | } 199 | 200 | hr { 201 | border:0; 202 | background:#e5e5e5; 203 | height:1px; 204 | margin:0 0 20px; 205 | } 206 | 207 | footer { 208 | width:270px; 209 | float:left; 210 | position:fixed; 211 | bottom:50px; 212 | } 213 | 214 | @media print, screen and (max-width: 960px) { 215 | 216 | div.wrapper { 217 | width:auto; 218 | margin:0; 219 | } 220 | 221 | header, section, footer { 222 | float:none; 223 | position:static; 224 | width:auto; 225 | } 226 | 227 | header { 228 | padding-right:320px; 229 | } 230 | 231 | section { 232 | border:1px solid #e5e5e5; 233 | border-width:1px 0; 234 | padding:20px 0; 235 | margin:0 0 20px; 236 | } 237 | 238 | header a small { 239 | display:inline; 240 | } 241 | 242 | header ul { 243 | position:absolute; 244 | right:50px; 245 | top:52px; 246 | } 247 | } 248 | 249 | @media print, screen and (max-width: 720px) { 250 | body { 251 | word-wrap:break-word; 252 | } 253 | 254 | header { 255 | padding:0; 256 | } 257 | 258 | header ul, header p.view { 259 | position:static; 260 | } 261 | 262 | pre, code { 263 | word-wrap:normal; 264 | } 265 | } 266 | 267 | @media print, screen and (max-width: 480px) { 268 | body { 269 | padding:15px; 270 | } 271 | 272 | header ul { 273 | display:none; 274 | } 275 | } 276 | 277 | @media print { 278 | body { 279 | padding:0.4in; 280 | font-size:12pt; 281 | color:#444; 282 | } 283 | } 284 | -------------------------------------------------------------------------------- /update-wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | repo='dist-snapshots' 4 | 5 | # .children[-2] selects the one before the last which is the all distro 6 | latestSnapshotPath=` 7 | http get https://repo.gradle.org/gradle/api/storage/$repo/ \ 8 | | jq -r '[ .children[] | select(.uri | startswith("/gradle-kotlin-dsl-")) ][-2].uri'` 9 | 10 | find . -name gradle-wrapper.properties \ 11 | | xargs perl -p -i -e "s|^(distributionUrl=.*$repo).*|\$1$latestSnapshotPath|" 12 | 13 | --------------------------------------------------------------------------------