Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support naming JAR files with embedded versions #1291

Closed
kayasoze opened this issue May 19, 2016 · 4 comments
Closed

Support naming JAR files with embedded versions #1291

kayasoze opened this issue May 19, 2016 · 4 comments

Comments

@kayasoze
Copy link

It would ease integration with other Java tools if java_library() were enhanced to take an optional version string, e.g.:

java_library(
  name = "foo",
  version = "1.1",
)

This would produce foo-1.1.jar rather than foo.jar. This avoids having to rename the library when the version changes. I realize that bind() can be used for this as well, but it's less convenient, as the WORKSPACE file must also be modified.

Embedding all versions in the WORKSPACE has its plusses: it may nice to have all the version information in one place. However, it may not be a scalable approach for embedding versions in JAR file names.

@kchodorow
Copy link
Contributor

There are already a couple mechanisms that you can use for this, but why do you want it? You can already avoid renaming the library by calling it "foo".

@kayasoze
Copy link
Author

I am not aware of any way to name a library "foo" but have the resulting JAR be named "foo-x.y.jar", where x.y is an arbitrary version number. The motivation is to allow publishing to a Maven artifactory.

@kchodorow
Copy link
Contributor

kchodorow commented May 23, 2016

Oh, then can you do something like:

def artifactory_artifact(name, version, srcs, deps = [], visibility = None):
  native.java_library(name = name, srcs = srcs, deps = deps, visibility = visibility)
  native.genrule(
     name = "artifactory-%s" % name,
     outs = ["%s-%s.jar" % (name, version)],
     srcs = ["lib%s.jar" % name],
     cmd = "cp $< $@",
)

@kayasoze
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants