diff options
-rw-r--r-- | src/engine/SCons/Tool/jar.py | 2 | ||||
-rw-r--r-- | test/Java/JAR.py | 87 |
2 files changed, 88 insertions, 1 deletions
diff --git a/src/engine/SCons/Tool/jar.py b/src/engine/SCons/Tool/jar.py index 49600e0..91222d6 100644 --- a/src/engine/SCons/Tool/jar.py +++ b/src/engine/SCons/Tool/jar.py @@ -161,7 +161,7 @@ def Jar(env, target = None, source = [], *args, **kw): # loop through the sources and handle each accordingly # the goal here is to get all the source files into a class # file or a directory that contains class files - for s in source: + for s in SCons.Util.flatten(source): s = env.subst(s) if isinstance(s, SCons.Node.FS.Base): if isinstance(s, SCons.Node.FS.File): diff --git a/test/Java/JAR.py b/test/Java/JAR.py index b9a5191..2353c10 100644 --- a/test/Java/JAR.py +++ b/test/Java/JAR.py @@ -330,6 +330,93 @@ test.must_exist(['testdir2','bar.jar']) test.must_exist(['testdir2', 'barTest', 'com', 'javasource', 'JavaFile1.class']) test.must_exist(['testdir2', 'barTest', 'com', 'javasource', 'JavaFile2.class']) test.must_exist(['testdir2', 'barTest', 'com', 'javasource', 'JavaFile3.class']) + + +####### +# test list of lists + +# make some directories to test in +test.subdir('listOfLists', + ['listOfLists', 'src'], + ['listOfLists', 'src', 'com'], + ['listOfLists', 'src', 'com', 'javasource'], + ['listOfLists', 'src', 'com', 'resource']) + +# simple SConstruct which passes the 3 .java as source +# and extracts the jars back to classes +test.write(['listOfLists', 'SConstruct'], """ +foo = Environment() +list_of_class_files = foo.Java('src', source=['src']) +resources = ['src/com/resource/resource1.txt', 'src/com/resource/resource2.txt'] +contents = [list_of_class_files, resources] +foo.Jar(target = 'lists', source = contents + ['MANIFEST.mf'], JARCHDIR='src') +foo.Command("listsTest", [], Mkdir("listsTest") ) +foo.Command('listsTest/src/com/javasource/JavaFile3.java', 'lists.jar', foo['JAR'] + ' xvf ../lists.jar', chdir='listsTest') +""") + +test.write(['listOfLists', 'src', 'com', 'javasource', 'JavaFile1.java'], """\ +package com.javasource; + +public class JavaFile1 +{ + public static void main(String[] args) + { + + } +} +""") + +test.write(['listOfLists', 'src', 'com', 'javasource', 'JavaFile2.java'], """\ +package com.javasource; + +public class JavaFile2 +{ + public static void main(String[] args) + { + + } +} +""") + +test.write(['listOfLists', 'src', 'com', 'javasource', 'JavaFile3.java'], """\ +package com.javasource; + +public class JavaFile3 +{ + public static void main(String[] args) + { + + } +} +""") + +test.write(['listOfLists', 'MANIFEST.mf'], +"""Manifest-Version: 1.0 +MyManifestTest: Test +""") + +test.write(['listOfLists', 'src', 'com', 'resource', 'resource1.txt'], """\ +this is a resource file +""") + +test.write(['listOfLists', 'src', 'com', 'resource', 'resource2.txt'], """\ +this is another resource file +""") + + +test.run(chdir='listOfLists') + +#test single target jar +test.must_exist(['listOfLists','lists.jar']) + +# make sure there are class in the jar +test.must_exist(['listOfLists', 'listsTest', 'com', 'javasource', 'JavaFile1.class']) +test.must_exist(['listOfLists', 'listsTest', 'com', 'javasource', 'JavaFile2.class']) +test.must_exist(['listOfLists', 'listsTest', 'com', 'javasource', 'JavaFile3.class']) +test.must_exist(['listOfLists', 'listsTest', 'com', 'resource', 'resource1.txt']) +test.must_exist(['listOfLists', 'listsTest', 'com', 'resource', 'resource2.txt']) +test.must_exist(['listOfLists', 'listsTest', 'META-INF', 'MANIFEST.MF']) +test.must_contain(['listOfLists', 'listsTest', 'META-INF', 'MANIFEST.MF'], b"MyManifestTest: Test" ) test.pass_test() |