File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed
src/main/java/org/eclipse/xtend/java2xtend Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 8383 val javaCode = '//java code'
8484 val String xtendCode = j2x.toXtend(javaCode);
8585
86+
87+ ** 5.** Or use it on the command line:
88+
89+ java -jar target/java2xtend-1.0-SNAPSHOT-jar-with-dependencies.jar <path to java file>
90+
91+ The converted XTend code will be output to stdout.
92+
8693Development
8794===========
88951 . Generate Eclipse project: ` mvn eclipse:eclipse `
Original file line number Diff line number Diff line change 5050 <groupId >commons-io</groupId >
5151 <artifactId >commons-io</artifactId >
5252 <version >2.4</version >
53- <scope >test</scope >
5453 </dependency >
5554 <dependency >
5655 <groupId >org.eclipse</groupId >
111110 </execution >
112111 </executions >
113112 </plugin >
113+ <plugin >
114+ <artifactId >maven-assembly-plugin</artifactId >
115+ <configuration >
116+ <archive >
117+ <manifest >
118+ <mainClass >org.eclipse.xtend.java2xtend.Java2Xtend</mainClass >
119+ </manifest >
120+ </archive >
121+ <descriptorRefs >
122+ <descriptorRef >jar-with-dependencies</descriptorRef >
123+ </descriptorRefs >
124+ </configuration >
125+ </plugin >
126+
114127 </plugins >
115128 </build >
116129 <repositories >
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ import org.eclipse.jdt.core.dom.AST
44import org.eclipse.jdt.core.dom.ASTParser
55import org.eclipse.jdt.core.dom.CompilationUnit
66import org.eclipse.jdt.internal.core.dom.XtendASTFlattener
7+ import org.apache.commons.io.FileUtils
8+ import java.nio.charset.Charset
79
810class Java2Xtend {
911 def String toXtend (String javaSrc ) {
@@ -21,4 +23,16 @@ class Java2Xtend {
2123 ast. accept(printer)
2224 return printer. result
2325 }
26+
27+ def static void main (String [] args ) {
28+ val j2x = new org.eclipse.xtend.java2xtend. Java2Xtend
29+
30+ val file = new java.io. File (args. get(0 ))
31+
32+ val javaCode = FileUtils :: readFileToString(file, Charset :: defaultCharset())
33+
34+ val String xtendCode = j2x. toXtend(javaCode)
35+
36+ println(xtendCode)
37+ }
2438}
You can’t perform that action at this time.
0 commit comments