diff options
author | Robert Bragg <robert@impossible.com> | 2018-02-08 00:11:26 +0000 |
---|---|---|
committer | Niclas Moeslund Overby <noverby@prozum.dk> | 2018-05-16 14:53:30 +0200 |
commit | 61dd46811b324a070c9a5007ac9b92a58fce9bb4 (patch) | |
tree | 8be65dcaf8f6859b01f9f20f951c407b5734f98f /test cases | |
parent | 65b730bd59790338a6bfad6f976ff74b12d6bc13 (diff) | |
download | meson-61dd46811b324a070c9a5007ac9b92a58fce9bb4.zip meson-61dd46811b324a070c9a5007ac9b92a58fce9bb4.tar.gz meson-61dd46811b324a070c9a5007ac9b92a58fce9bb4.tar.bz2 |
ninja: avoid needing include_directory('.') with jar()
Although only one file is passed to javac at a time, if your code has
any inter-file dependencies javac still needs to know how to find other
source files for its -implicit:class feature to work whereby it will
automatically also compile files that the given file depends on.
-implicit:class is the default, practical, behaviour of javac since
otherwise it would be necessary to declare the class dependencies
for parallel java builds to be feasible.
Passing "include_directory: include_directory('.')" to jar() causes
-souredir <path/to/top/of/java/src> to be passed to javac which then
enables your source code to have inter-file class dependencies -
assuming none of your source code is generated.
This ensures that '.' is included by default.
Diffstat (limited to 'test cases')
3 files changed, 36 insertions, 0 deletions
diff --git a/test cases/java/6 no includedirs/com/mesonbuild/Simple.java b/test cases/java/6 no includedirs/com/mesonbuild/Simple.java new file mode 100644 index 0000000..05a73ac --- /dev/null +++ b/test cases/java/6 no includedirs/com/mesonbuild/Simple.java @@ -0,0 +1,8 @@ +package com.mesonbuild; + +class Simple { + public static void main(String [] args) { + TextPrinter t = new TextPrinter("Printing from Java."); + t.print(); + } +} diff --git a/test cases/java/6 no includedirs/com/mesonbuild/TextPrinter.java b/test cases/java/6 no includedirs/com/mesonbuild/TextPrinter.java new file mode 100644 index 0000000..7e330a6 --- /dev/null +++ b/test cases/java/6 no includedirs/com/mesonbuild/TextPrinter.java @@ -0,0 +1,14 @@ +package com.mesonbuild; + +class TextPrinter { + + private String msg; + + TextPrinter(String s) { + msg = s; + } + + public void print() { + System.out.println(msg); + } +} diff --git a/test cases/java/6 no includedirs/meson.build b/test cases/java/6 no includedirs/meson.build new file mode 100644 index 0000000..b399211 --- /dev/null +++ b/test cases/java/6 no includedirs/meson.build @@ -0,0 +1,14 @@ +# It used to be necessary to pass: +# +# include_directories: include_directories('.') +# +# to any use of jar() to compile source code with inter-file class +# dependencies. This is now the default behaviour. + +project('noincludedirsjava', 'java') + +javaprog = jar('myprog', + 'com/mesonbuild/Simple.java', + 'com/mesonbuild/TextPrinter.java', + main_class : 'com.mesonbuild.Simple') +test('subdirtest', javaprog) |