Fixing local_jar stuff to work with runtime.

Change-Id: I3209167bc9660c6cd2e80521e3edd96b479bba71
Note: There's still a small cosmetic glitch in that the jars still get included under the original version; internally they are the new version though and OSGi recognizes them as such.
(cherry picked from commit 6a17acd1cb91d48078cc5015e562e3ef65a9f1ad)
diff --git a/WORKSPACE b/WORKSPACE
index a3d108d..723f0ac 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -9,13 +9,13 @@
 # Use this to build against locally built arbitrary 3rd party artifacts
 #local_jar(
 #    name = "atomix",
-#    path = "/users/tom/atomix/core/target/atomix-3.0.1-SNAPSHOT.jar",
+#    path = "/Users/tom/atomix/core/target/atomix-3.0.8-SNAPSHOT.jar",
 #)
 
 # Use this to build against locally built Atomix
 #local_atomix(
-#    path = "/users/tom/atomix",
-#    version = "3.0.1-SNAPSHOT",
+#    path = "/Users/tom/atomix",
+#    version = "3.0.8-SNAPSHOT",
 #)
 
 load("//tools/build/bazel:generate_workspace.bzl", "generated_maven_jars")
diff --git a/tools/build/bazel/local_jar.bzl b/tools/build/bazel/local_jar.bzl
index 31da241..14d9f7b 100644
--- a/tools/build/bazel/local_jar.bzl
+++ b/tools/build/bazel/local_jar.bzl
@@ -13,14 +13,29 @@
 # limitations under the License.
 
 def _local_jar_impl(repository_ctx):
-    repository_ctx.symlink(repository_ctx.attr.path, "jar/%s.jar" % repository_ctx.attr.name)
-    repository_ctx.file("jar/BUILD", content = """
+    file = repository_ctx.attr.path.split("/")[-1]
+    repository_ctx.symlink(repository_ctx.attr.path, "%s" % file)
+    repository_ctx.file("BUILD", content = """
 # DO NOT EDIT: automatically generated BUILD file for local_jar rule
 java_import(
-    name = "jar",
-    jars = ["%s.jar"],
+    name = "%s",
+    jars = ["%s"],
     visibility = ['//visibility:public']
 )
+    """ % (repository_ctx.attr.name, file))
+    repository_ctx.file("WORKSPACE", content = """
+# DO NOT EDIT: automatically generated BUILD file for local_jar rule
+workspace(name = "%s")
+    """ % repository_ctx.attr.name)
+    repository_ctx.file("jar/BUILD", content = """
+# DO NOT EDIT: automatically generated BUILD file for local_jar rule
+
+package(default_visibility = ["//visibility:public"])
+
+alias(
+    name = "jar",
+    actual = "@%s",
+)
     """ % repository_ctx.attr.name)
 
 # Workspace rule to allow override of a single locally built 3rd party jar