forked from pfn/kotlin-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f72112b
commit e26675c
Showing
20 changed files
with
134 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,40 @@ | ||
//import ScriptedPlugin._ | ||
import bintray.Keys._ | ||
|
||
name := "kotlin-plugin" | ||
|
||
organization := "com.hanhuy.sbt" | ||
|
||
version := "1.0.10-SNAPSHOT" | ||
version := "2.0.0-SNAPSHOT" | ||
|
||
scalacOptions ++= Seq("-deprecation","-Xlint","-feature") | ||
/* | ||
libraryDependencies ++= Seq( | ||
"com.hanhuy.sbt" %% "bintray-update-checker" % "0.2" | ||
) | ||
*/ | ||
|
||
libraryDependencies ++= | ||
"com.hanhuy.sbt" %% "bintray-update-checker" % "0.2" :: | ||
Nil | ||
libraryDependencies ++= Seq( | ||
"io.argonaut" %% "argonaut" % "6.2", | ||
"org.scalaz" %% "scalaz-core" % "7.2.28" | ||
) | ||
|
||
sbtPlugin := true | ||
|
||
// build info plugin | ||
|
||
buildInfoSettings | ||
|
||
sourceGenerators in Compile += buildInfo | ||
enablePlugins(BuildInfoPlugin, SbtPlugin) | ||
|
||
buildInfoPackage := "kotlin" | ||
|
||
// bintray | ||
bintrayPublishSettings | ||
|
||
repository in bintray := "sbt-plugins" | ||
bintrayRepository := "sbt-plugins" | ||
|
||
publishMavenStyle := false | ||
|
||
licenses += ("MIT", url("http://opensource.org/licenses/MIT")) | ||
|
||
bintrayOrganization in bintray := None | ||
bintrayOrganization := None | ||
|
||
// scripted | ||
scriptedSettings | ||
|
||
scriptedLaunchOpts ++= "-Xmx1024m" :: | ||
"-Dplugin.version=" + version.value :: | ||
Nil | ||
scriptedLaunchOpts ++= Seq( | ||
"-Xmx1024m", | ||
"-Dplugin.version=" + version.value | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version=0.13.16 | ||
sbt.version=1.2.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value | ||
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value | ||
|
||
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.1.2") | ||
|
||
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.2.5") | ||
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4") | ||
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package kotlin | ||
|
||
import java.io.{InputStreamReader, BufferedReader, StringWriter} | ||
|
||
import argonaut._, Argonaut._ | ||
|
||
import scala.concurrent.Future | ||
import scala.util.{Failure, Success} | ||
|
||
object UpdateChecker { | ||
import scala.concurrent.ExecutionContext.Implicits.global | ||
type Result = (Set[String],String) | ||
type Callback[A] = Either[Throwable,Result] => A | ||
|
||
def apply[A](user: String, repo: String, name: String)(result: Callback[A]): Unit = { | ||
val bintray = new java.net.URL( | ||
s"https://api.bintray.com/packages/$user/$repo/$name") | ||
Future { | ||
val uc = bintray.openConnection() | ||
val in = new BufferedReader(new InputStreamReader(uc.getInputStream, "utf-8")) | ||
try { | ||
val sw = new StringWriter | ||
val buf = Array.ofDim[Char](8192) | ||
Stream.continually(in.read(buf, 0, 8192)) takeWhile ( | ||
_ != -1) foreach (sw.write(buf, 0, _)) | ||
sw.toString | ||
} finally { | ||
in.close() | ||
} | ||
} onComplete { | ||
case Success(json) => | ||
val decoded = json.decode[PackageInfo] | ||
val res: Either[Throwable, Result] = decoded match { | ||
case Left(Left(str)) => | ||
Left(new IllegalArgumentException(str)) | ||
case Left(Right(cursorHistory)) => | ||
Left(new IllegalArgumentException(cursorHistory._1)) | ||
case Right(packageInfo) => | ||
Right(packageInfo.versions.toSet -> packageInfo.version) | ||
} | ||
result(res) | ||
case Failure(t) => result(Left(t)) | ||
} | ||
} | ||
|
||
implicit def PackageInfoCodecJson: CodecJson[PackageInfo] = casecodec3( | ||
PackageInfo.apply, PackageInfo.unapply)("name", "latest_version", "versions") | ||
|
||
case class PackageInfo(name: String, version: String, versions: List[String]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
androidBuild | ||
enablePlugins(AndroidApp) | ||
|
||
kotlinClasspath(Compile, bootClasspath in Android) | ||
|
||
kotlinLib("stdlib") | ||
kotlinLib("stdlib") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
addSbtPlugin("org.scala-android" % "sbt-android" % "1.6.15") | ||
addSbtPlugin("org.scala-android" % "sbt-android" % "2.0.0-SNAPSHOT") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
> android:package | ||
$ exists target/android/output/basic-android-debug.apk | ||
> check-dex | ||
> checkDex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
> compile | ||
> listClasses | ||
$ exists target/scala-2.10/classes/demo/SimpleKt.class | ||
$ exists target/scala-2.12/classes/demo/SimpleKt.class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
addSbtPlugin("org.scala-android" % "sbt-android" % "1.7.2") | ||
addSbtPlugin("org.scala-android" % "sbt-android" % "2.0.0-SNAPSHOT") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
> android:package | ||
$ exists target/android/output/extensions-android-debug.apk | ||
> check-dex | ||
> checkDex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package demo | ||
|
||
class ScalaA extends KotlinA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
> debug | ||
> compile | ||
> info | ||
$ exists target/scala-2.10/classes/demo/SimpleKt.class | ||
> check-classes | ||
$ exists target/scala-2.12/classes/demo/SimpleKt.class | ||
> checkClasses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
TaskKey[Unit]("check-classes") := { | ||
val classes = (classDirectory in Compile).value | ||
val classList = (classes ** "*.class").get | ||
if (classList.size != 5) { | ||
if (classList.size != 6) { | ||
throw new MessageOnlyException(s"Incorrect number of classes: ${classList.size} =>\n${classList.mkString("\n")}") | ||
} | ||
} |