[Gradle, JS] KT-37207 Leave constructor NpmDependency once
This commit is contained in:
+17
-6
@@ -22,20 +22,29 @@ interface KotlinDependencyHandler {
|
|||||||
fun implementation(dependencyNotation: Any): Dependency?
|
fun implementation(dependencyNotation: Any): Dependency?
|
||||||
fun implementation(dependencyNotation: String, configure: ExternalModuleDependency.() -> Unit): ExternalModuleDependency
|
fun implementation(dependencyNotation: String, configure: ExternalModuleDependency.() -> Unit): ExternalModuleDependency
|
||||||
fun <T : Dependency> implementation(dependency: T, configure: T.() -> Unit): T
|
fun <T : Dependency> implementation(dependency: T, configure: T.() -> Unit): T
|
||||||
fun implementation(dependencyNotation: String, configure: Closure<*>) = implementation(dependencyNotation) { ConfigureUtil.configure(configure, this) }
|
fun implementation(dependencyNotation: String, configure: Closure<*>) =
|
||||||
fun <T : Dependency> implementation(dependency: T, configure: Closure<*>) = implementation(dependency) { ConfigureUtil.configure(configure, this) }
|
implementation(dependencyNotation) { ConfigureUtil.configure(configure, this) }
|
||||||
|
|
||||||
|
fun <T : Dependency> implementation(dependency: T, configure: Closure<*>) =
|
||||||
|
implementation(dependency) { ConfigureUtil.configure(configure, this) }
|
||||||
|
|
||||||
fun compileOnly(dependencyNotation: Any): Dependency?
|
fun compileOnly(dependencyNotation: Any): Dependency?
|
||||||
fun compileOnly(dependencyNotation: String, configure: ExternalModuleDependency.() -> Unit): ExternalModuleDependency
|
fun compileOnly(dependencyNotation: String, configure: ExternalModuleDependency.() -> Unit): ExternalModuleDependency
|
||||||
fun <T : Dependency> compileOnly(dependency: T, configure: T.() -> Unit): T
|
fun <T : Dependency> compileOnly(dependency: T, configure: T.() -> Unit): T
|
||||||
fun compileOnly(dependencyNotation: String, configure: Closure<*>) = compileOnly(dependencyNotation) { ConfigureUtil.configure(configure, this) }
|
fun compileOnly(dependencyNotation: String, configure: Closure<*>) =
|
||||||
fun <T : Dependency> compileOnly(dependency: T, configure: Closure<*>) = compileOnly(dependency) { ConfigureUtil.configure(configure, this) }
|
compileOnly(dependencyNotation) { ConfigureUtil.configure(configure, this) }
|
||||||
|
|
||||||
|
fun <T : Dependency> compileOnly(dependency: T, configure: Closure<*>) =
|
||||||
|
compileOnly(dependency) { ConfigureUtil.configure(configure, this) }
|
||||||
|
|
||||||
fun runtimeOnly(dependencyNotation: Any): Dependency?
|
fun runtimeOnly(dependencyNotation: Any): Dependency?
|
||||||
fun runtimeOnly(dependencyNotation: String, configure: ExternalModuleDependency.() -> Unit): ExternalModuleDependency
|
fun runtimeOnly(dependencyNotation: String, configure: ExternalModuleDependency.() -> Unit): ExternalModuleDependency
|
||||||
fun <T : Dependency> runtimeOnly(dependency: T, configure: T.() -> Unit): T
|
fun <T : Dependency> runtimeOnly(dependency: T, configure: T.() -> Unit): T
|
||||||
fun runtimeOnly(dependencyNotation: String, configure: Closure<*>) = runtimeOnly(dependencyNotation) { ConfigureUtil.configure(configure, this) }
|
fun runtimeOnly(dependencyNotation: String, configure: Closure<*>) =
|
||||||
fun <T : Dependency> runtimeOnly(dependency: T, configure: Closure<*>) = runtimeOnly(dependency) { ConfigureUtil.configure(configure, this) }
|
runtimeOnly(dependencyNotation) { ConfigureUtil.configure(configure, this) }
|
||||||
|
|
||||||
|
fun <T : Dependency> runtimeOnly(dependency: T, configure: Closure<*>) =
|
||||||
|
runtimeOnly(dependency) { ConfigureUtil.configure(configure, this) }
|
||||||
|
|
||||||
fun kotlin(simpleModuleName: String): ExternalModuleDependency = kotlin(simpleModuleName, null)
|
fun kotlin(simpleModuleName: String): ExternalModuleDependency = kotlin(simpleModuleName, null)
|
||||||
fun kotlin(simpleModuleName: String, version: String?): ExternalModuleDependency
|
fun kotlin(simpleModuleName: String, version: String?): ExternalModuleDependency
|
||||||
@@ -49,6 +58,8 @@ interface KotlinDependencyHandler {
|
|||||||
|
|
||||||
fun npm(name: String, directory: File): Dependency
|
fun npm(name: String, directory: File): Dependency
|
||||||
|
|
||||||
|
fun npm(directory: File): Dependency
|
||||||
|
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
message = "Use npm(name, version) instead. Name like in package.json"
|
message = "Use npm(name, version) instead. Name like in package.json"
|
||||||
)
|
)
|
||||||
|
|||||||
+9
-2
@@ -7,6 +7,8 @@ import org.gradle.api.artifacts.ProjectDependency
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.HasKotlinDependencies
|
import org.jetbrains.kotlin.gradle.plugin.HasKotlinDependencies
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
|
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependency
|
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependency
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.npm.fileVersion
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.npm.moduleName
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class DefaultKotlinDependencyHandler(
|
class DefaultKotlinDependencyHandler(
|
||||||
@@ -88,9 +90,14 @@ class DefaultKotlinDependencyHandler(
|
|||||||
)
|
)
|
||||||
|
|
||||||
override fun npm(name: String, directory: File): NpmDependency =
|
override fun npm(name: String, directory: File): NpmDependency =
|
||||||
NpmDependency(
|
npm(
|
||||||
project = project,
|
|
||||||
name = name,
|
name = name,
|
||||||
|
version = fileVersion(directory)
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun npm(directory: File): NpmDependency =
|
||||||
|
npm(
|
||||||
|
name = moduleName(directory),
|
||||||
directory = directory
|
directory = directory
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+4
-20
@@ -30,25 +30,6 @@ data class NpmDependency(
|
|||||||
ResolvableDependency,
|
ResolvableDependency,
|
||||||
FileCollectionDependency {
|
FileCollectionDependency {
|
||||||
|
|
||||||
constructor(
|
|
||||||
project: Project,
|
|
||||||
name: String,
|
|
||||||
directory: File
|
|
||||||
) : this(
|
|
||||||
project,
|
|
||||||
name,
|
|
||||||
"$FILE_VERSION_PREFIX${directory.canonicalPath}"
|
|
||||||
)
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
project: Project,
|
|
||||||
directory: File
|
|
||||||
) : this(
|
|
||||||
project,
|
|
||||||
moduleName(directory),
|
|
||||||
directory
|
|
||||||
)
|
|
||||||
|
|
||||||
enum class Scope {
|
enum class Scope {
|
||||||
NORMAL,
|
NORMAL,
|
||||||
DEV,
|
DEV,
|
||||||
@@ -146,7 +127,10 @@ data class NpmDependency(
|
|||||||
override fun getReason(): String? = reason
|
override fun getReason(): String? = reason
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun moduleName(directory: File): String {
|
internal fun fileVersion(directory: File): String =
|
||||||
|
"$FILE_VERSION_PREFIX${directory.canonicalPath}"
|
||||||
|
|
||||||
|
internal fun moduleName(directory: File): String {
|
||||||
val packageJson = directory.resolve(PACKAGE_JSON)
|
val packageJson = directory.resolve(PACKAGE_JSON)
|
||||||
|
|
||||||
check(!packageJson.isFile) {
|
check(!packageJson.isFile) {
|
||||||
|
|||||||
+2
-3
@@ -29,10 +29,9 @@ fun Project.addNpmDependencyExtension() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
override operator fun invoke(name: String, directory: File): NpmDependency =
|
override operator fun invoke(name: String, directory: File): NpmDependency =
|
||||||
NpmDependency(
|
invoke(
|
||||||
project = this@addNpmDependencyExtension,
|
|
||||||
name = name,
|
name = name,
|
||||||
directory = directory
|
version = fileVersion(directory)
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun call(vararg args: Any?): NpmDependency {
|
override fun call(vararg args: Any?): NpmDependency {
|
||||||
|
|||||||
Reference in New Issue
Block a user