I was meaning just clone it ;)<br><br>Nice to hear about the scaffolding plugin.<br><br><div class="gmail_quote">2011/10/23 Paul Bakker <span dir="ltr">&lt;<a href="mailto:paul.bakker.nl@gmail.com">paul.bakker.nl@gmail.com</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word">Hi Rafael,<div><br></div><div>What do you mean by clone and forge the project? On github you can just clone the plugin-arquillian project and start hacking on it.</div>

<div>Formatting is a bit of a problem, that doesn&#39;t work very well now with the builder API. Maybe Lincoln can say more about that?</div><div><br></div><div>Note that within a few weeks Forge will have a new scaffolding plugin built-in, that does basically something that you are doing in your plugin. </div>

<div><br></div><font color="#888888"><div>Paul</div></font><div><div></div><div class="h5"><div><br><div><div>On Oct 23, 2011, at 3:45 PM, Rafael Pestano wrote:</div><br><blockquote type="cite">I&#39;ve managed to clone forge repo with this address <a href="https://github.com/forge/core.git" target="_blank">https://github.com/forge/core.git</a> now, i was using the old <a>github.com/seam/forge.git</a>.<br>

<br><div class="gmail_quote">

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div class="gmail_quote">2011/10/23 Rafael Pestano <span dir="ltr">&lt;<a href="mailto:rmpestano@gmail.com" target="_blank">rmpestano@gmail.com</a>&gt;</span><br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello Paul, thanks for your enlightening reply.<br><br>The plugin is about a code generator for a home made Java EE6 framework and for instance it will generate very simple xhtml and java classes, so for example the generate-controller plugin would generate  <br>






<br><i>@ViewAccessScoped<br>@Named(&quot;personMBean&quot;)<br>public class PersonMBean extends AbstractBaseMBean&lt;Person&gt; implements Serializable, ModalObserver {<br>    <br>   @Inject<br>    public void setPersonService(PersonService personService) {</i>//service layer will be generated togheter<i><br>






        super.setBaseService(personService);<br>    }<br><br>some other very simple methods<br>}</i><br><br>for the controller-plugin maybe i dont need to understand the model class (just to import it) cause its just a matter of replacing parammeters by the domain object but in the view-plugin it will be necessary for sure.<br>





<br>Another concern i have is how to format the generated code? maybe the velocity template could help on that.<br>
<br>Ive seen the Arquillian example, how can i clone it and forge project?<br><br>Thanks again!<div><div><br><br> <br><br><div class="gmail_quote">2011/10/23 Paul Bakker <span dir="ltr">&lt;<a href="mailto:paul.bakker.nl@gmail.com" target="_blank">paul.bakker.nl@gmail.com</a>&gt;</span><br>





<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>Hi Rafael,</div><div><br></div>There are two things you need to do:<div>1) &quot;understand&quot; the Person class</div><div>2) generate new code</div><div><br></div><div><br></div>





<div>
1)</div><div>You can use a command parameter to get the Person class: @Option(name = &quot;class&quot;, required = true, type = PromptType.JAVA_CLASS) JavaResource classUnderTest</div><div><br></div><div>JavaResource is a rich file representation of the class. </div>






<div>Now you can use the JavaSourceFacet to get information about the class itself:</div><div><div><br></div><div>JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);</div><div>JavaSource&lt;?&gt; javaSource = classUnderTest.getJavaSource();</div>






</div><div><br></div><div>javaSource has methods such as getPackage() etc.</div><div><br></div><div>2)</div><div>Now you have to generate code. There are two ways to do this, depending on your needs.</div><div>The most elegant way is to use the &quot;JavaParser&quot; builder API:</div>






<div><br></div><div><div>JavaClass javaClass = JavaParser.create(JavaClass.class)</div><div>               .setPackage(entityPackage)</div><div>               .setName(entityName)</div><div>               .setPublic()</div>






<div>               .addAnnotation(Entity.class).getOrigin()</div><div>               .addInterface(Serializable.class);</div></div><div>Field&lt;JavaClass&gt; id = javaClass.addField(&quot;private Long id = null;&quot;); </div>






<div>….</div><div><br></div><div>My experience is that this works best for small classes. If you need to generate a lot of code it might be better to use a tempting framework such as Apache Velocity.</div><div>You can find an example of this in the code of the Arquillian plugin: <a href="https://github.com/forge/plugin-arquillian/blob/master/src/main/java/org/jboss/seam/forge/arquillian/ArquillianPlugin.java#L93" target="_blank">https://github.com/forge/plugin-arquillian/blob/master/src/main/java/org/jboss/seam/forge/arquillian/ArquillianPlugin.java#L93</a></div>






<div><br></div><div>You can just add Velocity to your pom file and it will work.</div><div><br></div><div>If you have any more questions, let us know! What kind of plugin are you writing?</div><div><br></div><div>Paul Bakker</div>






<div><br></div><div><br><div><div><div><div><div>On Oct 23, 2011, at 2:26 AM, Rafael Pestano wrote:</div><br></div></div><blockquote type="cite"><div><div>Hi everyone,<br><br>this is my first mail to this list and id like to <span lang="en"><span>congratulate the Forge team</span></span> for their work.<br>






<br>my question is, what&#39;s the best way to generate .java, .xhtml files with forge?<br>

<br>Id like to write a plugin which would receive an entity class as parameter and generate some code on top of it, eg:<br><br><code>$ generate-service Person</code><br><code>$ generate-controller Person</code><br>

<code>$ </code><code>generate-view</code> <code>Person</code><br><br><br>Where Person is a domain object, is it possible with Forge? if yes, whats the best way?<br>

<br><br>thanks in advance.<br><br><br><br clear="all"><br>-- <br><a href="http://www.advancedit.com.br/" target="_blank"><span style="color:black;text-decoration:none"></span></a><span></span><span><span style="color:rgb(192, 192, 192)">Att, </span><br style="color:rgb(192, 192, 192)">








<br style="color:rgb(192, 192, 192)"><span style="color:rgb(192, 192, 192)">Rafael M. Pestano</span><br style="color:rgb(192, 192, 192)"><br style="color:rgb(192, 192, 192)"><span style="color:rgb(192, 192, 192)">Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul</span><br style="color:rgb(192, 192, 192)">








<span style="color:rgb(192, 192, 192)">Graduando em Ciência da Computação UFRGS</span></span><br></div></div>
_______________________________________________<br>forge-dev mailing list<br><a href="mailto:forge-dev@lists.jboss.org" target="_blank">forge-dev@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>






</blockquote></div><br></div></div></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.advancedit.com.br/" target="_blank"><span style="color:black;text-decoration:none"></span></a><span></span><span><span style="color:rgb(192, 192, 192)">Att, </span><br style="color:rgb(192, 192, 192)">






<br style="color:rgb(192, 192, 192)"><span style="color:rgb(192, 192, 192)">Rafael M. Pestano</span><br style="color:rgb(192, 192, 192)"><br style="color:rgb(192, 192, 192)"><span style="color:rgb(192, 192, 192)">Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul</span><br style="color:rgb(192, 192, 192)">






<span style="color:rgb(192, 192, 192)">Graduando em Ciência da Computação UFRGS</span></span><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.advancedit.com.br/" target="_blank"><span style="color:black;text-decoration:none"></span></a><span></span><span><span style="color:rgb(192, 192, 192)">Att, </span><br style="color:rgb(192, 192, 192)">




<br style="color:rgb(192, 192, 192)"><span style="color:rgb(192, 192, 192)">Rafael M. Pestano</span><br style="color:rgb(192, 192, 192)"><br style="color:rgb(192, 192, 192)"><span style="color:rgb(192, 192, 192)">Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul</span><br style="color:rgb(192, 192, 192)">




<span style="color:rgb(192, 192, 192)">Graduando em Ciência da Computação UFRGS</span></span><br>
</div></div></blockquote><br></div><br><br clear="all"><br>-- <br><a href="http://www.advancedit.com.br/" target="_blank"><span style="color:black;text-decoration:none"></span></a><span></span><span><span style="color:rgb(192, 192, 192)">Att, </span><br style="color:rgb(192, 192, 192)">



<br style="color:rgb(192, 192, 192)"><span style="color:rgb(192, 192, 192)">Rafael M. Pestano</span><br style="color:rgb(192, 192, 192)"><br style="color:rgb(192, 192, 192)"><span style="color:rgb(192, 192, 192)">Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul</span><br style="color:rgb(192, 192, 192)">



<span style="color:rgb(192, 192, 192)">Graduando em Ciência da Computação UFRGS</span></span><br>
_______________________________________________<br>forge-dev mailing list<br><a href="mailto:forge-dev@lists.jboss.org" target="_blank">forge-dev@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>

</blockquote></div><br></div></div></div></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.advancedit.com.br/" target="_blank"><span style="color:black;text-decoration:none"></span></a><span></span><span><span style="color:rgb(192, 192, 192)">Att, </span><br style="color:rgb(192, 192, 192)">

<br style="color:rgb(192, 192, 192)"><span style="color:rgb(192, 192, 192)">Rafael M. Pestano</span><br style="color:rgb(192, 192, 192)"><br style="color:rgb(192, 192, 192)"><span style="color:rgb(192, 192, 192)">Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul</span><br style="color:rgb(192, 192, 192)">

<span style="color:rgb(192, 192, 192)">Graduando em Ciência da Computação UFRGS</span></span><br>