Skip to content

Commit

Permalink
Feature: Micronaut Support
Browse files Browse the repository at this point in the history
This changeset adds basic initial support for Micronaut, with new
rule macros which inject dependencies, and support for a basic
testbed which works.

Changes so far:
- [x] Add Micronaut dependencies
- [x] Add rule macros for Micronaut libs/apps/etc.
- [x] Add a little testbed which executes controllers
  - [x] Add tests for Kotlin and Java
  - [x] Invoke Micronaut from a browser test
    - [x] From Java
    - [x] From Kotlin (this required a patch at
          bazelbuild/rules_webtesting#409)
- [x] Ability to opt-out of Micronaut dependencies
  • Loading branch information
sgammon committed Jan 28, 2020
1 parent f8f8abf commit 0f297ec
Show file tree
Hide file tree
Showing 24 changed files with 2,595 additions and 84 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
path = vendor/google/protobuf
url = [email protected]:protocolbuffers/protobuf.git
shallow = true
ignore = dirty
[submodule "J2CL"]
path = vendor/bazel/j2cl
url = [email protected]:sgammon/j2cl.git
Expand All @@ -12,3 +13,6 @@
path = vendor/bazel/rules_graal
url = [email protected]:sgammon/rules_graal.git
branch = feature/ee
[submodule "rules_webtesting"]
path = vendor/bazel/rules_webtesting
url = [email protected]:sgammon/rules_webtesting.git
2 changes: 2 additions & 0 deletions .ijwb/.bazelproject
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ directories:
javatests
tools
types
style
.github
node_modules

targets:
//proto/...
//java/...
//js/...
//style/...
//javatests/...
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ PROJECT ?= bloom-sandbox
RBE_INSTANCE ?= default_instance
CACHE_KEY ?= GustBuild

TARGETS ?= //java/... //proto/... //js/...
TARGETS ?= //java/... //proto/... //js/... //style/...
TESTS ?= //javatests/...

TAG ?= --config=dev
TEST_ARGS ?= --combined_report=lcov
TEST_ARGS ?= --test_output=errors
BUILD_ARGS ?=

BAZELISK ?= $(shell which bazelisk)
Expand Down Expand Up @@ -91,7 +91,7 @@ devtools: ## Install local development dependencies.

update-deps: ## Re-seal and update all dependencies.
@echo "Updating devtools..."
git submodule update --remote --init --recursive
git submodule update --remote --init
@echo "Re-pinning Maven dependencies..."
$(BAZELISK) $(BAZELISK_ARGS) run @unpinned_maven//:pin

Expand Down
7 changes: 4 additions & 3 deletions defs/build.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ DEPS = {
# Rules: Web Testing
"io_bazel_rules_webtesting": {
"type": "github",
"repo": "bazelbuild/rules_webtesting",
"target": "528c49b5be3bca7b835f8c42ccf326f882e825e9",
"seal": "c017dfe15e60a3f7e3a774484fee8d0573aed6e0fe304bac9aa5b9e5eef36368"},
"repo": "sgammon/rules_webtesting",
"target": "0a1cbf2c5bb878eb2ccbc304342b6a3619ba6e7d",
"seal": "01a8fd568b26dff2c8afd68a673890c38d2ea5324d2259580106e7b8ad3f8e95",
"local": "/workspace/GUST/vendor/bazel/rules_webtesting"},

# Rules: SCSS/SASS
"rules_sass": {
Expand Down
22 changes: 22 additions & 0 deletions defs/toolchain/backend.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

load(
"//defs/toolchain/java:rules.bzl",
_jdk_binary = "jdk_binary",
_jdk_library = "jdk_library",
_micronaut_library = "micronaut_library",
_micronaut_application = "micronaut_application",
)

load(
"//defs/toolchain/java:testing.bzl",
_jdk_test = "jdk_test",
_micronaut_test = "micronaut_test",
)


jdk_test = _jdk_test
jdk_binary = _jdk_binary
jdk_library = _jdk_library
micronaut_test = _micronaut_test
micronaut_library = _micronaut_library
micronaut_application = _micronaut_application
12 changes: 12 additions & 0 deletions defs/toolchain/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,16 @@ def _closure_path(*path):
return "@io_bazel_rules_closure//closure/library/%s" % genpath


def _maven(path):

""" Computes a Maven dependency path, based on the coordinates
for the artifact. """

return ("@maven//:" + path
.replace(":", "_")
.replace(".", "_")
.replace("-", "_"))


maven = _maven
closure = _closure_path
80 changes: 80 additions & 0 deletions defs/toolchain/java/plugins/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package(
default_visibility = ["//visibility:public"],
)

load(
"@rules_java//java:defs.bzl",
"java_plugin",
"java_library",
)

load(
"//defs/toolchain:deps.bzl",
"maven",
)


java_library(
name = "micronaut-inject",
exports = [
maven("io.micronaut:micronaut-core"),
maven("io.micronaut:micronaut-inject"),
maven("io.micronaut:micronaut-inject-java"),
maven("io.micronaut:micronaut-validation"),
],
runtime_deps = [
maven("io.micronaut:micronaut-core"),
maven("io.micronaut:micronaut-inject"),
maven("io.micronaut:micronaut-inject-java"),
maven("io.micronaut:micronaut-validation"),
]
)

java_library(
name = "dagger_compiler",
exports = ["//external:jar/com/google/dagger/dagger_compiler"],
runtime_deps = [
":dagger",
":dagger_producers",
"//third_party/java/com/google/code/findbugs:jsr305",
"//third_party/java/com/google/googlejavaformat:google_java_format",
"//third_party/java/com/google/guava",
"//third_party/java/com/squareup:javapoet",
"//third_party/java/javax/inject:javax_inject",
],
)

java_plugin(
name = "micronaut-beans",
generates_api = True,
processor_class = "io.micronaut.annotation.processing.BeanDefinitionInjectProcessor",
deps = [":micronaut-inject"],
)

java_plugin(
name = "micronaut-types",
generates_api = True,
processor_class = "io.micronaut.annotation.processing.TypeElementVisitorProcessor",
deps = [":micronaut-inject"],
)

java_plugin(
name = "micronaut-config",
generates_api = True,
processor_class = "io.micronaut.annotation.processing.PackageConfigurationInjectProcessor",
deps = [":micronaut-inject"],
)

java_library(
name = "micronaut",
exports = [
maven("io.micronaut:micronaut-core"),
maven("io.micronaut:micronaut-inject"),
maven("io.micronaut:micronaut-inject-java"),
],
exported_plugins = [
":micronaut-beans",
":micronaut-types",
":micronaut-config"
],
)
63 changes: 59 additions & 4 deletions defs/toolchain/java/repos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,81 @@ load(
"maven_install",
)

load(
"@rules_jvm_external//:specs.bzl",
"maven",
)


MICRONAUT_VERSION = "1.3.0.RC1"
MICRONAUT_TEST_VERSION = "1.1.2"


REPOSITORIES = [
"https://jcenter.bintray.com/",
"https://maven.google.com",
"https://repo1.maven.org/maven2",
]

BUILD_ARTIFACTS = [
"org.slf4j:slf4j-jdk14:1.7.25",
"javax.annotation:javax.annotation-api:1.3.2",
]

MICRONAUT_BUILD_ARTIFACTS = [
"io.micronaut:micronaut-aop:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-core:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-http:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-http-client:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-inject:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-inject-java:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-runtime:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-validation:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-http-server:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-http-server-netty:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-graal:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-views:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-router:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-session:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-tracing:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-security:%s" % MICRONAUT_VERSION,
"io.micronaut:micronaut-multitenancy:%s" % MICRONAUT_VERSION,
]

RUNTIME_ARTIFACTS = [
# No base runtime artifacts yet.
]

MICRONAUT_RUNTIME_ARTIFACTS = [
"io.micronaut:micronaut-runtime:1.3.0.RC1",
]

TEST_ARTIFACTS = [
# Add test artifacts here.
# No base testing artifacts yet.
] + RULES_WEBTESTING_ARTIFACTS

MICRONAUT_TEST_ARTIFACTS = [
maven.artifact("io.micronaut.test", "micronaut-test-core", MICRONAUT_TEST_VERSION, testonly = True),
maven.artifact("io.micronaut.test", "micronaut-test-kotlintest", MICRONAUT_TEST_VERSION, testonly = True),
]


def _gust_java_deps():
def _gust_java_deps(micronaut = True):

""" Install Gust runtime Java dependencies. """

artifacts = BUILD_ARTIFACTS + RUNTIME_ARTIFACTS + TEST_ARTIFACTS
if micronaut:
artifacts += (
MICRONAUT_BUILD_ARTIFACTS +
MICRONAUT_RUNTIME_ARTIFACTS +
MICRONAUT_TEST_ARTIFACTS)

maven_install(
artifacts = TEST_ARTIFACTS,
artifacts = artifacts,
repositories = REPOSITORIES,
maven_install_json = "@//:maven_install.json"
maven_install_json = "@//:maven_install.json",
generate_compat_repositories = True,
)


Expand Down
Loading

0 comments on commit 0f297ec

Please sign in to comment.