Consolidate resolving in the new lib, deprecate it in script-util

also deprecate Import and CompileOptions annotations, because they
do not seem generic enough. Create specific copie in the main-kts
instead.
This commit is contained in:
Ilya Chernikov
2020-05-14 21:05:32 +02:00
parent 7d426226f9
commit c112d37ac1
13 changed files with 115 additions and 86 deletions
@@ -16,33 +16,25 @@
package org.jetbrains.kotlin.script.util
// in case of flat or direct resolvers the value should be a direct path or file name of a jar respectively
// in case of maven resolver the maven coordinates string is accepted (resolved with com.jcabi.aether library)
@Deprecated("Use annotations an processing code from the kotlin-scripting-dependencies library")
@Target(AnnotationTarget.FILE)
@Repeatable
@Retention(AnnotationRetention.SOURCE)
annotation class DependsOn(val value: String = "", val groupId: String = "", val artifactId: String = "", val version: String = "")
// only flat directory repositories are supported now, so value should be a path to a directory with jars
// TODO: support other types of repos
@Deprecated("Use annotations an processing code from the kotlin-scripting-dependencies library")
@Target(AnnotationTarget.FILE)
@Repeatable
@Retention(AnnotationRetention.SOURCE)
annotation class Repository(val value: String = "", val id: String = "", val url: String = "")
/**
* Import other script(s)
*/
@Deprecated("Use your own annotations, this will be removed soon")
@Target(AnnotationTarget.FILE)
@Repeatable
@Retention(AnnotationRetention.SOURCE)
annotation class Import(vararg val paths: String)
/**
* Compiler options that will be applied on script compilation
*
* @see [kotlin.script.experimental.api.compilerOptions]
*/
@Deprecated("Use your own annotations, this will be removed soon")
@Target(AnnotationTarget.FILE)
@Repeatable
@Retention(AnnotationRetention.SOURCE)
@@ -30,6 +30,7 @@ import kotlin.script.dependencies.ScriptDependenciesResolver
import kotlin.script.dependencies.asFuture
import kotlin.script.templates.AcceptedAnnotations
@Deprecated("Use new resolving classes from kotlin-scripting-dependencies and kotlin-scripting-dependencies-maven")
open class KotlinAnnotatedScriptDependenciesResolver(val baseClassPath: List<File>, resolvers: Iterable<Resolver>)
: ScriptDependenciesResolver
{
@@ -75,9 +76,11 @@ 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()))
@@ -22,6 +22,7 @@ import java.io.File
import java.net.MalformedURLException
import java.net.URL
@Deprecated("Use new resolving classes from kotlin-scripting-dependencies")
class DirectResolver : GenericRepositoryWithBridge {
override fun tryResolve(artifactCoordinates: GenericArtifactCoordinates): Iterable<File>? =
artifactCoordinates.string.takeUnless(String::isBlank)
@@ -30,6 +31,7 @@ class DirectResolver : GenericRepositoryWithBridge {
override fun tryAddRepository(repositoryCoordinates: GenericRepositoryCoordinates): Boolean = false
}
@Deprecated("Use new resolving classes from kotlin-scripting-dependencies")
class FlatLibDirectoryResolver(vararg paths: File) : GenericRepositoryWithBridge {
private val localRepos = arrayListOf<File>()
@@ -13,10 +13,12 @@ import org.jetbrains.kotlin.script.util.resolvers.toRepositoryUrlOrNull
import java.io.File
import java.net.URL
@Deprecated("Use new resolving classes from kotlin-scripting-dependencies")
interface GenericArtifactCoordinates {
val string: String
}
@Deprecated("Use new resolving classes from kotlin-scripting-dependencies")
interface GenericRepositoryCoordinates {
val string: String
val name: String? get() = null
@@ -24,6 +26,7 @@ interface GenericRepositoryCoordinates {
val file: File? get() = (url?.takeIf { it.protocol == "file" }?.path ?: string).toRepositoryFileOrNull()
}
@Deprecated("Use new resolving classes from kotlin-scripting-dependencies")
interface GenericResolver {
fun tryResolve(artifactCoordinates: GenericArtifactCoordinates): Iterable<File>?
fun tryAddRepository(repositoryCoordinates: GenericRepositoryCoordinates): Boolean
@@ -34,10 +37,13 @@ interface GenericResolver {
tryAddRepository(BasicRepositoryCoordinates(repositoryCoordinates, id))
}
@Deprecated("Use new resolving classes from kotlin-scripting-dependencies")
open class BasicArtifactCoordinates(override val string: String) : GenericArtifactCoordinates
@Deprecated("Use new resolving classes from kotlin-scripting-dependencies")
open class BasicRepositoryCoordinates(override val string: String, override val name: String? = null) : GenericRepositoryCoordinates
@Deprecated("Use new resolving classes from kotlin-scripting-dependencies")
interface GenericRepositoryWithBridge : GenericResolver, Resolver {
override fun tryResolve(dependsOn: DependsOn): Iterable<File>? =
tryResolve(
@@ -55,6 +61,7 @@ interface GenericRepositoryWithBridge : GenericResolver, Resolver {
}
}
@Deprecated("Use new resolving classes from kotlin-scripting-dependencies")
open class MavenArtifactCoordinates(
val value: String?,
val groupId: String?,
@@ -31,8 +31,10 @@ 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
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.script.util.DependsOn
import org.jetbrains.kotlin.script.util.Repository
import java.io.File
@Deprecated("Use new resolving classes from kotlin-scripting-dependencies")
interface Resolver {
fun tryResolve(dependsOn: DependsOn): Iterable<File>?
fun tryAddRepo(annotation: Repository): Boolean