h-oikawa
12/16/2017 - 2:58 PM

Nexusで自前のMavenリポジトリを建ててsbtから使用する ref: https://qiita.com/tf-oikawa/items/791b6ee4e2f08645392c

Nexusで自前のMavenリポジトリを建ててsbtから使用する ref: https://qiita.com/tf-oikawa/items/791b6ee4e2f08645392c

$ sbt publish
...
[info]  published scala-libs-sample_2.10 to http://localhost:8081/repository/my-snapshots/com/example/scala-libs-sample_2.10/0.0.1-SNAPSHOT/scala-libs-sample_2.10-0.0.1-SNAPSHOT.pom
[info]  published scala-libs-sample_2.10 to http://localhost:8081/repository/my-snapshots/com/example/scala-libs-sample_2.10/0.0.1-SNAPSHOT/scala-libs-sample_2.10-0.0.1-SNAPSHOT.jar
[info]  published scala-libs-sample_2.10 to http://localhost:8081/repository/my-snapshots/com/example/scala-libs-sample_2.10/0.0.1-SNAPSHOT/scala-libs-sample_2.10-0.0.1-SNAPSHOT-sources.jar
[info]  published scala-libs-sample_2.10 to http://localhost:8081/repository/my-snapshots/com/example/scala-libs-sample_2.10/0.0.1-SNAPSHOT/scala-libs-sample_2.10-0.0.1-SNAPSHOT-javadoc.jar
[success] Total time: 2 s, completed 2017/12/16 23:14:43
$ docker-compose logs
...
nexus3_1  | -------------------------------------------------
nexus3_1  |
nexus3_1  | Started Sonatype Nexus OSS 3.6.2-01
nexus3_1  |
nexus3_1  | -------------------------------------------------
$ docker-compose up -d
Creating network "nexus_default" with the default driver
Creating nexus_nexus3_1 ...
Creating nexus_nexus3_1 ... done
$ mkdir nexus && cd nexus
$ vim docker-compose.yml
version: '2'
services:
  nexus3:
    image: sonatype/nexus3
    volumes:
      - nexus-data:/nexus-data
    ports:
      - 8081:8081
volumes:
  nexus-data:
organization := "com.example"

name := "scala-libs-sample"

version := "0.0.1-SNAPSHOT"

////////////////////////////////////////////////////////////////////////////////////
// My Hosted Repository
val myrepos = "http://localhost:8081/"
// リポジトリ認証情報 => 後述の[~/.sbt/.credentials]の内容を読み込む
credentials += Credentials(Path.userHome / ".sbt" / ".credentials")

// リポジトリへデプロイする側の設定
publishMavenStyle := true
publishArtifact in Test := false
pomIncludeRepository := { _ => false }
publishTo := {
  if (isSnapshot.value)
    Some("snapshots" at myrepos + "repository/my-snapshots")
  else
    Some("releases"  at myrepos + "repository/my-releases")
}

// モジュールを利用する側の設定
resolvers += "Nexus" at myrepos + "repository/my-repo-group/"
libraryDependencies += "com.example" % "scala-libs-sample" % "0.0.1-SNAPSHOT"
realm=Sonatype Nexus Repository Manager
host=localhost
user=admin
password=admin123