-
-
Notifications
You must be signed in to change notification settings - Fork 649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make JVM sources runnable #17847
Make JVM sources runnable #17847
Conversation
5d2a66b
to
3d7f431
Compare
3d7f431
to
471e138
Compare
I've rebased this one extensively. Reviewing the commits individually will yield better results than reading the final diff.. |
@@ -330,9 +372,9 @@ class JunitTestExtraEnvVarsField(TestExtraEnvVarsField): | |||
# ----------------------------------------------------------------------------------------------- | |||
|
|||
|
|||
class JvmMainClassNameField(StringField): | |||
alias = "main" | |||
class JvmRequiredMainClassNameField(JvmMainClassNameField): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made this a subclass rather than a standalone class to reduce churn elsewhere in the codebase.
My instinct is that I could make the new _find_main_by_javap
helper into a fully-fledged rule, and we could use that when constructing deploy_jar
s if main
is not specified. When that happens, this subclass can just go away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not an expert on the JVM rules, but seems good to me!
This adds
./pants run
/experimental_run_in_sandbox
support for more JVM targets without needing to explicitly declare adeploy_jar
. It does that by adapting the existingjvm_artifact
rule, which was already fairly generic thanks to the use ofClasspathEntryRequest
rules.The rules will attempt to automatically find a
main
method through either a JAR manifest (as before forjvm_artifact
) or by directly inspecting the contents of the classpath entry JAR returned from compilation. This also permits explicitly declaring amain
method in case the other approaches are inconclusive.