我试图让j2objc运行在gradle项目中的一些java模块上。我使用j2objc的gradle插件,但我不相信这是任何问题的根源。该模块使用XMLUnit来检测输入文件的差异。 XMLUnit包含一个org.xmlunit.builder.JaxbBuilder
类,由于没有看到j2objc中省略的一些javax类,可能会因翻译失败而导致翻译失败。无论如何,我的代码不会使用JaxbBuilder
类,因此我创建了一个死代码报告以省略它。我知道我可以使用proguard生成一个更完整的集合,但现在,我的重点仅仅是防止尝试这个类,因为我仍然在为所有这些构建一个gradle CI流水线。这份报告的题目是dead_code.log
,仅包含以下行:j2objc不尊重死代码报告
org.xmlunit.builder.JaxbBuilder
的j2objc插件配置规定为:
j2objcConfig {
autoConfigureDeps true
// Xcode workspace directory
xcodeProjectDir '../ios'
translateArgs '--dead-code-report', './dead_code.log'
translateArgs '--doc-comments'
translateArgs '-v'
finalConfigure() // Must be last call to configuration
}
而且我可以在加死码参数在日志中看到到命令行,但在执行我然后看到:
INEST: parsing jar:file:/Users/jenkins/.gradle/caches/modules-2/files-2.1/org.xmlunit/xmlunit-core/2.0.0-SNAPSHOT/b11b5e5d8e9f223af2fbaa93982d17b55899498/xmlunit-core-2.0.0-SNAPSHOT-sources.jar!org/xmlunit/builder/JaxbBuilder.java error: org/xmlunit/builder/JaxbBuilder.java:19: The import javax.xml.bind cannot be resolved error: org/xmlunit/builder/JaxbBuilder.java:20: The import javax.xml.bind cannot be resolved error: org/xmlunit/builder/JaxbBuilder.java:21: The import javax.xml.bind cannot be resolved error: org/xmlunit/builder/JaxbBuilder.java:22: The import javax.xml.bind cannot be resolved error: org/xmlunit/builder/JaxbBuilder.java:23: The import javax.xml.bind cannot be resolved error: org/xmlunit/builder/JaxbBuilder.java:24: The import javax.xml.bind cannot be resolved error: org/xmlunit/builder/JaxbBuilder.java:25: The import javax.xml.bind cannot be resolved error: org/xmlunit/builder/JaxbBuilder.java:26: The import javax.xml.bind cannot be resolved error: org/xmlunit/builder/JaxbBuilder.java:27: The import javax.xml.bind cannot be resolved error: org/xmlunit/builder/JaxbBuilder.java:31: The import java.beans.Introspector cannot be resolved error: org/xmlunit/builder/JaxbBuilder.java:43: Marshaller cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:56: Marshaller cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:57: Marshaller cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:82: Marshaller cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:83: The method createDefaultMarshaller() from the type JaxbBuilder refers to the missing type JAXBException error: org/xmlunit/builder/JaxbBuilder.java:87: JAXBSource cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:87: JAXBSource cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:87: Marshaller cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:92: JAXBException cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:93: DataBindingException cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:99: JAXBElement cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:103: XmlRootElement cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:103: Bound mismatch: The generic method getAnnotation(Class) of type AnnotatedElement is not applicable for the arguments (Class). The inferred type XmlRootElement is not a valid substitute for the bounded parameter error: org/xmlunit/builder/JaxbBuilder.java:103: XmlRootElement cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:106: The method createJAXBElement(Object) from the type JaxbBuilder refers to the missing type JAXBElement error: org/xmlunit/builder/JaxbBuilder.java:108: The method createInferredJAXBElement(Object) from the type JaxbBuilder refers to the missing type JAXBElement error: org/xmlunit/builder/JaxbBuilder.java:117: JAXBException cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:117: PropertyException cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:118: JAXBContext cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:119: JAXBElement cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:120: JAXBContext cannot be resolved error: org/xmlunit/builder/JaxbBuilder.java:120: JAXBElement cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:120: JAXBElement cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:123: JAXBContext cannot be resolved error: org/xmlunit/builder/JaxbBuilder.java:125: Marshaller cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:126: Marshaller cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:126: Marshaller cannot be resolved to a variable error: org/xmlunit/builder/JaxbBuilder.java:130: JAXBElement cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:133: JAXBElement cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:136: JAXBElement cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:137: JAXBElement cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:137: The method createJaxbElementFromObjectFactory(T) from the type JaxbBuilder refers to the missing type JAXBElement error: org/xmlunit/builder/JaxbBuilder.java:139: The method createInferredJAXBElement(T) from the type JaxbBuilder refers to the missing type JAXBElement error: org/xmlunit/builder/JaxbBuilder.java:146: JAXBElement cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:156: JAXBElement cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:161: JAXBElement cannot be resolved to a type error: org/xmlunit/builder/JaxbBuilder.java:174: Introspector cannot be resolved
我认为这意味着它试图处理是JaxbBuilder
类。配置中是否有某些我缺少的东西?
谢谢。现在我试着指定引导类路径,它工作。违规进口已经解决,但是这个违规类已经被翻译了。我想如果代码试图使用它的东西会失败,但我至少能够导出我需要的代码。一个让我前进的临时解决方案。我还会要求你建议的插件选项。 – Jared
Jared - 你能否在插件问题页面上写下请求:https://github.com/j2objc-contrib/j2objc-gradle/issues/ – brunobowden