我对ENTER
插件进行了一些更改,以支持类似于Java的语言(MaxJ)。我所做的更改可以在这里找到:
https://github.com/maxeler/eclipse.jdt.core/tree/MAXJ_4_4_maintenance
我的插件发布可以在这里找到:
https://github.com/maxeler/eclipse/releases
当我在GUI模式下使用eclipse时,一切正常,但我想从命令行(无头构建或使用ant)编译不同的项目,为此我需要创建新的elipse.jdt.core
文件。我尝试构建这个库:
https://github.com/maxeler/maxpower
根据这篇文章:
可以使用 ecj.jar
代替jdtCompilerAdapter.jar
,但这不起作用,因为它不包含编译器类(如ecj.jar
等)。
在CompilerOptions
文件中,我更改了以下行:
build.xml
用这个:
<taskdef name="maxjcompiler" classname="org.eclipse.jdt.core.ant.taskdef.MaxjTask" classpath="${env.MAXCOMPILERDIR}/lib/MaxIDE/ecj.jar" onerror="ignore"/>
<taskdef name="maxjdoc" classname="org.eclipse.jdt.core.ant.taskdef.MaxjDocTask" classpath="${env.MAXCOMPILERDIR}/lib/MaxIDE/ecj.jar"/>
然后我运行此命令来启动构建过程:
<taskdef name="maxjcompiler" classname="org.eclipse.jdt.core.ant.taskdef.MaxjTask" classpath="/pathToMyJar/jdtCompilerAdapter.jar" onerror="ignore"/>
<taskdef name="maxjdoc" classname="org.eclipse.jdt.core.ant.taskdef.MaxjDocTask" classpath="/home/ikulezic/Desktop/jdtCompilerAdapter.jar"/>
它会产生以下错误:
ant
目前似乎唯一的选择是构建一个新的Buildfile: /home/ikulezic/Desktop/maxpower/build.xml
[taskdef] Could not load definitions from resource org/jacoco/ant/antlib.xml. It could not be found.
clean:
[delete] Deleting directory /home/ikulezic/Desktop/maxpower/bin
compile:
[echo]
[echo] Using maxeda classpath '/opt/maxcompiler/lib/MaxCompiler.jar'
[echo] (Precedence: 1. $MAXCOMPILERJCP, 2. $MAXCOMPILERDIR)
[echo]
[echo]
[mkdir] Created dir: /home/ikulezic/Desktop/maxpower/bin
BUILD FAILED
/home/ikulezic/Desktop/maxpower/build.xml:66: Could not create type maxjcompiler due to java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/compiler/impl/CompilerOptions
at org.eclipse.jdt.core.ant.taskdef.MaxjTask.<init>(MaxjTask.java:80)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.tools.ant.AntTypeDefinition.innerCreateAndSet(AntTypeDefinition.java:328)
at org.apache.tools.ant.AntTypeDefinition.createAndSet(AntTypeDefinition.java:274)
at org.apache.tools.ant.AntTypeDefinition.icreate(AntTypeDefinition.java:219)
at org.apache.tools.ant.AntTypeDefinition.create(AntTypeDefinition.java:206)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:285)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:263)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:429)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
at org.apache.tools.ant.Task.perform(Task.java:347)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jdt.internal.compiler.impl.CompilerOptions
at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1366)
at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1315)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1068)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 24 more
Total time: 0 seconds
文件,但我找不到办法。
答案 0 :(得分:1)
如何构建ecj.jar
取决于您使用的构建技术。
如果您配置了上下文以便可以使用 Maven / Tycho 构建org.eclipse.jdt.core
,那么您应该调整项目内的batch-compiler
执行pom .XML。
否则,更轻量级的方法应该是使用scripts/export-ecj.xml
调用 Ant 。该文件可能有点过时,但您可以查看这是如何适应创建另一个ecj变体(OT/J),请参阅:http://git.eclipse.org/c/objectteams/org.eclipse.objectteams.git/tree/org.eclipse.jdt.core/scripts/export-ecj.xml。
对于OT / J,此脚本是从基于Ant的PDE构建过程调用的,因此对于独立调用,需要首先配置一组特性。
build.root.dir
等属性。否则,对apt和tool的部分进行注释应该可以帮到你。buildLabel
设置为有用的内容通过这些准备工作,我可以在IDE中成功运行Ant。