Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
186 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* 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' | ||
|
||
File versionFile = file( "${rootProject.projectDir}/gradle/version.properties" ) | ||
|
||
ext { | ||
ormVersionFile = versionFile | ||
ormVersion = HibernateVersion.fromFile( versionFile, project ) | ||
// Override during releases | ||
if ( project.hasProperty( 'releaseVersion' ) ) { | ||
ormVersion = new HibernateVersion( project.releaseVersion, project ) | ||
} | ||
jpaVersion = new JpaVersion('2.2') | ||
jakartaJpaVersion = new JpaVersion('3.0.0') | ||
} | ||
|
||
group = 'org.hibernate.orm' | ||
version = project.ormVersion.fullName | ||
|
||
class JpaVersion { | ||
/** The *normal* name (1.0, 2.0, ..) */ | ||
final String name | ||
|
||
final String osgiName | ||
|
||
JpaVersion(String version){ | ||
this.name = version | ||
this.osgiName = version + ".0" | ||
} | ||
|
||
@Override | ||
String toString() { | ||
return name | ||
} | ||
} | ||
|
||
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 | ||
} | ||
|
||
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 | ||
} | ||
|
||
@Override | ||
String toString() { | ||
return this.fullName | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.