Skip to content
This repository was archived by the owner on Dec 10, 2022. It is now read-only.

Commit 324b1b3

Browse files
committed
DRY gradle build system
1 parent ace0df0 commit 324b1b3

File tree

27 files changed

+198
-396
lines changed

27 files changed

+198
-396
lines changed

build.gradle

+181-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ buildscript {
1010

1111
dependencies {
1212
// Kotlin JVM
13-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
1414
}
1515
}
1616

@@ -33,13 +33,12 @@ allprojects { project ->
3333
//}
3434
ext {
3535
// Kotlin JVM
36-
general_kotlin_version = kotlin_version
36+
general_kotlinVersion = kotlinVersion
3737

3838
// Junit
3939
junitVersion = "4.12"
4040

41-
project.ext.kotlin_version = kotlinVersion
42-
project.ext.group = "com.jtransc"
41+
project.ext.kotlinVersion = kotlinVersion
4342
project.ext.jtranscVersion = "${jtranscVersion}"
4443
}
4544

@@ -54,6 +53,8 @@ allprojects { project ->
5453

5554
apply plugin: 'com.jfrog.bintray'
5655

56+
project.version = jtranscVersion
57+
5758
// Java target version
5859
sourceCompatibility = 1.8
5960
targetCompatibility = 1.8
@@ -80,7 +81,7 @@ task updateVersion() {
8081
doLast {
8182
def newversion = jtranscVersion
8283
println "Updating jtransc to version '$newversion'"
83-
println "Updating kotlin to version '$kotlin_version'"
84+
println "Updating kotlin to version '$kotlinVersion'"
8485

8586
def isSnapshot = "$newversion".endsWith("-SNAPSHOT")
8687

@@ -103,9 +104,9 @@ task updateVersion() {
103104
}
104105

105106
// Kotlin version
106-
sed("jtransc-utils/src/com/jtransc/KotlinVersion.kt", 'val KotlinVersion = "(.*)"', "val KotlinVersion = \"$kotlin_version\"")
107-
sed("jtransc-maven-plugin/resources/META-INF/maven/plugin.xml", '<!--kotlin--><version>(.*)<\\/version>', "<!--kotlin--><version>$kotlin_version</version>")
108-
sed("jtransc-maven-plugin/example/pom.xml", '<!--kotlin--><version>(.*)<\\/version>', "<!--kotlin--><version>$kotlin_version</version>")
107+
sed("jtransc-utils/src/com/jtransc/KotlinVersion.kt", 'val KotlinVersion = "(.*)"', "val KotlinVersion = \"$kotlinVersion\"")
108+
sed("jtransc-maven-plugin/resources/META-INF/maven/plugin.xml", '<!--kotlin--><version>(.*)<\\/version>', "<!--kotlin--><version>$kotlinVersion</version>")
109+
sed("jtransc-maven-plugin/example/pom.xml", '<!--kotlin--><version>(.*)<\\/version>', "<!--kotlin--><version>$kotlinVersion</version>")
109110
}
110111
}
111112

@@ -146,3 +147,175 @@ idea {
146147
]
147148
}
148149
}
150+
151+
subprojects {
152+
def hasKotlin = project.name != "jtransc-annotations"
153+
154+
apply plugin: 'maven-publish'
155+
apply plugin: 'com.jfrog.bintray'
156+
apply plugin: 'jacoco'
157+
158+
def props = rootProject.extensions.getExtraProperties()
159+
160+
if (!props.has("gitVersion")) {
161+
try {
162+
props.set("gitVersion", "git describe".execute().text.trim())
163+
} catch (Throwable) {
164+
props.set("gitVersion", "${jtranscVersion}")
165+
}
166+
}
167+
168+
def publicationVersion = (("$project.version".endsWith("-SNAPSHOT")) ? (props.get("gitVersion") ?: "git describe".execute().text.trim()) : "$project.version") ?: "$project.version" ?: "unknown"
169+
170+
publishing {
171+
publications {
172+
MyPublication(MavenPublication) {
173+
from components.java
174+
groupId group
175+
artifactId project.name
176+
version publicationVersion
177+
}
178+
}
179+
}
180+
181+
bintray {
182+
user = System.getenv("BINTRAY_USER") ?: properties['BINTRAY_USER'] ?: rootProject.properties['BINTRAY_USER']
183+
key = System.getenv("BINTRAY_KEY") ?: properties['BINTRAY_USER'] ?: rootProject.properties['BINTRAY_KEY']
184+
185+
publications = ['MyPublication']
186+
187+
dryRun = false
188+
publish = true
189+
if ("$project.version".endsWith("-SNAPSHOT")) {
190+
override = true
191+
}
192+
193+
pkg {
194+
userOrg = 'jtransc'
195+
repo = 'jtransc'
196+
name = 'jtransc'
197+
//name = rootProject.name
198+
licenses = ['Apache-2.0']
199+
vcsUrl = 'https://github.com/jtransc/jtransc.git'
200+
}
201+
}
202+
203+
jacocoTestReport {
204+
reports {
205+
xml.enabled true
206+
html.enabled false
207+
csv.enabled false
208+
}
209+
}
210+
211+
check.dependsOn jacocoTestReport
212+
213+
group = group
214+
version = "${project.ext.jtranscVersion}"
215+
216+
compileJava.options.encoding = 'UTF-8'
217+
compileTestJava.options.encoding = 'UTF-8'
218+
219+
configurations {
220+
provided
221+
}
222+
sourceSets {
223+
main { compileClasspath += configurations.provided }
224+
}
225+
226+
repositories {
227+
mavenLocal()
228+
mavenCentral()
229+
}
230+
231+
if (hasKotlin) {
232+
apply plugin: 'kotlin'
233+
234+
// https://kotlinlang.org/docs/reference/using-gradle.html#compiler-options
235+
236+
compileKotlin {
237+
kotlinOptions.suppressWarnings = true
238+
}
239+
compileTestKotlin {
240+
kotlinOptions.suppressWarnings = true
241+
}
242+
}
243+
244+
sourceSets {
245+
main.java.srcDirs = [ 'src' ]
246+
main.resources.srcDirs = [ 'resources' ]
247+
test.java.srcDirs = [ 'test' ]
248+
test.resources.srcDirs = [ 'testresources' ]
249+
if (hasKotlin) {
250+
main.kotlin.srcDirs = ['src']
251+
test.kotlin.srcDirs = ['test']
252+
}
253+
}
254+
255+
if (System.getenv("JTRANCS_DEPLOY") != null) {
256+
task javadoc2(type: Javadoc) {
257+
failOnError = false
258+
}
259+
260+
task javadocJar(type: Jar, dependsOn: javadoc2) {
261+
classifier = 'javadoc'
262+
from 'build/docs/javadoc'
263+
}
264+
265+
task sourcesJar(type: Jar) {
266+
from sourceSets.main.allSource
267+
classifier = 'sources'
268+
}
269+
270+
artifacts {
271+
archives jar
272+
archives javadocJar
273+
archives sourcesJar
274+
}
275+
276+
signing {
277+
sign configurations.archives
278+
}
279+
280+
uploadArchives {
281+
repositories {
282+
mavenDeployer {
283+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
284+
285+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
286+
authentication(userName: sonatypeUsername, password: sonatypePassword)
287+
}
288+
289+
pom.project {
290+
name "${project.name}"
291+
packaging 'jar'
292+
description 'JVM AOT compiler currently generating JavaScript, C++, Haxe, with initial focus on Kotlin and games.'
293+
url 'https://github.com/jtransc/jtransc/'
294+
inceptionYear '2015'
295+
296+
scm {
297+
url 'scm:[email protected]:jtransc/jtransc.git'
298+
connection 'scm:[email protected]:jtransc/jtransc.git'
299+
developerConnection 'scm:[email protected]:jtransc/jtransc.git'
300+
}
301+
302+
licenses {
303+
license {
304+
name 'The Apache Software License, Version 2.0'
305+
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
306+
distribution 'repo'
307+
}
308+
}
309+
310+
developers {
311+
developer {
312+
id 'soywiz'
313+
name 'Carlos Ballesteros Velasco'
314+
}
315+
}
316+
}
317+
}
318+
}
319+
}
320+
}
321+
}

gradle.properties

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
jtranscVersion=0.6.9-SNAPSHOT
2-
2+
group=com.jtransc
33
file.encoding=UTF-8
44
kotlin.incremental=true
55
org.gradle.daemon=true
66
org.gradle.daemon.idleTimeout=3600000
7-
org.gradle.jvmargs=-Xmx512m -XX:MaxPermSize=128m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
8-
7+
org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=128m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
98
kotlinVersion=1.4.0
10-
kotlin_version=1.4.10
119
bintrayVersion=1.7.3
12-
mavenPluginAnnotationsVersion = 3.4
13-
mavenCoreVersion = 3.3.9
14-
plexusArchiverVersion = 2.1.1
15-
mavenArtifactResolverVersion = 1.0
16-
aetherApiVersion = 1.1.0
17-
aetherUtilVersion = 1.1.0
18-
mavenCompatVersion = 3.0
10+
mavenPluginAnnotationsVersion=3.4
11+
mavenCoreVersion=3.3.9
12+
plexusArchiverVersion=2.1.1
13+
mavenArtifactResolverVersion=1.0
14+
aetherApiVersion=1.1.0
15+
aetherUtilVersion=1.1.0
16+
mavenCompatVersion=3.0

include.gradle

-117
This file was deleted.

0 commit comments

Comments
 (0)