5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 Test that when JARCHDIR that our command to create .jar files
28 correctly finds all the .class files (by putting -C in front
29 of each class file argument).
31 Includes logic to make sure that expansions of $JARCHDIR that include
32 ${TARGET} or ${SOURCE} work.
38 test
= TestSCons
.TestSCons()
39 # Keep this logic because it skips the test if javac or jar not found.
40 where_javac
, java_version
= test
.java_where_javac()
41 where_jar
= test
.java_where_jar()
43 test
.write('SConstruct', """
44 DefaultEnvironment(tools=[])
46 env = Environment(tools=['javac', 'jar'], JARCHDIR=dir)
47 bin = env.Java(dir, Dir('./'))
48 jar = env.Jar(File('c.jar', dir), bin)
50 # Make sure we handle class files with $ in them, such as typically
51 # created for inner classes.
52 env = env.Clone(JARCHDIR='.')
53 inner = env.Jar('inner.jar', 'Inner$$Class.class')
55 # Commented out as this logic doesn't work as is.
56 # target_env = env.Clone(JARCHDIR = '${TARGET.dir}')
57 # target_env.Jar('out/t.jar', 'in/t.class')
59 source_env = env.Clone(JARCHDIR='${SOURCE.dir}')
60 source_env.Jar('out/s.jar', 'in/s.class')
62 Default(bin, jar, inner)
67 test
.write('a.java', """\
72 test
.write('b.java', """\
77 test
.write(['in', 's.class'], "s.class\n")
79 # Okay, this is bogus, but we're going with it for testing purposes.
80 # If jar gets a command line like:
82 # jar cf out/t.jar -C out /tmp/tmpXYZZY/in/t.class
84 # Empirically, it doesn't seem to treat the absolute path name
85 # of the argument class file as an absolute path, but looks for
86 # "out/tmp/tmpXYZZY/in/t.class". SCons, however, still looks for it in
87 # the path name specified on the command line. To make this test work,
88 # we're going to just create the t.class file in both locations, and
89 # we can revisit this if someone actually tries to use ${TARGET.dir}
90 # in a real-life expansion. Right now, it at least makes sure things
91 # don't blow up (i.e., validates that we pass the right arguments to
92 # env.subst() in the code that handle jar).
94 # p = test.workpath('out')
95 # for d in test.workpath('in').split(os.sep):
100 # test.write([p, 't.class'], "t.class\n")
101 test
.write(['in', 't.class'], "t.class\n")
103 test
.write('Inner$Class.class', "Inner$Class.class\n")
105 test
.run(arguments
= '.')
111 # indent-tabs-mode:nil
113 # vim: set expandtab tabstop=4 shiftwidth=4: