All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlin.gradle.targets.js.subtargets.DefaultDistribution.kt Maven / Gradle / Ivy

There is a newer version: 2.0.0-RC3
Show newest version
/*
 * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
 * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
 */

package org.jetbrains.kotlin.gradle.targets.js.subtargets

import org.gradle.api.Project
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.Property
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.distsDirectory
import org.jetbrains.kotlin.gradle.targets.js.dsl.Distribution
import org.jetbrains.kotlin.gradle.targets.js.dsl.Distribution.Companion.DIST
import org.jetbrains.kotlin.gradle.utils.property
import java.io.File

internal fun createDefaultDistribution(
    project: Project,
    targetName: String,
    name: String? = null
) =
    DefaultDistribution(project, project.objects.property(targetName), project.objects.property(name))

internal fun createDefaultDistribution(
    project: Project,
    targetName: String,
    name: Property?
) =
    DefaultDistribution(project, project.objects.property(targetName), project.objects.property().apply {
        if (name != null) {
            value(name)
        }
    })

class DefaultDistribution(
    private val project: Project,
    private val targetName: Property,
    override val distributionName: Property,
) : Distribution {
    @Deprecated("Use `distributionName` instead", ReplaceWith("distributionName"))
    override var name: String?
        get() = distributionName.orNull
        set(value) {
            distributionName.set(value)
        }

    @Deprecated("Use `outputDirectory` instead", ReplaceWith("outputDirectory"))
    override var directory: File
        get() = outputDirectory.get().asFile
        set(value) {
            outputDirectory.set(value)
        }

    override val outputDirectory: DirectoryProperty = project.objects.directoryProperty().convention(
        distributionName.flatMap { project.layout.buildDirectory.dir("$DIST/${targetName.get()}/$it") }.orElse(project.distsDirectory)
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy