Skip to content
Permalink
Browse files

Bugfix and improvements to that lib

  • Loading branch information...
elucash committed Jun 29, 2019
1 parent 9734478 commit 994b3d3dbd975167e09aa6232031ff5c1c389d10

This file was deleted.

@@ -1,4 +1,4 @@
load('//lib:rules.bzl', 'java_module')
load('//mod:rules.bzl', 'java_module')

java_module(
name = 'common',
@@ -1,4 +1,4 @@
load('//lib:rules.bzl', 'java_module', 'java_test_vm_args')
load('//mod:rules.bzl', 'java_module', 'java_test_vm_args')

java_library(
name = 'grammar',
@@ -1,4 +1,4 @@
load('//lib:rules.bzl', 'java_module', 'java_test_vm_args')
load('//mod:rules.bzl', 'java_module', 'java_test_vm_args')

java_library(
name = 'lang',
@@ -1,4 +1,4 @@
load('//lib:rules.bzl', 'java_module')
load('//mod:rules.bzl', 'java_module')

java_module(
name = 'net',
@@ -0,0 +1,142 @@
# Definition of macros/shortcut rules used for typical type of modules

_java_library_deps_default = [
]

_java_test_deps_default = [
'//lib/junit:junit',
# '//lib/immutables/that:that',
]

_kotlin_library_deps_default = [
'//lib/kotlin/stdlib:stdlib',
]

_kotlin_test_deps_default = [
'//lib/junit:junit',
# '//lib/immutables/that:that',
]

_java_test_vm_args = [
'-ea',
'-Dio.immutables.that.replace-error-message= ',
]
_kotlinc_args = ['-jvm-target', '1.8']

def java_module(
name,
deps = [],
test_deps = [],
provided_deps = [],
exported_deps = [],
exported_provided_deps = [],
plugins = [],
visibility = None,
maven_coords = None,
resources_add = []):
native.java_library(
name = name,
srcs = native.glob(['src/**/*.java']),
resources = native.glob(['src/**'], exclude = ['*.java']) + resources_add,
resources_root = 'src',
deps = _dedupe(_java_library_deps_default + deps),
provided_deps = provided_deps,
exported_deps = exported_deps,
exported_provided_deps = exported_provided_deps,
plugins = plugins,
visibility = ['PUBLIC'] if not visibility else visibility,
maven_coords = maven_coords,
)
native.java_test(
name = 'test',
srcs = native.glob(['test/**/*.java']),
resources = native.glob(['test/**']),
resources_root = 'test',
deps = _dedupe([':' + name] + _java_test_deps_default + deps + test_deps),
plugins = plugins,
vm_args = _java_test_vm_args,
)

def kotlin_module(
name,
name_test = None,
deps = [],
test_deps = [],
provided_deps = [],
exported_deps = [],
exported_provided_deps = [],
plugins = [],
visibility = None,
maven_coords = None):
native.kotlin_library(
name = name,
srcs = native.glob(['src/**/*.kt']),
resources = native.glob(['src/**'], exclude = ['*.kt']),
resources_root = 'src',
deps = _dedupe(_kotlin_library_deps_default + deps),
provided_deps = provided_deps,
exported_deps = exported_deps,
exported_provided_deps = exported_provided_deps,
plugins = plugins,
visibility = ['PUBLIC'] if not visibility else visibility,
maven_coords = maven_coords,
extra_kotlinc_arguments = _kotlinc_args,
)
native.kotlin_test(
name = name_test if name_test else 'test',
srcs = native.glob(['test/**/*.kt']),
resources = native.glob(['test/**']),
resources_root = 'test',
# friend_paths = [':' + name],
deps = _dedupe([':' + name] + _kotlin_test_deps_default + deps + test_deps),
plugins = plugins,
vm_args = _java_test_vm_args,
extra_kotlinc_arguments = _kotlinc_args,
)

def _dedupe(seq):
seen = {}
return [x for x in seq if not (x in seen or seen.update({x: ()}))]

def java_test_vm_args():
return _java_test_vm_args

# for use in explicitly written kotlin_library
def kotlinc_args():
return _kotlinc_args

def kotlin_library_deps_default():
return _kotlin_library_deps_default

_doc_deps = [
'//tool/doc:doc',
'//lib/javax/jaxrs:jaxrs',
]

_doc_gen_deps = _doc_deps + [
'//lib/swagger:annotations',
]

# java_resources uses java_library and special labels (processed by IDE project generation tool)
# to create library of resources for the module, by default, if not set,
# resource root folder (resources_root) will be set to target name,
# but if it's nested, better just define it explicitly (resources_root = 'some/nested/folder')
def java_resources(
name,
test = False, # marks as test resources, but can be added to test and non-test rules as deps
exported_deps = [], # only exported deps makes sense for resources which are not compiled
resources = None, # derives from resources_root or can be specified
resources_root = None, # defaults to name
visibility = None,
):
resources_root = resources_root if resources_root else name
resources = resources if resources else native.glob([resources_root + '/**'])
native.java_library(
name = name,
srcs = [],
resources = resources,
resources_root = resources_root,
exported_deps = exported_deps,
labels = ['ide_test_res'] if test else ['ide_res'],
visibility = visibility,
)
@@ -1,4 +1,4 @@
load('//lib:rules.bzl', 'java_module')
load('//mod:rules.bzl', 'java_module')

java_module(
name = 'that',
@@ -153,7 +153,7 @@ private Assert() {}
*/
@CheckReturnValue
public static That.Int that(@Nullable Character actual) {
return that(actual == null ? null : (int) actual.charValue());
return that(actual == null ? null : (int) actual.charValue());
}

/**

0 comments on commit 994b3d3

Please sign in to comment.
You can’t perform that action at this time.