bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.32k stars 4.09k forks source link

wired error: "deps not allowed without srcs: move to runtime_deps?" while I do have a deps configured #1669

Closed ddwolf closed 8 years ago

ddwolf commented 8 years ago

here is my terminal.

root@myhost:~/desktop/build/iGuci# JAVA_HOME=/usr/lib/jvm/jdk1.8.0_102/ bazel run test_class2
ERROR: /root/desktop/build/iGuci/BUILD:5:12: in deps attribute of java_binary rule //:test_class2: deps not allowed without srcs; move to runtime_deps?
ERROR: Analysis of target '//:test_class2' failed; build aborted.
INFO: Elapsed time: 0.109s
ERROR: Build failed. Not running target.

root@myhost:~/desktop/build/iGuci# cat BUILD
java_binary(
    name = 'test_class2',
    srcs = glob(['**/*.java']),
    main_class = "com.Main",
    deps = [":greeter"],
)
java_import(
    name = "greeter",
    jars= glob(["WEB-INF/lib/**/*.jar"]),
)

while my file structure is like this:

# /WORKSPACE
workspace(name='mywar')
local_repository(
        name="war",
        path="rules",
)

#/BUILD
java_binary(
    name = 'cida_java',
    srcs = glob(['**/*.java']),
    deps = ["//java/com:desktop_class", "//java/org:gitlab_class"],
)
java_import(
    name = "greeter",
    jars= glob(["WEB-INF/lib/**/*.jar"]),
    visibility=["//visibility:public"],
)
#/java/com/BUILD
java_library(
  name="desktop_class",
  srcs=glob(["build/iGuci/java/com/**/*.java"]),
  visibility=["//visibility:public"],
  deps=["//:greeter"],
  )

#/java/org/BUILD
java_library(
  name="gitlab_class",
  srcs=glob(["build/iGuci/java/org/**/*.java"]),
  visibility=["//visibility:public"],
  deps=["//:greeter"],
  )
dslomov commented 8 years ago

Looks like srcs = glob(['**/*.java']) matches no files?

ddwolf commented 8 years ago

@dslomov you are right, I already figured out that, thks:) and I will close thie issue.