java - SCons 在创建 jar 时没有获取所有类文件

标签 java jar scons

SCons 新手在这里。我正在使用它(2.0 版)创建一个 jar,如下所示:

compiled_classes = env.Java \
                   (target = compiled_classes_dir, 
                    source = source_tld, 
                    JAVAVERSION='1.6',
                    JAVACLASSPATH=['source_tld/libs/' + 
                                   file.name 
                                   for file in 
                                   Glob('source_tld/' +
                                   'libs/*.jar')])

new_jar = env.Jar(target = jar_name,
                  source = compiled_classes_dir)

我看到一个问题,其中属于具有内部类的类的类文件(当编译成类文件时名称中有 $)没有被正确处理,即它们没有被包含在生成的 JAR 中。任何解决此问题的建议将不胜感激。 TIA。

附言:This添加 JAVAVERSION 的建议似乎没有帮助。

最佳答案

由于 SCons 无法正确计算输出类别,因此我建议采用此解决方法。

compiled_classes = env.Java \
                   (target = compiled_classes_dir, 
                    source = source_tld, 
                    JAVAVERSION='1.6',
                    JAVACLASSPATH=['source_tld/libs/' + 
                                   file.name 
                                   for file in 
                                   Glob('source_tld/' +
                                   'libs/*.jar')])
#workaround to make sure classes are cleaned
env.Clean(compiled_classes, env.Dir(compiled_classes_dir))

# its important to set the JARCHDIR or the Jar command will not be run
# from the correct location if you want an executable Jar add the manifest here  
new_jar = env.Jar(target = jar_name,
                  source = [compiled_classes_dir], JARCHDIR='$SOURCE')

关于java - SCons 在创建 jar 时没有获取所有类文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17180646/

相关文章:

java - 无法使用服务安装mysql

maven - 使用 maven 构建一个 fat jar 子

java - 谷歌应用程序引擎,导入的jar运行速度非常慢

scons:多个文件作为目标

java - 为什么 Java 编译器不能从另一个文件中找到类?

java - JPA 处理没有外键的关系

java - 如何使用Java BO SDK 读取联合和合并的Webi 报告?

java - 带空格的 Docker 环境变量

python - Py_Initialize 抛出 ModuleNotFoundError : No module named 'encodings'

java - "jar"命令何时会拒绝将类添加到 .jar 文件?