Refactor more tasks to lazy API
This commit is contained in:
@@ -145,7 +145,7 @@ dependencies {
|
|||||||
|
|
||||||
val makeIntellijCore = buildIvyRepositoryTask(intellijCore, customDepsOrg, customDepsRepoDir)
|
val makeIntellijCore = buildIvyRepositoryTask(intellijCore, customDepsOrg, customDepsRepoDir)
|
||||||
|
|
||||||
val makeIntellijAnnotations by tasks.creating(Copy::class.java) {
|
val makeIntellijAnnotations by tasks.registering(Copy::class) {
|
||||||
dependsOn(makeIntellijCore)
|
dependsOn(makeIntellijCore)
|
||||||
|
|
||||||
from(repoDir.resolve("intellij-core/$intellijVersion/artifacts/annotations.jar"))
|
from(repoDir.resolve("intellij-core/$intellijVersion/artifacts/annotations.jar"))
|
||||||
@@ -222,7 +222,7 @@ tasks.named("build") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Task to delete legacy repo locations
|
// Task to delete legacy repo locations
|
||||||
tasks.create("cleanLegacy", Delete::class.java) {
|
tasks.register<Delete>("cleanLegacy") {
|
||||||
delete("$projectDir/android-dx")
|
delete("$projectDir/android-dx")
|
||||||
delete("$projectDir/intellij-sdk")
|
delete("$projectDir/intellij-sdk")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,17 +8,12 @@ import org.gradle.api.artifacts.Configuration
|
|||||||
import org.gradle.api.artifacts.ConfigurationContainer
|
import org.gradle.api.artifacts.ConfigurationContainer
|
||||||
import org.gradle.api.artifacts.component.ProjectComponentIdentifier
|
import org.gradle.api.artifacts.component.ProjectComponentIdentifier
|
||||||
import org.gradle.api.file.DuplicatesStrategy
|
import org.gradle.api.file.DuplicatesStrategy
|
||||||
import org.gradle.api.file.SourceDirectorySet
|
|
||||||
import org.gradle.api.plugins.BasePluginConvention
|
import org.gradle.api.plugins.BasePluginConvention
|
||||||
import org.gradle.api.plugins.JavaPluginConvention
|
|
||||||
import org.gradle.api.tasks.AbstractCopyTask
|
|
||||||
import org.gradle.api.tasks.Copy
|
|
||||||
import org.gradle.api.tasks.TaskProvider
|
import org.gradle.api.tasks.TaskProvider
|
||||||
import org.gradle.api.tasks.Upload
|
import org.gradle.api.tasks.Upload
|
||||||
import org.gradle.api.tasks.javadoc.Javadoc
|
import org.gradle.api.tasks.javadoc.Javadoc
|
||||||
import org.gradle.jvm.tasks.Jar
|
import org.gradle.jvm.tasks.Jar
|
||||||
import org.gradle.kotlin.dsl.*
|
import org.gradle.kotlin.dsl.*
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
|
|
||||||
private const val MAGIC_DO_NOT_CHANGE_TEST_JAR_TASK_NAME = "testJar"
|
private const val MAGIC_DO_NOT_CHANGE_TEST_JAR_TASK_NAME = "testJar"
|
||||||
@@ -52,11 +47,11 @@ fun Project.removeArtifacts(configuration: Configuration, task: Task) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Project.noDefaultJar() {
|
fun Project.noDefaultJar() {
|
||||||
tasks.findByName("jar")?.let { defaultJarTask ->
|
tasks.named("jar").configure {
|
||||||
defaultJarTask.enabled = false
|
enabled = false
|
||||||
defaultJarTask.actions = emptyList()
|
actions = emptyList()
|
||||||
configurations.forEach { cfg ->
|
configurations.forEach { cfg ->
|
||||||
removeArtifacts(cfg, defaultJarTask)
|
removeArtifacts(cfg, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,9 +65,8 @@ fun Project.runtimeJarArtifactBy(task: Task, artifactRef: Any, body: Configurabl
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun <T : Jar> Project.runtimeJar(task: TaskProvider<T>, body: T.() -> Unit = {}): TaskProvider<T> {
|
fun <T : Jar> Project.runtimeJar(task: TaskProvider<T>, body: T.() -> Unit = {}): TaskProvider<T> {
|
||||||
extra["runtimeJarTask"] = task
|
tasks.named<Jar>("jar").configure {
|
||||||
tasks.findByName("jar")?.let { defaultJarTask ->
|
removeArtifacts(configurations.getOrCreate("archives"), this)
|
||||||
removeArtifacts(configurations.getOrCreate("archives"), defaultJarTask)
|
|
||||||
}
|
}
|
||||||
task.configure {
|
task.configure {
|
||||||
configurations.findByName("embedded")?.let { embedded ->
|
configurations.findByName("embedded")?.let { embedded ->
|
||||||
@@ -152,11 +146,6 @@ fun Project.publish(body: Upload.() -> Unit = {}): Upload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Project.runtimeJarTaskIfExists(): Task? =
|
|
||||||
if (extra.has("runtimeJarTask")) extra["runtimeJarTask"] as Task
|
|
||||||
else tasks.findByName("jar")
|
|
||||||
|
|
||||||
|
|
||||||
fun ConfigurationContainer.getOrCreate(name: String): Configuration = findByName(name) ?: create(name)
|
fun ConfigurationContainer.getOrCreate(name: String): Configuration = findByName(name) ?: create(name)
|
||||||
|
|
||||||
fun Jar.setupPublicJar(baseName: String, classifier: String = "") {
|
fun Jar.setupPublicJar(baseName: String, classifier: String = "") {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.gradle.api.artifacts.ModuleDependency
|
|||||||
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
||||||
import org.gradle.api.artifacts.repositories.IvyArtifactRepository
|
import org.gradle.api.artifacts.repositories.IvyArtifactRepository
|
||||||
import org.gradle.api.tasks.JavaExec
|
import org.gradle.api.tasks.JavaExec
|
||||||
|
import org.gradle.api.tasks.TaskProvider
|
||||||
import org.gradle.kotlin.dsl.*
|
import org.gradle.kotlin.dsl.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@@ -154,9 +155,9 @@ fun DependencyHandlerScope.excludeInAndroidStudio(rootProject: Project, block: D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.runIdeTask(name: String, ideaPluginDir: File, ideaSandboxDir: File, body: JavaExec.() -> Unit): JavaExec {
|
fun Project.runIdeTask(name: String, ideaPluginDir: File, ideaSandboxDir: File, body: JavaExec.() -> Unit): TaskProvider<JavaExec> {
|
||||||
|
|
||||||
return task<JavaExec>(name) {
|
return tasks.register<JavaExec>(name) {
|
||||||
val ideaSandboxConfigDir = File(ideaSandboxDir, "config")
|
val ideaSandboxConfigDir = File(ideaSandboxDir, "config")
|
||||||
|
|
||||||
classpath = mainSourceSet.runtimeClasspath
|
classpath = mainSourceSet.runtimeClasspath
|
||||||
|
|||||||
@@ -57,4 +57,4 @@ projectTest {
|
|||||||
val generateTests by generator("org.jetbrains.kotlin.android.tests.CodegenTestsOnAndroidGenerator")
|
val generateTests by generator("org.jetbrains.kotlin.android.tests.CodegenTestsOnAndroidGenerator")
|
||||||
|
|
||||||
generateTests.workingDir = rootDir
|
generateTests.workingDir = rootDir
|
||||||
generateTests.dependsOn(":dist")
|
generateTests.dependsOn(rootProject.tasks.named("dist"))
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ projectTest {
|
|||||||
exclude("**/benchmark/**")
|
exclude("**/benchmark/**")
|
||||||
}
|
}
|
||||||
|
|
||||||
val compactClasspath by tasks.creating(Jar::class) {
|
val compactClasspath by tasks.registering(Jar::class) {
|
||||||
archiveAppendix.set("classpath")
|
archiveAppendix.set("classpath")
|
||||||
inputs.files(sourceSets["main"].runtimeClasspath + sourceSets["test"].runtimeClasspath)
|
inputs.files(sourceSets["main"].runtimeClasspath + sourceSets["test"].runtimeClasspath)
|
||||||
doFirst {
|
doFirst {
|
||||||
@@ -46,7 +46,7 @@ val compactClasspath by tasks.creating(Jar::class) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val jmhBytecode by tasks.creating(JavaExec::class) {
|
val jmhBytecode by tasks.registering(JavaExec::class) {
|
||||||
tasks["classes"].mustRunAfter(tasks["clean"])
|
tasks["classes"].mustRunAfter(tasks["clean"])
|
||||||
tasks["compactClasspath"].mustRunAfter(tasks["classes"])
|
tasks["compactClasspath"].mustRunAfter(tasks["classes"])
|
||||||
dependsOn(tasks["clean"])
|
dependsOn(tasks["clean"])
|
||||||
@@ -68,14 +68,14 @@ tasks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val jmhCompile by tasks.creating(JavaCompile::class) {
|
val jmhCompile by tasks.registering(JavaCompile::class) {
|
||||||
/*classpath = sourceSets["test"].runtimeClasspath + files("${project.buildDir}/generated-sources/jmh/")
|
/*classpath = sourceSets["test"].runtimeClasspath + files("${project.buildDir}/generated-sources/jmh/")
|
||||||
|
|
||||||
source(fileTree("${project.buildDir}/generated-sources/jmh/"))
|
source(fileTree("${project.buildDir}/generated-sources/jmh/"))
|
||||||
destinationDir = file("${project.buildDir}/generated-classes/jmh/")*/
|
destinationDir = file("${project.buildDir}/generated-classes/jmh/")*/
|
||||||
}
|
}
|
||||||
|
|
||||||
val jmhExec by tasks.creating(JavaExec::class) {
|
val jmhExec by tasks.registering(JavaExec::class) {
|
||||||
dependsOn(tasks["compileTestJava"])
|
dependsOn(tasks["compileTestJava"])
|
||||||
doFirst {
|
doFirst {
|
||||||
classpath = files(
|
classpath = files(
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ dependencies {
|
|||||||
generatorClasspath(project("visitors-generator"))
|
generatorClasspath(project("visitors-generator"))
|
||||||
}
|
}
|
||||||
|
|
||||||
val generateVisitors by tasks.creating(NoDebugJavaExec::class) {
|
val generateVisitors by tasks.registering(NoDebugJavaExec::class) {
|
||||||
val generationRoot = "$projectDir/src/org/jetbrains/kotlin/fir/"
|
val generationRoot = "$projectDir/src/org/jetbrains/kotlin/fir/"
|
||||||
val output = "$projectDir/visitors"
|
val output = "$projectDir/visitors"
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ plugins {
|
|||||||
val builtinsSrc = fileFrom(rootDir, "core", "builtins", "src")
|
val builtinsSrc = fileFrom(rootDir, "core", "builtins", "src")
|
||||||
val builtinsNative = fileFrom(rootDir, "core", "builtins", "native")
|
val builtinsNative = fileFrom(rootDir, "core", "builtins", "native")
|
||||||
|
|
||||||
val serialize by tasks.creating(NoDebugJavaExec::class) {
|
val serialize by tasks.registering(NoDebugJavaExec::class) {
|
||||||
val outDir = "$buildDir/$name"
|
val outDir = "$buildDir/$name"
|
||||||
val inDirs = arrayOf(builtinsSrc, builtinsNative)
|
val inDirs = arrayOf(builtinsSrc, builtinsNative)
|
||||||
inDirs.forEach { inputs.dir(it) }
|
inDirs.forEach { inputs.dir(it) }
|
||||||
|
|||||||
+3
-3
@@ -51,7 +51,7 @@ dependencies {
|
|||||||
androidDxSources("google:dx:0@tar.gz")
|
androidDxSources("google:dx:0@tar.gz")
|
||||||
}
|
}
|
||||||
|
|
||||||
val unzipDxJar by tasks.creating {
|
val unzipDxJar by tasks.registering {
|
||||||
val outputDir = File(buildDir, name)
|
val outputDir = File(buildDir, name)
|
||||||
val outputFile = File(outputDir, "dx.jar")
|
val outputFile = File(outputDir, "dx.jar")
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ val unzipDxJar by tasks.creating {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val untarDxSources by tasks.creating {
|
val untarDxSources by tasks.registering {
|
||||||
val dxSourcesTargetDir = File(buildDir, name)
|
val dxSourcesTargetDir = File(buildDir, name)
|
||||||
dependsOn(androidDxSources)
|
dependsOn(androidDxSources)
|
||||||
inputs.files(androidDxSources)
|
inputs.files(androidDxSources)
|
||||||
@@ -83,7 +83,7 @@ val untarDxSources by tasks.creating {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val prepareDxSourcesJar by tasks.creating(Jar::class) {
|
val prepareDxSourcesJar by tasks.registering(Jar::class) {
|
||||||
dependsOn(untarDxSources)
|
dependsOn(untarDxSources)
|
||||||
from(untarDxSources)
|
from(untarDxSources)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -92,7 +92,7 @@ val clean by task<Delete> {
|
|||||||
delete(buildDir)
|
delete(buildDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
val extractAndroidJar by tasks.creating {
|
val extractAndroidJar by tasks.registering {
|
||||||
dependsOn(androidPlatform)
|
dependsOn(androidPlatform)
|
||||||
inputs.files(androidPlatform)
|
inputs.files(androidPlatform)
|
||||||
val targetFile = File(libsDestDir, "android.jar")
|
val targetFile = File(libsDestDir, "android.jar")
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ dependencies {
|
|||||||
relocatedProtobuf(project(":protobuf-relocated"))
|
relocatedProtobuf(project(":protobuf-relocated"))
|
||||||
}
|
}
|
||||||
|
|
||||||
val prepare by tasks.creating {
|
val prepare by tasks.registering {
|
||||||
inputs.files(relocatedProtobuf) // this also adds a dependency
|
inputs.files(relocatedProtobuf) // this also adds a dependency
|
||||||
outputs.file(outputJarPath)
|
outputs.file(outputJarPath)
|
||||||
doFirst {
|
doFirst {
|
||||||
|
|||||||
@@ -178,7 +178,9 @@ val checkRepositories: TaskProvider<Task> = tasks.register("checkRepositories")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.findByName("checkBuild")?.dependsOn(checkRepositories)
|
tasks.named("checkBuild").configure {
|
||||||
|
dependsOn(checkRepositories)
|
||||||
|
}
|
||||||
|
|
||||||
if (cacheRedirectorEnabled()) {
|
if (cacheRedirectorEnabled()) {
|
||||||
logger.info("Redirecting repositories for $displayName")
|
logger.info("Redirecting repositories for $displayName")
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ dependencies {
|
|||||||
sources(project(":kotlin-stdlib-common", configuration = "sources"))
|
sources(project(":kotlin-stdlib-common", configuration = "sources"))
|
||||||
}
|
}
|
||||||
|
|
||||||
val buildSources by tasks.creating(Jar::class.java) {
|
val buildSources by tasks.registering(Jar::class) {
|
||||||
dependsOn(sources)
|
dependsOn(sources)
|
||||||
from(provider { zipTree(sources.singleFile) })
|
from(provider { zipTree(sources.singleFile) })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
"yarn" {
|
named("yarn") {
|
||||||
outputs.upToDateWhen {
|
outputs.upToDateWhen {
|
||||||
projectDir.resolve("node_modules").isDirectory
|
projectDir.resolve("node_modules").isDirectory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
create<YarnTask>("yarnBuild") {
|
register<YarnTask>("yarnBuild") {
|
||||||
group = "build"
|
group = "build"
|
||||||
|
|
||||||
dependsOn("yarn")
|
dependsOn("yarn")
|
||||||
@@ -54,7 +54,7 @@ tasks {
|
|||||||
outputs.dir("lib")
|
outputs.dir("lib")
|
||||||
}
|
}
|
||||||
|
|
||||||
create<Delete>("cleanYarn") {
|
register<Delete>("cleanYarn") {
|
||||||
group = "build"
|
group = "build"
|
||||||
|
|
||||||
delete = setOf(
|
delete = setOf(
|
||||||
@@ -64,11 +64,13 @@ tasks {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getByName("clean").dependsOn("cleanYarn")
|
named("clean") {
|
||||||
|
dependsOn("cleanYarn")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val jar = tasks.create<Jar>("jar") {
|
val jar by tasks.creating(Jar::class) {
|
||||||
dependsOn("yarnBuild")
|
dependsOn(tasks.named("yarnBuild"))
|
||||||
from(projectDir.resolve("lib"))
|
from(projectDir.resolve("lib"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ tasks {
|
|||||||
}
|
}
|
||||||
"test" {
|
"test" {
|
||||||
// These dependencies are needed because ForTestCompileRuntime loads jars from dist
|
// These dependencies are needed because ForTestCompileRuntime loads jars from dist
|
||||||
dependsOn(":dist")
|
dependsOn(rootProject.tasks.named("dist"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ val buildVersion by configurations.creating
|
|||||||
val buildNumber: String by rootProject.extra
|
val buildNumber: String by rootProject.extra
|
||||||
val kotlinVersion: String by rootProject.extra
|
val kotlinVersion: String by rootProject.extra
|
||||||
|
|
||||||
val writeBuildNumber by tasks.creating {
|
val writeBuildNumber by tasks.registering {
|
||||||
val versionFile = File(buildVersionFilePath)
|
val versionFile = File(buildVersionFilePath)
|
||||||
inputs.property("version", buildNumber)
|
inputs.property("version", buildNumber)
|
||||||
outputs.file(versionFile)
|
outputs.file(versionFile)
|
||||||
@@ -30,7 +30,7 @@ fun replaceVersion(versionFile: File, versionPattern: String, replacement: (Matc
|
|||||||
versionFile.writeText(text.replaceRange(match.groups[1]!!.range, newValue))
|
versionFile.writeText(text.replaceRange(match.groups[1]!!.range, newValue))
|
||||||
}
|
}
|
||||||
|
|
||||||
val writeStdlibVersion by tasks.creating {
|
val writeStdlibVersion by tasks.registering {
|
||||||
val versionFile = rootDir.resolve("libraries/stdlib/src/kotlin/util/KotlinVersion.kt")
|
val versionFile = rootDir.resolve("libraries/stdlib/src/kotlin/util/KotlinVersion.kt")
|
||||||
inputs.property("version", kotlinVersion)
|
inputs.property("version", kotlinVersion)
|
||||||
outputs.file(versionFile)
|
outputs.file(versionFile)
|
||||||
@@ -44,7 +44,7 @@ val writeStdlibVersion by tasks.creating {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val writeCompilerVersion by tasks.creating {
|
val writeCompilerVersion by tasks.registering {
|
||||||
val versionFile = rootDir.resolve("core/util.runtime/src/org/jetbrains/kotlin/config/KotlinCompilerVersion.java")
|
val versionFile = rootDir.resolve("core/util.runtime/src/org/jetbrains/kotlin/config/KotlinCompilerVersion.java")
|
||||||
inputs.property("version", kotlinVersion)
|
inputs.property("version", kotlinVersion)
|
||||||
outputs.file(versionFile)
|
outputs.file(versionFile)
|
||||||
@@ -56,7 +56,7 @@ val writeCompilerVersion by tasks.creating {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val writePluginVersion by tasks.creating {
|
val writePluginVersion by tasks.registering {
|
||||||
val versionFile = project(":idea").projectDir.resolve("resources/META-INF/plugin.xml")
|
val versionFile = project(":idea").projectDir.resolve("resources/META-INF/plugin.xml")
|
||||||
val pluginVersion = rootProject.findProperty("pluginVersion") as String?
|
val pluginVersion = rootProject.findProperty("pluginVersion") as String?
|
||||||
inputs.property("version", pluginVersion)
|
inputs.property("version", pluginVersion)
|
||||||
@@ -70,6 +70,6 @@ val writePluginVersion by tasks.creating {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val writeVersions by tasks.creating {
|
val writeVersions by tasks.registering {
|
||||||
dependsOn(writeBuildNumber, writeStdlibVersion, writeCompilerVersion)
|
dependsOn(writeBuildNumber, writeStdlibVersion, writeCompilerVersion)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ val versionFilePath = "$rootDir/dependencies/dependencies.properties"
|
|||||||
val ideaVersion = findProperty("versions.intellijSdk").toString()
|
val ideaVersion = findProperty("versions.intellijSdk").toString()
|
||||||
val markdownVersion = findProperty("versions.markdown").toString()
|
val markdownVersion = findProperty("versions.markdown").toString()
|
||||||
|
|
||||||
val writeVersions by tasks.creating {
|
val writeVersions by tasks.registering {
|
||||||
val versionFile = File(versionFilePath)
|
val versionFile = File(versionFilePath)
|
||||||
inputs.property("ideaVersion", ideaVersion)
|
inputs.property("ideaVersion", ideaVersion)
|
||||||
inputs.property("markdownVersion", markdownVersion)
|
inputs.property("markdownVersion", markdownVersion)
|
||||||
|
|||||||
Reference in New Issue
Block a user