[Gradle, JS] Implement reason and other methods beside version
^KT-41054 fixed
This commit is contained in:
+46
-10
@@ -9,6 +9,7 @@ import org.gradle.api.Action
|
|||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.artifacts.*
|
import org.gradle.api.artifacts.*
|
||||||
import org.gradle.api.attributes.AttributeContainer
|
import org.gradle.api.attributes.AttributeContainer
|
||||||
|
import org.gradle.api.internal.artifacts.ModuleVersionSelectorStrictSpec
|
||||||
import org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint
|
import org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint
|
||||||
import org.gradle.api.internal.artifacts.dependencies.DependencyConstraintInternal
|
import org.gradle.api.internal.artifacts.dependencies.DependencyConstraintInternal
|
||||||
import org.gradle.api.internal.attributes.ImmutableAttributes
|
import org.gradle.api.internal.attributes.ImmutableAttributes
|
||||||
@@ -20,6 +21,8 @@ class NpmDependencyConstraint(
|
|||||||
private val version: String
|
private val version: String
|
||||||
) : DependencyConstraintInternal {
|
) : DependencyConstraintInternal {
|
||||||
|
|
||||||
|
private var reason: String? = null
|
||||||
|
|
||||||
private val versionConstraint = DefaultMutableVersionConstraint(version)
|
private val versionConstraint = DefaultMutableVersionConstraint(version)
|
||||||
|
|
||||||
override fun getGroup(): String? = null
|
override fun getGroup(): String? = null
|
||||||
@@ -28,8 +31,9 @@ class NpmDependencyConstraint(
|
|||||||
|
|
||||||
override fun getVersion(): String = versionConstraint.version
|
override fun getVersion(): String = versionConstraint.version
|
||||||
|
|
||||||
override fun matchesStrictly(p0: ModuleVersionIdentifier): Boolean {
|
override fun matchesStrictly(identifier: ModuleVersionIdentifier): Boolean {
|
||||||
TODO("Not yet implemented")
|
return ModuleVersionSelectorStrictSpec(this)
|
||||||
|
.isSatisfiedBy(identifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getModule(): ModuleIdentifier {
|
override fun getModule(): ModuleIdentifier {
|
||||||
@@ -44,20 +48,29 @@ class NpmDependencyConstraint(
|
|||||||
return ImmutableAttributes.EMPTY
|
return ImmutableAttributes.EMPTY
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun attributes(p0: Action<in AttributeContainer>): DependencyConstraint {
|
override fun attributes(configureAction: Action<in AttributeContainer>): DependencyConstraint {
|
||||||
|
warnAboutInternalApiUse()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun version(p0: Action<in MutableVersionConstraint>) {
|
private fun warnAboutInternalApiUse() {
|
||||||
TODO("Not yet implemented")
|
project.logger.warn(
|
||||||
|
"""Cannot set attributes for NPM constraint '${this.path}:${this.version}"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun version(configureAction: Action<in MutableVersionConstraint>) {
|
||||||
|
configureAction.execute(versionConstraint)
|
||||||
|
val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
|
||||||
|
nodeJs.npmResolutionManager.putNpmResolution(path, version)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getReason(): String? {
|
override fun getReason(): String? {
|
||||||
return null
|
return reason
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun because(p0: String?) {
|
override fun because(reason: String?) {
|
||||||
TODO("Not yet implemented")
|
this.reason = reason
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getVersionConstraint(): VersionConstraint {
|
override fun getVersionConstraint(): VersionConstraint {
|
||||||
@@ -66,11 +79,34 @@ class NpmDependencyConstraint(
|
|||||||
return versionConstraint
|
return versionConstraint
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setForce(p0: Boolean) {
|
override fun setForce(force: Boolean) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isForce(): Boolean {
|
override fun isForce(): Boolean {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (javaClass != other?.javaClass) return false
|
||||||
|
|
||||||
|
other as NpmDependencyConstraint
|
||||||
|
|
||||||
|
if (project != other.project) return false
|
||||||
|
if (path != other.path) return false
|
||||||
|
if (versionConstraint != other.versionConstraint) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = project.hashCode()
|
||||||
|
result = 31 * result + path.hashCode()
|
||||||
|
result = 31 * result + versionConstraint.hashCode()
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return "NpmDependencyConstraint(path='$path', versionConstraint=$versionConstraint)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user