Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6385aad

Browse files
author
Martin Hansen
committedMay 5, 2020
add managed sqlite dependency, rm sqlite binaries, rm obsolete doc
1 parent ce5a7fb commit 6385aad

9 files changed

+62
-8
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
.wercker
88
project/target
99
project/project
10+
lib_managed*/

‎README.md

-7
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,5 @@ The following Java system properties are available for configuration.
108108
- `aws.dynamodb.endpoint` endpoint to use for accessing the DynamoDB API.
109109
- `aws.sts.endpoint` endpoint to use for accessing the STS API when assuming the role indicated by the `roleArn` parameter.
110110

111-
## Running Unit Tests
112-
The unit tests are dependent on the AWS DynamoDBLocal client, which in turn is dependent on [sqlite4java](https://bitbucket.org/almworks/sqlite4java/src/master/). I had some problems running this on OSX, so I had to put the library directly in the /lib folder, as graciously explained in [this Stack Overflow answer](https://stackoverflow.com/questions/34137043/amazon-dynamodb-local-unknown-error-exception-or-failure/35353377#35353377).
113-
114-
In order to run the tests, make sure to put the following as additional VM parameters:
115-
116-
```-Djava.library.path=./lib/sqlite4java -Daws.dynamodb.endpoint=http://localhost:8000```
117-
118111
## Acknowledgements
119112
Usage of parallel scan and rate limiter inspired by work in https://github.com/traviscrawford/spark-dynamodb

‎build.sbt

+61-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,68 @@ libraryDependencies ++= {
3333
)
3434
}
3535

36+
libraryDependencies += "com.almworks.sqlite4java" % "sqlite4java" % "1.0.392" % "test"
37+
38+
retrieveManaged := true
39+
3640
fork in Test := true
37-
javaOptions in Test ++= Seq("-Djava.library.path=./lib/sqlite4java", "-Daws.dynamodb.endpoint=http://localhost:8000")
41+
42+
val libManaged = "lib_managed"
43+
val libManagedSqlite = s"${libManaged}_sqlite4java"
44+
45+
javaOptions in Test ++= Seq(s"-Djava.library.path=./$libManagedSqlite", "-Daws.dynamodb.endpoint=http://localhost:8000")
46+
47+
/**
48+
* Put all sqlite4java dependencies in [[libManagedSqlite]] for easy reference when configuring java.library.path.
49+
*/
50+
Test / resourceGenerators += Def.task {
51+
import java.nio.file.{Files, Path}
52+
import java.util.function.Predicate
53+
import java.util.stream.Collectors
54+
import scala.collection.JavaConverters._
55+
56+
def log(msg: Any) = println(s"[℣₳ℒ𐎅] $msg") //stand out in the crowd
57+
58+
val theOnesWeLookFor = Set(
59+
"libsqlite4java-linux-amd64-1.0.392.so",
60+
"libsqlite4java-linux-i386-1.0.392.so ",
61+
"libsqlite4java-osx-1.0.392.dylib ",
62+
"sqlite4java-1.0.392.jar ",
63+
"sqlite4java-win32-x64-1.0.392.dll ",
64+
"sqlite4java-win32-x86-1.0.392.dll "
65+
).map(_.trim)
66+
67+
val isOneOfTheOnes = new Predicate[Path] {
68+
override def test(p: Path) = theOnesWeLookFor exists (p endsWith _)
69+
}
70+
71+
val theOnesWeCouldFind: Set[Path] = Files
72+
.walk(new File(libManaged).toPath)
73+
.filter(isOneOfTheOnes)
74+
.collect(Collectors.toSet[Path])
75+
.asScala.toSet
76+
77+
theOnesWeCouldFind foreach { path =>
78+
log(s"found: ${path.toFile.getName}")
79+
}
80+
81+
assert(theOnesWeCouldFind.size == theOnesWeLookFor.size)
82+
83+
val libManagedSqliteDir = new File(s"$libManagedSqlite")
84+
sbt.IO delete libManagedSqliteDir
85+
sbt.IO createDirectory libManagedSqliteDir
86+
log(libManagedSqliteDir.getAbsolutePath)
87+
88+
theOnesWeCouldFind
89+
.map { path =>
90+
val source: File = path.toFile
91+
val target: File = libManagedSqliteDir / source.getName
92+
log(s"copying from $source to $target")
93+
sbt.IO.copyFile(source, target)
94+
target
95+
}
96+
.toSeq
97+
}.taskValue
3898

3999
/**
40100
* Maven specific settings for publishing to Maven central.
-881 KB
Binary file not shown.
-866 KB
Binary file not shown.
-1.6 MB
Binary file not shown.
-668 KB
Binary file not shown.
-517 KB
Binary file not shown.

‎lib/sqlite4java/sqlite4java.jar

-129 KB
Binary file not shown.

0 commit comments

Comments
 (0)
This repository has been archived.