Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _compile_java(file, variables, libraries=None):
resource_dir = variables['RESOURCES_DIR']
classpath = _form_classpath(libraries)
return_code, stdout, stderr = run_cmd('javac {} -d . *.java'.format(classpath),
variables,
cwd=resource_dir,
shell=True) # compile everything
if return_code != 0:
raise Exception("Can't compile {}. Out: {}, Err: {}".format(file, stdout, stderr))
class_file = file_utils.find_resource(resource_dir, file_utils.get_filename(file), '.class')
if len(class_file) > 1:
debug('Found more than 1 resource for {}: {}. Use last.'.format(file_utils.get_filename(file), class_file))
class_file = class_file[-1]
else:
class_file = class_file[0]
module = file_utils.cut_part_path(resource_dir, class_file).replace('/', '.')
return module.split('.class')[0]
def _compile_java(file, variables, libraries=None):
resource_dir = variables['RESOURCES_DIR']
classpath = _form_classpath(libraries)
return_code, stdout, stderr = run_cmd('javac {} -d . *.java'.format(classpath),
variables,
cwd=resource_dir,
shell=True) # compile everything
if return_code != 0:
raise Exception("Can't compile {}. Out: {}, Err: {}".format(file, stdout, stderr))
class_file = file_utils.find_resource(resource_dir, file_utils.get_filename(file), '.class')
if len(class_file) > 1:
debug('Found more than 1 resource for {}: {}. Use last.'.format(file_utils.get_filename(file), class_file))
class_file = class_file[-1]
else:
class_file = class_file[0]
module = file_utils.cut_part_path(resource_dir, class_file).replace('/', '.')
return module.split('.class')[0]
def __prepare_file(file: dict, variables: dict):
resources = variables['RESOURCES_DIR']
[file_key] = [k for k in file.keys() if k != 'type']
filepath = file[file_key]
file_type = file.get('type', 'text/plain')
filename = file_utils.get_filename(filepath)
file = fill_template_str(file_utils.read_file(os.path.join(resources, filepath)), variables)
return file_key, (filename, file, file_type)
def _compile_kotlin(file, variables, libraries=None):
resource_dir = variables['RESOURCES_DIR']
filename = file_utils.get_filename(file)
return_code, stdout, stderr = run_cmd('kotlinc {}.kt -include-runtime -d {}.jar'.format(filename, filename),
variables,
cwd=resource_dir,
shell=True) # compile everything
if return_code != 0:
raise Exception("Can't compile {}. Out: {}, Err: {}".format(file, stdout, stderr))
return filename + '.jar'