Skip to content
This repository was archived by the owner on Apr 23, 2019. It is now read-only.
Merged
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: 6 additions & 0 deletions app/dagger/ApplicationComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@
})
public interface ApplicationComponent {
play.Application application();

@Component.Builder
interface Builder {
@BindsInstance Builder context(play.ApplicationLoader.Context context);
ApplicationComponent build();
}
}
24 changes: 3 additions & 21 deletions app/dagger/ApplicationLoaderContextModule.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
package dagger;

import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Objects;

@Module
public class ApplicationLoaderContextModule {

private final play.ApplicationLoader.Context javaContext;

@Inject
public ApplicationLoaderContextModule(play.ApplicationLoader.Context context){
this.javaContext = Objects.requireNonNull(context);
}

@Singleton
@Provides
public play.api.ApplicationLoader.Context providesScalaContext() {
return this.javaContext.asScala();
}
public abstract class ApplicationLoaderContextModule {

@Singleton
@Provides
public play.ApplicationLoader.Context providesJavaContext() {
return javaContext;
public static play.api.ApplicationLoader.Context providesScalaContext(play.ApplicationLoader.Context context) {
return context.asScala();
}

}
4 changes: 2 additions & 2 deletions app/dagger/ApplicationModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import play.Application;

@Module
public class ApplicationModule {
public abstract class ApplicationModule {

@Provides
public Application providesApplication(MyComponentsFromContext myComponentsFromContext) {
public static Application providesApplication(MyComponentsFromContext myComponentsFromContext) {
return myComponentsFromContext.application();
}

Expand Down
4 changes: 2 additions & 2 deletions app/dagger/ClockModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* A module that provides a clock implementation.
*/
@Module
public class ClockModule {
public abstract class ClockModule {

@Provides
public Clock clock() {
public static Clock clock() {
return java.time.Clock.systemUTC();
}

Expand Down
2 changes: 1 addition & 1 deletion app/dagger/MyApplicationLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public Application load(Context context)
opt.ifPresent(lc -> lc.configure(context.environment(), context.initialConfig(), emptyMap()));

ApplicationComponent applicationComponent = DaggerApplicationComponent.builder()
.applicationLoaderContextModule(new ApplicationLoaderContextModule(context))
.context(context)
.build();

return applicationComponent.application();
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ scalaVersion := "2.12.2"

libraryDependencies += ws

libraryDependencies += "com.google.dagger" % "dagger" % "2.10"
libraryDependencies += "com.google.dagger" % "dagger-compiler" % "2.10"
libraryDependencies += "com.google.dagger" % "dagger" % "2.11"
libraryDependencies += "com.google.dagger" % "dagger-compiler" % "2.11"

javacOptions in Compile := { (managedSourceDirectories in Compile).value.head.mkdirs(); javacOptions.value }

Expand Down