我创建了一个 Perl 模块来提供与 RNG 处理 Java 库Jing的接口。代码位于此处。我[Inline::Java][3]
用来编译和加载一个使用 的小类jing.jar
,它们都位于java
目录中,通过[File::ShareDir][4]
. 运行prove -vl
or dzil test
,模块运行良好,测试全部通过:
>prove -vl
t\0-use.t .............
1..1
ok 1 - use XML::Jing;
ok
t\01-validates_xml.t ..
1..3
ok 1 - successfully reads a valid RNG
ok 2 - returns nothing when XML file is valid
ok 3
ok
t\02-exceptions.t .....
1..5
ok 1 - warning for nonexistent RNG file
ok 2 - constructor returns nothing for non-existent RNG file
ok 3 - warning for bad RNG file
ok 4 - constructor returns nothing for bad RNG file
ok 5 - warning for nonexistent XML file
ok
All tests successful.
Files=3, Tests=9, 6 wallclock secs ( 0.11 usr + 0.05 sys = 0.16 CPU)
Result: PASS
使用以下命令构建发行版时,测试也会通过dzil build
:
dzil build
cd XML-Jing-0.x
perl Build.PL
build
build test
但是,使用dzil release
Inline::Java 在尝试加载 jing.jar 时会发出嘶嘶声。我们在下面得到这些疯狂的错误:
BEGIN failed--compilation aborted at t/01-validates_xml.t line 5.
t/01-validates_xml.t ..........
Dubious, test returned 1 (wstat 256, 0x100)
No subtests run
A problem was encountered while attempting to compile and install your InlineJava code. The command that failed was:
"C:\Program Files\Java\jdk1.7.0_21\bin\javac.exe" -deprecation -d "C:\strawberry\cpan\build\XML-Jing-0.01-Skydfp\_Inline\lib\auto\XML\Jing_706b" RNGValidator.java > cmd.out 2>&1
The build directory was:
C:\strawberry\cpan\build\XML-Jing-0.01-Skydfp\_Inline\build\XML\Jing_706b
The error message was:
error: error reading C:\strawberry\cpan\build\XML-Jing-0.01-Skydfp\blib\lib\auto\share\dist\XML-Jing\jing.jar; invalid END header (bad central directory offset)
目前我使用开始块加载 jar 来编辑CLASSPATH
变量:
BEGIN{
use Env::Path;
my $classpath = Env::Path->CLASSPATH;
$classpath->Append(path(dist_dir('XML-Jing'),'jing.jar'));
}
使用jarsigner
,我验证了 jar 在由创建的构建文件夹中损坏,dzil release
但在由以下创建的文件夹中未损坏dzil build
:
在通过创建的构建中dzil build
:
jarsigner -verify java/jing.jar
jar is unsigned. (signatures missing or not parsable)
在通过创建的构建中dzil release
:
jarsigner -verify java/jing.jar
jarsigner: java.util.zip.ZipException: invalid END header (bad central directory offset)
总而言之,dzil release
在我的共享目录中破坏了一个 jar,而dzil build
没有。谁能告诉我我需要做什么才能使这个模块正常工作?