Pregoals and jar:jar goal

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Pregoals and jar:jar goal

Eric Tournier
Hi :)

 I currently use Maven 1.0 to package my Java projects into various
jar. To do this, I use the jar:jar and jar:install goals. Before
executing these goals, I want to generate Hibernate mapping files,
from XDoclet annotations in source files, with the ant tasks
<hibernatedoclet> and <hibernatecfg>.
 So, I wrote two pregoals in the maven.xml file of my project :
===
|  <preGoal name="jar:jar">
|    <attainGoal name="hibernate:mapping"/>
|  </preGoal>
|  <goal name="hibernate:mapping">
|    <ant:property
file="${basedir}/hibernate/${bdd.name}/hibernate.properties"/>
|    <ant:ant antfile="${maven.home.local}/build/mapping.xml" target="xdoclet">
|      <property name="src.dir" value="${pom.build.sourceDirectory}"/>
|    </ant:ant>
|  </goal>
===
 The generated *.hbm.xml and *.cfg.xml files are correctly created in
target/mappings and target/conf directories. These directories are
marked as resources in the project.xml file :
===
|  <build>
   (...)
|    <resources>
|      <resource>
|        <directory>target/conf</directory>
|        <filtering>false</filtering>
|      </resource>
|      <resource>
|        <directory>target/mappings</directory>
|        <filtering>false</filtering>
|      </resource>
|    (...)
|  </build>
===

I am facing a problem when I call jar:jar goal after calling
clean:clean goal or after making a modification in my XDoclet
annotations. The console output shows all the hibernate files are
created :

====
|>maven -Dbdd.name=MySQL jar:jar
| __  __
||  \/  |__ _Apache__ ___
|| |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
||_|  |_\__,_|\_/\___|_||_|  v. 1.0
|
|Plugin 'maven-deploy-plugin' in project 'Tools' is not available
|build:start:
|
|java:prepare-filesystem:
|    [mkdir] Created dir: xxx\target\classes
|
|java:compile:
|    [echo] Compiling to xxx\target/classes
|    [javac] Compiling 11 source files to xxx\target\classes
|
|java:jar-resources:
|
| (...)
|
|jar:jar:
|hibernate:mapping:
|    [echo] === Obtention du fichier de configuration Hibernate
|    [echo] === Generation fichiers de mapping Hibernate
|    [echo] WARNING Property libs.dir is not set ! Setting to default value
|    [mkdir] Created dir: xxx\target\conf
|    [mkdir] Created dir: xxx\target\mappings
|addOtherProperty(): name=null, null
|addOtherProperty(): name=null, null
|addOtherProperty(): name=null, null
|addOtherProperty(): name=null, null
|addOtherProperty(): name=null, null
|addOtherProperty(): name=null, null
|addOtherProperty(): name=null, null
|Generating hibernate.cfg.xml file
|Generating mapping file for com.xxx.users.Person.
|   com.keynectis.users.Person
|Generating mapping file for com.xxx.users.Address.
|   com.keynectis.users.Address
|
|    [jar] Building jar: xxx\tools-0.1-SNAPSHOT.jar
|BUILD SUCCESSFUL
|Total time: 6 seconds
|Finished at: Fri May 13 11:42:26 CEST 2005
===

Unfortunately, the tools jar does not include any of the generated
files (clean:clean option) or does include wrong version of them
(XDoclet modif option).
The only way to fix this issue is, for me, to modify maven.xml file to
create an encapsulating goal :

===
|  <preGoal name="k:jar">
|    <attainGoal name="hibernate:mapping"/>
|  </preGoal>
|  <goal name="hibernate:mapping">
|    <ant:property
file="${basedir}/hibernate/${bdd.name}/hibernate.properties"/>
|    <ant:ant antfile="${maven.home.local}/build/mapping.xml" target="xdoclet">
|      <property name="src.dir" value="${pom.build.sourceDirectory}"/>
|    </ant:ant>
|  </goal>
|  <goal name="k:jar">
|    <attainGoal name="jar:jar"/>
|  </goal>
===

And then, it works fine.
Does anybody faces the same problem ? I greatly appreciate any comment
on how I use Maven or how I should use it :)

Thnx in advance
Eric
from Paris, France

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]