通过IKVM关闭模板?

时间:2012-10-11 14:44:14

标签: google-closure-compiler ikvm

Google Closure在没有Java运行时环境by using IKVM

的情况下运行良好

如果它消失了,将它转换为exe的简化步骤是:

  1. 下载并解压缩(但安装除外)Closure CompilerIKVM
  2. 将compiler.jar移至IKVM bin文件夹
  3. ikvmc -target:exe -fileversion:2012.09.17 .\compiler.jar(带有jar的发布日期)。注意:我收到一些关于ANT库的警告。
  4. 将这些依赖项从ikvm bin目录复制到闭包目录:
    • IKVM.OpenJDK.Core.dll
    • IKVM.OpenJDK.Jdbc.dll
    • IKVM.OpenJDK.Misc.dll
    • IKVM.OpenJDK.SwingAWT.dll
    • IKVM.OpenJDK.Text.dll
    • IKVM.OpenJDK.Util.dll
    • XML.API.dll
    • IKVM.Runtime.dll
  5. 然后你可以将compiler.jar和new compiler.exe移回你的闭包目录。 Fredrik建议执行 powershell 版本,因为能够指定ascii编码覆盖unicode(一半字节):

    .\compiler.exe --js .\jquery-1.4.2.js --warning_level QUIET | out-file -encoding ascii .\jquery.min.js
    

    ==============================

    但是,我对Closure模板的SoyToJsSrcCompiler.jar没有同样的运气。我从ikvmc -target:exe -fileversion:2011.12.22 .\SoyToJsSrcCompiler.jar收到警告compiler.jar

    warning IKVMC0105: Unable to compile class "com.google.template.soy.jssrc.internal.GenerateSoyUtilsEscapingDirectiveCode"
        (missing class "org.apache.tools.ant.Task")
    warning IKVMC0100: Class "com.google.inject.internal.asm.util.$TraceClassVisitor" not found
    warning IKVMC0111: Emitted java.lang.NoClassDefFoundError in "com.google.inject.internal.cglib.core.$DebuggingClassWriter$1.run()Ljava.lang.Object;"
        ("com.google.inject.internal.asm.util.$TraceClassVisitor")
    warning IKVMC0100: Class "com.google.template.soy.jssrc.internal.GenerateSoyUtilsEscapingDirectiveCode" not found
    

    没有命令行参数的结果SoyToJsSrcCompiler.exe用于显示帮助页面,但提供.soy文件会给出:

    Exception in thread "main" cli.System.MethodAccessException: 
    com.google.inject.assistedinject.FactoryProvider2.getBindingFromNewInjector(java.lang.reflect.Method, System.Object[], AssistData) at 
    com.google.inject.assistedinject.FactoryProvider2$$FastClassByGuice$$9dcdf6d7.invoke() at 
    com.google.inject.internal.cglib.reflect.$FastMethod.invoke(FastMethod.java:53) at 
    com.google.inject.internal.SingleMethodInjector$1.invoke(SingleMethodInjector.java:56) at 
    com.google.inject.internal.SingleMethodInjector.inject(SingleMethodInjector.java:90) at 
    com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:107) at 
    com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:76) at 
    com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:73) at 
    com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031) at 
    com.google.inject.internal.MembersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:88) at
    com.google.inject.internal.Initializer$InjectableReference.get(Initializer.java:150) at 
    com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40) at 
    com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:53) at 
    com.google.inject.internal.InjectionRequestProcessor$StaticInjection$1.call(InjectionRequestProcessor.java:11 6) at 
    com.google.inject.internal.InjectionRequestProcessor$StaticInjection$1.call(InjectionRequestProcessor.java:11 0) at 
    com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024) at 
    com.google.inject.internal.InjectionRequestProcessor$StaticInjection.injectMembers(InjectionRequestProcessor. java:110) at 
    com.google.inject.internal.InjectionRequestProcessor.injectMembers(InjectionRequestProcessor.java:78) at 
    com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:171) at 
    com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:111) at 
    com.google.inject.Guice.createInjector(Guice.java:95) at 
    com.google.inject.Guice.createInjector(Guice.java:72) at 
    com.google.template.soy.MainClassUtils.createInjector(MainClassUtils.java:212) at 
    com.google.template.soy.SoyToJsSrcCompiler.execMain(SoyToJsSrcCompiler.java:223) at 
    com.google.template.soy.SoyToJsSrcCompiler.main(SoyToJsSrcCompiler.java:205)
    

    任何人都知道如何让它发挥作用?

1 个答案:

答案 0 :(得分:1)

异常可能是IKVM中的错误。你用的是哪个版本?测试最新版本。

  

警告IKVMC0100:未找到“com.google.template.soy.jssrc.internal.GenerateSoyUtilsEscapingDirectiveCode”类

另一个问题可能是您没有为SoyToJsSrcCompiler.jar编译所有需要的jar文件。哪个jar文件是这个丢失的类文件?查看wiki以了解如何编译多个jar文件。

下一个问题可能是不同的jar文件中有相同的包。对于某些方法,只有包可见,这对.NET不起作用。您可以测试sharedclassloader。有关详细信息,请参阅wiki