import org.gradle.gradlebuild.ProjectGroups import org.gradle.gradlebuild.PublicApi import org.gradle.gradlebuild.unittestandcompile.ModuleType /* * Copyright 2012 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 * * http://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. */ // This is a groovy project because we have int tests. // Remove any pre-configured archives configurations.all { artifacts.clear() } //tasks.remove(jar) tasks.withType(AbstractArchiveTask).configureEach { baseName "gradle-kotlin-dsl" // The CI server looks for the distributions at this location destinationDirectory.set(rootProject.layout.buildDirectory.dir(rootProject.distsDirName)) } tasks.named("clean").configure { delete tasks.withType(AbstractArchiveTask) } gradlebuildJava { moduleType = ModuleType.INTERNAL } configurations { dists buildReceipt { visible = false canBeResolved = true canBeConsumed = false extendsFrom(gradleRuntimeSource) attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME)) attributes.attribute(Attribute.of("org.gradle.api", String), "build-receipt") } gradleFullDocs { visible = false canBeResolved = true canBeConsumed = false extendsFrom(gradleDocumentation) attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, "docs")) attributes.attribute(Attribute.of("type", String), "full-docs") } gradleGettingStarted { visible = false canBeResolved = true canBeConsumed = false extendsFrom(gradleDocumentation) attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, "docs")) attributes.attribute(Attribute.of("type", String), "getting-started") } } dependencies { implementation(project(":distributionsDependencies")) } ext { zipRootFolder = "gradle-$version" binDistImage = copySpec { from("$rootDir/LICENSE") from('src/toplevel') into('bin') { from configurations.gradleScripts fileMode = 0755 } into('lib') { from configurations.coreGradleRuntime into('plugins') { from configurations.builtInGradlePlugins - configurations.coreGradleRuntime } } } binWithDistDocImage = copySpec { with binDistImage from configurations.gradleGettingStarted } allDistImage = copySpec { with binWithDistDocImage // TODO: Change this to a src publication too ProjectGroups.INSTANCE.getJavaProjects(project).each { project -> into("src/$project.projectDir.name") { from project.sourceSets.main.allSource } } into('docs') { from configurations.gradleFullDocs } into('samples') { from configurations.gradleSamples exclude '**/*.out' exclude '**/*.sample.conf*' } } } def allZip = tasks.register("allZip", Zip) { archiveClassifier.set('all') into(zipRootFolder) { with allDistImage } } def binZip = tasks.register("binZip", Zip) { archiveClassifier.set('bin') into(zipRootFolder) { with binWithDistDocImage } } def srcZip = tasks.register("srcZip", Zip) { archiveClassifier.set('src') into(zipRootFolder) { from(rootProject.file('gradlew')) { fileMode = 0755 } from(rootProject.projectDir) { def spec = delegate // TODO: Maybe make this some kind of publication too. ['buildSrc', 'buildSrc/subprojects/*', 'subprojects/*'].each { spec.include "$it/*.gradle" spec.include "$it/*.gradle.kts" spec.include "$it/src/" } include 'gradle.properties' include 'buildSrc/gradle.properties' include 'config/' include 'gradle/' include 'src/' include '*.gradle' include '*.gradle.kts' include 'wrapper/' include 'gradlew.bat' include 'version.txt' include 'released-versions.json' exclude '**/.gradle/' } } } tasks.register("outputsZip", Zip) { archiveFileName.set("outputs.zip") from(configurations.buildReceipt) from(allZip) from(binZip) from(srcZip) } artifacts { dists allZip, binZip, srcZip } integTestTasks.configureEach { binaryDistributions.distributionsRequired = true systemProperty 'org.gradle.public.api.includes', PublicApi.includes.join(':') systemProperty 'org.gradle.public.api.excludes', PublicApi.excludes.join(':') } apply from: 'binary-compatibility.gradle' task uploadDistributionSnapshot { dependsOn(binZip, allZip) doLast { def archives = [binZip, allZip].collect { it.get().archivePath } as List def username = project.findProperty("artifactory_user") ?: "nouser" def password = project.findProperty("artifactory_password") ?: "nopass" def baseUri = "https://repo.gradle.org/gradle/kotlin-dsl-snapshots-local" archives.each { archive -> def url = new URL("$baseUri/${archive.name}") println "PUT $url" println ((url.openConnection() as HttpURLConnection).with { doOutput = true requestMethod = "PUT" setRequestProperty("Authorization", "Basic ${Base64.urlEncoder.encodeToString("$username:$password".bytes)}") outputStream.withCloseable { out -> archive.withInputStream { out << it } } inputStream.text }) } } }