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

mysterious-waiter-14207

07/13/2022, 6:15 AM
Can a plugin override a pants rule? We would like to override
DeployJar
rules instead of adding a new goal or new target. Is this possible?
h

hundreds-father-404

07/15/2022, 6:41 PM
Hello! It is not currently possible, although I've wondered in the past if we should let plugin authors "unregister" a rule For now, you'd want to use a new goal or new target
I'm curious, would your change make sense to upstream? Either as a plugin API hook, or User API changes?
m

mysterious-waiter-14207

07/15/2022, 6:48 PM
We have a plugin that instead of creating a fatjar it just collect all jars to a directory. It is faster (and cacheable) and we later containerize that directory. Regarding upstream, it can either be a new target or a flag on DeployJar? I think it would be useful when containerizing.
h

hundreds-father-404

07/15/2022, 7:06 PM
cc @witty-crayon-22786 @ancient-vegetable-10556, does that sound useful upstreamed? I know very little about deploy jar
generally, I'd bias towards a field on the target. We try to limit the # of goals and targets. It's already overwhelming imo how many there are hah
a

ancient-vegetable-10556

07/19/2022, 6:23 PM
We’d probably want a new target — there’s already
war
support, which I believe uses a new target. As for upstreaming, yes, absolutely, there are a plenty of valid use cases there. I think we focused only on
deploy_jar
because there was a user who needed it urgently.
(@fast-nail-55400 probably knows more about
war
than I do, which is probably the prior art we’d want to follow)
f

fast-nail-55400

07/19/2022, 6:32 PM
It would probably be better as its own target. In my view, the target type models a specific class of output and fields configure aspects of that output but those aspects are still within that specific class of output.
deploy_jar
is intentionally runnable by
java -jar
. A flat directory of jars is not so runnable without special classloader support (which, for example,
war
files get by being run within a Servlet container, e.g. Tomcat). Thus, I submit a flat set of jars would be outside the “class” of
deploy_jar
.
a

ancient-vegetable-10556

07/19/2022, 6:33 PM
Right, I’d probably call the sort of jar this plugin uses a
library_jar
or a
simple_jar
(slight preference for the former)
f

fast-nail-55400

07/19/2022, 6:33 PM
Longer term, I would like to see a general “assembly” plugin for JVM similar to the Maven Assembly plugin. https://maven.apache.org/plugins/maven-assembly-plugin/. Such a plugin for Pants would take a list of directions on how to layout an archive. A flat directory of jars could be one of the instructions (as it is in Maven although I don’t recall which assembly directive it is offhand).
w

witty-crayon-22786

07/19/2022, 6:34 PM
yea, new target for sure.
v1
had some really weird semantics due to trying to pack too many behaviors (via boolean flags) into one target definition
but yea: that would be great to upstream @mysterious-waiter-14207. thanks!
m

mysterious-waiter-14207

07/19/2022, 7:05 PM
Thanks all, we would work on making it upstream. At the moment we have issues with resources and "collect all jars to a directory" (we have the same issue with scalatest_tests), as the classloader is not able to load the resources, we suspect this is because the resources are on their own jar (although they are in the classpath). So trying to figure this out.
w

witty-crayon-22786

07/19/2022, 7:06 PM
would suggest a new thread for the
resources
thing, but: you’ll want to check your source roots
m

mysterious-waiter-14207

07/19/2022, 7:10 PM
source roots are actually fine, I will make a sample repo to reproduce and open an issue.
👍 1
The resources issue we are suffering from: https://github.com/pantsbuild/pants/issues/16231
w

witty-crayon-22786

07/19/2022, 9:47 PM
thanks!
3 Views