Is it possible for you to share your project sourcecode? That would help figure this out. Also, if you could post your pom.xml, because it looks like some things are getting pulled in that shouldn't be.

Thanks,
Lincoln

On Mon, Oct 24, 2011 at 8:07 PM, Rafael Pestano <rmpestano@gmail.com> wrote:
Hi there,

I still dont know why it works with alpha4, ive downloaded todays snapshot and same error, the execution image is here;

alpha4 execution
snapshot execution

im just switching  the FORGE_HOME enviroment variable, generating the plugin and executing the command.

Im attaching both prompt output in this email, maybe it helps.



2011/10/24 Lincoln Baxter, III <lincolnbaxter@gmail.com>

Good! Glad you got it working.

I'm concerned that you are using an outdated version of Forge, however. It still does not work for you on Beta3 or latest SNAPSHOT versions?

I'd like to figure out why :)

Thanks!
~Lincoln


On Sun, Oct 23, 2011 at 6:31 PM, Rafael Pestano <rmpestano@gmail.com> wrote:
Now it's working!!!!! \o/

Ive downloaded the alpha4(tried SNAPSHOT, Betas 2 and 3 without success) release and just changed the FORGE_HOME to point to it and solved the injection problem.

I also had to add
 <dependency>
      <groupId>org.jboss.shrinkwrap.descriptors</groupId>
      <artifactId>shrinkwrap-descriptors-api</artifactId>
      <version>0.1.7</version>
    </dependency>

in order to use forge-shell-api 1.0.0-SNAPSHOT.

And finaly added commons-lang-2.4.jar, commons-collections-3.1 to forge_home/lib

and now i can see "Wrote /JAVA/Projetos/Conventions/Conventions/ConventionsLayers/src/main/java/com/jsf/conventions/layers/controller/Per
nMBean.java" after my command execution

many thanks for your help, keep the great work!


2011/10/23 Lincoln Baxter, III <lincolnbaxter@gmail.com>
Why are you importing @RequestScoped?

It's possible that is breaking something, though I don't see why it would. It looks like something else is happening in code that you did not show. Your plugin does not need to be @Scoped.

If this still occurs, try injecting Event<PickupResources> event; instead of injecting the BeanManager, though I don't see why that would make a difference either ;)

Hope this helps,
Lincoln


On Sun, Oct 23, 2011 at 4:15 PM, Rafael Pestano <rmpestano@gmail.com> wrote:
Hi Lincon,

yes i got a look at scaffolding plugins project source but for now im getting used to forge so the ideia is create some plugins to see how stuff works, but thanks for pointing that.

At the moment im trying to understand how resource injection is done in Forge cause i cant inject anything in my plugin.

Ive tried to make my plugin a CDI bean but when i execute the command i got " WELD-001303 No active contexts for scope type javax.enterprise.context.RequestScoped"

here is my plugin(same as arquillian plugin Paul has pointed out but with different velocity templete): http://pastebin.com/nrc3PTz2
and my pom.xml: http://pastebin.com/etcQYNt4

2011/10/23 Lincoln Baxter, III <lincolnbaxter@gmail.com>

Hi Rafael!

What you want to do sounds really interesting! Have you taken a look at the forge-scaffold-api? Its located as a sub-folder of the github repository that you just cloned.

This will let you use the 'scaffold from-entity' command to invoke your code, and it will also let people use the familiar api.  We can also make some improvements to that api if you need it :)

--
Lincoln Baxter's Droid
http://ocpsoft.com
"Keep it Simple"

On Oct 23, 2011 10:03 AM, "Rafael Pestano" <rmpestano@gmail.com> wrote:
I was meaning just clone it ;)

Nice to hear about the scaffolding plugin.

2011/10/23 Paul Bakker <paul.bakker.nl@gmail.com>
Hi Rafael,

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.
Formatting is a bit of a problem, that doesn't work very well now with the builder API. Maybe Lincoln can say more about that?

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. 

Paul

On Oct 23, 2011, at 3:45 PM, Rafael Pestano wrote:

I've managed to clone forge repo with this address https://github.com/forge/core.git now, i was using the old github.com/seam/forge.git.

2011/10/23 Rafael Pestano <rmpestano@gmail.com>
Hello Paul, thanks for your enlightening reply.

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 

@ViewAccessScoped
@Named("personMBean")
public class PersonMBean extends AbstractBaseMBean<Person> implements Serializable, ModalObserver {
   
   @Inject
    public void setPersonService(PersonService personService) {
//service layer will be generated togheter
        super.setBaseService(personService);
    }

some other very simple methods
}


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.

Another concern i have is how to format the generated code? maybe the velocity template could help on that.

Ive seen the Arquillian example, how can i clone it and forge project?

Thanks again!


 

2011/10/23 Paul Bakker <paul.bakker.nl@gmail.com>
Hi Rafael,

There are two things you need to do:
1) "understand" the Person class
2) generate new code


1)
You can use a command parameter to get the Person class: @Option(name = "class", required = true, type = PromptType.JAVA_CLASS) JavaResource classUnderTest

JavaResource is a rich file representation of the class. 
Now you can use the JavaSourceFacet to get information about the class itself:

JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);
JavaSource<?> javaSource = classUnderTest.getJavaSource();

javaSource has methods such as getPackage() etc.

2)
Now you have to generate code. There are two ways to do this, depending on your needs.
The most elegant way is to use the "JavaParser" builder API:

JavaClass javaClass = JavaParser.create(JavaClass.class)
               .setPackage(entityPackage)
               .setName(entityName)
               .setPublic()
               .addAnnotation(Entity.class).getOrigin()
               .addInterface(Serializable.class);
Field<JavaClass> id = javaClass.addField("private Long id = null;"); 
….

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.

You can just add Velocity to your pom file and it will work.

If you have any more questions, let us know! What kind of plugin are you writing?

Paul Bakker


On Oct 23, 2011, at 2:26 AM, Rafael Pestano wrote:

Hi everyone,

this is my first mail to this list and id like to congratulate the Forge team for their work.

my question is, what's the best way to generate .java, .xhtml files with forge?

Id like to write a plugin which would receive an entity class as parameter and generate some code on top of it, eg:

$ generate-service Person
$ generate-controller Person
$ generate-view Person


Where Person is a domain object, is it possible with Forge? if yes, whats the best way?


thanks in advance.




--
Att,

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
Graduando em Ciência da Computação UFRGS

_______________________________________________
forge-dev mailing list
forge-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev




--
Att,

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
Graduando em Ciência da Computação UFRGS




--
Att,

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
Graduando em Ciência da Computação UFRGS





--
Att,

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
Graduando em Ciência da Computação UFRGS

_______________________________________________
forge-dev mailing list
forge-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev




--
Att,

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
Graduando em Ciência da Computação UFRGS


_______________________________________________
forge-dev mailing list
forge-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev


_______________________________________________
forge-dev mailing list
forge-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev




--
Att,

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
Graduando em Ciência da Computação UFRGS


_______________________________________________
forge-dev mailing list
forge-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev




--
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"

_______________________________________________
forge-dev mailing list
forge-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev




--
Att,

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
Graduando em Ciência da Computação UFRGS


_______________________________________________
forge-dev mailing list
forge-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev




--
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"

_______________________________________________
forge-dev mailing list
forge-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev




--
Att,

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
Graduando em Ciência da Computação UFRGS


_______________________________________________
forge-dev mailing list
forge-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev




--
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"