java: add jar linking test
This commit is contained in:
parent
60b9c8300c
commit
bc8239ded0
|
@ -981,8 +981,9 @@ int dummy;
|
|||
class_list.append(plain_class_path)
|
||||
class_dep_list = [os.path.join(self.get_target_private_dir(target), i) for i in class_list]
|
||||
manifest_path = os.path.join(self.get_target_private_dir(target), 'Manifest.txt')
|
||||
os.makedirs(os.path.dirname(os.path.join(self.environment.get_build_dir(), manifest_path)), exist_ok=True)
|
||||
with open(manifest_path, 'w') as manifest:
|
||||
manifest_fullpath = os.path.join(self.environment.get_build_dir(), manifest_path)
|
||||
os.makedirs(os.path.dirname(manifest_fullpath), exist_ok=True)
|
||||
with open(manifest_fullpath, 'w') as manifest:
|
||||
if any(target.link_targets):
|
||||
manifest.write('Class-Path: ')
|
||||
cp_paths = [os.path.join(self.get_target_dir(l), l.get_filename()) for l in target.link_targets]
|
||||
|
@ -994,7 +995,6 @@ int dummy;
|
|||
if e != '':
|
||||
commands.append(main_class)
|
||||
commands.append(self.get_target_filename(target))
|
||||
commands.append(manifest_path)
|
||||
# Java compilation can produce an arbitrary number of output
|
||||
# class files for a single source file. Thus tell jar to just
|
||||
# grab everything in the final package.
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package com.mesonbuild;
|
||||
|
||||
import com.mesonbuild.SimpleLib;
|
||||
|
||||
class Linking {
|
||||
public static void main(String [] args) {
|
||||
SimpleLib.func();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
project('linkingjava', 'java')
|
||||
|
||||
subdir('sub')
|
||||
|
||||
javaprog = jar('myprog', 'com/mesonbuild/Linking.java',
|
||||
main_class : 'com.mesonbuild.Linking',
|
||||
link_with : simplelib)
|
||||
test('mytest', javaprog)
|
|
@ -0,0 +1,7 @@
|
|||
package com.mesonbuild;
|
||||
|
||||
public class SimpleLib {
|
||||
public static void func() {
|
||||
System.out.println("Java linking is working.\n");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
simplelib = jar('simplelib',
|
||||
'com/mesonbuild/SimpleLib.java')
|
Loading…
Reference in New Issue