Hi! I've been setting up our repo with pants v1 fo...
# general
l
Hi! I've been setting up our repo with pants v1 for scala. I like it quite a lot, I am eager to be able to use v2 šŸ˜‰ . In the meantime, I am trying to use the scalafmt task but it doesn't seem to be picking up my .scalafmt.conf and applying it to files. Ideally I would like the fmt task to always run on compile to enforce consistent formatting across the code base. An I am not sure how to do that, some of the logs on the formating task below
Copy code
16:41:08 [DEBUG] pants.engine.internals.scheduler:pid=68013: computed 1 nodes in 0.000809 seconds. there are 374 total nodes.

               Executing tasks in goals: bootstrap -> lint16:41:08 [DEBUG] pants.process.lock:pid=68013: acquiring lock: <pants.process.lock.OwnerPrintingInterProcessFileLock object at 0x1105a1c10>

11:41:08 00:01   [bootstrap]
11:41:08 00:01     [substitute-aliased-targets]
                   expanding //:platform
11:41:08 00:01     [jar-dependency-management]16:41:08 [DEBUG] pants.java.distribution.distribution:pid=68013: Located Distribution('/Users/nicolasjoseph/.sdkman/candidates/java/current/bin', minimum_version=None, maximum_version=None jdk=True) for constraints: minimum_version None, maximum_version None, jdk True

11:41:08 00:01     [bootstrap-jvm-tools]
11:41:08 00:01     [provide-tools-jar]
11:41:08 00:01   [lint]
11:41:08 00:01     [scalafix]
11:41:08 00:01     [scalafmt]
11:41:08 00:01     [scalastyle]
11:41:08 00:01     [checkstyle]
11:41:08 00:01     [jvm-dep-check]16:41:08 [DEBUG] pants.process.lock:pid=68013: releasing lock: <pants.process.lock.OwnerPrintingInterProcessFileLock object at 0x1105a1c10>

               Waiting for background workers to finish.
11:41:08 00:01   [complete]
               SUCCESS
h
@fancy-queen-20734 or @witty-crayon-22786 Do you happen to know about this?
w
hey @loud-stone-83419! to tell pants where your scalafmt.conf is, you’ll need to set the
--scalafmt-config
option, which is
[scalafmt] config = ..
in pants.ini/pants.toml
l
Nice!
Trying that now
thx
w
np. and as previously discussed, it might be a little while before the JVM is ā€œbackā€ for v2, but it’s a priority for us.
l
Yeah that's why I am investing in the v1
It is defintely going to be worth it
but I might bug you as the setup is quite diverse
Scala + Python + typescript + docker
Would be super happy when you have some beta for me to test to try it out
w
for sure. note also that it’s also possible to run both v1 and v2 in parallel if you have different portions of your team using one language vs the other… maybe not worth it if it’s the same folks using all three languages, but.
l
How does the engine pick up what to format?
It doesn't seem to be applying the formating
I am using ./pants --level=debug fmt :platform
w
it will format whichever targets are specified on the command line, or the targets matched by
--changed-*
options
l
Does it format the dependencies of the target?
w
only if
--transitive
is specified
l
ie not sure if it is best practice but I created a plaform target with my services as dependencies
w
generally you should create targets if you’d want someone to be able to depend on that target
a platform target might imply that you want someone to be able to depend on ā€œall of the servicesā€
l
I would want them to be able to build everything with one command
not necessarily depend on it
w
the other way to spell that is
./pants $goal ::
… where
::
means all targets recursively
or
./pants $goal $dir::
for all targets under a directory
l
oh nice!
w
the
--changed
options are described for v1 here: https://v1.pantsbuild.org/orgs.html#continuous-integration … they can be helpful for CI, but also for commithooks
it’s common to do
./pants --changed-since=HEAD fmt
, for example
l
While you are here, I could not figure out why in the pants repo there are files that are mentioned with the
files
build function
w
so, on the v2 cusp, tests become a lot more sandboxed
(in v1 it’s possible to enable via flags:
--chroot
)
when a test is chrooted, only loose
files
that it declares dependencies on will be present in the chroot.
resources
on the other hand are placed on the classpath and/or pythonpath, and are loaded via System.getResource / pkg_resources, respectively.
l
Makes sense - Thank you for the help!
šŸ‘ 1
ā¤ļø 1