Adopt configuration-avoidance where possible
Before this change `./gradlew help` (with native enabled) Created immediately: 1322 Created during configuration: 1541 after this change: Created immediately: 596 Created during configuration: 1509 To know more about configuration avoidance: https://docs.gradle.org/current/userguide/task_configuration_avoidance.html
This commit is contained in:
committed by
Space Team
parent
ad8909113d
commit
46d113605b
@@ -6,6 +6,7 @@
|
||||
import org.jetbrains.kotlin.tools.lib
|
||||
import org.jetbrains.kotlin.tools.solib
|
||||
import org.jetbrains.kotlin.*
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
import org.jetbrains.kotlin.konan.target.ClangArgs
|
||||
import org.jetbrains.kotlin.konan.target.Family.*
|
||||
@@ -144,7 +145,7 @@ dependencies {
|
||||
testImplementation(kotlin("test-junit"))
|
||||
}
|
||||
|
||||
val nativelibs = project.tasks.create<Copy>("nativelibs") {
|
||||
val nativelibs = project.tasks.register<Copy>("nativelibs") {
|
||||
val clangstubsSolib = solib("clangstubs")
|
||||
dependsOn(clangstubsSolib)
|
||||
|
||||
@@ -161,9 +162,8 @@ kotlinNativeInterop {
|
||||
genTask.inputs.dir(libclangextDir)
|
||||
}
|
||||
}
|
||||
val compileKotlin: org.jetbrains.kotlin.gradle.tasks.KotlinCompile by tasks
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
|
||||
tasks.withType<KotlinCompile>().configureEach {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs += listOf(
|
||||
"-Xskip-prerelease-check",
|
||||
@@ -195,14 +195,9 @@ tasks.withType<Test>().configureEach {
|
||||
systemProperty("kotlin.native.interop.indexer.temp", File(buildDir, "testTemp"))
|
||||
}
|
||||
|
||||
tasks.matching { it.name == "linkClangstubsSharedLibrary" }.all {
|
||||
dependsOn(libclangextTask)
|
||||
inputs.dir(libclangextDir)
|
||||
}
|
||||
|
||||
// Please note that list of headers should be fixed manually.
|
||||
// See KT-46231 for details.
|
||||
tasks.create("updatePrebuilt") {
|
||||
tasks.register("updatePrebuilt") {
|
||||
dependsOn("genClangInteropStubs")
|
||||
|
||||
doLast {
|
||||
|
||||
@@ -184,7 +184,7 @@ dependencies {
|
||||
|
||||
classes.dependsOn 'compilerClasses', 'cli_bcClasses'
|
||||
|
||||
jar {
|
||||
tasks.named("jar") {
|
||||
from sourceSets.cli_bc.output,
|
||||
sourceSets.compiler.output,
|
||||
sourceSets.filesInteropStubs.output,
|
||||
@@ -196,8 +196,8 @@ jar {
|
||||
|
||||
def externalJars = ['compiler', 'stdlib', 'reflect', 'script_runtime']
|
||||
|
||||
task trove4jCopy(type: Copy) {
|
||||
from configurations.getByName("trove4j_jar") {
|
||||
tasks.register("trove4jCopy", Copy) {
|
||||
from configurations.named("trove4j_jar") {
|
||||
include "trove4j*.jar"
|
||||
rename "trove4j(.*).jar", "trove4j.jar"
|
||||
|
||||
@@ -207,9 +207,9 @@ task trove4jCopy(type: Copy) {
|
||||
|
||||
externalJars.each { arg ->
|
||||
def jar = arg.replace('_', '-') // :(
|
||||
task("${arg}Copy", type: Copy) {
|
||||
tasks.register("${arg}Copy", Copy) {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
from configurations.getByName("kotlin_${arg}_jar") {
|
||||
from configurations.named("kotlin_${arg}_jar") {
|
||||
include "kotlin-${jar}*.jar"
|
||||
rename "kotlin-${jar}(.*).jar", "kotlin-${jar}.jar"
|
||||
|
||||
@@ -218,12 +218,12 @@ externalJars.each { arg ->
|
||||
}
|
||||
}
|
||||
|
||||
task external_jars(type: Copy) {
|
||||
tasks.register("external_jars", Copy) {
|
||||
dependsOn externalJars.collect { "${it}Copy" }
|
||||
dependsOn trove4jCopy
|
||||
}
|
||||
|
||||
task debugCompiler(type: JavaExec) {
|
||||
tasks.register("debugCompiler", JavaExec) {
|
||||
dependsOn ':dist'
|
||||
mainClass = 'org.jetbrains.kotlin.cli.bc.K2NativeKt'
|
||||
classpath = project.fileTree("${distDir.canonicalPath}/konan/lib/") {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+51
-39
@@ -179,22 +179,30 @@ apply plugin: GitClangFormatPlugin
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: BasePlugin
|
||||
|
||||
task dist_compiler(dependsOn: "distCompiler")
|
||||
task dist_runtime(dependsOn: "distRuntime")
|
||||
task cross_dist(dependsOn: "crossDist")
|
||||
task list_dist(dependsOn: "listDist")
|
||||
tasks.register("dist_compiler") {
|
||||
dependsOn("distCompiler")
|
||||
}
|
||||
tasks.register("dist_runtime") {
|
||||
dependsOn("distRuntime")
|
||||
}
|
||||
tasks.register("cross_dist") {
|
||||
dependsOn("crossDist")
|
||||
}
|
||||
tasks.register("list_dist") {
|
||||
dependsOn("listDist")
|
||||
}
|
||||
|
||||
tasks.named("build") {
|
||||
dependsOn 'dist', 'distPlatformLibs'
|
||||
}
|
||||
|
||||
task distCommonSources(type: CopyCommonSources) {
|
||||
tasks.register("distCommonSources", CopyCommonSources) {
|
||||
outputDir "$distDir/sources"
|
||||
sourcePaths configurations.commonSources
|
||||
zipSources true
|
||||
}
|
||||
|
||||
task distNativeSources(type: Zip) {
|
||||
tasks.register("distNativeSources", Zip) {
|
||||
destinationDirectory = file("$distDir/sources")
|
||||
archiveFileName = "kotlin-stdlib-native-sources.zip"
|
||||
|
||||
@@ -210,12 +218,12 @@ task distNativeSources(type: Zip) {
|
||||
}
|
||||
}
|
||||
|
||||
task distSources {
|
||||
tasks.register("distSources") {
|
||||
dependsOn(distCommonSources)
|
||||
dependsOn(distNativeSources)
|
||||
}
|
||||
|
||||
task shadowJar(type: ShadowJar) {
|
||||
tasks.register("shadowJar", ShadowJar) {
|
||||
mergeServiceFiles()
|
||||
destinationDirectory.set(file("$distDir/konan/lib"))
|
||||
archiveBaseName.set("kotlin-native")
|
||||
@@ -230,7 +238,7 @@ task shadowJar(type: ShadowJar) {
|
||||
}
|
||||
}
|
||||
|
||||
task distCompiler(type: Copy) {
|
||||
tasks.register("distCompiler", Copy) {
|
||||
// Workaround: make distCompiler no-op if we are using custom dist:
|
||||
// the dist is already in place and has the compiler, so we don't have to
|
||||
// build and copy the compiler to dist.
|
||||
@@ -319,7 +327,7 @@ task distCompiler(type: Copy) {
|
||||
}
|
||||
}
|
||||
|
||||
task distDef(type: Copy) {
|
||||
tasks.register("distDef", Copy) {
|
||||
destinationDir project.file("$distDir/konan/platformDef/")
|
||||
|
||||
platformManager.targetValues.each { target ->
|
||||
@@ -333,15 +341,15 @@ task distDef(type: Copy) {
|
||||
}
|
||||
}
|
||||
|
||||
task listDist(type: Exec) {
|
||||
tasks.register("listDist", Exec) {
|
||||
commandLine 'find', distDir
|
||||
}
|
||||
|
||||
task distRuntime(type: Copy) {
|
||||
tasks.register("distRuntime", Copy) {
|
||||
dependsOn "${hostName}CrossDistRuntime"
|
||||
}
|
||||
|
||||
task distStdlibCache {
|
||||
tasks.register("distStdlibCache") {
|
||||
if (hostName in cacheableTargetNames) {
|
||||
dependsOn("${hostName}StdlibCache")
|
||||
}
|
||||
@@ -350,24 +358,24 @@ task distStdlibCache {
|
||||
def stdlib = 'klib/common/stdlib'
|
||||
def stdlibDefaultComponent = "$stdlib/default"
|
||||
|
||||
task crossDistRuntime {
|
||||
tasks.register("crossDistRuntime") {
|
||||
dependsOn.addAll(targetList.collect { "${it}CrossDistRuntime" })
|
||||
}
|
||||
|
||||
task crossDistPlatformLibs {
|
||||
tasks.register("crossDistPlatformLibs") {
|
||||
dependsOn.addAll(targetList.collect { "${it}PlatformLibs" })
|
||||
}
|
||||
|
||||
task crossDistStdlib {
|
||||
tasks.register("crossDistStdlib") {
|
||||
dependsOn.addAll(targetList.collect { "${it}CrossDistStdlib" })
|
||||
}
|
||||
|
||||
task crossDistStdlibCache {
|
||||
tasks.register("crossDistStdlibCache") {
|
||||
dependsOn.addAll(targetList.findAll { it in cacheableTargetNames }.collect { "${it}StdlibCache" })
|
||||
}
|
||||
|
||||
targetList.each { target ->
|
||||
task("${target}CrossDistStdlib", type: Copy) {
|
||||
tasks.register("${target}CrossDistStdlib", Copy) {
|
||||
dependsOn ":kotlin-native:runtime:${target}Stdlib"
|
||||
// TODO: add explicit dependency on host task with IR klib stdlib parts
|
||||
// As for now it is possibly to build up distribution from the tc-dist to crossdist
|
||||
@@ -403,7 +411,7 @@ targetList.each { target ->
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
|
||||
task("${target}CrossDistBitcodeCopy", type: Copy) {
|
||||
tasks.register("${target}CrossDistBitcodeCopy", Copy) {
|
||||
def bitcodeFiles = configurations.runtimeBitcode.incoming.artifactView {
|
||||
attributes {
|
||||
attribute(TargetWithSanitizer.TARGET_ATTRIBUTE, new TargetWithSanitizer(platformManager.targetByName(target), null))
|
||||
@@ -419,7 +427,7 @@ targetList.each { target ->
|
||||
}
|
||||
}
|
||||
|
||||
task("${target}CrossDistRuntime", type: Copy) {
|
||||
tasks.register("${target}CrossDistRuntime", Copy) {
|
||||
dependsOn ":kotlin-native:${target}CrossDistStdlib"
|
||||
dependsOn "${target}CrossDistBitcodeCopy"
|
||||
|
||||
@@ -434,7 +442,7 @@ targetList.each { target ->
|
||||
}
|
||||
}
|
||||
|
||||
task("${target}PlatformLibs") {
|
||||
tasks.register("${target}PlatformLibs") {
|
||||
dependsOn ":kotlin-native:platformLibs:${target}Install"
|
||||
if (target in cacheableTargetNames) {
|
||||
dependsOn(":kotlin-native:platformLibs:${target}Cache")
|
||||
@@ -442,7 +450,7 @@ targetList.each { target ->
|
||||
}
|
||||
|
||||
if (target in cacheableTargetNames) {
|
||||
task ("${target}StdlibCache", type: Copy) {
|
||||
tasks.register("${target}StdlibCache", Copy) {
|
||||
dependsOn "${target}CrossDistStdlib"
|
||||
dependsOn ":kotlin-native:runtime:${target}StdlibCache"
|
||||
|
||||
@@ -454,7 +462,7 @@ targetList.each { target ->
|
||||
}
|
||||
}
|
||||
|
||||
task("${target}CrossDist") {
|
||||
tasks.register("${target}CrossDist") {
|
||||
dependsOn "${target}CrossDistRuntime", "distCompiler"
|
||||
if (target in cacheableTargetNames) {
|
||||
dependsOn "${target}StdlibCache"
|
||||
@@ -462,19 +470,19 @@ targetList.each { target ->
|
||||
}
|
||||
}
|
||||
|
||||
task distPlatformLibs {
|
||||
tasks.register("distPlatformLibs") {
|
||||
dependsOn ':kotlin-native:platformLibs:hostInstall'
|
||||
dependsOn ':kotlin-native:platformLibs:hostCache'
|
||||
}
|
||||
|
||||
task dist {
|
||||
tasks.register("dist") {
|
||||
dependsOn "distCompiler",
|
||||
"distRuntime",
|
||||
"distDef",
|
||||
"distStdlibCache"
|
||||
}
|
||||
|
||||
task crossDist {
|
||||
tasks.register("crossDist") {
|
||||
dependsOn "distCompiler",
|
||||
"crossDistRuntime",
|
||||
"distDef",
|
||||
@@ -482,11 +490,11 @@ task crossDist {
|
||||
"crossDistStdlibCache"
|
||||
}
|
||||
|
||||
task bundle {
|
||||
tasks.register("bundle") {
|
||||
dependsOn 'bundleRegular', 'bundlePrebuilt'
|
||||
}
|
||||
|
||||
task bundleRegular(type: (isWindows()) ? Zip : Tar) {
|
||||
tasks.register("bundleRegular", (isWindows()) ? Zip : Tar) {
|
||||
def simpleOsName = HostManager.platformName()
|
||||
archiveBaseName.set("kotlin-native-$simpleOsName")
|
||||
archiveVersion.set(kotlinVersion)
|
||||
@@ -502,7 +510,7 @@ task bundleRegular(type: (isWindows()) ? Zip : Tar) {
|
||||
}
|
||||
}
|
||||
|
||||
task bundlePrebuilt(type: (isWindows()) ? Zip : Tar) {
|
||||
tasks.register("bundlePrebuilt", (isWindows()) ? Zip : Tar) {
|
||||
dependsOn("crossDistPlatformLibs")
|
||||
def simpleOsName = HostManager.platformName()
|
||||
archiveBaseName.set("kotlin-native-prebuilt-$simpleOsName")
|
||||
@@ -532,8 +540,12 @@ void configurePackingLicensesToBundle(AbstractArchiveTask task, boolean contains
|
||||
}
|
||||
}
|
||||
|
||||
configurePackingLicensesToBundle(bundleRegular, /* containsPlatformLibraries = */ false)
|
||||
configurePackingLicensesToBundle(bundlePrebuilt, /* containsPlatformLibraries = */ true)
|
||||
tasks.named("bundleRegular").configure {
|
||||
configurePackingLicensesToBundle(it, /* containsPlatformLibraries = */ false)
|
||||
}
|
||||
tasks.named("bundlePrebuilt").configure {
|
||||
configurePackingLicensesToBundle(it, /* containsPlatformLibraries = */ true)
|
||||
}
|
||||
|
||||
configure([bundleRegular, bundlePrebuilt]) {
|
||||
dependsOn("crossDist")
|
||||
@@ -555,7 +567,7 @@ configure([bundleRegular, bundlePrebuilt]) {
|
||||
}
|
||||
}
|
||||
|
||||
task 'tc-dist'(type: (isWindows()) ? Zip : Tar) {
|
||||
tasks.register("tc-dist", (isWindows()) ? Zip : Tar) {
|
||||
dependsOn('dist')
|
||||
dependsOn('distSources')
|
||||
def simpleOsName = HostManager.platformName()
|
||||
@@ -577,12 +589,12 @@ task 'tc-dist'(type: (isWindows()) ? Zip : Tar) {
|
||||
}
|
||||
}
|
||||
|
||||
task samples {
|
||||
tasks.register("samples") {
|
||||
dependsOn 'samplesZip', 'samplesTar'
|
||||
}
|
||||
|
||||
task samplesZip(type: Zip)
|
||||
task samplesTar(type: Tar) {
|
||||
tasks.register("samplesZip", Zip)
|
||||
tasks.register("samplesTar", Tar) {
|
||||
archiveExtension = 'tar.gz'
|
||||
compression = Compression.GZIP
|
||||
}
|
||||
@@ -616,10 +628,10 @@ configure([samplesZip, samplesTar]) {
|
||||
exclude '**/*.kt.bc-build/'
|
||||
}
|
||||
|
||||
project.tasks.register("copy_samples") {
|
||||
tasks.register("copy_samples") {
|
||||
dependsOn 'copySamples'
|
||||
}
|
||||
project.tasks.register("copySamples", CopySamples) {
|
||||
tasks.register("copySamples", CopySamples) {
|
||||
destinationDir file('build/samples-under-test')
|
||||
}
|
||||
|
||||
@@ -638,7 +650,7 @@ tasks.register("compdb", Copy) {
|
||||
}
|
||||
|
||||
targetList.each { targetName ->
|
||||
task "${targetName}CheckPlatformAbiCompatibility"(type: CompareDistributionSignatures) {
|
||||
tasks.register("${targetName}CheckPlatformAbiCompatibility", CompareDistributionSignatures) {
|
||||
dependsOn "${targetName}PlatformLibs"
|
||||
|
||||
libraries = new CompareDistributionSignatures.Libraries.Platform(targetName)
|
||||
@@ -649,7 +661,7 @@ targetList.each { targetName ->
|
||||
}
|
||||
}
|
||||
|
||||
task "checkStdlibAbiCompatibility"(type: CompareDistributionSignatures) {
|
||||
tasks.register("checkStdlibAbiCompatibility", CompareDistributionSignatures) {
|
||||
dependsOn "distRuntime"
|
||||
|
||||
libraries = CompareDistributionSignatures.Libraries.Standard.INSTANCE
|
||||
|
||||
@@ -82,7 +82,7 @@ def platformManager = rootProject.project(":kotlin-native").ext.platformManager
|
||||
platformManager.enabled.each { target ->
|
||||
def loader = platformManager.loader(target)
|
||||
|
||||
task "${target}Dependencies"(type: NativeDep) {
|
||||
tasks.register("${target}Dependencies", NativeDep) {
|
||||
konanPropertiesLoader = loader
|
||||
}
|
||||
|
||||
@@ -107,13 +107,13 @@ platformManager.enabled.each { target ->
|
||||
}
|
||||
}
|
||||
|
||||
task update {
|
||||
tasks.register("update") {
|
||||
dependsOn tasks.withType(NativeDep)
|
||||
mustRunAfter(tasks.withType(NativeDep))
|
||||
}
|
||||
rootProject.project(":kotlin-native").ext.nativeDependencies = tasks.withType(NativeDep)
|
||||
|
||||
task rmDotKonan(type: Delete) {
|
||||
tasks.register("rmDotKonan", Delete) {
|
||||
def dir = System.getenv("KONAN_DATA_DIR") ?: "${System.getProperty("user.home")}/.konan"
|
||||
delete dir
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ subprojects { proj ->
|
||||
|
||||
def rootBuildDirectory = projectDir.parentFile
|
||||
|
||||
task buildAnalyzer(type: GradleBuild) {
|
||||
tasks.register("buildAnalyzer", GradleBuild) {
|
||||
buildFile = "../tools/benchmarksAnalyzer/build.gradle"
|
||||
tasks = [":${getAnalyzerTargetName()}Binaries".toString()]
|
||||
startParameter.setProjectProperties(this.project.gradle.startParameter.projectProperties)
|
||||
@@ -235,7 +235,7 @@ task registerExternalBenchmarks {
|
||||
}
|
||||
}
|
||||
|
||||
task registerBuild(type: BuildRegister) {
|
||||
tasks.register("registerBuild", BuildRegister) {
|
||||
onlyBranch = project.findProperty('kotlin.register.branch')
|
||||
def uploadedFile = getUploadedFile(nativeJson)
|
||||
if (uploadedFile != null) {
|
||||
@@ -252,7 +252,7 @@ task registerBuild(type: BuildRegister) {
|
||||
buildNumberSuffix = project.findProperty('buildNumberSuffix')
|
||||
}
|
||||
|
||||
task registerExternalBuild(type: BuildRegister) {
|
||||
tasks.register("registerExternalBuild", BuildRegister) {
|
||||
onlyBranch = project.findProperty('kotlin.register.branch')
|
||||
def uploadedFile = getUploadedFile(externalBenchmarksReport)
|
||||
if (uploadedFile != null) {
|
||||
|
||||
@@ -406,7 +406,7 @@ val hostRuntimeTests by tasks.registering {
|
||||
dependsOn("${hostName}RuntimeTests")
|
||||
}
|
||||
|
||||
val assemble by tasks.getting {
|
||||
tasks.named("assemble") {
|
||||
dependsOn(targetList.map { "${it}Runtime" })
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ val hostAssemble by tasks.registering {
|
||||
dependsOn("${hostName}Runtime")
|
||||
}
|
||||
|
||||
val clean by tasks.getting {
|
||||
tasks.named("clean") {
|
||||
doFirst {
|
||||
delete(buildDir)
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ def getMingwPath() {
|
||||
return directory
|
||||
}
|
||||
|
||||
task assembleWeb(type: Sync) {
|
||||
tasks.register("assembleWeb", Sync) {
|
||||
def runtimeDependencies = kotlin.targets.js.compilations.main.runtimeDependencyFiles
|
||||
from(files {
|
||||
runtimeDependencies.collect { File file ->
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ class PathSpecification extends BaseKonanSpecification {
|
||||
dynamic('dynamic')
|
||||
}
|
||||
|
||||
task checkArtifacts(type: DefaultTask) {
|
||||
tasks.register("checkArtifacts", DefaultTask) {
|
||||
dependsOn(':build')
|
||||
doLast {
|
||||
for(artifact in konanArtifacts) {
|
||||
|
||||
+4
-4
@@ -29,8 +29,8 @@ class TaskSpecification extends BaseKonanSpecification {
|
||||
when:
|
||||
def project = KonanProject.createWithInterop(projectDirectory, ArtifactType.LIBRARY)
|
||||
project.buildFile.append("""
|
||||
task beforeInterop(type: DefaultTask) { doLast { println("Before Interop") } }
|
||||
task beforeCompilation(type: DefaultTask) { doLast { println("Before compilation") } }
|
||||
tasks.register("beforeInterop", DefaultTask) { doLast { println("Before Interop") } }
|
||||
tasks.register("beforeCompilation", DefaultTask) { doLast { println("Before compilation") } }
|
||||
""".stripIndent())
|
||||
project.addSetting(KonanProject.DEFAULT_INTEROP_NAME,"dependsOn", "beforeInterop")
|
||||
project.addSetting("dependsOn", "beforeCompilation")
|
||||
@@ -147,7 +147,7 @@ class TaskSpecification extends BaseKonanSpecification {
|
||||
|
||||
BuildResult failOnPropertyAccess(KonanProject project, String property) {
|
||||
project.buildFile.append("""
|
||||
task testTask(type: DefaultTask) {
|
||||
tasks.register("testTask", DefaultTask) {
|
||||
doLast {
|
||||
println(${project.defaultInteropConfig()}.$property)
|
||||
}
|
||||
@@ -158,7 +158,7 @@ class TaskSpecification extends BaseKonanSpecification {
|
||||
|
||||
BuildResult failOnTaskAccess(KonanProject project, String task) {
|
||||
project.buildFile.append("""
|
||||
task testTask(type: DefaultTask) {
|
||||
tasks.register("testTask", DefaultTask) {
|
||||
dependsOn $task
|
||||
}
|
||||
""".stripIndent())
|
||||
|
||||
Reference in New Issue
Block a user