templates and command line support

27 views
Skip to first unread message

Sebastian Gurin

unread,
Sep 13, 2010, 10:01:54 AM9/13/10
to java2...@googlegroups.com
Hi all.

I have updated my 2 new projects, command line api support for j2s and j2s application template renderization support at:

http://groups.google.com/group/java2script/web/net.sf.j2s.ui.cmdline.tar.gz

http://groups.google.com/group/java2script/web/net.sf.j2s.ui.template.velocity.tar.gz

both projects has a project description and documentation inside the docs/ subfolder.

I'm planing to commit both projects this week at https://java2script.googlecode.com/svn/trunk/sources. Is this the best place to put these projects?

About command line api, now the user can specify several commands in a single command line. For example, the following command line has 3 commands on it: 1) import a project j2stest 2) build the previously imported project j2stest 3) render a java main class of that project:

./eclipse -clean -nosplash -data "/home/sebastian/desarrollo/workspaceTest2" -application net.sf.j2s.ui.cmdlineApi \
-cmd import -path "/home/sebastian/desarrollo/sgurin_workspace/j2stest" -projectName j2stest \
-cmd build -projectName j2stest \
-cmd render -mainType org.s.d.M1 -projectName j2stest -outputName "\${mainType}.html" -j2slibUrl "../yui3/j2slib" -template "/home/sebastian/desarrollo/j2s_3.6_workspace/net.sf.j2s.ui.template.velocity/src/net/sf/j2s/ui/launching/template/velocity/templates/simpleHtmlDocument.vm"

notice how the user can reference imported projects by name in further commands...

So this way, the user can build all of its projects and render some of its java main classes in a single command line. cmdline seems to be working fine in all my tests. Since I'm not interested (at this time) on building/launching my j2s projects and applications from command line, I will pause this plugin testing and developing until more requeriments emerge. I will work on templates.velocity project, since I'm very interesting on this feature.

About template support for rendering a j2s app, if a template contribution is found, then the HTML tab in the launcher dialog is replaced by the template tab. Else, if no template contribution is found, everithing is unchanged.

Well, suggestions or any feedback is appreciated.

Regards

--
Sebastian Gurin <sgu...@softpoint.org>

James Cowan

unread,
Sep 14, 2010, 7:59:52 AM9/14/10
to java2...@googlegroups.com

Just wondered whether the JDT core component might make it possible to
decouple this from eclipse:

http://www.eclipse.org/jdt/core/index.php

Most projects that do command line builds are likely to being using
maven or ant/ivy where all the dependencies
in the project are listed in pom.xml or ivy.xml; a maven or and ant task
is then used to handle the compilation.

Your solution looks like it is using the eclipse project to define the
dependencies and to drive the compilation which
fits with the java2script eclipse plugin. This does not sit comfortably
with how maven and ant/ivy developers work.

I guess it largely depends on how you want to use java2script. I agree
that it provides a very cool way of compiling a SWT application to run
on the web; I am also impressed by the YUI bindings. Something that
worked with the UFaceproject and/or E4/XWT would also be cool.

However just getting java2script to compile java into javascript in the
same way that the GWT compiler/GWT maven plugin does it is what
interests me most. I want to be able to write a model and controller in
java that can be automatically compiled into javascript. The view could
be developed in SWT, YUI or plain HTML.

I would be interested in having a chat on skye about this and how I
might help - the bandwidth of email is too small tends to limit discussion.

James

Sebastian Gurin

unread,
Sep 14, 2010, 9:30:32 AM9/14/10
to java2...@googlegroups.com
On Tue, 14 Sep 2010 12:59:52 +0100
James Cowan <james...@googlemail.com> wrote:

>
> Just wondered whether the JDT core component might make it possible to
> decouple this from eclipse:
>
> http://www.eclipse.org/jdt/core/index.php
>

I don't know. According to previous posts in this group, I don't think so. In my particular case, for the moment, I'm not thinking about separating j2s from eclipse at all.

> Most projects that do command line builds are likely to being using
> maven or ant/ivy where all the dependencies
> in the project are listed in pom.xml or ivy.xml; a maven or and ant task
> is then used to handle the compilation.
>
> Your solution looks like it is using the eclipse project to define the
> dependencies and to drive the compilation which
> fits with the java2script eclipse plugin. This does not sit comfortably
> with how maven and ant/ivy developers work.

First of all, my project net.sf.j2s.ui.cmdline is kind of a proof of concept that shows that Java2Script core functionality can be invoked from command line, or more generally, programatically. Notice that the syntax doesn't have to be command line, but something more structured like a xml document. And more, notice that the medium doesn't have to be the command line neither , but other, for example, comunication via web service / sockets with the cmdline eclipse plugin instance...

I only implemented basic support for core functionality like import, build and render. I think others can enrich current or add new functionality based on current work, for example, defining project dependencies programatically, and other desired features by ant or maven users.

I think we should discuss, particular features that current sullution is missing. When you talk about "dependencies", from the point of view of a java to javascript translator, I think you mean the java classpath of the project to be translated. is this right? I'm missing something else? If that is so, I think current sollution may be expanded to support the user to pass desired classpath to the target project building.

>
> I guess it largely depends on how you want to use java2script. I agree
> that it provides a very cool way of compiling a SWT application to run
> on the web; I am also impressed by the YUI bindings. Something that
> worked with the UFaceproject and/or E4/XWT would also be cool.
>
> However just getting java2script to compile java into javascript in the
> same way that the GWT compiler/GWT maven plugin does it is what
> interests me most. I want to be able to write a model and controller in
> java that can be automatically compiled into javascript. The view could
> be developed in SWT, YUI or plain HTML.

I also think such a great java to javascript translator as j2s should be able to be handled more programatically. That's why I made the project cmdline, not as a defenitly sollution, but as a starting point... I would like to have more feedback from other ant or maven users like you about real needs.

>
> I would be interested in having a chat on skye about this and how I
> might help - the bandwidth of email is too small tends to limit discussion.
>

what about opening a #java2script channel on irc.freenode.org ? I will try to be there from time to time...

> James
>
> On 13/09/2010 15:01, Sebastian Gurin wrote:
> > Hi all.
> >
> > I have updated my 2 new projects, command line api support for j2s and j2s application template renderization support at:
> >
> > http://groups.google.com/group/java2script/web/net.sf.j2s.ui.cmdline.tar.gz
> >
> > http://groups.google.com/group/java2script/web/net.sf.j2s.ui.template.velocity.tar.gz
> >
> > both projects has a project description and documentation inside the docs/ subfolder.
> >
> > I'm planing to commit both projects this week at https://java2script.googlecode.com/svn/trunk/sources. Is this the best place to put these projects?
> >
> > About command line api, now the user can specify several commands in a single command line. For example, the following command line has 3 commands on it: 1) import a project j2stest 2) build the previously imported project j2stest 3) render a java main class of that project:
> >
> > ./eclipse -clean -nosplash -data "/home/sebastian/desarrollo/workspaceTest2" -application net.sf.j2s.ui.cmdlineApi \
> > -cmd import -path "/home/sebastian/desarrollo/sgurin_workspace/j2stest" -projectName j2stest \
> > -cmd build -projectName j2stest \
> > -cmd render -mainType org.s.d.M1 -projectName j2stest -outputName "\${mainType}.html" -j2slibUrl "../yui3/j2slib" -template "/home/sebastian/desarrollo/j2s_3.6_workspace/net.sf.j2s.ui.template.velocity/src/net/sf/j2s/ui/launching/template/velocity/templates/simpleHtmlDocument.vm"
> >
> > notice how the user can reference imported projects by name in further commands...
> >
> > So this way, the user can build all of its projects and render some of its java main classes in a single command line. cmdline seems to be working fine in all my tests. Since I'm not interested (at this time) on building/launching my j2s projects and applications from command line, I will pause this plugin testing and developing until more requeriments emerge. I will work on templates.velocity project, since I'm very interesting on this feature.
> >
> > About template support for rendering a j2s app, if a template contribution is found, then the HTML tab in the launcher dialog is replaced by the template tab. Else, if no template contribution is found, everithing is unchanged.
> >
> > Well, suggestions or any feedback is appreciated.
> >
> > Regards
> >
>

> --
> You received this message because you are subscribed to the Google Groups "Java2Script" group.
> To post to this group, send email to java2...@googlegroups.com.
> To unsubscribe from this group, send email to java2script...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/java2script?hl=en.
>


--
Sebastian Gurin <sgu...@softpoint.org>

James Cowan

unread,
Sep 14, 2010, 1:03:32 PM9/14/10
to java2...@googlegroups.com

>I think we should discuss, particular features that current sullution is missing. When you talk about>"dependencies", from the point of view of a java to javascript translator, I think you mean the java classpath>of the project to be translated. is this right? I'm missing something else? If that is so, I think current>sollution may be expanded to support the user to pass desired classpath to the target project building.

this is right. A maven pom.xml contains dependency clauses which define
the classpath which can be passed to a maven mojo plugin which runs for
example the GWT compiler or the java2script compiler.

This xml fragment from a pom.xml tells the maven build tool that you
want log4j added to your classpath:

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>

>I also think such a great java to javascript translator as j2s should
be able to be handled more >programatically. That's why I made the
project cmdline, not as a defenitly sollution, but as a starting
>point... I would like to have more feedback from other ant or maven
users like you about real needs.

Happy help with anything about maven - I tend to prefer maven over
ant/ivy. maven and eclipse work very well together - maven can generate
an eclipse project on the command line for example. Things are a bit
harder when it comes to eclipse development as the eclipse libraries are
not always present in the central maven repositories - this may have
changed since my last SWT project.

James

Sebastian Gurin

unread,
Oct 10, 2010, 9:30:19 AM10/10/10
to java2...@googlegroups.com
I have committed my changes to the svn repository for supporting template based J2S application launcher and command line API. I left both projects at https://java2script.googlecode.com/svn/trunk/incubator/. Also I have commited my changes to j2s.core.ui (branch 3.6) (https://java2script.googlecode.com/svn/branches/net.sf.j2s.ui_3.6) for including template contribution support.

Both projects contains docbook documentation that try to be extensive in folder doc/

The command line api plugin now supports more project configuration options, as sugested by James, like importing non-eclipse projects, setting sourcefolders, output folders (where .js will be generated), setting classpath and other.

For example, suppose I have a non-eclipse project that uses SWT at /home/sebastian/desarrollo/j2scmdlintests/nonEclipseSWTProject

The following is a command line example that shows how to import the project, set the output and source folders, set the classpath, build it and render it with a velocity template:

eclipse -data /path/to/myCleanworkspace -nosplash -application net.sf.j2s.ui.cmdlineApi \
-cmd newProject -projectName test -path /home/sebastian/desarrollo/j2scmdlintests/nonEclipseSWTProject \
-cmd setOutputFolder -projectName test -outputFolder javascriptOutput \
-cmd setSourceFolders -projectName test -sourceFolders src \
-cmd setClassPath -projectName test -classPath /home/sebastian/Desktop/downloads/swt33/swt-debug.jar \
-cmd build -projectName test -problemsLog build.log \
-cmd render -projectName test -mainType foo.test1.NewSWTApp -j2slibUrl ../j2slib -template /home/sebastian/desarrollo/j2scmdlintests/nonEclipseSWTProject/simpleHtmlDocument.vm -outputName${mainType}.html

Teh second command will set the output folder to javascriptOutput/ so all generated javascript files will go there.

The forth command will add swt.jar to project's classpath.

the last command (render) will render the main java class foo.test1.NewSWTApp to file foo.test1.NewSWTApp.html using the j2s velocity template simpleHtmlDocument.vm

Also notice that in the build command, all build problems will be reported to build.log file.

I'm working on developing, in separate projects support for ant task and maven artifacts.

I will keep testing... there are *many* scenarios for testing cmdline support...


Feedback is very welcome.

Regards,

> --
> You received this message because you are subscribed to the Google Groups "Java2Script" group.
> To post to this group, send email to java2...@googlegroups.com.
> To unsubscribe from this group, send email to java2script...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/java2script?hl=en.
>


--
Sebastian Gurin <sgu...@softpoint.org>

Reply all
Reply to author
Forward
0 new messages