[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: String, configure: ExternalModuleDependency.() -> Unit): ExternalModuleDependency
|
||||
fun <T : Dependency> implementation(dependency: T, configure: T.() -> Unit): T
|
||||
fun implementation(dependencyNotation: String, configure: Closure<*>) = implementation(dependencyNotation) { ConfigureUtil.configure(configure, this) }
|
||||
fun <T : Dependency> implementation(dependency: T, configure: Closure<*>) = implementation(dependency) { ConfigureUtil.configure(configure, this) }
|
||||
fun implementation(dependencyNotation: String, configure: Closure<*>) =
|
||||
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: String, configure: ExternalModuleDependency.() -> Unit): ExternalModuleDependency
|
||||
fun <T : Dependency> compileOnly(dependency: T, configure: T.() -> Unit): T
|
||||
fun compileOnly(dependencyNotation: String, configure: Closure<*>) = compileOnly(dependencyNotation) { ConfigureUtil.configure(configure, this) }
|
||||
fun <T : Dependency> compileOnly(dependency: T, configure: Closure<*>) = compileOnly(dependency) { ConfigureUtil.configure(configure, this) }
|
||||
fun compileOnly(dependencyNotation: String, configure: Closure<*>) =
|
||||
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: String, configure: ExternalModuleDependency.() -> Unit): ExternalModuleDependency
|
||||
fun <T : Dependency> runtimeOnly(dependency: T, configure: T.() -> Unit): T
|
||||
fun runtimeOnly(dependencyNotation: String, configure: Closure<*>) = runtimeOnly(dependencyNotation) { ConfigureUtil.configure(configure, this) }
|
||||
fun <T : Dependency> runtimeOnly(dependency: T, configure: Closure<*>) = runtimeOnly(dependency) { ConfigureUtil.configure(configure, this) }
|
||||
fun runtimeOnly(dependencyNotation: String, configure: Closure<*>) =
|
||||
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, version: String?): ExternalModuleDependency
|
||||
@@ -49,6 +58,8 @@ interface KotlinDependencyHandler {
|
||||
|
||||
fun npm(name: String, directory: File): Dependency
|
||||
|
||||
fun npm(directory: File): Dependency
|
||||
|
||||
@Deprecated(
|
||||
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.KotlinDependencyHandler
|
||||
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
|
||||
|
||||
class DefaultKotlinDependencyHandler(
|
||||
@@ -88,9 +90,14 @@ class DefaultKotlinDependencyHandler(
|
||||
)
|
||||
|
||||
override fun npm(name: String, directory: File): NpmDependency =
|
||||
NpmDependency(
|
||||
project = project,
|
||||
npm(
|
||||
name = name,
|
||||
version = fileVersion(directory)
|
||||
)
|
||||
|
||||
override fun npm(directory: File): NpmDependency =
|
||||
npm(
|
||||
name = moduleName(directory),
|
||||
directory = directory
|
||||
)
|
||||
|
||||
|
||||
+4
-20
@@ -30,25 +30,6 @@ data class NpmDependency(
|
||||
ResolvableDependency,
|
||||
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 {
|
||||
NORMAL,
|
||||
DEV,
|
||||
@@ -146,7 +127,10 @@ data class NpmDependency(
|
||||
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)
|
||||
|
||||
check(!packageJson.isFile) {
|
||||
|
||||
+2
-3
@@ -29,10 +29,9 @@ fun Project.addNpmDependencyExtension() {
|
||||
)
|
||||
|
||||
override operator fun invoke(name: String, directory: File): NpmDependency =
|
||||
NpmDependency(
|
||||
project = this@addNpmDependencyExtension,
|
||||
invoke(
|
||||
name = name,
|
||||
directory = directory
|
||||
version = fileVersion(directory)
|
||||
)
|
||||
|
||||
override fun call(vararg args: Any?): NpmDependency {
|
||||
|
||||
Reference in New Issue
Block a user