Skip to content

Commit 738aeae

Browse files
committed
HBX-2984: Create Reference Guide for Ant
- Add an example for the 'classpath' configuration Signed-off-by: Koen Aers <[email protected]>
1 parent 2a3c0a7 commit 738aeae

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
additional/classes
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Hibernate Tools, Tooling for your Hibernate Projects
3+
*
4+
* Copyright 2004-2025 Red Hat, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" basis,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
import org.hibernate.tool.api.export.Exporter;
19+
20+
import java.util.Properties;
21+
22+
public class HelloExporter implements Exporter {
23+
24+
@Override
25+
public Properties getProperties() {
26+
return new Properties();
27+
}
28+
29+
@Override
30+
public void start() {
31+
System.out.println("Hello from Exporter!");
32+
}
33+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<project xmlns:ivy="antlib:org.apache.ivy.ant">
2+
3+
<property name="hibernate-tools.version" value="7.0.0.CR1"/>
4+
<property name="jdbc-driver.org" value="com.h2database"/>
5+
<property name="jdbc-driver.module" value="h2"/>
6+
<property name="jdbc-driver.version" value="2.3.232"/>
7+
8+
<ivy:cachepath
9+
organisation="org.hibernate.tool"
10+
module="hibernate-tools-ant"
11+
revision="${hibernate-tools.version}"
12+
pathid="hibernate-tools.path"
13+
inline="true"/>
14+
<ivy:cachepath
15+
organisation="${jdbc-driver.org}"
16+
module="${jdbc-driver.module}"
17+
revision="${jdbc-driver.version}"
18+
pathid="jdbc-driver.path"
19+
inline="true"/>
20+
21+
<path id="classpath">
22+
<path refid="hibernate-tools.path"/>
23+
<path refid="jdbc-driver.path"/>
24+
</path>
25+
26+
<taskdef
27+
name="hibernatetool"
28+
classname="org.hibernate.tool.ant.HibernateToolTask"
29+
classpathref="classpath" />
30+
31+
<target name="clean">
32+
<delete dir="additional/classes"/>
33+
</target>
34+
35+
<target name="compile" depends="clean">
36+
<!-- Create the target folder 'additional/classes' -->
37+
<mkdir dir="additional/classes"/>
38+
<!-- Compile the custom exporter 'HelloExporter' -->
39+
<javac
40+
srcdir="additional/src"
41+
destdir="additional/classes"
42+
classpathref="classpath"/>
43+
</target>
44+
45+
<target name="reveng" depends="compile">
46+
<hibernatetool destdir="generated-sources">
47+
<!-- The classpath to be used by the 'hibernatetool' task
48+
to look up additional classes or resources -->
49+
<classpath>
50+
<pathelement location="additional/classes"/>
51+
</classpath>
52+
<!-- Dummy configuration, as it is needed for any 'hibernatetool' task -->
53+
<configuration />
54+
<!-- Custom exporter of class 'HelloExporter' to be found on the specified classpath -->
55+
<hbmtemplate exporterclass="HelloExporter"/>
56+
</hibernatetool>
57+
</target>
58+
59+
</project>
60+

0 commit comments

Comments
 (0)