XTend的命令行编译器

时间:2012-12-30 16:08:15

标签: eclipse command-line compiler-construction xtend

大家好,我发现了XTend(http://xtend-lang.org),听起来真棒!但是,我看不到这种语言的任何独立命令行编译器。它似乎只能在日食下运行。我做了一些研究,发现有人说,它有一个命令行编译器,但我找不到下载链接。
编译器是存在的,独立的,还是需要eclipse才能使用它? 此致

2 个答案:

答案 0 :(得分:6)

没有记录,但Xtend代码库中确实存在命令行编译器 - 与Maven plug-in使用的命令行编译器相同(在Xtend主页中记录)。

如果Maven插件不适合您,那么您可以直接从http://build.eclipse.org/common/xtend/maven/org/eclipse/xtend/org.eclipse.xtend.standalone/2.3.1/(版本2.3.1)的Maven存储库下载独立jar版本,并执行org.eclipse.xtend.core.compiler.batch.Main类从它。

此类执行xtend编译器,并且可以显示用法信息(也可以从source file读取)。

答案 1 :(得分:1)

您可以使用xtend独立编译器。就我而言,我将以下.jar文件复制到名为xtendc的文件夹中:

com.google.guava_21.0.0.v20170206-1425.jar
com.google.inject_3.0.0.v201312141243.jar
javax.inject_1.0.0.v20091030.jar
org.antlr.runtime_3.2.0.v201101311130.jar
org.apache.log4j_1.2.15.v201012070815.jar
org.eclipse.emf.common_2.15.0.v20180914-1817.jar
org.eclipse.emf.ecore.xmi_2.15.0.v20180706-1146.jar
org.eclipse.emf.ecore_2.16.0.v20181124-0637.jar
org.eclipse.equinox.common_3.10.200.v20181021-1645.jar
org.eclipse.jdt.core_3.16.0.v20181130-1748.jar
org.eclipse.xtend.core_2.16.0.v20181203-1347.jar
org.eclipse.xtend.lib.macro_2.16.0.v20181203-0507.jar
org.eclipse.xtext.common.types_2.16.0.v20181203-0528.jar
org.eclipse.xtext.util_2.16.0.v20181203-0514.jar
org.eclipse.xtext.xbase.lib_2.16.0.v20181203-0507.jar
org.eclipse.xtext.xbase_2.16.0.v20181203-0528.jar
org.eclipse.xtext_2.16.0.v20181203-0514.jar
org.objectweb.asm_7.0.0.v20181030-2244.jar

然后,在该文件夹中,我执行了批处理编译器的CLI主类:

java -cp "*" org.eclipse.xtend.core.compiler.batch.Main -d <path-to-xtend-gen-folder>  -useCurrentClassLoader <path-to-src-folder>

主要类的CLI用法记录如下:

Usage: Main <options> <source directories>
where possible options include:
-d <directory>                      Specify where to place generated xtend files
-tp <path>                          Temp directory to hold generated stubs and classes
-cp <path>                          Specify where to find user class files
-encoding <encoding>                Specify character encoding used by source files
-javaSourceVersion <version>        Create Java Source compatible to this version. Can be: 1.5, 1.6, 1.7, 1.8, 9, 10
-noSuppressWarningsAnnotation       Don't put @SuppressWarnings() into generated Java Code
-generateGeneratedAnnotation        Put @Generated into generated Java Code
-includeDateInGeneratedAnnnotation  If -generateGeneratedAnnotation is used, add the current date/time.
-generateAnnotationComment <string> If -generateGeneratedAnnotation is used, add a comment.
-useCurrentClassLoader              Use current classloader as parent classloader
-writeTraceFiles                    Write Trace-Files

所以您需要在此处传递类路径。