Skip to content

Commit

Permalink
Reorganized modules and improved build
Browse files Browse the repository at this point in the history
  • Loading branch information
mgdigital committed May 9, 2019
1 parent 46c5132 commit f5fcdeb
Show file tree
Hide file tree
Showing 53 changed files with 239 additions and 113 deletions.
28 changes: 12 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,32 @@ ENV SCALA_VERSION 2.12
ENV CHROMAPRINT_VERSION 0.1.0-SNAPSHOT

RUN \
sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
apt-get update && \
apt-get -y upgrade && \
apt-get install -y \
sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list \
&& apt-get update \
&& apt-get -y upgrade \
&& apt-get install -y \
build-essential \
software-properties-common \
curl \
default-jdk \
ffmpeg \
libavcodec-extra
libavcodec-extra \
&& rm -rf /etc/apt/sources.list /tmp/*

RUN \
curl -L -o sbt-$SBT_VERSION.deb https://dl.bintray.com/sbt/debian/sbt-$SBT_VERSION.deb && \
dpkg -i sbt-$SBT_VERSION.deb && \
rm sbt-$SBT_VERSION.deb && \
apt-get update && \
apt-get install -y \
sbt
curl -L -o /tmp/sbt-$SBT_VERSION.deb https://dl.bintray.com/sbt/debian/sbt-$SBT_VERSION.deb \
&& dpkg -i /tmp/sbt-$SBT_VERSION.deb \
&& rm /tmp/sbt-$SBT_VERSION.deb

RUN mkdir /chromaprint
ADD . /chromaprint
WORKDIR /chromaprint

RUN sbt package
RUN sbt assembly
RUN sbt "; test; package; assembly"

RUN echo "#!/bin/sh\n\
set -e\n\
sh -c \"java -jar /chromaprint/target/scala-$SCALA_VERSION/chromaprint-assembly-$CHROMAPRINT_VERSION.jar \$@\"\n\
" > /docker-entrypoint.sh && \
chmod +x /docker-entrypoint.sh
" > /docker-entrypoint.sh \
&& chmod +x /docker-entrypoint.sh

ENTRYPOINT ["/docker-entrypoint.sh"]
178 changes: 157 additions & 21 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,38 +1,174 @@
import Dependencies._

ThisBuild / scalaVersion := "2.12.8"
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / organization := "com.mgdigital"
ThisBuild / organizationName := "chromaprint"

lazy val root = (project in file("."))
.settings(
name := "chromaprint",
lazy val commonSettings = Seq(
version := "0.1.0-SNAPSHOT",
organization := "com.mgdigital",
organizationName := "chromaprint",
scalaVersion := "2.12.8",
crossScalaVersions := Seq("2.8.2", "2.9.3", "2.10.7", "2.11.12"),
resolvers ++=
Seq(
Resolver.mavenCentral,
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")
),
parallelExecution in Test := false,
sourceDirectory := baseDirectory.value,
target := baseDirectory.value / ".." / ".." / "target" / "modules" / name.value,
artifactName := { (_, module, artifact) =>
organizationName.value + "-" + artifact.name + "-" + module.revision + "." + artifact.extension
}
)

lazy val dependencies = new {
val versions =
new {
val spire = "0.13.0"
val scopt = "4.0.0-RC2"
val sttp = "1.5.15"
val playJson = "2.7.2"
val jflacCodec = "1.5.2"
val tritonusShare = "0.3.7.4"
val tritonusAll = "0.3.7.2"
val breeze = "0.13.2"
val javaCppPresets = "1.4"
val javaCpp = javaCppPresets + ".3"
val javaCppFftw = "3.3.7"
val scalaTest = "3.0.5"
}

val spire = "org.spire-math" %% "spire" % versions.spire
val scopt = "com.github.scopt" %% "scopt" % versions.scopt
val sttp = "com.softwaremill.sttp" %% "core" % versions.sttp
val playJson = "com.typesafe.play" %% "play-json" % versions.playJson
val breezeCore = "org.scalanlp" %% "breeze" % versions.breeze
val breezeNatives = "org.scalanlp" %% "breeze-natives" % versions.breeze % Optional
val scalaTest = "org.scalatest" %% "scalatest" % versions.scalaTest % Test

val jflacCodec = "org.jflac" % "jflac-codec" % versions.jflacCodec % Optional
val tritonusShare = "com.googlecode.soundlibs" % "tritonus-share" % versions.tritonusShare % Optional
val tritonusAll = "com.googlecode.soundlibs" % "tritonus-all" % versions.tritonusAll % Optional

val codecs = Seq(
jflacCodec,
tritonusShare,
tritonusAll
)
}

lazy val mapAll = "runtime->runtime;test->test;compile->compile"

lazy val core = (project in file("./src/core"))
.settings(
name := "core",
commonSettings,
libraryDependencies ++= Seq(
"org.scalanlp" %% "breeze" % "0.13.2",
"org.scalanlp" %% "breeze-natives" % "0.13.2",
"com.googlecode.soundlibs" % "mp3spi" % "1.9.5.4",
"org.jflac" % "jflac-codec" % "1.5.2",
"com.googlecode.soundlibs" % "tritonus-share" % "0.3.7.4",
"com.googlecode.soundlibs" % "tritonus-all" % "0.3.7.2",
"com.github.scopt" %% "scopt" % "4.0.0-RC2",
"com.softwaremill.sttp" %% "core" % "1.5.15",
"com.typesafe.play" %% "play-json" % "2.7.2",
scalaTest % Test
dependencies.spire,
dependencies.scalaTest
)
).disablePlugins(org.bytedeco.sbt.javacpp.Plugin, AssemblyPlugin)

lazy val acoustid = (project in file("./src/acoustid"))
.settings(
name := "acoustid",
commonSettings,
libraryDependencies ++= Seq(
dependencies.sttp,
dependencies.playJson
)
)
.disablePlugins(org.bytedeco.sbt.javacpp.Plugin, AssemblyPlugin)
.dependsOn(core % mapAll)

lazy val cli = (project in file("./src/cli"))
.settings(
name := "cli",
commonSettings,
libraryDependencies ++= Seq(
dependencies.scopt
)
)
.disablePlugins(org.bytedeco.sbt.javacpp.Plugin, AssemblyPlugin)
.dependsOn(
core % mapAll,
acoustid % mapAll
)

lazy val breeze = (project in file("./src/breeze"))
.settings(
name := "breeze",
commonSettings,
libraryDependencies ++= Seq(
dependencies.breezeCore,
dependencies.breezeNatives
),
parallelExecution in Test := false,
dependencyOverrides ++= Seq(
dependencies.spire
)
)
.disablePlugins(org.bytedeco.sbt.javacpp.Plugin, AssemblyPlugin)
.dependsOn(core % mapAll)

lazy val fftw = (project in file("./src/fftw"))
.settings(
name := "fftw",
commonSettings,
javaCppPresetLibs := Seq(
"fftw" -> "3.3.7"
),
javaCppVersion := "1.4.4"
)
.disablePlugins(AssemblyPlugin)
.dependsOn(core % mapAll)

lazy val dist = (project in file("./src/dist"))
.settings(
name := "dist",
commonSettings,
libraryDependencies ++= dependencies.codecs,
target := baseDirectory.value / ".." / ".." / "target",
unmanagedSourceDirectories in Compile ++= Seq("core", "acoustid", "cli", "breeze")
.map(baseDirectory.value / ".." / _ / "main" / "scala"),
artifactName := { (_, module, artifact) =>
organizationName.value + "-" + module.revision + "." + artifact.extension
},
assemblyMergeStrategy in assembly := {
case PathList("META-INF", "MANIFEST.MF") =>
MergeStrategy.discard
case PathList("META-INF", _*) =>
MergeStrategy.concat
case _ =>
MergeStrategy.deduplicate
},
assemblyJarName in assembly := s"${organizationName.value}-assembly-${version.value}.jar"
)
.disablePlugins(org.bytedeco.sbt.javacpp.Plugin)
.aggregate(core, acoustid, cli, breeze)
.dependsOn(
core % mapAll,
acoustid % mapAll,
cli % mapAll,
breeze % mapAll
)

lazy val root = (project in file("."))
.settings(
name := "root",
commonSettings,
libraryDependencies ++= dependencies.codecs,
unmanagedSourceDirectories in Compile ++= Seq("core", "acoustid", "cli", "breeze", "dist", "fftw")
.map(baseDirectory.value / "src" / _ / "main" / "scala"),
target := baseDirectory.value / "target" / name.value,
mainClass in (Compile, run) := Some("chromaprint.Main")
)
.disablePlugins(org.bytedeco.sbt.javacpp.Plugin)
.aggregate(core, acoustid, cli, breeze, fftw, dist)
.dependsOn(
core % mapAll,
acoustid % mapAll,
cli % mapAll,
breeze % mapAll,
fftw % mapAll,
dist % mapAll
)

// Uncomment the following for publishing to Sonatype.
// See https://www.scala-sbt.org/1.x/docs/Using-Sonatype.html for more detail.
Expand Down
5 changes: 0 additions & 5 deletions project/Dependencies.scala

This file was deleted.

1 change: 0 additions & 1 deletion project/assembly.sbt

This file was deleted.

1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
addSbtPlugin("org.bytedeco" % "sbt-javacpp" % "1.13")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chromaprint.acoustid

import chromaprint.core.Fingerprint
import chromaprint.Fingerprint

import com.softwaremill.sttp.Uri
import com.softwaremill.sttp.quick._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package chromaprint.breeze

import breeze.linalg.DenseVector
import breeze.signal.fourierTr
import chromaprint.core.{FFT => CoreFFT}
import chromaprint.FFT

object FFT extends CoreFFT {
object FFTImpl extends FFT {

import CoreFFT._
import FFT._

def computeFrames(input: Seq[Vector[Double]]): Seq[Vector[Complex]] =
input.map(computeFrame)
Expand Down
8 changes: 8 additions & 0 deletions src/breeze/test/scala/chromaprint/breeze/FFTImplSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package chromaprint.breeze

import chromaprint.AbstractFFTSpec

class FFTImplSpec extends AbstractFFTSpec {

val fftImpl: chromaprint.FFT = FFTImpl
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package chromaprint.fpcalc
package chromaprint.cli

import java.io.File

import chromaprint.core.{AudioSource,Config,FFT,fingerprinter,Presets}
import chromaprint.{Config,Presets,AudioSource,FFT,fingerprinter}
import chromaprint.acoustid.lookup

object Command {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

import scala.language.implicitConversions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

object Base64 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

import scala.math.log

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

import Classifier.{Filter,Quantizer}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

object Config {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

object FFT {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

import spire.math.UInt

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

object Image {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

final case class MovingAverage (window: Int, data: List[Short] = List.empty) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

object Presets {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

import spire.math.UShort

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

object chromaFilter {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

import scala.math.sqrt

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

import spire.math.UInt

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

import spire.math.UInt

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chromaprint.core
package chromaprint

import spire.math.{UInt, UShort}

Expand Down
Loading

0 comments on commit f5fcdeb

Please sign in to comment.