Skip to content

Commit 79e8c25

Browse files
authored
Merge pull request #36 from allenai/sbt-codeartifact
Sbt codeartifact
2 parents ebe3ea0 + 5c31ff4 commit 79e8c25

File tree

16 files changed

+147
-123
lines changed

16 files changed

+147
-123
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
docker:
66
- image: openjdk:8
77
environment:
8-
SBT_VERSION: 1.2.8
8+
SBT_VERSION: 1.4.9
99
steps:
1010
- run: echo 'export ARTIFACT_BUILD=$CIRCLE_PROJECT_REPONAME-$CIRCLE_BUILD_NUM.zip' >> $BASH_ENV
1111
- run:
@@ -25,7 +25,7 @@ jobs:
2525
command: cat /dev/null | sbt clean
2626
- run:
2727
name: Test package (only integration tests)
28-
command: cat /dev/null | sbt +test
28+
command: cat /dev/null | sbt +it:test
2929
- run:
3030
name: Check formatting
3131
command: cat /dev/null | sbt scalafmtCheckAll

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@
44
.settings
55
bin/
66
target/
7+
.bloop/
8+
.bsp/
9+
.metals/
10+
.vscode/
11+
project/metals.sbt
12+
project/project/

README.md

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
1-
datastore
2-
======
1+
# datastore
32

43
**Boss**: Dirk
54

65
A thin wrapper over S3 that stores and retrieves immutable data in S3 and supports versioning.
76

87
The real READMEs are [here for the API](datastore/README.md) and [here for the CLI](datastore-cli/README.md).
98

10-
### Releasing
9+
## Releasing
1110

12-
This project releases to BinTray. To make a release:
11+
This project releases to CodeArtifact. To make a release, simply run:
1312

14-
1. Pull the latest code on the master branch that you want to release
15-
1. Edit `build.sbt` to remove "-SNAPSHOT" from the current version
16-
1. Create a pull request if desired or push to master if you are only changing the version
17-
1. Tag the release `git tag -a vX.Y.Z -m "Release X.Y.Z"` replacing X.Y.Z with the correct version
18-
1. Push the tag back to origin `git push origin vX.Y.Z`
19-
1. Release the build on Bintray `sbt +publish` (the "+" is required to cross-compile)
20-
1. Verify publication [on bintray.com](https://bintray.com/allenai/maven)
21-
1. Bump the version in `build.sbt` on master (and push!) with X.Y.Z+1-SNAPSHOT (e.g., 2.5.1
22-
-SNAPSHOT after releasing 2.5.0)
23-
24-
If you make a mistake you can rollback the release with `sbt bintrayUnpublish` and retag the
25-
version to a different commit as necessary.
13+
```bash
14+
sbt release
15+
```

build.sbt

Lines changed: 13 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,13 @@
1-
import Dependencies._
2-
3-
lazy val scala211 = "2.11.12"
4-
lazy val scala212 = "2.12.9"
5-
lazy val scala213 = "2.13.0" // Not supported yet (collections changes required in common)
6-
lazy val supportedScalaVersions = List(scala212, scala211)
7-
8-
ThisBuild / organization := "org.allenai.datastore"
9-
ThisBuild / scalaVersion := scala212
10-
ThisBuild / version := "2.0.0"
11-
12-
lazy val projectSettings = Seq(
13-
crossScalaVersions := supportedScalaVersions,
14-
resolvers ++= Seq(Resolver.bintrayRepo("allenai", "maven")),
15-
dependencyOverrides ++= Logging.loggingDependencyOverrides,
16-
publishMavenStyle := true,
17-
publishArtifact in Test := false,
18-
pomIncludeRepository := { _ => false },
19-
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html")),
20-
homepage := Some(url("https://github.com/allenai/datastore")),
21-
scmInfo := Some(ScmInfo(
22-
url("https://github.com/allenai/datastore"),
23-
"https://github.com/allenai/datastore.git")),
24-
pomExtra := (
25-
<developers>
26-
<developer>
27-
<id>allenai-dev-role</id>
28-
<name>Allen Institute for Artificial Intelligence</name>
29-
<email>dev-role@allenai.org</email>
30-
</developer>
31-
</developers>),
32-
bintrayPackage := s"${organization.value}:${name.value}_${scalaBinaryVersion.value}",
33-
bintrayOrganization := Some("allenai"),
34-
bintrayRepository := "maven"
35-
)
36-
37-
inConfig(IntegrationTest)(org.scalafmt.sbt.ScalafmtPlugin.scalafmtConfigSettings)
38-
39-
lazy val root = (project in file("."))
40-
.aggregate(
41-
datastore,
42-
cli
43-
)
44-
.configs(IntegrationTest)
45-
.settings(
46-
crossScalaVersions := Nil,
47-
publish / skip := true
48-
)
49-
50-
lazy val datastore = (project in file("datastore"))
51-
.settings(
52-
Defaults.itSettings,
53-
projectSettings
54-
)
55-
.configs(IntegrationTest)
56-
57-
lazy val cli = (project in file("datastore-cli"))
58-
.settings(
59-
Defaults.itSettings,
60-
projectSettings
61-
)
62-
.dependsOn(datastore)
63-
.configs(IntegrationTest)
1+
lazy val datastore = project
2+
.in(file("datastore"))
3+
.settings(Release.publishSettings)
4+
5+
lazy val cli = project
6+
.in(file("datastore-cli"))
7+
.settings(Release.publishSettings)
8+
.dependsOn(datastore)
9+
10+
lazy val root = project
11+
.in(file("."))
12+
.aggregate(datastore, cli)
13+
.settings(Release.noPublishSettings)

datastore-cli/src/main/scala/org/allenai/datastore/cli/DownloadApp.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ object DownloadApp extends App {
1313
)
1414

1515
val parser = new scopt.OptionParser[Options]("scopt") {
16-
opt[Boolean]("assumeFile") action { (f, c) =>
16+
opt[Boolean]("assumeFile").action { (f, c) =>
1717
c.copy(assumeFile = f)
1818
} text ("Assumes that the object in the datastore is a file.")
1919

20-
opt[Boolean]("assumeDirectory") action { (d, c) =>
20+
opt[Boolean]("assumeDirectory").action { (d, c) =>
2121
c.copy(assumeDirectory = d)
2222
} text ("Assumes that the object in the datastore is a directory.")
2323

@@ -34,19 +34,19 @@ object DownloadApp extends App {
3434
"whether the object in the datastore is a file or a directory."
3535
)
3636

37-
opt[String]('g', "group") required () action { (g, c) =>
37+
opt[String]('g', "group").required().action { (g, c) =>
3838
c.copy(group = g)
3939
} text ("Group name of the object in the datastore")
4040

41-
opt[String]('n', "name") required () action { (n, c) =>
41+
opt[String]('n', "name").required().action { (n, c) =>
4242
c.copy(name = n)
4343
} text ("Name of the object in the datastore")
4444

45-
opt[Int]('v', "version") required () action { (v, c) =>
45+
opt[Int]('v', "version").required().action { (v, c) =>
4646
c.copy(version = v)
4747
} text ("Version number of the object in the datastore")
4848

49-
opt[String]('d', "datastore") action { (d, c) =>
49+
opt[String]('d', "datastore").action { (d, c) =>
5050
c.copy(datastore = Some(Datastore(d)))
5151
} text (s"Datastore to use. Default is ${Datastore.defaultName}")
5252

datastore-cli/src/main/scala/org/allenai/datastore/cli/UploadApp.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,35 @@ object UploadApp extends App {
1515
)
1616

1717
val parser = new scopt.OptionParser[Options]("scopt") {
18-
opt[File]('p', "path") required () action { (p, c) =>
18+
opt[File]('p', "path").required().action { (p, c) =>
1919
c.copy(path = p)
2020
} text ("Path to the file or directory you want uploaded")
2121

22-
opt[String]('g', "group") required () action { (g, c) =>
22+
opt[String]('g', "group").required().action { (g, c) =>
2323
c.copy(group = g)
2424
} text ("Group name to store the file or directory under")
2525

26-
opt[String]('n', "name") required () action { (n, c) =>
26+
opt[String]('n', "name").required().action { (n, c) =>
2727
c.copy(name = n)
2828
} text ("Name to store the file or directory under")
2929

30-
opt[Int]('v', "version") required () action { (v, c) =>
30+
opt[Int]('v', "version").required().action { (v, c) =>
3131
c.copy(version = v)
3232
} text ("Version number to store the file or directory under")
3333

34-
opt[String]('d', "datastore") action { (d, c) =>
34+
opt[String]('d', "datastore").action { (d, c) =>
3535
c.copy(datastore = Some(Datastore(d)))
3636
} text (s"Datastore to use. Default is ${Datastore.defaultName}")
3737

38-
opt[Boolean]("overwrite") action { (_, c) =>
38+
opt[Boolean]("overwrite").action { (_, c) =>
3939
c.copy(overwrite = true)
4040
} text ("Overwrite if the group, version, and name already exists")
4141

4242
help("help")
4343
}
4444

4545
Common.handleDatastoreExceptions {
46-
parser.parse(args, Options()) foreach { config =>
46+
parser.parse(args, Options()).foreach { config =>
4747
val datastore = config.datastore.getOrElse {
4848
Common.printDefaultDatastoreWarning()
4949
Datastore

datastore-cli/src/main/scala/org/allenai/datastore/cli/UrlApp.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ object UrlApp extends App {
1313
)
1414

1515
val parser = new scopt.OptionParser[Options]("scopt") {
16-
opt[Boolean]("assumeFile") action { (f, c) =>
16+
opt[Boolean]("assumeFile").action { (f, c) =>
1717
c.copy(assumeFile = f)
1818
} text ("Assumes that the object in the datastore is a file.")
1919

20-
opt[Boolean]("assumeDirectory") action { (d, c) =>
20+
opt[Boolean]("assumeDirectory").action { (d, c) =>
2121
c.copy(assumeDirectory = d)
2222
} text ("Assumes that the object in the datastore is a directory.")
2323

@@ -34,27 +34,27 @@ object UrlApp extends App {
3434
"whether the object in the datastore is a file or a directory."
3535
)
3636

37-
opt[String]('g', "group") required () action { (g, c) =>
37+
opt[String]('g', "group").required().action { (g, c) =>
3838
c.copy(group = g)
3939
} text ("Group name of the object in the datastore")
4040

41-
opt[String]('n', "name") required () action { (n, c) =>
41+
opt[String]('n', "name").required().action { (n, c) =>
4242
c.copy(name = n)
4343
} text ("Name of the object in the datastore")
4444

45-
opt[Int]('v', "version") required () action { (v, c) =>
45+
opt[Int]('v', "version").required().action { (v, c) =>
4646
c.copy(version = v)
4747
} text ("Version number of the object in the datastore")
4848

49-
opt[String]('d', "datastore") action { (d, c) =>
49+
opt[String]('d', "datastore").action { (d, c) =>
5050
c.copy(datastore = Some(Datastore(d)))
5151
} text (s"Datastore to use. Default is ${Datastore.defaultName}")
5252

5353
help("help")
5454
}
5555

5656
Common.handleDatastoreExceptions {
57-
parser.parse(args, Options()) foreach { config =>
57+
parser.parse(args, Options()).foreach { config =>
5858
val datastore = config.datastore.getOrElse {
5959
Common.printDefaultDatastoreWarning()
6060
Datastore

datastore/build.sbt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import Dependencies._
33
name := "datastore"
44

55
libraryDependencies ++= Seq(
6-
awsJavaSdk exclude("commons-logging", "commons-logging"),
6+
awsJavaSdk exclude ("commons-logging", "commons-logging"),
77
commonsIO,
88
allenAiCommon,
99
allenAiTestkit % "test,it",
1010
Logging.logbackClassic,
1111
Logging.logbackCore,
1212
Logging.slf4jApi,
13-
"org.slf4j" % "jcl-over-slf4j" % Logging.slf4jVersion)
13+
"org.slf4j" % "jcl-over-slf4j" % Logging.slf4jVersion
14+
)
1415

1516
fork in IntegrationTest := true

datastore/src/main/scala/org/allenai/datastore/Datastore.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import org.apache.commons.io.FileUtils
1919
import org.slf4j.LoggerFactory
2020
import ch.qos.logback.classic.Level
2121

22+
import scala.collection.compat._
2223
import scala.collection.JavaConverters._
2324
import scala.util.control.NonFatal
2425
import scala.util.Random
@@ -684,7 +685,7 @@ class Datastore(val name: String, val s3: AmazonS3Client) extends Logging {
684685
getAllListings(listObjectsRequest)
685686
.flatMap(_.getCommonPrefixes.asScala)
686687
.map(_.stripSuffix("/"))
687-
.to[collection.SortedSet]
688+
.to(collection.SortedSet)
688689
}
689690

690691
/** Lists all items in a group
@@ -706,7 +707,7 @@ class Datastore(val name: String, val s3: AmazonS3Client) extends Logging {
706707
.map { os =>
707708
Locator.fromKey(os.getKey)
708709
}
709-
.to[collection.SortedSet]
710+
.to(collection.SortedSet)
710711
}
711712

712713
//

project/Dependencies.scala

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import sbt._
22

33
object Dependencies {
4-
val allenAiCommon = "org.allenai.common" %% "common-core" % "2.0.0"
5-
val allenAiTestkit = "org.allenai.common" %% "common-testkit" % "2.0.0"
4+
val scalaCollectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.4.3"
5+
6+
val commonVersion = "2.3.1"
7+
val allenAiCommon = "org.allenai.common" %% "common-core" % commonVersion
8+
val allenAiTestkit = "org.allenai.common" %% "common-testkit" % commonVersion
69

710
val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.11.4"
811
val scalaTest = "org.scalatest" %% "scalatest" % "3.0.8"
@@ -44,19 +47,19 @@ object Dependencies {
4447
// Exclude the transitive dependencies that might mess things up for us.
4548
// slf4j replaces log4j.
4649
(module
47-
exclude ("log4j", "log4j")
48-
exclude ("commons-logging", "commons-logging")
49-
// We're using logback as the slf4j implementation, and we're providing it below.
50-
exclude ("org.slf4j", "slf4j-log4j12")
51-
exclude ("org.slf4j", "slf4j-jdk14")
52-
exclude ("org.slf4j", "slf4j-jcl")
53-
exclude ("org.slf4j", "slf4j-simple")
54-
// We'll explicitly provide the logback version; this avoids having to do an override.
55-
exclude ("ch.qos.logback", "logback-core")
56-
exclude ("ch.qos.logback", "logback-classic")
57-
// We add bridges explicitly as well
58-
exclude ("org.slf4j", "log4j-over-slf4j")
59-
exclude ("org.slf4j", "jcl-over-slf4j"))
50+
exclude ("log4j", "log4j")
51+
exclude ("commons-logging", "commons-logging")
52+
// We're using logback as the slf4j implementation, and we're providing it below.
53+
exclude ("org.slf4j", "slf4j-log4j12")
54+
exclude ("org.slf4j", "slf4j-jdk14")
55+
exclude ("org.slf4j", "slf4j-jcl")
56+
exclude ("org.slf4j", "slf4j-simple")
57+
// We'll explicitly provide the logback version; this avoids having to do an override.
58+
exclude ("ch.qos.logback", "logback-core")
59+
exclude ("ch.qos.logback", "logback-classic")
60+
// We add bridges explicitly as well
61+
exclude ("org.slf4j", "log4j-over-slf4j")
62+
exclude ("org.slf4j", "jcl-over-slf4j"))
6063
}
6164
}
6265
// Now, add the logging libraries.

project/GlobalPlugin.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import Dependencies._
2+
3+
import sbt._
4+
import Keys._
5+
import codeartifact.CodeArtifactKeys
6+
7+
object GlobalPlugin extends AutoPlugin {
8+
override def trigger = allRequirements
9+
10+
override def projectConfigurations: Seq[Configuration] = Seq(IntegrationTest)
11+
12+
override def projectSettings =
13+
Defaults.itSettings ++ inConfig(IntegrationTest)(
14+
org.scalafmt.sbt.ScalafmtPlugin.scalafmtConfigSettings
15+
) ++ Seq(
16+
organization := "org.allenai.datastore",
17+
scalaVersion := ScalaVersions.SCALA_213,
18+
CodeArtifactKeys.codeArtifactUrl := "https://org-allenai-s2-896129387501.d.codeartifact.us-west-2.amazonaws.com/maven/private",
19+
fork in Test := true,
20+
libraryDependencies += scalaCollectionCompat,
21+
dependencyOverrides ++= Logging.loggingDependencyOverrides
22+
)
23+
}

0 commit comments

Comments
 (0)