bitter-ability-32190
05/16/2022, 3:49 PMfiles
and resources
into one target type: asset
?
Are there languages/ecosystems where the distinction is important (from a Build tooling perspective)?resource
if it's under path
, use file
otherwise"witty-crayon-22786
05/16/2022, 4:53 PMForresources have source roots applied: i.e., they live in packages, and have a prefix stripped… files do not, and will be at their absolute path in the repothe loose files exist either way. There’s no discernible difference in thetest
sandbox. So a user can use either, and they can also usetest
andopen
.pkgutil
it matters in: go, python, java, scala, kotlin, etcit matters in every language which has a way of loading resources “from your binary” as opposed to loose files in the filesystem.
bitter-ability-32190
05/16/2022, 4:54 PMopen
a resource
or pkgutil
load a file
if I get the right info in my test. I'm not verifying I "did the right thing as if I was packaged".enough-analyst-54434
05/16/2022, 4:54 PMbitter-ability-32190
05/16/2022, 5:01 PMpkgutil
load them at test-timeenough-analyst-54434
05/16/2022, 5:07 PM__init__.py
in parent dirs - I'm pretty sure. For example.bitter-ability-32190
05/16/2022, 5:09 PMenough-analyst-54434
05/16/2022, 5:11 PMbitter-ability-32190
05/16/2022, 5:11 PMenough-analyst-54434
05/16/2022, 5:12 PMbitter-ability-32190
05/16/2022, 5:13 PMenough-analyst-54434
05/16/2022, 5:15 PMfile
targets. For further complication, assume the html / css is shared amongst several projects and langs stacks. There is some corporate branding in there that should be fixed.witty-crayon-22786
05/16/2022, 6:20 PMI’m a bit lost, but from a build tooling perspective there is only the stripping of some prefix path that is different.
…
That’s kind of my point. Could that not just happen for you?in Python maybe: but not on the JVM. on the JVM,
resources
are ~always in JARs, while files
aren’t.That’s an example case that I think Pants tells you you’re not allowed to do in a natural way today withwell… the answer right now would be to put both thetargets. For further complication, assume the html / css is shared amongst several projects and langs stacks. There is some corporate branding in there that should be fixed.file
pex_binary
and the files
in an archive
target, and ship the archive to productionbitter-ability-32190
05/16/2022, 6:24 PMwitty-crayon-22786
05/16/2022, 6:24 PMbitter-ability-32190
05/16/2022, 6:25 PMenough-analyst-54434
05/16/2022, 6:39 PMin Python maybe: but not on the JVM. on the JVM,Resources are always on the classpath. They may be loose on the fs.are ~always in JARs, whileresources
aren’t. (edited)files
witty-crayon-22786
05/16/2022, 6:40 PMenough-analyst-54434
05/16/2022, 6:43 PMbitter-ability-32190
05/16/2022, 6:46 PMzipapp
arguments are out for the most part. It's mostly about correctness and "dont have 2 ways of doing one thing"enough-analyst-54434
05/16/2022, 6:47 PMbitter-ability-32190
05/16/2022, 6:47 PMenough-analyst-54434
05/16/2022, 6:49 PMbitter-ability-32190
05/16/2022, 6:51 PMstill same amount of work for BUILD file writer IIUCI would argue less work -> less cognitive burden of choosing one or the other
enough-analyst-54434
05/16/2022, 6:51 PMbitter-ability-32190
05/16/2022, 6:56 PMSo if I place a file under a source root I'm foced to use it source-root-stripped?Yes but IMO that follows the element of least surprise. • In the sandbox it isn't in some other path (wtf did my file go?!) • How you load it during test time is how you'll load it in the deployed env • You can relocate your code and your code doesn't break (depending on how you wrote your value. No hope today if you're hardcoding source root)
experimental_shell_command
. How can this work for both file
and resource
? Two codegenerators? Two targets?
• No more possibility of getting this wrong for new code (we will continue to get this wrong, it's just the nature of bugs)
◦ Again experimental_shell_command
chose files. Then I ran into an issue, what if it was a non-maintainer that ran into this? I can debug and then hack together a plugin, but most people can'twitty-crayon-22786
05/16/2022, 8:24 PMYes but IMO that follows the element of least surprise.i don’t think that i agree on “least surprise”… doing something differently in a context-specific way rather than due to an explicit use of one target type vs another is magical. for example: what is currently an error (using
resources
outside of a source root) would become a silent missing file.
i agree that it would simplify the code though.bitter-ability-32190
05/16/2022, 8:26 PMwould become a silent missing file.Missing when? In a packaged thing?
resources
to files
, then warn if an unrooted file is trying to be packaged.witty-crayon-22786
05/16/2022, 8:34 PMbitter-ability-32190
05/16/2022, 8:36 PMwitty-crayon-22786
05/16/2022, 8:37 PMexperimental_shell_command
not giving you a choice with `resources`/`files` targets, which are very explicitly a choicebitter-ability-32190
05/16/2022, 8:38 PMresources
and files
there will be code which has to choose. And therefore choose wrongwitty-crayon-22786
05/16/2022, 8:40 PMthere will be code which has to choose. And therefore choose wrongthe code shouldn’t be choosing though… it should be pushing the choice to the user. as you said: that makes the code more complicated, and we need a solution for
experimental_shell_command
.bitter-ability-32190
05/16/2022, 8:44 PMwitty-crayon-22786
05/16/2022, 8:44 PMbitter-ability-32190
05/16/2022, 8:45 PMwitty-crayon-22786
05/16/2022, 8:46 PMbitter-ability-32190
05/16/2022, 8:46 PM/
) so the distinction gets really arbitrarywitty-crayon-22786
05/16/2022, 8:46 PMbitter-ability-32190
05/16/2022, 8:48 PMIn the sandbox it isn't in some other path (wtf did my file go?!)
witty-crayon-22786
05/16/2022, 8:49 PM