https://pantsbuild.org/ logo
#general
Title
# general
s

salmon-forest-59879

10/18/2019, 12:44 PM
Pants question: I have a 3rdparty set of jars that live as a
jar_library "foo"
. I need to make a tarball (or other archive) of these and make that available to a
scala_library "bar"
at runtime. The archive should be on the classpath somehow, but NOT the individual jars in that comprise "foo". How can i do this? I've tried my usual "create archive" trick of making a
jvm_binary
target that has
foo
as a dependency, then a
jvm_app
wrapping that with
archive = "tar"
, but now i need to make THIS a runtime dependency of a
bar
. In prior cases, i'd get a tarball from this, but it doesn't seem to be happening Ideas? (NB: again, the jars in
foo
can NOT be directly on the runtime classpath of
bar
. This is a hard requirement.)
a

aloof-angle-91616

10/19/2019, 6:49 AM
In prior cases, i'd get a tarball from this, but it doesn't seem to be happening
what is the expected behavior and what is the failure?
(NB: again, the jars in
foo
can NOT be directly on the runtime classpath of
bar
. This is a hard requirement.)
deploy_excludes
may be useful here, see https://www.pantsbuild.org/build_dictionary.html#bdict_jvm_binary
s

salmon-forest-59879

10/23/2019, 4:50 PM
Thanks for the response.
given:
Copy code
resources(
    name = "runtime-jar-resource",
    sources = ["3rdparty/jvm:jarjar"],
    dependencies = [
        "3rdparty/jvm:jarjar",
    ]
)

jvm_binary(
    name = "runtime-jar-bin",
    source = "BUILD.pants",  # Unused, but required by pants.
    basename = "runtime_jar_shading",
    dependencies = [
        ":runtime-jar-resource",
    ],
)

jvm_app(
    name = "runtime-jar-shading",
    archive = "tar",
    dependencies = [":runtime-jar-bin", ],
    bundles = [
    ],
)
where
3rdparty/jvm:jarjar
is a
jar_library
which pulls some set of jars from the internet
i would expect
./pants bundle :runtime-jar-shading
to produce a
dist/.../runtime-jar-bin.tar
file which contains the jars from
3rdparty
instead what i see is
dist/.../...runtime-jar-bin.tar
which contains directory entries but no files
--- Further, i need to be able to add the 'target which produces the tarball' as a
dependencies
to another jvm target and have that tarball appear in the classpath of that latter target, so i can find the tarball at runtime
a

aloof-angle-91616

10/23/2019, 4:57 PM
ok so i think you’ve been able to replicate a bug i’ve found before but not sure yet. can you first confirm that if you run
./pants binary :runtime-jar-bin
, that you get a jar with the appropriate files?
s

salmon-forest-59879

10/23/2019, 4:57 PM
checking...
so i actually got nothing from that command (!!). Pants output a line of
creating dist/runtime_jar_shading.jar
but this didn't actually get created
checking the pants logs for more detail now. I should note that we're on an obscenely old version of pants (1.3 !!), which my current effort will be used as part of the migration off of
a

aloof-angle-91616

10/23/2019, 5:00 PM
ah
that’s fine, i think i first started contributing to the pants project at 1.3
-ldebug
on the command line will print out not a ridiculous amount of output
s

salmon-forest-59879

10/23/2019, 5:04 PM
ok, it did indeed produce some output, but nothing that looks helpful to this issue
i'm going to do a clean and try again
👍 1
a

aloof-angle-91616

10/23/2019, 5:04 PM
hm, yes. sorry.
good idea
s

salmon-forest-59879

10/23/2019, 5:10 PM
clean completed, yay +40GB disk. Rerunning the build command
still nothing. And there's nothing in my
./dist
either (!!)
oh wait, sorry
i did
binary
on
runtime-jar-shading
not
runtime-jar-bin
. trying again
...but that made no difference. still nothing in
./dist
despite pants claiming otherwise
any other ideas? I'm bordering on the idea of just circumventing pants completely here and bundling the tarball once, statically, and using it as a loose dependency. This seems... suboptimal, but after days of banging my head against pants, i'm not sure what else to do 😞
a

aloof-angle-91616

10/23/2019, 6:54 PM
yes, i'm sorry, i've got something i have to finish pretty soon
asking in #jvm might also be a good way to get a response if you're not getting one here
making an issue at https://github.com/pantsbuild/pants/issues/new is probably what i'd suggest, especially since your goal is in attempting to upgrade pants
please ping me later today if you haven't gotten a reply
s

salmon-forest-59879

10/23/2019, 6:56 PM
👍
thanks again for your time so far 🙂
a

aloof-angle-91616

10/23/2019, 6:56 PM
thanks for your patience!!!
i understand your frustration and hope we can avoid much further difficulty
s

salmon-forest-59879

10/23/2019, 9:03 PM
FYI - stu tells me this isn't possible out-of-box (would require a custom pants target). Looks like "add it as an unmanaged jar" is going to be the easiest way forward for me.
a

aloof-angle-91616

10/29/2019, 4:31 PM
ok -- it's super easy to make a custom pants target, but if you've synced with stu i'd follow up on what he prescribed. please let me know if this is still not doable
3 Views