diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cba7ae8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,21 @@ +name: CI +on: + pull_request: + push: +jobs: + build: + runs-on: ubuntu-latest + env: + JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }} + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup JDK + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 17 + - name: Build and Test + run: sbt compile scripted + - name: Publish + run: sbt publish \ No newline at end of file diff --git a/.gitignore b/.gitignore index 58d1ff7..36eb4ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ target/ -.idea \ No newline at end of file +.idea +.bsp diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2d2c052..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: android -os: - - linux -jdk: - - oraclejdk8 -cache: - directories: - - $HOME/.m2/repository - - $HOME/.sbt - - $HOME/.ivy2 -android: - components: - - build-tools-23.0.1 - - platform-tools - - tools - - extra -script: - - curl -o sbt-launcher.sh https://raw.githubusercontent.com/paulp/sbt-extras/master/sbt - - chmod a+x ./sbt-launcher.sh - - ./sbt-launcher.sh compile scripted diff --git a/README.md b/README.md index 8ab50e9..9d8d87c 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,20 @@ -# kotlin-plugin +# sbt-kotlin-plugin -[![Build Status](https://travis-ci.org/pfn/kotlin-plugin.svg?branch=master)](https://travis-ci.org/pfn/kotlin-plugin) +[![Build Status](https://travis-ci.org/pfn/sbt-kotlin-plugin.svg?branch=master)](https://travis-ci.org/pfn/sbt-kotlin-plugin) Build kotlin code using sbt Current version 2.0.0 +## Install +``` +addSbtPlugin("community.flock.sbt" % "sbt-kotlin-plugin" % "3.0.1") +``` + ## Usage -* for sbt 1.0.0+ `addSbtPlugin("com.hanhuy.sbt" % "kotlin-plugin" % "2.0.0")` -* for sbt 0.13.x `addSbtPlugin("com.hanhuy.sbt" % "kotlin-plugin" % "1.0.9")` +* for sbt 1.0.0+ `addSbtPlugin("flock.community.sbt" % "sbt-kotlin-plugin" % "2.0.0")` +* for sbt 0.13.x `addSbtPlugin("flock.community.sbt" % "sbt-kotlin-plugin" % "1.0.9")` * Kotlin code will build automatically from `src/XXX/kotlin` * If necessary, add `kotlinLib("stdlib")`, it is not included by default. * Loading standard kotlin libraries and plugins: use `kotlinLib(NAME)` as diff --git a/build.sbt b/build.sbt index e5ba767..dc9de48 100644 --- a/build.sbt +++ b/build.sbt @@ -1,15 +1,10 @@ -name := "kotlin-plugin" +name := "sbt-kotlin-plugin" -organization := "com.hanhuy.sbt" +organization := "community.flock.sbt" -version := "2.0.1-SNAPSHOT" +version := "3.0.1" scalacOptions ++= Seq("-deprecation","-Xlint","-feature") -/* -libraryDependencies ++= Seq( - "com.hanhuy.sbt" %% "bintray-update-checker" % "0.2" -) -*/ libraryDependencies ++= Seq( "io.argonaut" %% "argonaut" % "6.2", @@ -24,15 +19,6 @@ enablePlugins(BuildInfoPlugin, SbtPlugin) buildInfoPackage := "kotlin" -// bintray -bintrayRepository := "sbt-plugins" - -publishMavenStyle := false - -licenses += ("MIT", url("http://opensource.org/licenses/MIT")) - -bintrayOrganization := None - // scripted scriptedLaunchOpts ++= Seq( "-Xmx1024m", diff --git a/project/build.properties b/project/build.properties index 6adcdc7..46e43a9 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.3.3 +sbt.version=1.8.2 diff --git a/project/plugins.sbt b/project/plugins.sbt index 966fde3..d5d7bbc 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value -addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4") -addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") \ No newline at end of file +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") +addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") \ No newline at end of file diff --git a/publish.sbt b/publish.sbt new file mode 100644 index 0000000..a0563b4 --- /dev/null +++ b/publish.sbt @@ -0,0 +1,34 @@ +ThisBuild / organization := "community.flock.sbt" +ThisBuild / organizationName := "sbt-kotlin-plugin" +ThisBuild / organizationHomepage := Some(url("https://flock.community")) + +ThisBuild / scmInfo := Some( + ScmInfo( + url("https://github.com/flock-community/kotlin-plugin"), + "scm:git@github.com:flock-community/kotlin-plugin.git" + ) +) +ThisBuild / developers := List( + Developer( + id = "Veelenturf", + name = "Willem Veelenturf", + email = "willem.veelenturf@flock.community", + url = url("https://flock.community") + ) +) + +ThisBuild / description := "Sbt Kotlin plugin" +ThisBuild / licenses := List( + "MIT" -> url("http://opensource.org/licenses/MIT") +) + +ThisBuild / homepage := Some(url("https://github.com/flock-community/kotlin-plugin")) + +// Remove all additional repository other than Maven Central from POM +ThisBuild / pomIncludeRepository := { _ => false } +ThisBuild / publishTo := { + val nexus = "https://s01.oss.sonatype.org/" + if (isSnapshot.value) Some("snapshots" at nexus + "content/repositories/snapshots") + else Some("releases" at nexus + "service/local/staging/deploy/maven2") +} +ThisBuild / publishMavenStyle := true \ No newline at end of file diff --git a/src/main/scala/Keys.scala b/src/main/scala/Keys.scala index 2110a93..51cfdc8 100644 --- a/src/main/scala/Keys.scala +++ b/src/main/scala/Keys.scala @@ -31,7 +31,7 @@ object Keys { "org.jetbrains.kotlin" % ("kotlin-" + name) % kotlinVersion.value % "compile-internal" def kotlinClasspath(config: Configuration, classpathKey: Def.Initialize[sbt.Keys.Classpath]): Setting[_] = - kotlincOptions in config ++= { + config / kotlincOptions ++= { "-cp" :: classpathKey.value.map(_.data.getAbsolutePath).mkString( java.io.File.pathSeparator) :: Nil diff --git a/src/main/scala/KotlinCompile.scala b/src/main/scala/KotlinCompile.scala index 9b506cc..4195531 100644 --- a/src/main/scala/KotlinCompile.scala +++ b/src/main/scala/KotlinCompile.scala @@ -7,9 +7,10 @@ import java.util.jar.JarEntry import sbt.Keys.{Classpath, TaskStreams} import sbt._ import sbt.io._ -import sbt.internal.inc.classpath.ClasspathUtilities +import sbt.internal.inc.classpath.ClasspathUtil import collection.JavaConverters._ +import scala.math.Ordered.orderingToOrdered import scala.util.Try /** @@ -27,6 +28,7 @@ object KotlinCompile { def compile(options: Seq[String], jvmTarget: String, + kotlinVersion: String, sourceDirs: Seq[File], kotlinPluginOptions: Seq[String], classpath: Classpath, @@ -35,7 +37,7 @@ object KotlinCompile { import language.reflectiveCalls val stub = KotlinStub(s, kotlinMemo(compilerClasspath)) val args = stub.compilerArgs - stub.parse(args.instance, options.toList) + stub.parse(kotlinVersion, args.instance, options.toList) val kotlinFiles = "*.kt" || "*.kts" val javaFiles = "*.java" @@ -75,7 +77,7 @@ object KotlinCompile { object KotlinReflection { def fromClasspath(cp: Classpath): KotlinReflection = { - val cl = ClasspathUtilities.toLoader(cp.map(_.data)) + val cl = ClasspathUtil.toLoader(cp.map(_.data)) val compilerClass = cl.loadClass("org.jetbrains.kotlin.cli.jvm.K2JVMCompiler") val servicesClass = cl.loadClass("org.jetbrains.kotlin.config.Services") val messageCollectorClass = cl.loadClass("org.jetbrains.kotlin.cli.common.messages.MessageCollector") @@ -147,16 +149,32 @@ case class KotlinStub(s: TaskStreams, kref: KotlinReflection) { Proxy.newProxyInstance(cl, Array(messageCollectorClass), messageCollectorInvocationHandler) } - def parse(args: Object, options: List[String]): Unit = { + def parse(kotlinVersion: String, args: Object, options: List[String]): Unit = { // TODO FIXME, this is much worse than it used to be, the parsing api has been // deeply in flux since 1.1.x val parser = kref.cl.loadClass( - "org.jetbrains.kotlin.cli.common.arguments.ParseCommandLineArgumentsKt") + "org.jetbrains.kotlin.cli.common.arguments.ParseCommandLineArgumentsKt" + ) val commonToolArguments = cl.loadClass( - "org.jetbrains.kotlin.cli.common.arguments.CommonToolArguments") - val parserMethod = parser.getMethod("parseCommandLineArguments", classOf[java.util.List[java.lang.String]], commonToolArguments) + "org.jetbrains.kotlin.cli.common.arguments.CommonToolArguments" + ) import collection.JavaConverters._ - parserMethod.invoke(null, options.asJava, args) + if (KotlinVersion(kotlinVersion) < KotlinVersion("1.7.0")) { + val parserMethod = parser.getMethod( + "parseCommandLineArguments", + classOf[java.util.List[java.lang.String]], + commonToolArguments + ) + parserMethod.invoke(null, options.asJava, args) + } else { + val parserMethod = parser.getMethod( + "parseCommandLineArguments", + classOf[java.util.List[java.lang.String]], + commonToolArguments, + classOf[Boolean] + ) + parserMethod.invoke(null, options.asJava, args, false: java.lang.Boolean) + } } def compilerArgs = { diff --git a/src/main/scala/KotlinPlugin.scala b/src/main/scala/KotlinPlugin.scala index 151b634..7254fba 100644 --- a/src/main/scala/KotlinPlugin.scala +++ b/src/main/scala/KotlinPlugin.scala @@ -15,7 +15,7 @@ object KotlinPlugin extends AutoPlugin { override def projectConfigurations = KotlinInternal :: Nil override def globalSettings = (onLoad := onLoad.value andThen { s => - Project.runTask(updateCheck in Keys.Kotlin, s).fold(s)(_._1) + Project.runTask(Keys.Kotlin / updateCheck, s).fold(s)(_._1) }) :: Nil private def kotlinScriptCompilerDeps(kotlinVer: String) = { @@ -37,10 +37,10 @@ object KotlinPlugin extends AutoPlugin { libraryDependencies ++= Seq( "org.jetbrains.kotlin" % "kotlin-compiler-embeddable" % kotlinVersion.value % KotlinInternal.name ) ++ kotlinScriptCompilerDeps(kotlinVersion.value), - managedClasspath in KotlinInternal := Classpaths.managedJars(KotlinInternal, classpathTypes.value, update.value), - updateCheck in Kotlin := { + KotlinInternal / managedClasspath := Classpaths.managedJars(KotlinInternal, classpathTypes.value, update.value), + Kotlin / updateCheck := { val log = streams.value.log - UpdateChecker("pfn", "sbt-plugins", "kotlin-plugin") { + UpdateChecker("pfn", "sbt-plugins", "sbt-kotlin-plugin") { case Left(t) => log.debug("Failed to load version info: " + t) case Right((versions, current)) => @@ -50,21 +50,21 @@ object KotlinPlugin extends AutoPlugin { if (versions(BuildInfo.version)) { if (BuildInfo.version != current) { log.warn( - s"UPDATE: A newer kotlin-plugin is available:" + + s"UPDATE: A newer sbt-kotlin-plugin is available:" + s" $current, currently running: ${BuildInfo.version}") } } } }, kotlinVersion := "1.3.50", - kotlincJvmTarget := "1.6", + kotlincJvmTarget := "1.8", kotlincOptions := Nil, kotlincPluginOptions := Nil, watchSources ++= { import language.postfixOps val kotlinSources = "*.kt" || "*.kts" - (sourceDirectories in Compile).value.flatMap(_ ** kotlinSources get) ++ - (sourceDirectories in Test).value.flatMap(_ ** kotlinSources get) + (Compile / sourceDirectories).value.flatMap(_ ** kotlinSources get) ++ + (Test / sourceDirectories).value.flatMap(_ ** kotlinSources get) } ) ++ inConfig(Compile)(kotlinCompileSettings) ++ inConfig(Test)(kotlinCompileSettings) @@ -80,12 +80,13 @@ object KotlinPlugin extends AutoPlugin { kotlinCompile := Def.task { KotlinCompile.compile(kotlincOptions.value, kotlincJvmTarget.value, + kotlinVersion.value, sourceDirectories.value, kotlincPluginOptions.value, - dependencyClasspath.value, (managedClasspath in KotlinInternal).value, + dependencyClasspath.value, (KotlinInternal / managedClasspath).value, classDirectory.value, streams.value) - }.dependsOn (compileInputs in (Compile,compile)).value, + }.dependsOn (Compile / compile / compileInputs).value, compile := (compile dependsOn kotlinCompile).value, kotlinSource := sourceDirectory.value / "kotlin", - definedTests in Test ++= KotlinTest.kotlinTests.value + Test / definedTests ++= KotlinTest.kotlinTests.value ) } diff --git a/src/main/scala/KotlinTest.scala b/src/main/scala/KotlinTest.scala index 20573e0..51d683c 100644 --- a/src/main/scala/KotlinTest.scala +++ b/src/main/scala/KotlinTest.scala @@ -1,62 +1,85 @@ package sbt -import sbt.Keys._ -import sbt.internal.inc.classfile.Analyze -import sbt.internal.inc.classpath.ClasspathUtilities -import sbt.internal.inc._ -import xsbti.compile._ +import sbt.Keys.* +import sbt.internal.inc.classfile.JavaAnalyze +import sbt.internal.inc.classpath.ClasspathUtil +import sbt.internal.inc.* +import xsbti.{VirtualFile, VirtualFileRef} +import xsbti.compile.* object KotlinTest { private object EmptyLookup extends Lookup { def changedClasspathHash: Option[Vector[FileHash]] = None def analyses: Vector[CompileAnalysis] = Vector.empty - - def lookupOnClasspath(binaryClassName: String): Option[File] = None - + def lookupOnClasspath(binaryClassName: String): Option[VirtualFileRef] = None def lookupAnalysis(binaryClassName: String): Option[CompileAnalysis] = None - def changedBinaries(previousAnalysis: xsbti.compile.CompileAnalysis): Option[Set[java.io.File]] = None - def changedSources(previousAnalysis: xsbti.compile.CompileAnalysis): Option[xsbti.compile.Changes[java.io.File]] = None - def removedProducts(previousAnalysis: xsbti.compile.CompileAnalysis): Option[Set[java.io.File]] = None + def changedBinaries(previousAnalysis: xsbti.compile.CompileAnalysis): Option[Set[VirtualFileRef]] = None + def changedSources(previousAnalysis: xsbti.compile.CompileAnalysis): Option[xsbti.compile.Changes[VirtualFileRef]] = None + def removedProducts(previousAnalysis: xsbti.compile.CompileAnalysis): Option[Set[VirtualFileRef]] = None def shouldDoIncrementalCompilation(changedClasses: Set[String],analysis: xsbti.compile.CompileAnalysis): Boolean = true - - def hashClasspath(x$1: Array[java.io.File]): java.util.Optional[Array[xsbti.compile.FileHash]] = java.util.Optional.empty() + override def hashClasspath(classpath: Array[VirtualFile]): java.util.Optional[Array[FileHash]] = java.util.Optional.empty() } val kotlinTests = Def.task { - val out = ((target in Test).value ** "scala-*").get.head / "test-classes" - val srcs = ((sourceDirectory in Test).value ** "*.kt").get.toList + val out = ((Test / target).value ** "scala-*").get.head / "test-classes" + val srcs = ((Test / sourceDirectory).value ** "*.kt").get.map(f => PlainVirtualFile(f.toPath())).toList val xs = (out ** "*.class").get.toList - val loader = ClasspathUtilities.toLoader((fullClasspath in Test).value map { + val loader = ClasspathUtil.toLoader((Test / fullClasspath).value map { _.data }) + val log = streams.value.log val output = new SingleOutput { def getOutputDirectory: File = out } - val a0 = IncrementalCompile( + + val so = (Test / scalacOptions).value + val jo = (Test / javacOptions).value + val c = (Test / compile).value + + val incremental = Incremental( srcs.toSet, + PlainVirtualFileConverter.converter, EmptyLookup, - (fs, changs, callback, clsFileMgr) => { - def readAPI(source: File, classes: Seq[Class[_]]): Set[(String, String)] = { - val (apis, mainClasses, inherits) = ClassToAPI.process(classes) - apis.foreach(callback.api(source, _)) - mainClasses.foreach(callback.mainClass(source, _)) - inherits.map { - case (from, to) => (from.getName, to.getName) - } - } - - Analyze(xs, srcs, log, output, None)(callback, loader, readAPI) - }, Analysis.Empty, + IncOptions.of(), + MiniSetup.of( + output, + MiniOptions.of(null, so.toArray, jo.toArray), + null, + null, + false, + null + ), + c.readStamps(), output, + JarUtils.createOutputJarContent(output), + None, + None, + None, log, - incOptions.value, - JarUtils.createOutputJarContent(output))._2 - val frameworks = (loadedTestFrameworks in Test).value.values.toList + )((_, _, callback, _) => { + def readAPI(source: VirtualFileRef, classes: Seq[Class[_]]): Set[(String, String)] = { + val (apis, mainClasses, inherits) = ClassToAPI.process(classes) + apis.foreach(callback.api(source, _)) + mainClasses.foreach(callback.mainClass(source, _)) + inherits.map { + case (from, to) => (from.getName, to.getName) + } + } + JavaAnalyze( + xs.map(_.toPath), + srcs, + log, + output, + None + )(callback, loader, readAPI) + }) + + val frameworks = (Test / loadedTestFrameworks).value.values.toList log.info(s"Compiling ${srcs.length} Kotlin source to $out...") - Tests.discover(frameworks, a0, log)._1 + Tests.discover(frameworks, incremental._2, log)._1 } } diff --git a/src/main/scala/worksheet.sc b/src/main/scala/worksheet.sc new file mode 100644 index 0000000..e7b9b3c --- /dev/null +++ b/src/main/scala/worksheet.sc @@ -0,0 +1 @@ +/Users/willemveelenturf/projects/sbt/sbt-kotlin-plugin/src/main/scala \ No newline at end of file diff --git a/src/sbt-test/kotlin/basic-android/build.sbt b/src/sbt-test/kotlin/basic-android/build.sbt deleted file mode 100644 index 513bf22..0000000 --- a/src/sbt-test/kotlin/basic-android/build.sbt +++ /dev/null @@ -1,5 +0,0 @@ -enablePlugins(AndroidApp) - -kotlinClasspath(Compile, bootClasspath in Android) - -kotlinLib("stdlib") diff --git a/src/sbt-test/kotlin/basic-android/project.properties b/src/sbt-test/kotlin/basic-android/project.properties deleted file mode 100644 index 68a9814..0000000 --- a/src/sbt-test/kotlin/basic-android/project.properties +++ /dev/null @@ -1 +0,0 @@ -target=android-22 diff --git a/src/sbt-test/kotlin/basic-android/project/android.sbt b/src/sbt-test/kotlin/basic-android/project/android.sbt deleted file mode 100644 index 52df55a..0000000 --- a/src/sbt-test/kotlin/basic-android/project/android.sbt +++ /dev/null @@ -1 +0,0 @@ -addSbtPlugin("org.scala-android" % "sbt-android" % "2.0.0-SNAPSHOT") diff --git a/src/sbt-test/kotlin/basic-android/project/plugins.sbt b/src/sbt-test/kotlin/basic-android/project/plugins.sbt deleted file mode 100644 index e12d712..0000000 --- a/src/sbt-test/kotlin/basic-android/project/plugins.sbt +++ /dev/null @@ -1,9 +0,0 @@ -{ - val ver = System.getProperty("plugin.version") - if (ver == null) - throw new RuntimeException(""" - |The system property 'plugin.version' is not defined. - |Specify this property using scriptedLaunchOpts -Dplugin.version.""" - .stripMargin) - else addSbtPlugin("com.hanhuy.sbt" % "kotlin-plugin" % ver) -} \ No newline at end of file diff --git a/src/sbt-test/kotlin/basic-android/src/main/AndroidManifest.xml b/src/sbt-test/kotlin/basic-android/src/main/AndroidManifest.xml deleted file mode 100644 index 487bf68..0000000 --- a/src/sbt-test/kotlin/basic-android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - diff --git a/src/sbt-test/kotlin/basic-android/src/main/kotlin/MainActivity.kt b/src/sbt-test/kotlin/basic-android/src/main/kotlin/MainActivity.kt deleted file mode 100644 index 49cc92c..0000000 --- a/src/sbt-test/kotlin/basic-android/src/main/kotlin/MainActivity.kt +++ /dev/null @@ -1,14 +0,0 @@ -package sbt.kotlin.test - -import android.app.Activity -import android.os.Bundle - -class MainActivity : Activity() -{ - /** Called when the activity is first created. */ - override fun onCreate(savedInstanceState: Bundle?) - { - super.onCreate(savedInstanceState) - setContentView(R.layout.main) - } -} diff --git a/src/sbt-test/kotlin/basic-android/src/main/res/drawable-hdpi/ic_launcher.png b/src/sbt-test/kotlin/basic-android/src/main/res/drawable-hdpi/ic_launcher.png deleted file mode 100644 index 96a442e..0000000 Binary files a/src/sbt-test/kotlin/basic-android/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/src/sbt-test/kotlin/basic-android/src/main/res/drawable-ldpi/ic_launcher.png b/src/sbt-test/kotlin/basic-android/src/main/res/drawable-ldpi/ic_launcher.png deleted file mode 100644 index 9923872..0000000 Binary files a/src/sbt-test/kotlin/basic-android/src/main/res/drawable-ldpi/ic_launcher.png and /dev/null differ diff --git a/src/sbt-test/kotlin/basic-android/src/main/res/drawable-mdpi/ic_launcher.png b/src/sbt-test/kotlin/basic-android/src/main/res/drawable-mdpi/ic_launcher.png deleted file mode 100644 index 359047d..0000000 Binary files a/src/sbt-test/kotlin/basic-android/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ diff --git a/src/sbt-test/kotlin/basic-android/src/main/res/drawable-xhdpi/ic_launcher.png b/src/sbt-test/kotlin/basic-android/src/main/res/drawable-xhdpi/ic_launcher.png deleted file mode 100644 index 71c6d76..0000000 Binary files a/src/sbt-test/kotlin/basic-android/src/main/res/drawable-xhdpi/ic_launcher.png and /dev/null differ diff --git a/src/sbt-test/kotlin/basic-android/src/main/res/layout/main.xml b/src/sbt-test/kotlin/basic-android/src/main/res/layout/main.xml deleted file mode 100644 index e745f63..0000000 --- a/src/sbt-test/kotlin/basic-android/src/main/res/layout/main.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - diff --git a/src/sbt-test/kotlin/basic-android/src/main/res/values/strings.xml b/src/sbt-test/kotlin/basic-android/src/main/res/values/strings.xml deleted file mode 100644 index 0be1647..0000000 --- a/src/sbt-test/kotlin/basic-android/src/main/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - MainActivity - diff --git a/src/sbt-test/kotlin/basic-android/test b/src/sbt-test/kotlin/basic-android/test deleted file mode 100644 index 472120d..0000000 --- a/src/sbt-test/kotlin/basic-android/test +++ /dev/null @@ -1,3 +0,0 @@ -> android:package -$ exists target/android/output/basic-android-debug.apk -> checkDex diff --git a/src/sbt-test/kotlin/basic-android/tests.sbt b/src/sbt-test/kotlin/basic-android/tests.sbt deleted file mode 100644 index de14985..0000000 --- a/src/sbt-test/kotlin/basic-android/tests.sbt +++ /dev/null @@ -1,23 +0,0 @@ -import android.Keys._ -import sys.process._ - -val androidBuilder = SettingKey[Logger => com.android.builder.core.AndroidBuilder]("android-builder") in Android - -TaskKey[Unit]("checkDex") := { - val p = androidBuilder.value - val s = streams.value - val layout = (projectLayout in Android).value - implicit val out = outputLayout.value - val tools = p(s.log).getTargetInfo.getBuildTools.getLocation - val dexdump = tools / "dexdump" - val lines = Seq( - dexdump.getAbsolutePath, "-i", - (layout.dex / "classes.dex").getAbsolutePath).lineStream - val hasKotlinClasses = lines map (_.trim) exists { l => - l.startsWith("Class descriptor") && l.endsWith("'Lkotlin/Unit;'") - } - if (!hasKotlinClasses) { - lines filter (_.trim.startsWith("Class descriptor")) foreach (l => s.log.info(l)) - sys.error("Kotlin classes not found") - } -} diff --git a/src/sbt-test/kotlin/basic-tests/project/build.properties b/src/sbt-test/kotlin/basic-tests/project/build.properties new file mode 100644 index 0000000..46e43a9 --- /dev/null +++ b/src/sbt-test/kotlin/basic-tests/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.8.2 diff --git a/src/sbt-test/kotlin/basic-tests/project/plugins.sbt b/src/sbt-test/kotlin/basic-tests/project/plugins.sbt index f3894bd..5d420de 100644 --- a/src/sbt-test/kotlin/basic-tests/project/plugins.sbt +++ b/src/sbt-test/kotlin/basic-tests/project/plugins.sbt @@ -5,5 +5,5 @@ |The system property 'plugin.version' is not defined. |Specify this property using scriptedLaunchOpts -Dplugin.version.""" .stripMargin) - else addSbtPlugin("com.hanhuy.sbt" % "kotlin-plugin" % ver) + else addSbtPlugin("community.flock.sbt" % "sbt-kotlin-plugin" % ver) } \ No newline at end of file diff --git a/src/sbt-test/kotlin/basic-tests/test b/src/sbt-test/kotlin/basic-tests/test index 08d1296..48674d5 100644 --- a/src/sbt-test/kotlin/basic-tests/test +++ b/src/sbt-test/kotlin/basic-tests/test @@ -1,3 +1,3 @@ > compile > test -> "checkTestPass SimpleTest" \ No newline at end of file +> checkTestPass TEST-SimpleTest \ No newline at end of file diff --git a/src/sbt-test/kotlin/basic/build.sbt b/src/sbt-test/kotlin/basic/build.sbt index e9f343c..9746ab2 100644 --- a/src/sbt-test/kotlin/basic/build.sbt +++ b/src/sbt-test/kotlin/basic/build.sbt @@ -3,6 +3,6 @@ kotlinLib("stdlib") val listClasses = taskKey[Unit]("listClasses") listClasses := { - val classes = (classDirectory in Compile).value.listFiles() + val classes = (Compile / classDirectory).value.listFiles() streams.value.log.info("classes: " + classes) } diff --git a/src/sbt-test/kotlin/basic/project/build.properties b/src/sbt-test/kotlin/basic/project/build.properties new file mode 100644 index 0000000..46e43a9 --- /dev/null +++ b/src/sbt-test/kotlin/basic/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.8.2 diff --git a/src/sbt-test/kotlin/basic/project/plugins.sbt b/src/sbt-test/kotlin/basic/project/plugins.sbt index e12d712..4873a6b 100644 --- a/src/sbt-test/kotlin/basic/project/plugins.sbt +++ b/src/sbt-test/kotlin/basic/project/plugins.sbt @@ -5,5 +5,5 @@ |The system property 'plugin.version' is not defined. |Specify this property using scriptedLaunchOpts -Dplugin.version.""" .stripMargin) - else addSbtPlugin("com.hanhuy.sbt" % "kotlin-plugin" % ver) + else addSbtPlugin("community.flock.sbt" % "sbt-kotlin-plugin" % ver) } \ No newline at end of file diff --git a/src/sbt-test/kotlin/extensions-android/build.sbt b/src/sbt-test/kotlin/extensions-android/build.sbt deleted file mode 100644 index ce387f0..0000000 --- a/src/sbt-test/kotlin/extensions-android/build.sbt +++ /dev/null @@ -1,13 +0,0 @@ -enablePlugins(AndroidApp) -javacOptions in Compile ++= "-source" :: "1.7" :: "-target" :: "1.7" :: Nil - -kotlinClasspath(Compile, bootClasspath in Android) -kotlinPlugin("android-extensions") -kotlinLib("stdlib") -kotlincPluginOptions in Compile ++= { - val plugin = KotlinPluginOptions("org.jetbrains.kotlin.android") - val layout = (projectLayout in Android).value - plugin.option("package", applicationId.value) :: - plugin.option("variant", "main;" + layout.res.getCanonicalPath) :: - Nil -} diff --git a/src/sbt-test/kotlin/extensions-android/project.properties b/src/sbt-test/kotlin/extensions-android/project.properties deleted file mode 100644 index 68a9814..0000000 --- a/src/sbt-test/kotlin/extensions-android/project.properties +++ /dev/null @@ -1 +0,0 @@ -target=android-22 diff --git a/src/sbt-test/kotlin/extensions-android/project/android.sbt b/src/sbt-test/kotlin/extensions-android/project/android.sbt deleted file mode 100644 index 52df55a..0000000 --- a/src/sbt-test/kotlin/extensions-android/project/android.sbt +++ /dev/null @@ -1 +0,0 @@ -addSbtPlugin("org.scala-android" % "sbt-android" % "2.0.0-SNAPSHOT") diff --git a/src/sbt-test/kotlin/extensions-android/project/plugins.sbt b/src/sbt-test/kotlin/extensions-android/project/plugins.sbt deleted file mode 100644 index 39ed0d0..0000000 --- a/src/sbt-test/kotlin/extensions-android/project/plugins.sbt +++ /dev/null @@ -1,11 +0,0 @@ -{ - val ver = System.getProperty("plugin.version") - if (ver == null) - throw new RuntimeException(""" - |The system property 'plugin.version' is not defined. - |Specify this property using scriptedLaunchOpts -Dplugin.version.""" - .stripMargin) - else addSbtPlugin("com.hanhuy.sbt" % "kotlin-plugin" % ver) -} - - diff --git a/src/sbt-test/kotlin/extensions-android/src/main/AndroidManifest.xml b/src/sbt-test/kotlin/extensions-android/src/main/AndroidManifest.xml deleted file mode 100644 index 487bf68..0000000 --- a/src/sbt-test/kotlin/extensions-android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - diff --git a/src/sbt-test/kotlin/extensions-android/src/main/kotlin/MainActivity.kt b/src/sbt-test/kotlin/extensions-android/src/main/kotlin/MainActivity.kt deleted file mode 100644 index 5eae48c..0000000 --- a/src/sbt-test/kotlin/extensions-android/src/main/kotlin/MainActivity.kt +++ /dev/null @@ -1,17 +0,0 @@ -package sbt.kotlin.test - -import android.app.Activity -import android.os.Bundle - -import kotlinx.android.synthetic.main.main.* - -class MainActivity : Activity() -{ - /** Called when the activity is first created. */ - override fun onCreate(savedInstanceState: Bundle?) - { - super.onCreate(savedInstanceState) - setContentView(R.layout.main) - this_is_test.setText("Wow?") - } -} diff --git a/src/sbt-test/kotlin/extensions-android/src/main/res/drawable-hdpi/ic_launcher.png b/src/sbt-test/kotlin/extensions-android/src/main/res/drawable-hdpi/ic_launcher.png deleted file mode 100644 index 96a442e..0000000 Binary files a/src/sbt-test/kotlin/extensions-android/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/src/sbt-test/kotlin/extensions-android/src/main/res/drawable-ldpi/ic_launcher.png b/src/sbt-test/kotlin/extensions-android/src/main/res/drawable-ldpi/ic_launcher.png deleted file mode 100644 index 9923872..0000000 Binary files a/src/sbt-test/kotlin/extensions-android/src/main/res/drawable-ldpi/ic_launcher.png and /dev/null differ diff --git a/src/sbt-test/kotlin/extensions-android/src/main/res/drawable-mdpi/ic_launcher.png b/src/sbt-test/kotlin/extensions-android/src/main/res/drawable-mdpi/ic_launcher.png deleted file mode 100644 index 359047d..0000000 Binary files a/src/sbt-test/kotlin/extensions-android/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ diff --git a/src/sbt-test/kotlin/extensions-android/src/main/res/drawable-xhdpi/ic_launcher.png b/src/sbt-test/kotlin/extensions-android/src/main/res/drawable-xhdpi/ic_launcher.png deleted file mode 100644 index 71c6d76..0000000 Binary files a/src/sbt-test/kotlin/extensions-android/src/main/res/drawable-xhdpi/ic_launcher.png and /dev/null differ diff --git a/src/sbt-test/kotlin/extensions-android/src/main/res/layout/main.xml b/src/sbt-test/kotlin/extensions-android/src/main/res/layout/main.xml deleted file mode 100644 index 96731b3..0000000 --- a/src/sbt-test/kotlin/extensions-android/src/main/res/layout/main.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - diff --git a/src/sbt-test/kotlin/extensions-android/src/main/res/values/strings.xml b/src/sbt-test/kotlin/extensions-android/src/main/res/values/strings.xml deleted file mode 100644 index 0be1647..0000000 --- a/src/sbt-test/kotlin/extensions-android/src/main/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - MainActivity - diff --git a/src/sbt-test/kotlin/extensions-android/test b/src/sbt-test/kotlin/extensions-android/test deleted file mode 100644 index 1898447..0000000 --- a/src/sbt-test/kotlin/extensions-android/test +++ /dev/null @@ -1,3 +0,0 @@ -> android:package -$ exists target/android/output/extensions-android-debug.apk -> checkDex diff --git a/src/sbt-test/kotlin/extensions-android/tests.sbt b/src/sbt-test/kotlin/extensions-android/tests.sbt deleted file mode 100644 index 60dbe94..0000000 --- a/src/sbt-test/kotlin/extensions-android/tests.sbt +++ /dev/null @@ -1,23 +0,0 @@ -import android.Keys._ -import sys.process._ - -val androidBuilder = SettingKey[Logger => com.android.builder.core.AndroidBuilder]("android-builder") in Android - -TaskKey[Unit]("checkDex") := { - implicit val out = outputLayout.value - val p = androidBuilder.value - val s = streams.value - val layout = (projectLayout in Android).value - val tools = p(s.log).getTargetInfo.getBuildTools.getLocation - val dexdump = tools / "dexdump" - val lines = Seq( - dexdump.getAbsolutePath, "-i", - (layout.dex / "classes.dex").getAbsolutePath).lineStream - val hasKotlinClasses = lines map (_.trim) exists { l => - l.startsWith("Class descriptor") && l.endsWith("'Lkotlin/Unit;'") - } - if (!hasKotlinClasses) { - lines filter (_.trim.startsWith("Class descriptor")) foreach (l => s.log.info(l)) - sys.error("Kotlin classes not found") - } -} diff --git a/src/sbt-test/kotlin/kotlin-1.1-compat/project/plugins.sbt b/src/sbt-test/kotlin/kotlin-1.1-compat/project/plugins.sbt deleted file mode 100644 index ff38770..0000000 --- a/src/sbt-test/kotlin/kotlin-1.1-compat/project/plugins.sbt +++ /dev/null @@ -1 +0,0 @@ -addSbtPlugin("com.hanhuy.sbt" % "kotlin-plugin" % sys.props("plugin.version")) diff --git a/src/sbt-test/kotlin/kotlin-1.1-compat/src/main/kotlin/simple.kt b/src/sbt-test/kotlin/kotlin-1.1-compat/src/main/kotlin/simple.kt deleted file mode 100644 index 161133a..0000000 --- a/src/sbt-test/kotlin/kotlin-1.1-compat/src/main/kotlin/simple.kt +++ /dev/null @@ -1,10 +0,0 @@ -package demo -fun main(args: Array) { - val map = mapOf("key" to 42) - val emptyMap = map - "key" - - val list1 = listOf("a", "b") - val list2 = listOf("x", "y", "z") - val minSize = minOf(list1.size, list2.size) - val longestList = maxOf(list1, list2, compareBy { it.size }) -} diff --git a/src/sbt-test/kotlin/kotlin-1.2-compat/build.sbt b/src/sbt-test/kotlin/kotlin-1.2-compat/build.sbt index 8a787d1..b695120 100644 --- a/src/sbt-test/kotlin/kotlin-1.2-compat/build.sbt +++ b/src/sbt-test/kotlin/kotlin-1.2-compat/build.sbt @@ -5,6 +5,6 @@ kotlinVersion := "1.2.71" val listClasses = taskKey[Unit]("listClasses") listClasses := { - val classes = (classDirectory in Compile).value.listFiles() + val classes = (Compile / classDirectory).value.listFiles() streams.value.log.info("classes: " + classes) } diff --git a/src/sbt-test/kotlin/kotlin-1.2-compat/project/build.properties b/src/sbt-test/kotlin/kotlin-1.2-compat/project/build.properties new file mode 100644 index 0000000..46e43a9 --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.2-compat/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.8.2 diff --git a/src/sbt-test/kotlin/kotlin-1.2-compat/project/plugins.sbt b/src/sbt-test/kotlin/kotlin-1.2-compat/project/plugins.sbt index ff38770..ce4564c 100644 --- a/src/sbt-test/kotlin/kotlin-1.2-compat/project/plugins.sbt +++ b/src/sbt-test/kotlin/kotlin-1.2-compat/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("com.hanhuy.sbt" % "kotlin-plugin" % sys.props("plugin.version")) +addSbtPlugin("community.flock.sbt" % "sbt-kotlin-plugin" % sys.props("plugin.version")) diff --git a/src/sbt-test/kotlin/kotlin-1.3-compat/build.sbt b/src/sbt-test/kotlin/kotlin-1.3-compat/build.sbt index 90e16c1..a014e2f 100644 --- a/src/sbt-test/kotlin/kotlin-1.3-compat/build.sbt +++ b/src/sbt-test/kotlin/kotlin-1.3-compat/build.sbt @@ -5,6 +5,6 @@ kotlinVersion := "1.3.41" val listClasses = taskKey[Unit]("listClasses") listClasses := { - val classes = (classDirectory in Compile).value.listFiles() + val classes = (Compile / classDirectory).value.listFiles() streams.value.log.info("classes: " + classes) } diff --git a/src/sbt-test/kotlin/kotlin-1.3-compat/project/build.properties b/src/sbt-test/kotlin/kotlin-1.3-compat/project/build.properties new file mode 100644 index 0000000..46e43a9 --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.3-compat/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.8.2 diff --git a/src/sbt-test/kotlin/kotlin-1.3-compat/project/plugins.sbt b/src/sbt-test/kotlin/kotlin-1.3-compat/project/plugins.sbt index ff38770..ce4564c 100644 --- a/src/sbt-test/kotlin/kotlin-1.3-compat/project/plugins.sbt +++ b/src/sbt-test/kotlin/kotlin-1.3-compat/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("com.hanhuy.sbt" % "kotlin-plugin" % sys.props("plugin.version")) +addSbtPlugin("community.flock.sbt" % "sbt-kotlin-plugin" % sys.props("plugin.version")) diff --git a/src/sbt-test/kotlin/kotlin-1.1-compat/build.sbt b/src/sbt-test/kotlin/kotlin-1.5-compat/build.sbt similarity index 60% rename from src/sbt-test/kotlin/kotlin-1.1-compat/build.sbt rename to src/sbt-test/kotlin/kotlin-1.5-compat/build.sbt index 1165e95..ff07f10 100644 --- a/src/sbt-test/kotlin/kotlin-1.1-compat/build.sbt +++ b/src/sbt-test/kotlin/kotlin-1.5-compat/build.sbt @@ -1,10 +1,10 @@ kotlinLib("stdlib") -kotlinVersion := "1.1.4-3" +kotlinVersion := "1.5.30" val listClasses = taskKey[Unit]("listClasses") listClasses := { - val classes = (classDirectory in Compile).value.listFiles() + val classes = (Compile / classDirectory).value.listFiles() streams.value.log.info("classes: " + classes) } diff --git a/src/sbt-test/kotlin/kotlin-1.5-compat/project/build.properties b/src/sbt-test/kotlin/kotlin-1.5-compat/project/build.properties new file mode 100644 index 0000000..46e43a9 --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.5-compat/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.8.2 diff --git a/src/sbt-test/kotlin/kotlin-1.5-compat/project/plugins.sbt b/src/sbt-test/kotlin/kotlin-1.5-compat/project/plugins.sbt new file mode 100644 index 0000000..ce4564c --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.5-compat/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("community.flock.sbt" % "sbt-kotlin-plugin" % sys.props("plugin.version")) diff --git a/src/sbt-test/kotlin/kotlin-1.1-compat/src/main/kotlin/SimpleScript.kts b/src/sbt-test/kotlin/kotlin-1.5-compat/src/main/kotlin/SimpleScript.kts similarity index 100% rename from src/sbt-test/kotlin/kotlin-1.1-compat/src/main/kotlin/SimpleScript.kts rename to src/sbt-test/kotlin/kotlin-1.5-compat/src/main/kotlin/SimpleScript.kts diff --git a/src/sbt-test/kotlin/kotlin-1.5-compat/src/main/kotlin/simple.kt b/src/sbt-test/kotlin/kotlin-1.5-compat/src/main/kotlin/simple.kt new file mode 100644 index 0000000..59ad996 --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.5-compat/src/main/kotlin/simple.kt @@ -0,0 +1,7 @@ +package demo +fun main(args: Array) { + // Test some Kotlin 1.3 features + val keys = 'a'..'f' + val map = keys.associateWith { it.toString().repeat(5).capitalize() } + map.forEach { println(it) } +} diff --git a/src/sbt-test/kotlin/kotlin-1.1-compat/test b/src/sbt-test/kotlin/kotlin-1.5-compat/test similarity index 100% rename from src/sbt-test/kotlin/kotlin-1.1-compat/test rename to src/sbt-test/kotlin/kotlin-1.5-compat/test diff --git a/src/sbt-test/kotlin/kotlin-1.6-compat/build.sbt b/src/sbt-test/kotlin/kotlin-1.6-compat/build.sbt new file mode 100644 index 0000000..a2e0b3e --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.6-compat/build.sbt @@ -0,0 +1,10 @@ +kotlinLib("stdlib") + +kotlinVersion := "1.6.21" + +val listClasses = taskKey[Unit]("listClasses") + +listClasses := { + val classes = (Compile / classDirectory).value.listFiles() + streams.value.log.info("classes: " + classes) +} diff --git a/src/sbt-test/kotlin/kotlin-1.6-compat/project/build.properties b/src/sbt-test/kotlin/kotlin-1.6-compat/project/build.properties new file mode 100644 index 0000000..46e43a9 --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.6-compat/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.8.2 diff --git a/src/sbt-test/kotlin/kotlin-1.6-compat/project/plugins.sbt b/src/sbt-test/kotlin/kotlin-1.6-compat/project/plugins.sbt new file mode 100644 index 0000000..ce4564c --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.6-compat/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("community.flock.sbt" % "sbt-kotlin-plugin" % sys.props("plugin.version")) diff --git a/src/sbt-test/kotlin/kotlin-1.6-compat/src/main/kotlin/SimpleScript.kts b/src/sbt-test/kotlin/kotlin-1.6-compat/src/main/kotlin/SimpleScript.kts new file mode 100644 index 0000000..50095f7 --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.6-compat/src/main/kotlin/SimpleScript.kts @@ -0,0 +1 @@ +println("Hello world!") diff --git a/src/sbt-test/kotlin/kotlin-1.6-compat/src/main/kotlin/simple.kt b/src/sbt-test/kotlin/kotlin-1.6-compat/src/main/kotlin/simple.kt new file mode 100644 index 0000000..59ad996 --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.6-compat/src/main/kotlin/simple.kt @@ -0,0 +1,7 @@ +package demo +fun main(args: Array) { + // Test some Kotlin 1.3 features + val keys = 'a'..'f' + val map = keys.associateWith { it.toString().repeat(5).capitalize() } + map.forEach { println(it) } +} diff --git a/src/sbt-test/kotlin/kotlin-1.6-compat/test b/src/sbt-test/kotlin/kotlin-1.6-compat/test new file mode 100644 index 0000000..3ac0ebe --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.6-compat/test @@ -0,0 +1,4 @@ +> compile +> listClasses +$ exists target/scala-2.12/classes/demo/SimpleKt.class +$ exists target/scala-2.12/classes/SimpleScript.class diff --git a/src/sbt-test/kotlin/kotlin-1.7-compat/build.sbt b/src/sbt-test/kotlin/kotlin-1.7-compat/build.sbt new file mode 100644 index 0000000..787b406 --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.7-compat/build.sbt @@ -0,0 +1,10 @@ +kotlinLib("stdlib") + +kotlinVersion := "1.7.21" + +val listClasses = taskKey[Unit]("listClasses") + +listClasses := { + val classes = (Compile / classDirectory).value.listFiles() + streams.value.log.info("classes: " + classes) +} diff --git a/src/sbt-test/kotlin/kotlin-1.7-compat/project/build.properties b/src/sbt-test/kotlin/kotlin-1.7-compat/project/build.properties new file mode 100644 index 0000000..46e43a9 --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.7-compat/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.8.2 diff --git a/src/sbt-test/kotlin/kotlin-1.7-compat/project/plugins.sbt b/src/sbt-test/kotlin/kotlin-1.7-compat/project/plugins.sbt new file mode 100644 index 0000000..ce4564c --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.7-compat/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("community.flock.sbt" % "sbt-kotlin-plugin" % sys.props("plugin.version")) diff --git a/src/sbt-test/kotlin/kotlin-1.7-compat/src/main/kotlin/SimpleScript.kts b/src/sbt-test/kotlin/kotlin-1.7-compat/src/main/kotlin/SimpleScript.kts new file mode 100644 index 0000000..50095f7 --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.7-compat/src/main/kotlin/SimpleScript.kts @@ -0,0 +1 @@ +println("Hello world!") diff --git a/src/sbt-test/kotlin/kotlin-1.7-compat/src/main/kotlin/simple.kt b/src/sbt-test/kotlin/kotlin-1.7-compat/src/main/kotlin/simple.kt new file mode 100644 index 0000000..59ad996 --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.7-compat/src/main/kotlin/simple.kt @@ -0,0 +1,7 @@ +package demo +fun main(args: Array) { + // Test some Kotlin 1.3 features + val keys = 'a'..'f' + val map = keys.associateWith { it.toString().repeat(5).capitalize() } + map.forEach { println(it) } +} diff --git a/src/sbt-test/kotlin/kotlin-1.7-compat/test b/src/sbt-test/kotlin/kotlin-1.7-compat/test new file mode 100644 index 0000000..3ac0ebe --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.7-compat/test @@ -0,0 +1,4 @@ +> compile +> listClasses +$ exists target/scala-2.12/classes/demo/SimpleKt.class +$ exists target/scala-2.12/classes/SimpleScript.class diff --git a/src/sbt-test/kotlin/kotlin-1.8-compat/build.sbt b/src/sbt-test/kotlin/kotlin-1.8-compat/build.sbt new file mode 100644 index 0000000..8fec78a --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.8-compat/build.sbt @@ -0,0 +1,10 @@ +kotlinLib("stdlib") + +kotlinVersion := "1.8.10" + +val listClasses = taskKey[Unit]("listClasses") + +listClasses := { + val classes = (Compile / classDirectory).value.listFiles() + streams.value.log.info("classes: " + classes) +} diff --git a/src/sbt-test/kotlin/kotlin-1.8-compat/project/build.properties b/src/sbt-test/kotlin/kotlin-1.8-compat/project/build.properties new file mode 100644 index 0000000..46e43a9 --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.8-compat/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.8.2 diff --git a/src/sbt-test/kotlin/kotlin-1.8-compat/project/plugins.sbt b/src/sbt-test/kotlin/kotlin-1.8-compat/project/plugins.sbt new file mode 100644 index 0000000..ce4564c --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.8-compat/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("community.flock.sbt" % "sbt-kotlin-plugin" % sys.props("plugin.version")) diff --git a/src/sbt-test/kotlin/kotlin-1.8-compat/src/main/kotlin/SimpleScript.kts b/src/sbt-test/kotlin/kotlin-1.8-compat/src/main/kotlin/SimpleScript.kts new file mode 100644 index 0000000..50095f7 --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.8-compat/src/main/kotlin/SimpleScript.kts @@ -0,0 +1 @@ +println("Hello world!") diff --git a/src/sbt-test/kotlin/kotlin-1.8-compat/src/main/kotlin/simple.kt b/src/sbt-test/kotlin/kotlin-1.8-compat/src/main/kotlin/simple.kt new file mode 100644 index 0000000..59ad996 --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.8-compat/src/main/kotlin/simple.kt @@ -0,0 +1,7 @@ +package demo +fun main(args: Array) { + // Test some Kotlin 1.3 features + val keys = 'a'..'f' + val map = keys.associateWith { it.toString().repeat(5).capitalize() } + map.forEach { println(it) } +} diff --git a/src/sbt-test/kotlin/kotlin-1.8-compat/test b/src/sbt-test/kotlin/kotlin-1.8-compat/test new file mode 100644 index 0000000..3ac0ebe --- /dev/null +++ b/src/sbt-test/kotlin/kotlin-1.8-compat/test @@ -0,0 +1,4 @@ +> compile +> listClasses +$ exists target/scala-2.12/classes/demo/SimpleKt.class +$ exists target/scala-2.12/classes/SimpleScript.class diff --git a/src/sbt-test/kotlin/kotlin-script/build.sbt b/src/sbt-test/kotlin/kotlin-script/build.sbt index 638b95f..43eb941 100644 --- a/src/sbt-test/kotlin/kotlin-script/build.sbt +++ b/src/sbt-test/kotlin/kotlin-script/build.sbt @@ -5,6 +5,6 @@ kotlinVersion := "1.3.21" val listClasses = taskKey[Unit]("listClasses") listClasses := { - val classes = (classDirectory in Compile).value.listFiles() + val classes = (Compile / classDirectory).value.listFiles() streams.value.log.info("classes: " + classes) } diff --git a/src/sbt-test/kotlin/kotlin-script/project/build.properties b/src/sbt-test/kotlin/kotlin-script/project/build.properties index c0bab04..46e43a9 100644 --- a/src/sbt-test/kotlin/kotlin-script/project/build.properties +++ b/src/sbt-test/kotlin/kotlin-script/project/build.properties @@ -1 +1 @@ -sbt.version=1.2.8 +sbt.version=1.8.2 diff --git a/src/sbt-test/kotlin/kotlin-script/project/plugins.sbt b/src/sbt-test/kotlin/kotlin-script/project/plugins.sbt index ff38770..ce4564c 100644 --- a/src/sbt-test/kotlin/kotlin-script/project/plugins.sbt +++ b/src/sbt-test/kotlin/kotlin-script/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("com.hanhuy.sbt" % "kotlin-plugin" % sys.props("plugin.version")) +addSbtPlugin("community.flock.sbt" % "sbt-kotlin-plugin" % sys.props("plugin.version")) diff --git a/src/sbt-test/kotlin/mixed-tests/project/build.properties b/src/sbt-test/kotlin/mixed-tests/project/build.properties new file mode 100644 index 0000000..46e43a9 --- /dev/null +++ b/src/sbt-test/kotlin/mixed-tests/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.8.2 diff --git a/src/sbt-test/kotlin/mixed-tests/project/plugins.sbt b/src/sbt-test/kotlin/mixed-tests/project/plugins.sbt index f3894bd..5d420de 100644 --- a/src/sbt-test/kotlin/mixed-tests/project/plugins.sbt +++ b/src/sbt-test/kotlin/mixed-tests/project/plugins.sbt @@ -5,5 +5,5 @@ |The system property 'plugin.version' is not defined. |Specify this property using scriptedLaunchOpts -Dplugin.version.""" .stripMargin) - else addSbtPlugin("com.hanhuy.sbt" % "kotlin-plugin" % ver) + else addSbtPlugin("community.flock.sbt" % "sbt-kotlin-plugin" % ver) } \ No newline at end of file diff --git a/src/sbt-test/kotlin/mixed-tests/test b/src/sbt-test/kotlin/mixed-tests/test index b9dde07..8295630 100644 --- a/src/sbt-test/kotlin/mixed-tests/test +++ b/src/sbt-test/kotlin/mixed-tests/test @@ -1,3 +1,3 @@ > compile > test -> "checkTestPass MixedTest" \ No newline at end of file +> checkTestPass TEST-MixedTest \ No newline at end of file diff --git a/src/sbt-test/kotlin/mixed/project/build.properties b/src/sbt-test/kotlin/mixed/project/build.properties new file mode 100644 index 0000000..46e43a9 --- /dev/null +++ b/src/sbt-test/kotlin/mixed/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.8.2 diff --git a/src/sbt-test/kotlin/mixed/project/plugins.sbt b/src/sbt-test/kotlin/mixed/project/plugins.sbt index 39ed0d0..a5b030d 100644 --- a/src/sbt-test/kotlin/mixed/project/plugins.sbt +++ b/src/sbt-test/kotlin/mixed/project/plugins.sbt @@ -5,7 +5,7 @@ |The system property 'plugin.version' is not defined. |Specify this property using scriptedLaunchOpts -Dplugin.version.""" .stripMargin) - else addSbtPlugin("com.hanhuy.sbt" % "kotlin-plugin" % ver) + else addSbtPlugin("community.flock.sbt" % "sbt-kotlin-plugin" % ver) } diff --git a/src/sbt-test/kotlin/mixed/tests.sbt b/src/sbt-test/kotlin/mixed/tests.sbt index 597407c..fb2fc97 100644 --- a/src/sbt-test/kotlin/mixed/tests.sbt +++ b/src/sbt-test/kotlin/mixed/tests.sbt @@ -1,5 +1,5 @@ TaskKey[Unit]("check-classes") := { - val classes = (classDirectory in Compile).value + val classes = (Compile / classDirectory).value val classList = (classes ** "*.class").get if (classList.size != 7) { throw new MessageOnlyException(s"Incorrect number of classes: ${classList.size} =>\n${classList.mkString("\n")}")