Skip to content
This repository was archived by the owner on Jun 6, 2018. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions plugin/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ name := "sbtix"
organization := "se.nullable.sbtix"
version := "0.2-SNAPSHOT"

addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M15-1")
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.3")

ScriptedPlugin.scriptedSettings
scriptedLaunchOpts ++= Seq(
s"-Dplugin.version=${version.value}"
)
Expand Down
20 changes: 10 additions & 10 deletions plugin/nix-exprs/sbtix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let sbtTemplate = repoDefs: versioning:
# http://www.scala-sbt.org/0.13.5/docs/Launcher/Configuration.html
sbtixRepos = writeText "sbtixRepos" ''
[repositories]
${concatStringsSep "\n " repoDefs}
${concatStringsSep "\n " repoDefs}
local
'';
in stdenv.mkDerivation (rec {
Expand Down Expand Up @@ -52,7 +52,7 @@ let sbtTemplate = repoDefs: versioning:

buildInputs = [ jdk sbt ];

buildPhase = ''sbt compile:compileIncremental'';
buildPhase = ''sbt update'';

installPhase =''
mkdir -p $out
Expand Down Expand Up @@ -119,8 +119,8 @@ in rec {
# http://www.scala-sbt.org/0.13.5/docs/Launcher/Configuration.html
sbtixRepos = writeText "sbtixRepos" ''
[repositories]
${concatStringsSep "\n " (map (d: "${d.name}: file://${d}, ${ivyRepoPattern}") builtDependencies)}
${concatStringsSep "\n " repoDefs}
${concatStringsSep "\n " (map (d: "${d.name}: file://${d}, ${ivyRepoPattern}") builtDependencies)}
${concatStringsSep "\n " repoDefs}
local
'';

Expand All @@ -131,12 +131,12 @@ in rec {
# COURSIER_CACHE env variable is needed if one wants to use non-sbtix repositories in the below repo list, which is sometimes useful.
COURSIER_CACHE = "./.coursier/cache/v1";

configurePhase = ''
cp -Lr ${sbtSetupTemplate}/ivy ./.ivy2
cp -Lr ${sbtSetupTemplate}/sbt ./.sbt
chmod -R 755 ./.ivy2/
chmod -R 755 ./.sbt/
'';
# configurePhase = ''
# cp -Lr ${sbtSetupTemplate}/ivy ./.ivy2
# cp -Lr ${sbtSetupTemplate}/sbt ./.sbt
# chmod -R 755 ./.ivy2/
# chmod -R 755 ./.sbt/
# '';

# set environment variable to affect all SBT commands
SBT_OPTS = ''
Expand Down
2 changes: 1 addition & 1 deletion plugin/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.16
sbt.version=1.1.4
6 changes: 4 additions & 2 deletions plugin/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value

addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M15-1")
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.3")

resolvers += Resolver.typesafeIvyRepo("releases")

// addSbtPlugin("se.nullable.sbtix" % "sbtix" % "0.2-SNAPSHOT")
1 change: 1 addition & 0 deletions plugin/project/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// addSbtPlugin("se.nullable.sbtix" % "sbtix" % "0.2-SNAPSHOT")
1,908 changes: 1,344 additions & 564 deletions plugin/project/repo.nix

Large diffs are not rendered by default.

1,988 changes: 1,406 additions & 582 deletions plugin/repo.nix

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import scalaz.concurrent.Task

import scalaz.{ -\/, \/-, EitherT }
import java.util.concurrent.ConcurrentSkipListSet
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._
import java.util.concurrent.ExecutorService
import scala.concurrent.duration.Duration
import scala.util.control.NonFatal
import java.nio.file.{ StandardCopyOption, Files => NioFiles }
case class GenericModule(primaryArtifact: Artifact, dep: Dependency, localFile: java.io.File) {
private val isIvy = localFile.getParentFile().getName() == "jars"
private val moduleId = ToSbt.moduleId(dep)
private val moduleId = ToSbt.moduleId(dep, Map())
val url = new URL(primaryArtifact.url)

private val authedUri = authed(url)
Expand Down Expand Up @@ -89,7 +89,7 @@ class CoursierArtifactFetcher(logger: Logger, resolvers: Set[Resolver], credenti
val mods = mods1.flatten

//remove metaArtifacts that we already have a module for. We do not need to look them up twice.
val metaArtifacts = metaArtifactCollector.toSet.filterNot { meta =>mods.exists { meta.matchesGenericModule} }
val metaArtifacts = metaArtifactCollector.asScala.toSet.filterNot { meta =>mods.exists { meta.matchesGenericModule} }

//object to work with the rootUrl of Resolvers
val nixResolver = resolvers.map(NixResolver.resolve)
Expand Down
31 changes: 8 additions & 23 deletions plugin/src/main/scala/se/nullable/sbtix/FindArtifacts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,27 @@ import java.security.MessageDigest
import java.util.concurrent.Semaphore

import sbt.Logger
import sun.misc.IOUtils

import scala.util.{Failure, Success, Try}

object FindArtifactsOfRepo {
private val semaphore = new Semaphore(4, false)

def fetchChecksum(originalUrl: String, artifactType: String, url: URL): Try[String] = {
semaphore.acquireUninterruptibly()
val checksum = calculateChecksum(url)
semaphore.release()

checksum
}
def fetchChecksum(originalUrl: String, artifactType: String, url: URL): Try[String] =
calculateChecksum(url)

private def calculateChecksum(url: URL): Try[String] = {
val tmpFile = File.createTempFile(s"sbtix-${url.toString}", ".tmp")
val path = tmpFile.toPath

try {
val hash = MessageDigest getInstance "SHA-256"
val input = url.openConnection.getInputStream
val w = new FileOutputStream(tmpFile)

Stream.continually(input.read).takeWhile(_ != -1).foreach(w.write)

hash update (Files readAllBytes path)
input.close()

Files.delete(path)

val is = url.openConnection.getInputStream()
val input = IOUtils.readFully(is, -1, true)
is.close()
Success {
hash.digest() map { "%02X" format _ } mkString
hash.digest(input) map { "%02X" format _ } mkString
}
} catch { case e: IOException =>
Files.delete(path)
Failure(e)
Failure(e)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/scala/se/nullable/sbtix/NixPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object NixPlugin extends AutoPlugin {
+ scalaCompilerBridgeSource.value
-- projectDependencies.value)

val depends = modules.flatMap(coursier.FromSbt.dependencies(_, scalaVersion.value, scalaBinaryVersion.value, "jar")).map(_._2)
val depends = modules.flatMap(coursier.FromSbt.dependencies(_, scalaVersion.value, scalaBinaryVersion.value)).map(_._2)
.filterNot {
_.module.organization == "se.nullable.sbtix"
} //ignore the sbtix dependency that gets added because of the global sbtix plugin
Expand Down
3 changes: 1 addition & 2 deletions plugin/src/main/scala/se/nullable/sbtix/NixResolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ object NixResolver {
NixResolver(ivy.name, root, Some(pattern))
case mvn: MavenRepository => NixResolver(mvn.name, mvn.root, None)
case cr: ChainedResolver => ???
case jn1: JavaNet1Repository => ???
case raw: RawRepository => ???
}

Expand Down Expand Up @@ -44,4 +43,4 @@ case class NixResolver(private val name: String, rootUrl: String, pattern: Optio
case metas => Some((nixRepo, finder.findMetaArtifacts(logger, metas)))
}
}
}
}
2 changes: 1 addition & 1 deletion sbtix-tool.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let
];

installPhase =''
sbt publish-local
sbt publishLocal
mkdir -p $out/plugin-repo
cp ./.ivy2/local/* $out/plugin-repo -r
'';
Expand Down