diff --git a/maven/src/it/output-directory/invoker.properties b/maven/src/it/output-directory/invoker.properties new file mode 100644 index 0000000000..27e586ee24 --- /dev/null +++ b/maven/src/it/output-directory/invoker.properties @@ -0,0 +1,18 @@ +############################################################################ +# Hibernate Tools, Tooling for your Hibernate Projects # +# # +# Copyright 2018-2025 Red Hat, Inc. # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" basis, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +############################################################################ +invoker.goals = generate-resources \ No newline at end of file diff --git a/maven/src/it/output-directory/pom.xml b/maven/src/it/output-directory/pom.xml new file mode 100644 index 0000000000..26d63b3f61 --- /dev/null +++ b/maven/src/it/output-directory/pom.xml @@ -0,0 +1,56 @@ + + + + 4.0.0 + + org.hibernate.tool.maven.test + jpa-default + 0.0.1-SNAPSHOT + + + + com.h2database + h2 + @h2.version@ + + + + + + + org.hibernate.tool + hibernate-tools-maven + @project.version@ + + + Entity generation + generate-sources + + hbm2java + + + + + ${build.directory}/someRandomFolder + + + + + + \ No newline at end of file diff --git a/maven/src/it/output-directory/setup.bsh b/maven/src/it/output-directory/setup.bsh new file mode 100644 index 0000000000..70f35cb226 --- /dev/null +++ b/maven/src/it/output-directory/setup.bsh @@ -0,0 +1,26 @@ +/* + * Hibernate Tools, Tooling for your Hibernate Projects + * + * Copyright 2018-2025 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.sql.DriverManager; +import java.sql.Connection; + +String JDBC_CONNECTION = "jdbc:h2:" + basedir + "/test"; +String CREATE_PERSON_TABLE = "create table PERSON (ID int not null, NAME varchar(20), primary key (ID))"; + +Connection connection = DriverManager.getConnection(JDBC_CONNECTION); +connection.createStatement().execute(CREATE_PERSON_TABLE); +connection.close(); diff --git a/maven/src/it/output-directory/src/main/resources/hibernate.properties b/maven/src/it/output-directory/src/main/resources/hibernate.properties new file mode 100644 index 0000000000..32da3e5d10 --- /dev/null +++ b/maven/src/it/output-directory/src/main/resources/hibernate.properties @@ -0,0 +1,21 @@ +############################################################################ +# Hibernate Tools, Tooling for your Hibernate Projects # +# # +# Copyright 2018-2025 Red Hat, Inc. # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" basis, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +############################################################################ +hibernate.connection.driver_class=org.h2.Driver +hibernate.connection.url=jdbc:h2:./test +hibernate.default_catalog=TEST +hibernate.default_schema=PUBLIC \ No newline at end of file diff --git a/maven/src/it/output-directory/verify.bsh b/maven/src/it/output-directory/verify.bsh new file mode 100644 index 0000000000..33fef7e283 --- /dev/null +++ b/maven/src/it/output-directory/verify.bsh @@ -0,0 +1,29 @@ +/* + * Hibernate Tools, Tooling for your Hibernate Projects + * + * Copyright 2018-2025 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.nio.file.Files; + +File personEntity = new File(basedir, "target/someRandomFolder/Person.java"); +if (!personEntity.isFile()) { + throw new FileNotFoundException("Could not find generated JPA Entity: " + personEntity); +} +byte[] raw = Files.readAllBytes(personEntity.toPath()); +if (!new String(raw).contains("import jakarta.persistence.Entity;")) { + throw new RuntimeException("The generated java file is not a JPA Entity"); +} + +