Skip to content
Open
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
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
.idea
project
target
logs
project/project
project/target
target
logs/
tmp
.history
dist
Expand Down
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: scala
script:
- sbt clean compile test publishLocal
- cd sample/java && sbt clean compile test
- sbt clean compile test

jdk:
- oraclejdk8
scala:
- 2.12.4
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ object ApplicationBuild extends Build {

val appDependencies = Seq(
// Add your project dependencies here,
javaCore,
javaJdbc,
"com.edulify" %% "geolocation" % "2.1.0"
)

Expand All @@ -84,13 +82,13 @@ object ApplicationBuild extends Build {
Since there is support to Freegeoip and Maxmind, there is also two modules that you enable, depending on which one you want to use. To eanble the module, just add the following line to you `conf/application.conf` file:

```
play.modules.enabled += "com.edulify.modules.geolocation.providers.FreegeoipModule"
play.modules.enabled += "com.edulify.modules.geolocation.FreegeoipModule"
```

Or, in case you want to use Maxmind instead:

```
play.modules.enabled += "com.edulify.modules.geolocation.providers.MaxmindModule"
play.modules.enabled += "com.edulify.modules.geolocation.MaxmindModule"
```

## Configurations
Expand All @@ -112,14 +110,13 @@ geolocation {
on = true
ttl = 10s
}
maxmind.license = "your-maxmind-license"
}
```

Also, notice that the cache uses the cache support offered by Playframework. A complete configuration can be found below:

```
play.modules.enabled += "com.edulify.modules.geolocation.providers.FreegeoipModule"
play.modules.enabled += "com.edulify.modules.geolocation.FreegeoipModule"

geolocation {
cache {
Expand Down
12 changes: 0 additions & 12 deletions app/com/edulify/modules/geolocation/providers/FreegeoipModule.java

This file was deleted.

12 changes: 0 additions & 12 deletions app/com/edulify/modules/geolocation/providers/MaxmindModule.java

This file was deleted.

46 changes: 0 additions & 46 deletions app/com/edulify/modules/geolocation/providers/MaxmindProvider.java

This file was deleted.

193 changes: 132 additions & 61 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,67 +1,138 @@
name := "geolocation"

version := "2.1.0"

scalaVersion := "2.11.7"

lazy val root = (project in file(".")).enablePlugins(PlayJava)

libraryDependencies ++= Seq(
javaCore,
javaWs,
cache,
"org.mockito" % "mockito-core" % "2.0.43-beta" % Test,
"com.jayway.awaitility" % "awaitility" % "1.7.0" % Test
val javacSettings = Seq(
"-source", "1.8",
"-target", "1.8",
"-Xlint:deprecation",
"-Xlint:unchecked"
)

testOptions += Tests.Argument(TestFrameworks.JUnit, "-v", "-q")

organization := "com.edulify"

organizationName := "Edulify.com"

organizationHomepage := Some(new URL("https://edulify.com"))

publishMavenStyle := true

publishArtifact in Test := false

pomIncludeRepository := { _ => false }

publishTo := {
if (version.value.trim.endsWith("SNAPSHOT"))
Some(Resolver.sonatypeRepo("snapshots"))
else
Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
}

startYear := Some(2013)

description := "This is a geolocation module for Playframework."

licenses := Seq("The Apache Software License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
lazy val commonSettings = Seq(
scalaVersion := "2.12.4",
organization := "com.edulify",
organizationName := "Edulify.com",
organizationHomepage := Some(new URL("https://edulify.com")),
startYear := Some(2013),
licenses := Seq("The Apache Software License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
homepage := Some(url("http://edulify.github.io/play-geolocation-module.edulify.com/")),
pomExtra :=
<scm>
<url>https://github.com/edulify/play-geolocation-module.edulify.com</url>
<connection>scm:git:git@github.com:edulify/play-geolocation-module.edulify.com.git</connection>
<developerConnection>scm:git:https://github.com/edulify/play-geolocation-module.edulify.com.git</developerConnection>
</scm>
<developers>
<developer>
<id>megazord</id>
<name>Megazord</name>
<email>contact [at] edulify.com</email>
<url>https://github.com/megazord</url>
</developer>
<developer>
<id>ranierivalenca</id>
<name>Ranieri Valença</name>
<email>ranierivalenca [at] edulify.com</email>
<url>https://github.com/ranierivalenca</url>
</developer>
</developers>,
publishMavenStyle := true,
pomIncludeRepository := { _ => false },
publishTo := { Some(if (isSnapshot.value) Resolver.sonatypeRepo("snapshots") else "releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2") },
scalacOptions := Seq("-feature", "-deprecation"),
javacOptions in (Compile, doc) ++= javacSettings,
javacOptions in Test ++= javacSettings,
javacOptions in IntegrationTest ++= javacSettings,
testOptions += Tests.Argument(TestFrameworks.JUnit, "-v", "-q", "-a"),
)

homepage := Some(url("http://edulify.github.io/play-geolocation-module.edulify.com/"))
val disableDocs = Seq[Setting[_]](
sources in (Compile, doc) := Seq.empty,
publishArtifact in (Compile, packageDoc) := false
)

pomExtra :=
<scm>
<url>https://github.com/edulify/play-geolocation-module.edulify.com</url>
<connection>scm:git:git@github.com:edulify/play-geolocation-module.edulify.com.git</connection>
<developerConnection>scm:git:https://github.com/edulify/play-geolocation-module.edulify.com.git</developerConnection>
</scm>
<developers>
<developer>
<id>megazord</id>
<name>Megazord</name>
<email>contact [at] edulify.com</email>
<url>https://github.com/megazord</url>
</developer>
<developer>
<id>ranierivalenca</id>
<name>Ranieri Valença</name>
<email>ranierivalenca [at] edulify.com</email>
<url>https://github.com/ranierivalenca</url>
</developer>
</developers>
val disablePublishing = Seq[Setting[_]](
publishArtifact := false,
// The above is enough for Maven repos but it doesn't prevent publishing of ivy.xml files
publish := {},
publishLocal := {}
)

scalacOptions := Seq("-feature", "-deprecation")
val playWsStandalone = "com.typesafe.play" %% "play-ahc-ws-standalone" % "1.1.3"
val junit = "junit" % "junit" % "4.12" % Test
val junitInterface = "com.novocode" % "junit-interface" % "0.11" % Test
val mockito = "org.mockito" % "mockito-core" % "2.11.0" % Test
val hamcrest = "org.hamcrest" % "hamcrest-core" % "1.3" % Test

lazy val root = (project in file("."))
.enablePlugins(PlayMinimalJava)
.aggregate(geolocation, `geolocation-guice`, freegeoip, `freegeoip-guice`, `maxmind-geoip2web`, `maxmind-geoip2web-guice`, `javaSample`)
.settings(commonSettings, disablePublishing, disableDocs, name := "edulify-geolocation")

lazy val geolocation = (project in file("geolocation"))
.settings(
name := "geolocation",
description := "This is a geolocation module for Playframework.",
commonSettings
)
.settings(libraryDependencies ++= Seq(
component("play-cache"),
ehcache % Test, // Should be removed with deprecated GeolocationService and GeolocationCache
junit,
junitInterface,
mockito
))

lazy val `geolocation-guice` = (project in file("geolocation-guice"))
.settings(commonSettings)
.settings(libraryDependencies ++= Seq(
guice,
hamcrest
))
.dependsOn(geolocation % "test->test;compile->compile")

lazy val freegeoip = (project in file("freegeoip"))
.settings(commonSettings)
.settings(libraryDependencies ++= Seq(
playWsStandalone
))
.dependsOn(geolocation)

lazy val `freegeoip-guice` = (project in file("freegeoip-guice"))
.settings(commonSettings)
.settings(libraryDependencies ++= Seq(
component("play-server") % Test,
javaCore % Test,
component("play-test") % Test,
component("play-ahc-ws") % Test,
component("play-akka-http-server") % Test
))
.dependsOn(freegeoip, `geolocation-guice` % "test->test;compile->compile")

lazy val `maxmind-geoip2web` = (project in file("maxmind-geoip2web"))
.settings(commonSettings)
.settings(libraryDependencies ++= Seq(
playWsStandalone
))
.dependsOn(geolocation)

lazy val `maxmind-geoip2web-guice` = (project in file("maxmind-geoip2web-guice"))
.settings(commonSettings)
.settings(libraryDependencies ++= Seq(
component("play-server") % Test,
javaCore % Test,
component("play-ahc-ws") % Test,
component("play-akka-http-server") % Test
))
.dependsOn(`maxmind-geoip2web`, `geolocation-guice` % "test->test;compile->compile")

lazy val `javaSample` = (project in file("sample/java"))
.enablePlugins(PlayMinimalJava)
.settings(routesGenerator := InjectedRoutesGenerator)
.settings(
commonSettings,
disableDocs,
disablePublishing
)
.settings(libraryDependencies ++= Seq(
ehcache, ws
))
.dependsOn(`freegeoip-guice`)
8 changes: 0 additions & 8 deletions conf/application.conf

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.edulify.modules.geolocation;

import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.typesafe.config.Config;
import play.Environment;
import play.libs.ws.StandaloneWSClient;

import java.util.concurrent.Executor;

public class FreegeoipModule extends AbstractModule {

private final Environment environment;
private final Config config;

public FreegeoipModule(Environment environment, Config config)
{
this.environment = environment;
this.config = config;
}

@Override
protected void configure() {
install(new GeolocationModule(environment, config));
}

@Provides
public GeolocationProvider geolocationProvider(StandaloneWSClient wsClient, Executor wsExecutor) {
return new FreegeoipProvider(wsClient, wsExecutor);
}
}
1 change: 1 addition & 0 deletions freegeoip-guice/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
play.modules.enabled += "com.edulify.modules.geolocation.FreegeoipModule"
Loading