]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/dev/archery/archery/lang/java.py
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / dev / archery / archery / lang / java.py
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
17
18 import os
19
20 from ..utils.command import Command, CommandStackMixin, default_bin
21 from ..utils.maven import MavenDefinition
22
23
24 class Java(Command):
25 def __init__(self, java_bin=None):
26 self.bin = default_bin(java_bin, "java")
27
28
29 class Jar(CommandStackMixin, Java):
30 def __init__(self, jar, *args, **kwargs):
31 self.jar = jar
32 self.argv = ("-jar", jar)
33 Java.__init__(self, *args, **kwargs)
34
35
36 class JavaConfiguration:
37 def __init__(self,
38
39 # toolchain
40 java_home=None, java_options=None,
41 # build & benchmark
42 build_extras=None, benchmark_extras=None):
43 self.java_home = java_home
44 self.java_options = java_options
45
46 self.build_extras = list(build_extras) if build_extras else []
47 self.benchmark_extras = list(
48 benchmark_extras) if benchmark_extras else []
49
50 @property
51 def build_definitions(self):
52 return self.build_extras
53
54 @property
55 def benchmark_definitions(self):
56 return self.benchmark_extras
57
58 @property
59 def environment(self):
60 env = os.environ.copy()
61
62 if self.java_home:
63 env["JAVA_HOME"] = self.java_home
64
65 if self.java_options:
66 env["JAVA_OPTIONS"] = self.java_options
67
68 return env
69
70
71 class JavaMavenDefinition(MavenDefinition):
72 def __init__(self, source, conf, **kwargs):
73 self.configuration = conf
74 super().__init__(source, **kwargs,
75 build_definitions=conf.build_definitions,
76 benchmark_definitions=conf.benchmark_definitions,
77 env=conf.environment)