diff --git a/.travis.yml b/.travis.yml index 37b9c6d..fec5c26 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ jdk: oraclejdk8 env: matrix: - - SBT_CMD="test" - - SBT_CMD="++2.12.2 ^^1.0.0-M6 test" + - SBT_CMD=";test;scripted" + - SBT_CMD=";++2.12.2;^^1.0.0-RC2;test;scripted" script: sbt "$SBT_CMD" diff --git a/build.sbt b/build.sbt index 71beb36..859dea4 100644 --- a/build.sbt +++ b/build.sbt @@ -29,8 +29,41 @@ lazy val root = (project in file(".")) .settings( name := "sbt-bintray", sbtPlugin := true, + crossSbtVersions := List("0.13.15", "1.0.0-RC2"), + scalaVersion := (CrossVersion partialVersion sbtCrossVersion.value match { + case Some((0, 13)) => "2.10.6" + case Some((1, _)) => "2.12.2" + case _ => sys error s"Unhandled sbt version ${sbtCrossVersion.value}" + }), libraryDependencies ++= Seq( - "org.foundweekends" %% "bintry" % "0.5.0", + "org.foundweekends" %% "bintry" % "0.5.1", "org.slf4j" % "slf4j-nop" % "1.7.7"), // https://github.com/softprops/bintray-sbt/issues/26 - resolvers += Resolver.sonatypeRepo("releases") + resolvers += Resolver.sonatypeRepo("releases"), + scriptedSettings, + scriptedBufferLog := true, + scriptedLaunchOpts ++= Seq( + "-Xmx1024M", + "-XX:MaxPermSize=256M", + "-Dbintray.user=username", + "-Dbintray.pass=password", + "-Dplugin.version=" + version.value + ) ) + +val sbtCrossVersion = sbtVersion in pluginCrossBuild + +// WORKAROUND https://github.com/sbt/sbt/issues/3325 +def scriptedSettings = Def settings ( + ScriptedPlugin.scriptedSettings filterNot (_.key.key.label == libraryDependencies.key.label), + libraryDependencies ++= { + val cross = CrossVersion partialVersion scriptedSbt.value match { + case Some((0, 13)) => CrossVersion.Disabled + case Some((1, _)) => CrossVersion.binary + case _ => sys error s"Unhandled sbt version ${scriptedSbt.value}" + } + Seq( + "org.scala-sbt" % "scripted-sbt" % scriptedSbt.value % scriptedConf.toString cross cross, + "org.scala-sbt" % "sbt-launch" % scriptedSbt.value % scriptedLaunchConf.toString + ) + } +) diff --git a/project/plugins.sbt b/project/plugins.sbt index 1c24478..37fd4e2 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,10 +1,3 @@ -resolvers += Resolver.url( - "bintray-sbt-plugin-releases", - url("http://dl.bintray.com/content/sbt/sbt-plugin-releases"))( - Resolver.ivyStylePatterns) - -// addSbtPlugin("me.lessis" % "ls-sbt" % "0.1.3") - addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0") addSbtPlugin("com.dwijnand" % "sbt-dynver" % "1.3.0") diff --git a/scripted.sbt b/scripted.sbt deleted file mode 100644 index 30bb209..0000000 --- a/scripted.sbt +++ /dev/null @@ -1,9 +0,0 @@ -ScriptedPlugin.scriptedSettings -scriptedLaunchOpts := { scriptedLaunchOpts.value ++ Seq( - "-Xmx1024M", - "-XX:MaxPermSize=256M", - "-Dbintray.user=username", - "-Dbintray.pass=password", - "-Dplugin.version=" + version.value) -} -scriptedBufferLog := false diff --git a/src/main/scala-sbt-0.13/Compat.scala b/src/main/scala-sbt-0.13/Compat.scala new file mode 100644 index 0000000..05ef2b4 --- /dev/null +++ b/src/main/scala-sbt-0.13/Compat.scala @@ -0,0 +1,9 @@ +package bintray + +import sbt._ +import org.apache.ivy.plugins.resolver.DependencyResolver + +object RawRepository { + def apply(resolver: DependencyResolver): RawRepository = + new RawRepository(resolver) +} diff --git a/src/main/scala-sbt-1.0/Compat.scala b/src/main/scala-sbt-1.0/Compat.scala new file mode 100644 index 0000000..c6fe580 --- /dev/null +++ b/src/main/scala-sbt-1.0/Compat.scala @@ -0,0 +1,10 @@ +package bintray + +import scala.language.reflectiveCalls + +import sbt.librarymanagement.RawRepository + +object RawRepository { + def apply(resolver: AnyRef): RawRepository = + new RawRepository(resolver, resolver.asInstanceOf[{ def getName(): String }].getName) +} diff --git a/src/main/scala/Bintray.scala b/src/main/scala/Bintray.scala index ad96e8a..7f2050c 100644 --- a/src/main/scala/Bintray.scala +++ b/src/main/scala/Bintray.scala @@ -12,10 +12,10 @@ object Bintray { def publishTo(repo: Client#Repo, pkg: Client#Repo#Package, version: String, mvnStyle: Boolean = true, isSbtPlugin: Boolean = false, release: Boolean = false): Resolver = - if (mvnStyle) new RawRepository( + if (mvnStyle) RawRepository( BintrayMavenResolver(s"Bintray-Maven-Publish-${repo.subject}-${repo.repo}-${pkg.name}", s"https://api.bintray.com/maven/${repo.subject}/${repo.repo}/${repo.repo}", pkg, release)) - else new RawRepository( + else RawRepository( BintrayIvyResolver(s"Bintray-${if (isSbtPlugin) "Sbt" else "Ivy"}-Publish-${repo.subject}-${repo.repo}-${pkg.name}", pkg.version(version), sbt.Resolver.ivyStylePatterns.artifactPatterns, release)) diff --git a/src/sbt-test/sbt-bintray/jsonErrorTest/build.sbt b/src/sbt-test/sbt-bintray/jsonErrorTest/build.sbt new file mode 100644 index 0000000..72043f9 --- /dev/null +++ b/src/sbt-test/sbt-bintray/jsonErrorTest/build.sbt @@ -0,0 +1,31 @@ +val jsonStr = taskKey[String]("") + +// Reproduces issue: https://github.com/sbt/sbt-bintray/issues/104 +jsonStr := { + import org.json4s.JsonDSL._ + import org.json4s.native.JsonMethods + + val jsonMethods = new JsonMethods {} + jsonMethods.compact( + jsonMethods.render( + ("name" -> "randomName") ~ + ("desc" -> Option("basicDescription")) ~ + ("licenses" -> List("Apache", "MIT")) ~ + ("labels" -> List("label1", "label2")) ~ + ("vcs_url" -> Option("vcs")) + ) + ) +} + +TaskKey[Unit]("check") := { + val expected = + "{" + + """"name":"randomName",""" + + """"desc":"basicDescription",""" + + """"licenses":["Apache","MIT"],""" + + """"labels":["label1","label2"],""" + + """"vcs_url":"vcs"""" + + "}" + val found = jsonStr.value + assert(expected == found, s"Expected: $expected but found: $found") +} diff --git a/src/sbt-test/sbt-bintray/jsonErrorTest/project/plugins.sbt b/src/sbt-test/sbt-bintray/jsonErrorTest/project/plugins.sbt new file mode 100644 index 0000000..2df6fc1 --- /dev/null +++ b/src/sbt-test/sbt-bintray/jsonErrorTest/project/plugins.sbt @@ -0,0 +1,5 @@ +sys.props.get("plugin.version") match { + case Some(x) => addSbtPlugin("org.foundweekends" % "sbt-bintray" % x) + case _ => sys.error("""|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin) +} diff --git a/src/sbt-test/sbt-bintray/jsonErrorTest/test b/src/sbt-test/sbt-bintray/jsonErrorTest/test new file mode 100644 index 0000000..15675b1 --- /dev/null +++ b/src/sbt-test/sbt-bintray/jsonErrorTest/test @@ -0,0 +1 @@ +> check