2018-01-10 16:06:58 -05:00
/ *
* Hibernate , Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License ( LGPL ) , version 2.1 or later
* See the lgpl . txt file in the root directory or http: //www.gnu.org/licenses/lgpl-2.1.html
* /
apply plugin: 'base'
2022-01-11 16:47:13 -05:00
buildscript {
dependencies {
constraints {
classpath ( "org.apache.logging.log4j:log4j-core" ) {
version {
2022-01-12 09:37:16 -05:00
strictly ( "[2.17.1, 3[" )
prefer ( "2.17.1" )
2022-01-11 16:47:13 -05:00
}
2022-01-12 09:37:16 -05:00
because ( 'CVE-2021-44228, CVE-2021-45046, CVE-2021-45105, CVE-2021-44832: Log4j vulnerable to remote code execution and other critical security vulnerabilities' )
2022-01-11 16:47:13 -05:00
}
}
}
}
2018-01-10 16:06:58 -05:00
ext {
2021-05-18 14:06:57 -04:00
ormVersionFile = file ( "${rootProject.projectDir}/gradle/version.properties" )
2020-06-03 05:48:45 -04:00
if ( project . hasProperty ( 'releaseVersion' ) ) {
2021-05-14 18:31:28 -04:00
// Override during releases
ormVersion = new HibernateVersion ( project . property ( 'releaseVersion' ) as String , project )
2020-06-03 05:48:45 -04:00
}
2021-05-14 18:31:28 -04:00
else {
ormVersion = HibernateVersion . fromFile ( ormVersionFile , project )
}
2018-04-11 14:18:19 -04:00
jpaVersion = new JpaVersion ( '2.2' )
2021-05-24 14:41:03 -04:00
jakartaJpaVersion = new JpaVersion ( '3.0.0' )
2018-01-10 16:06:58 -05:00
}
2019-05-21 17:29:57 -04:00
group = 'org.hibernate.orm'
2018-04-30 11:38:09 -04:00
version = project . ormVersion . fullName
2018-04-11 14:18:19 -04:00
class JpaVersion {
/** The *normal* name (1.0, 2.0, ..) */
2019-12-20 07:53:47 -05:00
final String name
2018-04-11 14:18:19 -04:00
final String osgiName
JpaVersion ( String version ) {
this . name = version
this . osgiName = version + ".0"
}
@Override
String toString ( ) {
return name
}
}
2018-04-30 11:38:09 -04:00
class HibernateVersion {
final String fullName
final String majorVersion
final String family
final String osgiVersion
final boolean isSnapshot
HibernateVersion ( String fullName , Project project ) {
this . fullName = fullName
final String [ ] hibernateVersionComponents = fullName . split ( '\\.' )
this . majorVersion = hibernateVersionComponents [ 0 ]
this . family = hibernateVersionComponents [ 0 ] + '.' + hibernateVersionComponents [ 1 ]
this . isSnapshot = fullName . endsWith ( '-SNAPSHOT' )
this . osgiVersion = isSnapshot ? family + '.' + hibernateVersionComponents [ 2 ] + '.SNAPSHOT' : fullName
}
2020-04-15 08:20:29 -04:00
static HibernateVersion fromFile ( File file , Project project ) {
def fullName = readVersionProperties ( file )
return new HibernateVersion ( fullName , project )
}
private static String readVersionProperties ( File file ) {
if ( ! file . exists ( ) ) {
throw new GradleException ( "Version file $file.canonicalPath does not exists" )
}
Properties versionProperties = new Properties ( )
file . withInputStream {
stream - > versionProperties . load ( stream )
}
return versionProperties . hibernateVersion
}
2018-04-30 11:38:09 -04:00
@Override
String toString ( ) {
return this . fullName
}
2018-07-05 08:28:19 -04:00
}