emeraldnas.blogg.se

Building a java jar file
Building a java jar file






  1. #Building a java jar file archive#
  2. #Building a java jar file code#
  3. #Building a java jar file plus#

List of labels optional DO NOT USE THIS OPTION UNLESS THERE IS NO OTHER WAY)Ī list of resources that must be located at the root of the java tree. Resources may be source files or generated files. If that is notįound, Bazel then looks for the topmost directory named "java" or "javatests" (so, forĮxample, if a resource is at /x/java/y/java/z, the (a "src" directory followed by a "resources" directory grandchild). Of the jar file is determined by the project structure. If resources are specified, they will be bundled in the jar along with the usual This argument is almost always required, except if aĬlass on the runtime classpath or you specify the runtime_deps argument.Ī list of data files to include in a Java jar. Rules: if the rule (typically genrule or filegroup) generatesĪny of the files listed above, they will be used the same way as described for source You should not list the generating rule in deps Makes the rule more resilient to future changes: if the generating rule generatesĭifferent files in the future, you only need to fix one place: the outs of Here instead of the name of the file itself. java files it is generally advisable to put the generating rule's name This attribute is almost always required see exceptions below. The list of source files that are processed to create the target. The list of other libraries to be linked in to the target. For example, if your entry point is called It is good practice to use the name of the source file that is the main entry point of theĪpplication (minus the extension). java fileĭeps =, # rule that generates that fileĪ unique name for this target.

#Building a java jar file code#

The following code snippet illustrates a common mistake: These will match the classes in theĭeploy.jar except where jars have no matching source jar.Ī deps attribute is not allowed in a java_binary rule without

#Building a java jar file archive#

  • name_deploy-src.jar: An archive containing the sourcesĬollected from the transitive closure of the target.
  • Like you would execute any native binary. You can execute the resulting jar file directly The actual jar file's bytes will beĪppended to that native binary, creating a single binary blob containing both theĮxecutable and the Java code. Your rule, all linked into a static binary.

    #Building a java jar file plus#

    This will contain the launcher plus any native (C++) dependencies of These are automatically loadedĪttribute, then instead of being a normal JAR file, the _deploy.jar will be a It alsoĬontains the native libraries needed for dependencies. Searched the classpath from the binary's wrapper script from beginning to end. The deploy jar contains all the classes that would be found by a classloader that Using the wrapper script is preferred to java -jar because itĪlso passes the JVM flags and the options Java -jar command or with the wrapper script's -singlejar name_deploy.jar: A Java archive suitable for deployment (onlyīuilding the _deploy.jar target for your ruleĬreates a self-contained jar file with a manifest that allows it to be run with the.name-src.jar: An archive containing the sources ("source.Resources corresponding to the binary's direct dependencies. name.jar: A Java archive, containing the class files and other.src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txtįor a list of configurable flags and environment variables accepted by the wrapper. The wrapper script accepts several unique flags. The wrapper shell script uses a classpath that includes, among other things, a jar file for each Java_binary( name, deps, srcs, data, resources, args, classpath_resources, compatible_with, create_executable, deploy_env, deploy_manifest_lines, deprecation, distribs, env, exec_compatible_with, exec_properties, features, javacopts, jvm_flags, launcher, licenses, main_class, output_licenses, plugins, resource_jars, resource_strip_prefix, restricted_to, runtime_deps, stamp, tags, target_compatible_with, testonly, toolchains, use_launcher, use_testrunner, visibility)īuilds a Java archive ("jar file"), plus a wrapper shell script with the same name as the rule.








    Building a java jar file