I have a JVM binary target that looks like:
jvm_binary(
name = "server-binary",
dependencies = [
":server-library",
"static_files:make"
],
main= "Main",
)
I can add command line arguments to the server like so:
./pants run server:server-binary --jvm-run-jvm-program-args='-port:9000'
But I'd like to have to have some arguments be part of the target, so I don't have to specify the arguments on the command line everytime I invoke pants.
Ideally I could type something like:
jvm_binary(
name = "server-binary",
dependencies = [
":server-library",
"static_files:make"
],
main= "Main",
args = {
"--jvm-run-jvm-program-args": "-port:9000"
}
)
Is there a way to do this?
You can use a jvm_prep_command()
that depends on your jvm_library()
targets:
Here's an example from our repo:
jvm_prep_command(name='migrate',
goal='run',
mainclass='com.squareup.dbmigrate.tools.Migrator',
args=[
'--url="jdbc:mysql://localhost/sms_development"',
'--type="sql:mysql"',
'--username="root"',
'--password=""',
'--migrations-dir="sms/src/main/resources/sql/sms/migrations"',
],
dependencies=[
'dbmigrate:lib'
],
)
Run this with ./pants run sms:migrate