在 IntelliJ Idea 15.04 上使用 maven 构建 jcarsdsim

Posted

技术标签:

【中文标题】在 IntelliJ Idea 15.04 上使用 maven 构建 jcarsdsim【英文标题】:Building jcarsdsim with maven on IntelliJ Idea 15.04 【发布时间】:2016-06-19 20:32:08 【问题描述】:

所以假设我正在从源代码构建that 存储库。 Here是开发者给出的指令。

使用内置的 ItlliJ VCS 工具克隆它之后,我稍微修改了默认 pom.xml 以便 maven 工作。

所以,在 maven 控制台中执行 mvn initialize 后,我得到了以下日志:

"C:\Program Files\Java\jdk1.8.0_73\bin\java" "-Dmaven.home=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\plugins\maven\lib\maven3\bin\m2.conf" -Didea.launcher.port=7537 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\plugins\maven\lib\maven3\boot\plexus-classworlds-2.4.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=15.0.4 initialize
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Java Card Runime Environment Simulator 3.0.4
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install-file (default) @ jcardsim ---
[INFO] pom.xml not found in api.jar
[INFO] Installing C:\java_card_kit-2_2_2\lib\api.jar to C:\Users\Foo\.m2\repository\oracle\javacard\api_classic\2.2.2\api_classic-2.2.2.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.527s
[INFO] Finished at: Sun Mar 06 10:19:39 MSK 2016
[INFO] Final Memory: 5M/116M
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

没关系,我猜。

但是在执行mvn clean install 以制作.jar 文件时,我遇到了以下错误:

"C:\Program Files\Java\jdk1.8.0_73\bin\java" "-Dmaven.home=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\plugins\maven\lib\maven3\bin\m2.conf" -Didea.launcher.port=7538 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\plugins\maven\lib\maven3\boot\plexus-classworlds-2.4.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=15.0.4 clean install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Java Card Runime Environment Simulator 3.0.4
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ jcardsim ---
[INFO] Deleting C:\Users\Foo\Documents\GitHub\jcardsim\target
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install-file (default) @ jcardsim ---
[INFO] pom.xml not found in api.jar
[INFO] Installing C:\java_card_kit-2_2_2\lib\api.jar to C:\Users\Foo\.m2\repository\oracle\javacard\api_classic\2.2.2\api_classic-2.2.2.jar
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ jcardsim ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Foo\Documents\GitHub\jcardsim\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ jcardsim ---
[INFO] Compiling 86 source files to C:\Users\Foo\Documents\GitHub\jcardsim\target\classes
[INFO] 
[INFO] --- maven-dependency-plugin:2.10:unpack (default) @ jcardsim ---
[INFO] Configured Artifact: oracle.javacard:api_classic:2.2.2:jar
[INFO] Unpacking C:\Users\Foo\.m2\repository\oracle\javacard\api_classic\2.2.2\api_classic-2.2.2.jar to C:\Users\Foo\Documents\GitHub\jcardsim\target\classes with includes "**/*.class" and excludes ""
[INFO] 
[INFO] --- exec-maven-plugin:1.4.0:java (default) @ jcardsim ---
[WARNING] 
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: ClassReader.accept() should be called with EXPAND_FRAMES flag
    at org.objectweb.asm.commons.LocalVariablesSorter.visitFrame(Unknown Source)
    at org.objectweb.asm.commons.RemappingMethodAdapter.visitFrame(Unknown Source)
    at org.objectweb.asm.tree.FrameNode.accept(Unknown Source)
    at org.objectweb.asm.tree.InsnList.accept(Unknown Source)
    at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
    at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
    at org.objectweb.asm.tree.ClassNode.accept(Unknown Source)
    at com.licel.jcardsim.utils.JavaCardApiProcessor.proxyClass(JavaCardApiProcessor.java:92)
    at com.licel.jcardsim.utils.JavaCardApiProcessor.main(JavaCardApiProcessor.java:47)
    ... 6 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.245s
[INFO] Finished at: Sun Mar 06 10:21:25 MSK 2016
[INFO] Final Memory: 20M/201M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (default) on project jcardsim: An exception occured while executing the Java class. null: InvocationTargetException: ClassReader.accept() should be called with EXPAND_FRAMES flag -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Process finished with exit code 1

由于我是 Java 世界的新手,尤其是 Maven,我想知道问题是什么以及如何正确解决它?

我正在使用IntelliJ Idea 15.04Java 1.8JCSDK 2.2.2 运行 Windows 8.1

更新

Here 是原版和我的pom.xml 之间的区别

Here 是mvn -X clean install 的输出

【问题讨论】:

我没有检查项目,但您可以使用 -Xe 标志尝试更详细的 maven 输出。 您是否更改了pom.xml 中的任何依赖版本,例如org.ow2.asm/asm-all?您对pom.xml 做了哪些更改? 【参考方案1】:

如果您从

恢复更改
<java.version>1.8</java.version>

返回

<java.version>1.5</java.version>

它会起作用的。

如果要生成 Java 8 字节码,需要以适当的方式修改 JavaCardApiProcessor.java 类。

【讨论】:

【参考方案2】:

我已经包含了几个拉取请求,这个版本使用my fork 中更新的代码库。还有一个新发布的Maven package。

【讨论】:

以上是关于在 IntelliJ Idea 15.04 上使用 maven 构建 jcarsdsim的主要内容,如果未能解决你的问题,请参考以下文章

20220723-Mac上使用IntelliJ IDEA

怎样在intellij idea 上开发struts应用

IntelliJ IDEA常用快捷键总结

idea 使用idea上传项目到码云(gitee)上 IntelliJ IDEA

在Intellij IDEA搭建Scala开发环境,以及使用Intellij IDEA开发Scala程序

在Mac上安装IntelliJ IDEA