Remove deprecated dependencies resolvers from kotlin-script-util
along with outdated maven dependencies
This commit is contained in:
committed by
Space Team
parent
56b57f1908
commit
5db9c2990a
@@ -15,17 +15,11 @@ dependencies {
|
||||
compileOnly(project(":daemon-common"))
|
||||
compileOnly(project(":kotlin-scripting-compiler"))
|
||||
api(project(":kotlin-daemon-client"))
|
||||
compileOnly("org.jetbrains.kotlin:jcabi-aether:1.0-dev-3")
|
||||
compileOnly("org.sonatype.aether:aether-api:1.13.1")
|
||||
compileOnly("org.apache.maven:maven-core:3.0.3")
|
||||
testCompileOnly(project(":compiler:cli"))
|
||||
testApi(project(":kotlin-test:kotlin-test-junit"))
|
||||
testApi(commonDependency("junit:junit"))
|
||||
testApi(project(":kotlin-scripting-compiler"))
|
||||
testRuntimeOnly(project(":kotlin-compiler"))
|
||||
testImplementation("org.jetbrains.kotlin:jcabi-aether:1.0-dev-3")
|
||||
testImplementation("org.sonatype.aether:aether-api:1.13.1")
|
||||
testImplementation("org.apache.maven:maven-core:3.0.3")
|
||||
testApi(intellijCore())
|
||||
}
|
||||
|
||||
|
||||
-6
@@ -20,7 +20,6 @@ package org.jetbrains.kotlin.script.util
|
||||
|
||||
import org.jetbrains.kotlin.script.util.resolvers.DirectResolver
|
||||
import org.jetbrains.kotlin.script.util.resolvers.FlatLibDirectoryResolver
|
||||
import org.jetbrains.kotlin.script.util.resolvers.MavenResolver
|
||||
import org.jetbrains.kotlin.script.util.resolvers.Resolver
|
||||
import org.jetbrains.kotlin.scripting.resolve.InvalidScriptResolverAnnotation
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
@@ -81,8 +80,3 @@ open class KotlinAnnotatedScriptDependenciesResolver(val baseClassPath: List<Fil
|
||||
@Deprecated("Use FileSystemDependenciesResolver from kotlin-scripting-dependencies instead")
|
||||
class LocalFilesResolver :
|
||||
KotlinAnnotatedScriptDependenciesResolver(emptyList(), arrayListOf(DirectResolver()))
|
||||
|
||||
@Deprecated("Use CompoundDependenciesResolver and MavenDependenciesResolver from kotlin-scripting-dependencies and kotlin-scripting-dependencies-maven")
|
||||
class FilesAndMavenResolver :
|
||||
KotlinAnnotatedScriptDependenciesResolver(emptyList(), arrayListOf(DirectResolver(), MavenResolver()))
|
||||
|
||||
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:DependsOn("org.funktionale:funktionale:0.9.6")
|
||||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package org.jetbrains.kotlin.script.util.resolvers
|
||||
|
||||
import com.jcabi.aether.Aether
|
||||
import org.jetbrains.kotlin.script.util.DependsOn
|
||||
import org.jetbrains.kotlin.script.util.resolvers.experimental.GenericArtifactCoordinates
|
||||
import org.jetbrains.kotlin.script.util.resolvers.experimental.GenericRepositoryCoordinates
|
||||
import org.jetbrains.kotlin.script.util.resolvers.experimental.GenericRepositoryWithBridge
|
||||
import org.jetbrains.kotlin.script.util.resolvers.experimental.MavenArtifactCoordinates
|
||||
import org.sonatype.aether.repository.RemoteRepository
|
||||
import org.sonatype.aether.resolution.DependencyResolutionException
|
||||
import org.sonatype.aether.util.artifact.DefaultArtifact
|
||||
import org.sonatype.aether.util.artifact.JavaScopes
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
@Deprecated("Use new resolving classes from kotlin-scripting-dependencies and kotlin-scripting-dependencies-maven")
|
||||
val mavenCentral = RemoteRepository("maven-central", "default", "https://repo.maven.apache.org/maven2/")
|
||||
|
||||
@Deprecated("Use kotlin.script.experimental.dependencies.maven.MavenDependenciesResolver from kotlin-scripting-dependencies-maven")
|
||||
class MavenResolver(val reportError: ((String) -> Unit)? = null): GenericRepositoryWithBridge {
|
||||
|
||||
// TODO: make robust
|
||||
val localRepo = File(File(System.getProperty("user.home")!!, ".m2"), "repository")
|
||||
|
||||
val repos: ArrayList<RemoteRepository> = arrayListOf()
|
||||
|
||||
private fun currentRepos() = if (repos.isEmpty()) arrayListOf(mavenCentral) else repos
|
||||
|
||||
private fun String?.isValidParam() = this?.isNotBlank() ?: false
|
||||
|
||||
override fun tryResolve(artifactCoordinates: GenericArtifactCoordinates): Iterable<File>? {
|
||||
|
||||
fun error(msg: String) {
|
||||
reportError?.invoke(msg) ?: throw RuntimeException(msg)
|
||||
}
|
||||
|
||||
fun String?.orNullIfBlank(): String? = this?.takeUnless(String::isBlank)
|
||||
|
||||
val artifactId: DefaultArtifact = with(artifactCoordinates) {
|
||||
if (this is MavenArtifactCoordinates && (groupId.isValidParam() || artifactId.isValidParam())) {
|
||||
DefaultArtifact(
|
||||
groupId.orNullIfBlank(),
|
||||
artifactId.orNullIfBlank(),
|
||||
null,
|
||||
version.orNullIfBlank()
|
||||
)
|
||||
} else {
|
||||
val coordinatesString = string
|
||||
if (coordinatesString.isValidParam() && coordinatesString.count { it == ':' } == 2) {
|
||||
DefaultArtifact(coordinatesString)
|
||||
} else {
|
||||
error("Unknown set of arguments to maven resolver: $coordinatesString")
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
val deps = Aether(currentRepos(), localRepo).resolve( artifactId, JavaScopes.RUNTIME)
|
||||
if (deps != null)
|
||||
return deps.map { it.file }
|
||||
else {
|
||||
error("resolving ${artifactId.artifactId} failed: no results")
|
||||
}
|
||||
} catch (e: DependencyResolutionException) {
|
||||
reportError?.invoke("resolving ${artifactId.artifactId} failed: $e") ?: throw e
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun tryAddRepository(repositoryCoordinates: GenericRepositoryCoordinates): Boolean {
|
||||
val url = repositoryCoordinates.url
|
||||
if (url != null) {
|
||||
repos.add(
|
||||
RemoteRepository(
|
||||
if (repositoryCoordinates.name.isValidParam()) repositoryCoordinates.name else url.host,
|
||||
"default",
|
||||
url.toString()
|
||||
)
|
||||
)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
-7
@@ -18,18 +18,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.script.util.templates
|
||||
|
||||
import org.jetbrains.kotlin.script.util.FilesAndMavenResolver
|
||||
import org.jetbrains.kotlin.script.util.LocalFilesResolver
|
||||
import kotlin.script.templates.ScriptTemplateDefinition
|
||||
|
||||
@ScriptTemplateDefinition(resolver = LocalFilesResolver::class, scriptFilePattern = ".*\\.kts")
|
||||
abstract class StandardArgsScriptTemplateWithLocalResolving(val args: Array<String>)
|
||||
|
||||
@ScriptTemplateDefinition(resolver = FilesAndMavenResolver::class, scriptFilePattern = ".*\\.kts")
|
||||
abstract class StandardArgsScriptTemplateWithMavenResolving(val args: Array<String>)
|
||||
|
||||
@ScriptTemplateDefinition(resolver = LocalFilesResolver::class, scriptFilePattern = ".*\\.kts")
|
||||
abstract class BindingsScriptTemplateWithLocalResolving(val bindings: Map<String, Any?>)
|
||||
|
||||
@ScriptTemplateDefinition(resolver = FilesAndMavenResolver::class, scriptFilePattern = ".*\\.kts")
|
||||
abstract class BindingsScriptTemplateWithMavenResolving(val bindings: Map<String, Any?>)
|
||||
|
||||
Reference in New Issue
Block a user