Skip to content

Commit 82788b1

Browse files
committed
HBX-2984: Create Reference Guide for Ant
- Add an example for native configurations Signed-off-by: Koen Aers <[email protected]>
1 parent c5f928c commit 82788b1

File tree

6 files changed

+105
-0
lines changed

6 files changed

+105
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
generated-sources
19+
*.class
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<hibernate-mapping>
2+
<class name="Foo">
3+
<id name="id"/>
4+
<property name="bar" type="string"/>
5+
</class>
6+
</hibernate-mapping>

ant/docs/examples/native/Foo.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// Source code recreated from a .class file by IntelliJ IDEA
3+
// (powered by FernFlower decompiler)
4+
//
5+
public class Foo {
6+
7+
public int id;
8+
public String bar;
9+
10+
}

ant/docs/examples/native/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!--
2+
~ Copyright 2004 - 2025 Red Hat, Inc.
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" basis,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
To run this example:
17+
- Have [Apache Ant](https://ant.apache.org) installed
18+
- Issue `ant` from a command-line window

ant/docs/examples/native/build.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!--
2+
~ Copyright 2004 - 2025 Red Hat, Inc.
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" basis,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
<project name="native" default="reveng">
17+
18+
<!-- Include the 'hibernatetool' task definition from the file '../common/included.xml' -->
19+
<include file="../common/included.xml"/>
20+
21+
<target name="clean">
22+
<!-- Delete the folder 'generated-sources' if it exists -->
23+
<delete dir="generated-sources"/>
24+
<delete file="Foo.class"/>
25+
</target>
26+
27+
<target name="compile" depends="clean">
28+
<!-- Compile the custom exporter 'HelloExporter' -->
29+
<javac srcdir="." destdir="." classpathref="classpath"/>
30+
</target>
31+
32+
<target name="reveng" depends="compile">
33+
<hibernatetool destdir="generated-sources">
34+
<classpath location="."/>
35+
<!-- Native configuration read from 'hibernate.cfg.xml' -->
36+
<configuration configurationfile="hibernate.cfg.xml"/>
37+
<hbm2ddl outputfilename="foo.sql"/>
38+
</hibernatetool>
39+
</target>
40+
41+
</project>
42+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
3+
<hibernate-configuration>
4+
<session-factory>
5+
<property name="hibernate.connection.driver_class">org.h2.Driver</property>
6+
<property name="hibernate.connection.url">jdbc:h2:mem:</property>
7+
<property name="hibernate.connection.username">sa</property>
8+
<mapping resource="Foo.hbm.xml"/>
9+
</session-factory>
10+
</hibernate-configuration>

0 commit comments

Comments
 (0)