This repository has been archived by the owner on Dec 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathbuild.gradle
333 lines (273 loc) · 8.73 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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
import java.nio.charset.Charset
// http://jedicoder.blogspot.com.es/2011/11/automated-gradle-project-deployment-to.html
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
// Kotlin JVM
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
plugins {
// Bintray
id "com.jfrog.bintray" version "$bintrayVersion"
}
apply plugin: 'idea'
//tasks.withType(Test) {
// scanForTestClasses = false
// include "**/*Test.class" // whatever Ant pattern matches your test class files
//}
allprojects { project ->
//task hello << {task ->
// println "I'm $task.project.name: ${task.project.ext.jtranscVersion}"
//}
ext {
// Kotlin JVM
general_kotlinVersion = kotlinVersion
// Junit
junitVersion = "4.12"
project.ext.kotlinVersion = kotlinVersion
project.ext.jtranscVersion = "${jtranscVersion}"
}
repositories {
jcenter()
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'com.jfrog.bintray'
project.version = jtranscVersion
// Java target version
sourceCompatibility = 1.8
targetCompatibility = 1.8
//apply from: '../include.gradle'
dependencies {
// Junit
testImplementation "junit:junit:$junitVersion"
}
test {
minHeapSize = "128m"
maxHeapSize = "2g"
}
}
def sed = { String file, /* language=RegExp */ String regexp, String replacement ->
def f = new File(file)
if (f.exists()) {
def content = f.getText("UTF-8")
def res = content.replaceAll(regexp, replacement)
//println(res)
f.write(res)
}
}
println("Charset.defaultCharset(): " + Charset.defaultCharset())
task updateVersion() {
doLast {
def newversion = jtranscVersion
println "Updating jtransc to version '$newversion'"
println "Updating kotlin to version '$kotlinVersion'"
def isSnapshot = "$newversion".endsWith("-SNAPSHOT")
// JTransc version
sed("jtransc-rt-core/src/com/jtransc/JTranscVersion.java", 'static private final String version = "(.*)"', "static private final String version = \"$newversion\"")
sed("gradle.properties", 'jtranscVersion=(.*)', "jtranscVersion=$newversion")
sed("jtransc-main-run/example-gradle/gradle.properties", 'jtranscVersion=(.*)', "jtranscVersion=$newversion")
sed("jtransc-main-run/example-gradle-multi/gradle.properties", 'jtranscVersion=(.*)', "jtranscVersion=$newversion")
sed("benchmark/gradle.properties", 'jtranscVersion=(.*)', "jtranscVersion=$newversion")
sed("jtransc-maven-plugin/resources/META-INF/maven/com.jtransc/jtransc-maven-plugin/pom.properties", 'version=(.*)', "version=$newversion")
sed("jtransc-main-run/pom.xml", '<!--jtransc--><version>(.*)<\\/version>', "<!--jtransc--><version>$newversion</version>")
sed("jtransc-maven-plugin/example/pom.xml", '<!--jtransc--><version>(.*)<\\/version>', "<!--jtransc--><version>$newversion</version>")
sed("jtransc-maven-plugin/resources/META-INF/maven/com.jtransc/jtransc-maven-plugin/plugin-help.xml", '<!--jtransc--><version>(.*)<\\/version>', "<!--jtransc--><version>$newversion</version>")
sed("jtransc-maven-plugin/resources/META-INF/maven/com.jtransc/jtransc-maven-plugin/pom.xml", '<!--jtransc--><version>(.*)<\\/version>', "<!--jtransc--><version>$newversion</version>")
sed("jtransc-maven-plugin/resources/META-INF/maven/plugin.xml", '<!--jtransc--><version>(.*)<\\/version>', "<!--jtransc--><version>$newversion</version>")
// JTransc non-snapshot versions
if (!isSnapshot) {
sed("README.md", 'id "com.jtransc" version "(.*)"', "id \"com.jtransc\" version \"$newversion\"")
}
// Kotlin version
sed("jtransc-utils/src/com/jtransc/KotlinVersion.kt", 'val KotlinVersion = "(.*)"', "val KotlinVersion = \"$kotlinVersion\"")
sed("jtransc-maven-plugin/resources/META-INF/maven/plugin.xml", '<!--kotlin--><version>(.*)<\\/version>', "<!--kotlin--><version>$kotlinVersion</version>")
sed("jtransc-maven-plugin/example/pom.xml", '<!--kotlin--><version>(.*)<\\/version>', "<!--kotlin--><version>$kotlinVersion</version>")
}
}
task travisDeploy(dependsOn: ['bintrayUpload']) {
doLast {
println("Deployed!")
}
}
task snapshotTask() {
}
task releaseTask() {
}
if ("$jtranscVersion".endsWith("-snapshot")) {
travisDeploy.dependsOn('snapshotTask')
} else {
travisDeploy.dependsOn('releaseTask')
}
clean.doFirst {
delete "${project.rootDir}/classes"
for (p in project.allprojects) {
delete "${p.projectDir}/out"
println "Deleting... ${p.projectDir}/out"
}
}
idea {
module {
excludeDirs = [
file(".gradle"), file(".idea"), file(".github"), file("build"),
file("docs"), file("benchmark"), file("benchmark_kotlin_mpp"),
file("examples"), file("extra"),
file("gradle"), file("inception"),
file("jtransc-intellij-plugin"), file("jtransc-main-run")
]
}
}
subprojects {
def hasKotlin = project.name != "jtransc-annotations" && project.name != "jtransc-rt" && project.name != "jtransc-rt-core"
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'jacoco'
def props = rootProject.extensions.getExtraProperties()
//if (!props.has("gitVersion")) {
// try {
// props.set("gitVersion", "git describe".execute().text.trim())
// } catch (Throwable) {
// props.set("gitVersion", "${jtranscVersion}")
// }
//}
//def publicationVersion = ("$project.version".endsWith("-SNAPSHOT") ? (props.get("gitVersion") ?: "$project.version") ?: "$project.version" ?: "unknown"
def publicationVersion = project.version
publishing {
publications {
MyPublication(MavenPublication) {
from components.java
groupId group
artifactId project.name
version publicationVersion
}
}
}
bintray {
user = System.getenv("BINTRAY_USER") ?: properties['BINTRAY_USER'] ?: rootProject.properties['BINTRAY_USER']
key = System.getenv("BINTRAY_KEY") ?: properties['BINTRAY_USER'] ?: rootProject.properties['BINTRAY_KEY']
publications = ['MyPublication']
dryRun = false
publish = true
if ("$project.version".endsWith("-SNAPSHOT")) {
override = true
}
pkg {
userOrg = 'jtransc'
repo = 'jtransc'
name = 'jtransc'
//name = rootProject.name
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/jtransc/jtransc.git'
}
}
jacocoTestReport {
reports {
xml.enabled true
html.enabled false
csv.enabled false
}
}
check.dependsOn jacocoTestReport
group = group
version = "${project.ext.jtranscVersion}"
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
configurations {
provided
}
sourceSets {
main { compileClasspath += configurations.provided }
}
repositories {
mavenLocal()
mavenCentral()
}
if (hasKotlin) {
apply plugin: 'kotlin'
// https://kotlinlang.org/docs/reference/using-gradle.html#compiler-options
compileKotlin {
kotlinOptions.suppressWarnings = true
}
compileTestKotlin {
kotlinOptions.suppressWarnings = true
}
dependencies {
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}"
implementation "org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}"
}
}
sourceSets {
main.java.srcDirs = [ 'src' ]
main.resources.srcDirs = [ 'resources' ]
test.java.srcDirs = [ 'test' ]
test.resources.srcDirs = [ 'testresources' ]
if (hasKotlin) {
main.kotlin.srcDirs = ['src']
test.kotlin.srcDirs = ['test']
}
}
if (System.getenv("JTRANCS_DEPLOY") != null) {
task javadoc2(type: Javadoc) {
failOnError = false
}
task javadocJar(type: Jar, dependsOn: javadoc2) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
signing {
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
pom.project {
name "${project.name}"
packaging 'jar'
description 'JVM AOT compiler currently generating JavaScript, C++, C# and Dart, with initial focus on Kotlin and games.'
url 'https://github.com/jtransc/jtransc/'
inceptionYear '2015'
scm {
url 'scm:[email protected]:jtransc/jtransc.git'
connection 'scm:[email protected]:jtransc/jtransc.git'
developerConnection 'scm:[email protected]:jtransc/jtransc.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'soywiz'
name 'Carlos Ballesteros Velasco'
}
}
}
}
}
}
}
}