maven

4 posts / 0 new
Last post
atao
Offline
Joined: 10/15/2008
maven

Vincent,

 

I'm new with maven, so I need some help.

1/ How can I specify to take in account with the command

        mvn package

   some java classes from non jspresso standard directories,  i.e. directories I added under the project root directory.

 

2/ Under Eclipse I wrote an ant task just to generate java classes from HibernateXdocletEntity.ftl

   Is there a way to do it with Maven, either from Eclipse or from a console?

 

Regards

Pierre

 

 

 

 

vvandens
Offline
Joined: 05/29/2008
maven

Pierre,

1/ You just can't do that with maven. The best solution would be to make a module of your classes, and include this module as a dependency of the war module :

  • clone the core/ directory structure (e.g. custom/)  under the root of your project, including src/main/java, src/main/resources. Put your source files in there.
  • create a pom.xml to materialize your module (copy the one of the core/ directory) into the custom/ directory. Update the necessary fields and take away the sections you don't need (e.g. jasper reports compilation).
  • declare your new module in the pom.xml located at the root of your project, e.g. in the <modules> section, add : <module>custom</module>
  • edit the webapp/pom.xml file and declare your new module as a dependency (like the others).

Now, mvn package will automatically put your custom.jar in the WEB-INF/lib directory of your war.

2/ Look at what is done in the core/pom.xml. Look for "generate-entities". This is where we use the maven-antrun-plugin to trigger the entities generation during the build process. The entities generation is attached to the generate-sources standard maven phase so that it occurs before actual compilation of the module sources.

It's quite difficult to explain everything from scratch. But I hope these hints help.

By the way, there is a very good, free and online book written by one of the original maven project leader : Maven : The definitive guide.

Did you manage to solve the joda/flex problem ?

Vincent

atao
Offline
Joined: 10/15/2008
maven

Vincent,

 

After some hard learning times, I got what I wanted, i.e. a "mvn package" that manages the joda-time type.

So, now two requests:

- in core/pom.xml, put "generate-mysql-schema", "generate-postgresql-schema" and "attach-ddl-scripts" in a profile

  Note: in previous version, i.e. with Ant build, these tasks were launched only if needed.

- in core/pom.xml, should be nice if "-templateResourcePath" and "-templateName" (or at least the first one) were parameters

Regards

Pierre

 

 

vvandens
Offline
Joined: 05/29/2008
maven

Pierre,

As requested, I've variabilized the entities generation with the following properties you can set on the commandline when running maven ("-Dxxxx") :

  • generator.templateResourcePath[=/path/to/resource]
  • generator.templateName[=MyTemplate.ftl]

The generation of the ddl scripts is now part of the generate-ddl-scripts profile that is active by default. You can disable it by calling maven with the following parameter : -P!generate-ddl-scripts (don't forget the !). Note that this syntax to disable default active profiles is only available with Maven 2.1.

Of course, all this will be available for new projects generated by the updated Jspresso archetype. I've just deployed it (3.0.1-SNAPSHOT) in the Jspresso maven repo.

Regards,

Vincent