compile via command line

114 views
Skip to first unread message

Ben

unread,
Aug 23, 2014, 10:37:41 PM8/23/14
to xtend...@googlegroups.com
I don't under stand how to go about compiling via command line & without eclipse. It's been asked a few times the best I can find is this:

https://groups.google.com/forum/#!searchin/xtend-lang/command$20line/xtend-lang/jx0DsWx5JSE/nl5CLPfAbj4J



There is also a simple main class you can call from the command line. Its name is org.eclipse.xtend.core.
compiler.batch.Main and it is part of the org.eclipse.xtend.core artifact. The Gradle plugin also just delegates to this class.

But I don't understand what I need to type in command line. I noticed there is a standalone file but doing this

java -jar ~/eclipse/plugins/org.eclipse.xtend.standalone_2.6.2.v201407030533.jar

only errored with "no main manifest attribute".

How can I compile xtend sources without eclipse?

Thank you.

Ben

unread,
Aug 23, 2014, 10:45:50 PM8/23/14
to xtend...@googlegroups.com

I'm using ant if that helps.

Artur Biesiadowski

unread,
Aug 24, 2014, 9:54:26 AM8/24/14
to xtend...@googlegroups.com
Maybe
java -cp ~/eclipse/plugins/org.eclipse.xtend.standalone_2.6.2.v201407030533.jar org.eclipse.xtend.core.compiler.batch.Main
will work better?

Ben

unread,
Aug 24, 2014, 5:31:26 PM8/24/14
to xtend...@googlegroups.com
It gives error "Error: Could not find or load main class org.eclipse.xtend.core.compiler.batch.Main"

Stefan Oehme

unread,
Aug 25, 2014, 3:17:37 AM8/25/14
to xtend...@googlegroups.com
As stated in the instruction you cited, please use the org.eclipse.xtend.core.jar

Ben

unread,
Aug 25, 2014, 10:23:45 PM8/25/14
to xtend...@googlegroups.com
I get this error now

java -cp ~/eclipse/plugins/org.eclipse.xtend.core_2.6.2.v201407030533.jar org.eclipse.xtend.core.compiler.batch.Main
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/BasicConfigurator
    at org.eclipse.xtend.core.compiler.batch.Main.main(Main.java:28)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.BasicConfigurator
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 1 more
I hope I don't have to specify all the dependencies :(

java -cp $HOME/eclipse/plugins/org.eclipse.xtend.core_2.6.2.v201407030533.jar:$HOME/eclipse/plugins/org.apache.log4j_1.2.15.v201012070815.jar org.eclipse.xtend.core.compiler.batch.Main
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/xtext/ISetup
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at org.eclipse.xtend.core.XtendInjectorSingleton.<clinit>(XtendInjectorSingleton.java:16)
    at org.eclipse.xtend.core.compiler.batch.Main.main(Main.java:29)
Caused by: java.lang.ClassNotFoundException: org.eclipse.xtext.ISetup
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 26 more
java -cp $HOME/eclipse/plugins/org.eclipse.xtend.core_2.6.2.v201407030533.jar:$HOME/eclipse/plugins/* org.eclipse.xtend.core.compiler.batch.Main
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
-useCurrentClassLoader       Use current classloader as parent classloader

ok I'm almost there

java -cp $HOME/eclipse/plugins/org.eclipse.xtend.core_2.6.2.v201407030533.jar:$HOME/eclipse/plugins/* org.eclipse.xtend.core.compiler.batch.Main -d gen/ -cp libs/* src
0    [main] INFO  e.compiler.batch.XtendBatchCompiler  - Compiling 1 source file to gen/
0 [main] INFO org.eclipse.xtend.core.compiler.batch.XtendBatchCompiler  - Compiling 1 source file to gen/


yay :). Thank you. Once I put this into my build process I will evaluate if I will use more xtend as I'm moving away from Eclipse IDE. I really like the language and want to continue using it. My favourite part is the operator overloading.

Thanks again!

Stefan Oehme

unread,
Aug 26, 2014, 4:39:46 AM8/26/14
to xtend...@googlegroups.com
I highly recommend using Gradle instead of Ant, because that will free you from having to manually keep track of transitive dependencies =) Also, configuration tends to be wayyy shorter.


--
You received this message because you are subscribed to a topic in the Google Groups "Xtend Programming Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/xtend-lang/0FwIBuSdres/unsubscribe.
To unsubscribe from this group and all its topics, send an email to xtend-lang+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ben

unread,
Aug 26, 2014, 9:55:42 PM8/26/14
to xtend...@googlegroups.com
Yes that's my plan. I  have alot of ant projects already and other inhouse tools that expect ant setup. It will take time for everything to be migrated.
Reply all
Reply to author
Forward
0 new messages