@@ -134,33 +134,46 @@ def package_code(
134134 directory , language_name , language_version , architecture , benchmark , is_cached
135135 )
136136
137- CONFIG_FILES = {
138- "python" : ["handler.py" , "requirements.txt" , ".python_packages" ],
139- "nodejs" : ["handler.js" , "package.json" , "node_modules" ],
140- }
141- package_config = CONFIG_FILES [language_name ]
142- function_dir = os .path .join (directory , "function" )
143- os .makedirs (function_dir )
144- # move all files to 'function' except handler.py
145- for file in os .listdir (directory ):
146- if file not in package_config :
147- file = os .path .join (directory , file )
148- shutil .move (file , function_dir )
149- # FIXME: use zipfile
150- # create zip with hidden directory but without parent directory
151- execute ("zip -qu -r9 {}.zip * ." .format (benchmark ), shell = True , cwd = directory )
152- benchmark_archive = "{}.zip" .format (os .path .join (directory , benchmark ))
153- self .logging .info ("Created {} archive" .format (benchmark_archive ))
154-
155- bytes_size = os .path .getsize (os .path .join (directory , benchmark_archive ))
156- mbytes = bytes_size / 1024.0 / 1024.0
157- self .logging .info ("Zip archive size {:2f} MB" .format (mbytes ))
158-
159- return (
160- os .path .join (directory , "{}.zip" .format (benchmark )),
161- bytes_size ,
162- container_uri ,
163- )
137+ if (language_name == 'java' ):
138+
139+ jar_path = os .path .join (directory , "target" , "benchmark-1.0.jar" )
140+ bytes_size = os .path .getsize (jar_path )
141+
142+ return (
143+ jar_path ,
144+ bytes_size ,
145+ container_uri ,
146+ )
147+
148+ else :
149+ # so no need to add anything here
150+ CONFIG_FILES = {
151+ "python" : ["handler.py" , "requirements.txt" , ".python_packages" ],
152+ "nodejs" : ["handler.js" , "package.json" , "node_modules" ],
153+ }
154+ package_config = CONFIG_FILES [language_name ]
155+ function_dir = os .path .join (directory , "function" )
156+ os .makedirs (function_dir )
157+ # move all files to 'function' except handler.py
158+ for file in os .listdir (directory ):
159+ if file not in package_config :
160+ file = os .path .join (directory , file )
161+ shutil .move (file , function_dir )
162+ # FIXME: use zipfile
163+ # create zip with hidden directory but without parent directory
164+ execute ("zip -qu -r9 {}.zip * ." .format (benchmark ), shell = True , cwd = directory )
165+ benchmark_archive = "{}.zip" .format (os .path .join (directory , benchmark ))
166+ self .logging .info ("Created {} archive" .format (benchmark_archive ))
167+
168+ bytes_size = os .path .getsize (os .path .join (directory , benchmark_archive ))
169+ mbytes = bytes_size / 1024.0 / 1024.0
170+ self .logging .info ("Zip archive size {:2f} MB" .format (mbytes ))
171+
172+ return (
173+ os .path .join (directory , "{}.zip" .format (benchmark )),
174+ bytes_size ,
175+ container_uri ,
176+ )
164177
165178 def _map_architecture (self , architecture : str ) -> str :
166179
@@ -254,7 +267,10 @@ def create_function(
254267 create_function_params ["Runtime" ] = "{}{}" .format (
255268 language , self ._map_language_runtime (language , language_runtime )
256269 )
257- create_function_params ["Handler" ] = "handler.handler"
270+ if language == "java" :
271+ create_function_params ["Handler" ] = "Handler::handleRequest"
272+ else :
273+ create_function_params ["Handler" ] = "handler.handler"
258274
259275 create_function_params = {
260276 k : v for k , v in create_function_params .items () if v is not None
0 commit comments