Git Product home page Git Product logo

java-scala-bazel-example's Introduction

run and build

bazel run //src/main/java/com/example/JavaMain:JavaMain
bazel build //src/main/java/com/example/JavaMain:JavaMain_deploy.jar

bazel run //src/main/scala/com/example/ScalaMain:ScalaMain
bazel build //src/main/scala/com/example/ScalaMain:ScalaMain_deploy.jar

scala java cooperation

scala call java lib

# java BUILD
java_library(
    name = "me",
    srcs = ["Mine.java"],
    deps = [],
)

# scala BUILD

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library", "scala_binary", "scala_test")

scala_binary(
    name = "ScalaMain",
    srcs = glob(["*.scala"]),
    main_class = "com.example.ScalaMain.Main",
    deps = [
        "//src/main/java/com/example/me:me",
    ],
)

java call scala lib

# scala BUILD
scala_library(
    name = "scala_me",
    srcs = ["DoubleMe.scala"],
    deps = [
        "//src/main/java/com/example/me:me",
    ]
)

java_import(
    name = "java_me",
    deps = [],
    jars = [":scala_me"],
)

# java BUILD, deps the java_import versin lib

java_binary(
    name = "JavaMain",
    srcs = ["Main.java"],
    main_class = "com.example.JavaMain.Main",
    deps = [
        "//src/main/scala/com/example/me:java_me",
    ]
)

import project to intellij

# .bazelproject

directories:
  .
targets:
  //...:all
workspace_type: java
java_language_level: 8

bazel manven deps

git clone https://github.com/pgr0ss/bazel-deps.git
cd bazel-deps
bazel build //src/main/java/braintree:bazeldeps_deploy.jar
java -jar bazel-bin/src/main/java/braintree/bazeldeps_deploy.jar

bazeldeps junit:junit:4.12


--------- Add these lines to your WORKSPACE file ---------

maven_jar(name = "org_hamcrest_hamcrest_core_1_3", artifact = "org.hamcrest:hamcrest-core:jar:1.3")
maven_jar(name = "junit_junit_4_12", artifact = "junit:junit:jar:4.12")


--------- Add these lines to your BUILD file ---------

java_library(
  name="junit",
  visibility = ["//visibility:public"],
  exports = [
    "@junit_junit_4_12//jar",
    "@org_hamcrest_hamcrest_core_1_3//jar",
  ],
)

java-scala-bazel-example's People

Contributors

unship avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.