Skip to content

Commit

Permalink
Configure dagger
Browse files Browse the repository at this point in the history
  • Loading branch information
jordansimsmith committed Aug 8, 2024
1 parent e95b1ce commit bc15ac2
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 2 deletions.
12 changes: 12 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ module(
bazel_dep(name = "rules_java", version = "7.7.0")
bazel_dep(name = "rules_jvm_external", version = "6.1")

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "dagger",
sha256 = "4062fa2cda8dab32d1961fb10ed50f40aca759149efb64dd5a08077a6fcb2fbc",
strip_prefix = "dagger-dagger-2.52",
url = "https://github.com/google/dagger/archive/dagger-2.52.zip",
)

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
artifacts = [
Expand All @@ -24,6 +33,9 @@ maven.install(
"software.amazon.awssdk:dynamodb-enhanced:2.26.19",
"com.google.guava:guava:33.2.1-jre",
"com.amazonaws:aws-lambda-java-core:1.2.3",
"com.google.dagger:dagger:2.52",
"com.google.dagger:dagger-compiler:2.52",
"com.google.dagger:dagger-producers:2.52",
],
)
use_repo(maven, "maven")
Expand Down
5 changes: 4 additions & 1 deletion MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions immersion_tracker_api/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
load("@contrib_rules_jvm//java:defs.bzl", "JUNIT5_DEPS", "java_test_suite")
load("@dagger//:workspace_defs.bzl", "dagger_rules")

dagger_rules()

HANDLERS = glob(["src/main/java/**/*Handler.java"])

java_library(
name = "lib",
srcs = glob(
["src/main/java/**/*.java"],
exclude = HANDLERS,
),
deps = [
":dagger",
],
)

java_binary(
name = "get-progress-handler",
srcs = glob(["src/main/java/com/jordansimsmith/immersiontracker/GetProgressHandler.java"]),
create_executable = False,
deps = [
":lib",
"@maven//:com_amazonaws_aws_lambda_java_core",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
import com.amazonaws.services.lambda.runtime.RequestHandler;

public class GetProgressHandler implements RequestHandler<Object, String> {
private final Hello hello;

public GetProgressHandler() {
this.hello = DaggerImmersionTrackerComponent.create().hello();
}

@Override
public String handleRequest(Object s, Context context) {
return "hello, world";
return hello.hello();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.jordansimsmith.immersiontracker;

import javax.inject.Inject;

public class Hello {

@Inject
public Hello() {}

public String hello() {
return "hello, world";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.jordansimsmith.immersiontracker;

import dagger.Component;

@Component
public interface ImmersionTrackerComponent {
Hello hello();
}

0 comments on commit bc15ac2

Please sign in to comment.