Skip to content

Commit 92ad2ef

Browse files
committed
HBX-2984: Create Reference Guide for Ant
- Add structure for Hibernate Tools Configurations and Exporters - Add section on <hibernatetool> task configuration * Add subsection for the 'destdir' attribute * Add subsection for the 'templatepath' attribute Signed-off-by: Koen Aers <[email protected]>
1 parent e89275a commit 92ad2ef

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

ant/docs/reference-guide.md

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
## 1. The `<hibernatetool>` Task
2222

23-
### 1.1 `<hibernatetool>` task definition
23+
### 1.1 `<hibernatetool>` Task Definition
2424
To use the Ant tasks you need to have the `<hibernatetool>` task defined.
2525
That is done in your `build.xml` file by inserting the following XML.
2626

@@ -55,4 +55,70 @@ the jdbc driver and for the version information. See an example in the snippet b
5555
<property name="jdbc-driver.version" value="2.3.232"/>
5656
```
5757

58+
### 1.2 `<hibernatetool>` Task Element
5859

60+
As an introductory example, look at the XML snippet below.
61+
```xml
62+
<target name="reveng">
63+
<hibernatetool destdir="generated-sources">
64+
<jdbcconfiguration propertyfile="hibernate.properties" />
65+
<hbm2java/>
66+
</hibernatetool>
67+
</target>
68+
```
69+
The snippet creates an Ant target named `reveng` which contains an embedded `hibernatetool` task.
70+
This task has the folder `generated-sources` set as its destination directory. Additionally
71+
it specifies a JDBC configuration for which the connection information is to be found in the
72+
file `hibernate.properties`. Finally it contains a `hbm2java` element that will generate Java files
73+
based on the JDBC configuration in the specified destination directory.
74+
75+
As illustrated, the `hibernatetool` task element can be configured with additional attributes
76+
and nested elements.
77+
78+
Let's walk through the different possibilities.
79+
80+
#### 1.2.1 The 'destdir' Attribute
81+
82+
This mandatory attribute lets you control the folder where the artefacts will be generated. If the
83+
specified folder does not exist it will be created.
84+
85+
```xml
86+
<hibernatetool destdir="path/to/generated/sources">
87+
...
88+
</hibernatetool>
89+
```
90+
In the snippet above the artefacts will be generated in the subfolder `path/to/generated/sources` of
91+
the working directory.
92+
93+
#### 1.2.2 The 'templatepath' Attribute
94+
95+
The generation of artefacts is based on FreeMarker templates. By default, the templates are
96+
looked up on the classpath. If you want to have fine control over the artefact generation
97+
you can create custom templates. The optional `templatepath` attribute lets you specify the
98+
location of those templates.
99+
100+
```xml
101+
<hibernatetool
102+
destdir="..."
103+
templatepath="path/to/templates">
104+
...
105+
</hibernatetool>
106+
```
107+
108+
109+
#### 1.2.3 The 'classpath' Element
110+
111+
112+
113+
114+
## 2. The Hibernate Tools Configurations
115+
116+
The reverse engineering and generation of artefacts with Hibernate Tools is based on a
117+
118+
### 2.1 JDBC Configuration
119+
120+
### 2.2 JPA Configuration
121+
122+
### 2.3 Native Configuration
123+
124+
## 3. The Hibernate Tools Exporters

0 commit comments

Comments
 (0)