build|interpreter: move main_class to typed_kwargs

Also move it into the Jar class. This is an exclusive Jar keyword
argument, and is only used inside java paths, so there's no reason to
have this in all build targets.
pull/12020/head
Dylan Baker 1 year ago committed by Xavier Claessens
parent 68da3669a4
commit 01b5581a10
  1. 5
      mesonbuild/build.py
  2. 3
      mesonbuild/interpreter/kwargs.py
  3. 4
      mesonbuild/interpreter/type_checking.py

@ -1150,10 +1150,6 @@ class BuildTarget(Target):
(str, bool))
self.install_mode = kwargs.get('install_mode', None)
self.install_tag = stringlistify(kwargs.get('install_tag', [None]))
main_class = kwargs.get('main_class', '')
if not isinstance(main_class, str):
raise InvalidArguments('Main class must be a string')
self.main_class = main_class
if isinstance(self, Executable):
# This kwarg is deprecated. The value of "none" means that the kwarg
# was not specified and win_subsystem should be used instead.
@ -2913,6 +2909,7 @@ class Jar(BuildTarget):
self.filename = self.name + '.jar'
self.outputs = [self.filename]
self.java_args = kwargs.get('java_args', [])
self.main_class = kwargs.get('main_class', '')
self.java_resources: T.Optional[StructuredSources] = kwargs.get('java_resources', None)
def get_main_class(self):

@ -352,4 +352,5 @@ class BuildTarget(Library):
class Jar(_BaseBuildTarget):
pass
main_class: str

@ -532,7 +532,9 @@ SHARED_MOD_KWS = [
# Arguments exclusive to JAR. These are separated to make integrating
# them into build_target easier
_EXCLUSIVE_JAR_KWS: T.List[KwargInfo] = []
_EXCLUSIVE_JAR_KWS: T.List[KwargInfo] = [
KwargInfo('main_class', str, default=''),
]
# The total list of arguments used by JAR
JAR_KWS = [

Loading…
Cancel
Save