forked from hibernate/hibernate-orm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
212 lines (169 loc) · 5.89 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*
* 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>.
*/
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'org.hibernate.build.gradle:hibernate-matrix-testing:3.0.0.Final'
classpath 'org.hibernate.build.gradle:version-injection-plugin:1.0.0'
classpath 'gradle.plugin.com.github.lburgazzoli:gradle-karaf-plugin:0.5.1'
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.7'
classpath 'de.thetaphi:forbiddenapis:3.0.1'
}
}
plugins {
id 'me.champeau.buildscan-recipes' version '0.2.3'
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'nu.studer.credentials' version '2.1'
id 'org.hibernate.build.xjc' version '2.0.1' apply false
id 'org.hibernate.build.maven-repo-auth' version '3.0.3' apply false
id 'biz.aQute.bnd' version '5.1.1' apply false
}
ext {
sonatypeOssrhUser = project.findProperty( 'SONATYPE_OSSRH_USER' )
sonatypeOssrhPassword = project.findProperty( 'SONATYPE_OSSRH_PASSWORD' )
}
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')
}
// The Gradle Nexus Publish Plugin must be applied to the root project and requires group and version
group = 'org.hibernate'
version = project.ormVersion.fullName
nexusPublishing {
repositories {
sonatype {
username = project.sonatypeOssrhUser
password = project.sonatypeOssrhPassword
}
}
}
allprojects {
repositories {
mavenCentral()
//Allow loading additional dependencies from a local path;
//useful to load JDBC drivers which can not be distributed in public.
if (System.env['ADDITIONAL_REPO'] != null) {
flatDir {
dirs "${System.env.ADDITIONAL_REPO}"
}
}
}
apply plugin: 'idea'
// minimize changes, at least for now (gradle uses 'build' by default)..
buildDir = "target"
group = 'org.hibernate'
version = project.ormVersion.fullName
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Release Task
task release {
description = "The task performed when we are performing a release build. Relies on " +
"the fact that subprojects will appropriately define a release task " +
"themselves if they have any release-related activities to perform"
doFirst {
def javaVersionsInUse = [gradle.ext.javaVersions.main.compiler, gradle.ext.javaVersions.main.release,
gradle.ext.javaVersions.test.compiler, gradle.ext.javaVersions.test.release,
gradle.ext.javaVersions.test.launcher].toSet()
// Force to release with JDK 8. It used to not work on JDK11 because of the hibernate-orm-modules module,
// but this limitation might be resolved now that this module has been deleted?
if ( javaVersionsInUse != [JavaLanguageVersion.of( 8 )].toSet() ) {
throw new IllegalStateException( "Please use JDK 8 to perform the release. Currently using: ${javaVersionsInUse}" )
}
}
}
task publish {
description = "The task performed when we want to just publish maven artifacts. Relies on " +
"the fact that subprojects will appropriately define a release task " +
"themselves if they have any release-related activities to perform"
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CI Build Task
task ciBuild {
description = "The task performed when one of the 'main' jobs are triggered on the " +
"CI server. Just as above, relies on the fact that subprojects will " +
"appropriately define a release task themselves if they have any tasks " +
"which should be performed from these CI jobs"
}
wrapper {
// To upgrade the version of gradle used in the wrapper, run:
// ./gradlew wrapper --gradle-version NEW_VERSION
distributionType = Wrapper.DistributionType.ALL
}
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
buildScanRecipes {
recipe 'git-commit', baseUrl: 'https://github.com/hibernate/hibernate-orm/tree'
}
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
}
}
//idea {
// project {
// jdkName = gradle.ext.baselineJavaVersion
// languageLevel = gradle.ext.baselineJavaVersion
//
// vcs = 'Git'
// }
// module {
// name = "hibernate-orm"
// }
//}