When pants check :: is run a terminal, should it o...
# general
a
When pants check :: is run a terminal, should it output a result to the console ?
f
yes, it should.
Copy code
❯ pants check ::
12:07:19.67 [INFO] Completed: Check javac compilation - javac - javac succeeded.
12:07:19.67 [INFO] Completed: Check compilation for Scala - scalac - scalac succeeded.

✓ javac succeeded.
✓ scalac succeeded.
It's possible that you have not enabled the relevant backends, what's in your
pants.toml
file?
a
Thanks, have done that and run $ pants generate-lockfiles to generate the lockfile. Then when I ran pants check :: everything work fine and I got the response similar to yours. Thanks
1
@fresh-cat-90827 my final question is, after getting the compilation succeed, where would I find the jar file and run it with javac. I can actually run the code on intellij with run button but I felt pants check :: will output the jar file somewhere. Thanks
f
you don't need to run
check
first, you can run from sources straight away:
Copy code
❯ pants run src/jvm/org/pantsbuild/example/app:app
Hello World!
a
Ohh, okay...
f
to produce a jar you'd do
pants package src/jvm/org/pantsbuild/example/app
and then
Copy code
❯ java -jar dist/src.jvm.org.pantsbuild.example.app/bin.jar 
Hello World!
a
Thanks for the help. What of adding third party dependency. There's no clear example on how to add third party dependency. I mean something like pom.xml like maven
@fresh-cat-90827 Thanks a lot
f
and the example repo has 3rd-party deps as well, so definitely worth taking a look there!
a
Okay... thanks @fresh-cat-90827
f
and this is the target of interest: https://www.pantsbuild.org/docs/reference-jvm_artifact
I mean something like pom.xml like maven
I am afraid Pants won't be able to interact with your
pom.xml
file; support for JVM is not as comprehensive as of Python.
a
Hi @fresh-cat-90827 I get it to work perfectly with intellij but the only place I still have big issue is importing third party plugin. I followed the guide for plugin but the code doesn't import the plugin into the project. If I run the code I get an error attached to the picture.
erro2.png
I hope this run, I'm trying to write a technical article on how to use pant with Java. Thanks @fresh-cat-90827
f
you cannot run
pants run ::
- this would attempt all your targets in the repo, recursively. You would normally want to run a single target, e.g.
pants run src/jvm/org/pantsbuild/example/app:app
a
Thanks a bunch @fresh-cat-90827 It works perfectly now. I guess there will be support for import suggestion in intellij someday. Thanks a lot
Pants is really promising
f
I guess there will be support for import suggestion in intellij someday.
I am sorry, I don't follow, could you please provide a bit more information?
a
When you check the picture I sent, the second picture, intellij doesn't recognize the import statements, it mark it red cos it can't keep track of the dependency. But pant recognize the import statement and run the code perfectly.
using BSP to bootstrap the project on intellij. APIs in JDK are recignize by intellij but not extended to third party API yet. Did I make sense @fresh-cat-90827
f
right, so for Intellij to recognize 3rd party imports you'd have to have Maven/Gradle/etc file with the information about them, wouldn't you
a
Not really anytime I'm working with gradle/maven cos they both download the dependencies into the external library folder and intellij pick it up from there
Hi @fresh-cat-90827, Please I have another question. I'm trying to generate a jar file. When I run pants package src/hellopant:hellopant I got an error that deploy_jar is not define. In the BUILD file, I have java_sources() defined. When I try to add deploy_jar() to the same build file, It throws an error and no jar file is built, what am I doing in a wrong way ? Thanks
f
could you share your BUILD file contents and the exact error message + command?
a
Hi @fresh-cat-90827 I attached the build file content and the error message
This config work @fresh-cat-90827 but can't find the output of the built jar
@fresh-cat-90827 everything now work fine. I can find the jar file now. Thanks for your guidiance. I couldn't have gone this far without you
1