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

Commit ccc319d

Browse files
committed
Use custom gradle to cross-compile
1 parent 8d309c9 commit ccc319d

File tree

3 files changed

+87
-23
lines changed

3 files changed

+87
-23
lines changed

build.gradle

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,31 @@ apply plugin: "com.github.maiflai.scalatest"
66
apply plugin: 'signing'
77
apply plugin: 'maven'
88
apply plugin: 'org.scoverage'
9-
apply plugin: 'net.researchgate.release'
109
apply plugin: 'io.codearte.nexus-staging'
1110
apply plugin: 'org.owasp.dependencycheck'
12-
apply plugin: "com.adtran.scala-multiversion-plugin"
1311
apply plugin: 'com.github.ben-manes.versions'
1412

1513
repositories {
1614
mavenCentral()
1715
}
1816

19-
ext {
20-
reactorVersion = "3.1.3.RELEASE"
21-
scoverageVersion = "1.3.0"
22-
mockitoVersion = "2.13.0"
23-
}
24-
2517
dependencies {
26-
// scala dependencies
27-
compile "org.scala-lang:scala-library:%scala-version%"
28-
// reactor dependencies
29-
compile group: 'io.projectreactor', name: 'reactor-core', version: "$reactorVersion"
30-
// jsr305
31-
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
18+
compile libraries.scalaLibrary
19+
compile libraries.reactorCore
20+
compile libraries.findbugs
3221

3322
// test dependencies
34-
testCompile "org.scalatest:scalatest_%%:3.0.3"
35-
testRuntime "org.pegdown:pegdown:1.6.0"
36-
testCompile group: 'io.projectreactor', name: 'reactor-test', version: "$reactorVersion"
37-
testCompile "org.mockito:mockito-inline:$mockitoVersion"
38-
testCompile "com.typesafe.scala-logging:scala-logging_%%:3.7.2"
23+
testCompile libraries.scalatest
24+
testRuntime libraries.pegdown
25+
testCompile libraries.reactorTest
26+
testCompile libraries.mockitoInline
27+
testCompile libraries.scalaLogging
3928

40-
scoverage "org.scoverage:scalac-scoverage-plugin_%%:$scoverageVersion", "org.scoverage:scalac-scoverage-runtime_%%:$scoverageVersion"
29+
scoverage libraries.scoveragePlugin, libraries.scoverageRuntime
4130
}
4231

4332
buildscript {
33+
apply from: file('versions.gradle')
4434
repositories {
4535
maven {
4636
url "https://plugins.gradle.org/m2/"
@@ -61,7 +51,45 @@ buildscript {
6151
}
6252

6353
dependencyCheck {
64-
skipConfigurations=["apiElements", "implementation", "runtimeElements", "runtimeOnly", "testImplementation", "testRuntimeOnly", "scoverageImplementation", "scoverageRuntimeOnly"]
54+
skipConfigurations = ["apiElements", "implementation", "runtimeElements", "runtimeOnly", "testImplementation", "testRuntimeOnly", "scoverageImplementation", "scoverageRuntimeOnly"]
55+
}
56+
57+
if (!project.parent) {
58+
apply plugin: 'net.researchgate.release'
59+
final svs = ['2.12.4', '2.11.8']
60+
61+
for (sv in svs) {
62+
String scalaVersionInDot = sv.replaceAll("_", ".")
63+
64+
tasks.create(name: "build_$sv", type: GradleBuild) {
65+
buildFile = './build.gradle'
66+
tasks = ['build']
67+
startParameter.projectProperties = [scalaVersion: "${scalaVersionInDot}"]
68+
}
69+
70+
tasks.create(name: "uploadArchives_${sv}", type: GradleBuild) {
71+
buildFile = './build.gradle'
72+
tasks = ['uploadArchives']
73+
startParameter.projectProperties = [scalaVersion: "${scalaVersionInDot}"]
74+
}
75+
}
76+
77+
tasks.create(name: "buildAll", dependsOn: svs.collect{"build_${it}"}) {}
78+
79+
tasks.create(name: "uploadArchivesAll", dependsOn: svs.collect{"uploadArchives_${it}"}) {}
80+
81+
project.task("releaseAll", description: 'Verify project, release and update version to next.', group: "Release", type: GradleBuild) {
82+
startParameter = project.getGradle().startParameter.newInstance()
83+
tasks = [
84+
'createScmAdapter', 'checkCommitNeeded', 'checkUpdateNeeded', 'unSnapshotVersion',
85+
'confirmReleaseVersion', 'checkSnapshotDependencies', 'buildAll',
86+
'preTagCommit', 'createReleaseTag', 'updateVersion', 'commitNewVersion'
87+
]
88+
}
89+
90+
project.createReleaseTag.dependsOn {
91+
project.uploadArchivesAll
92+
}
6593
}
6694

6795
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
@@ -140,7 +168,7 @@ ScalaCompileOptions.metaClass.fork = true
140168
ScalaCompileOptions.metaClass.useAnt = false
141169
ScalaCompileOptions.metaClass.useCompileDaemon = false
142170

143-
project.tasks.scaladoc.scalaDocOptions.additionalParameters=["-no-link-warnings"]
171+
project.tasks.scaladoc.scalaDocOptions.additionalParameters = ["-no-link-warnings"]
144172

145173
release {
146174
git {

gradle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
version=0.3.5-SNAPSHOT
2-
scalaVersions=2.12.4,2.11.11

versions.gradle

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
ext.defaultScala_2_11_Version = '2.11.12'
2+
ext.defaultScala_2_12_Version = '2.12.4'
3+
4+
if (!hasProperty('scalaVersion')) {
5+
ext.scalaVersion = ext.defaultScala_2_12_Version
6+
}
7+
8+
if (scalaVersion.startsWith('2.11')) {
9+
ext.baseScalaVersion = '2.11'
10+
} else if (scalaVersion.startsWith('2.12')) {
11+
ext.baseScalaVersion = '2.12'
12+
} else {
13+
ext.baseScalaVersion = scalaVersion
14+
}
15+
16+
ext {
17+
findBugsVersion = "3.0.2"
18+
mockitoVersion = "2.13.0"
19+
pegdownVersion = "1.6.0"
20+
reactorVersion = "3.1.3.RELEASE"
21+
scalaLoggingVersion = "3.7.2"
22+
scalatestVersion = "3.0.3"
23+
scoverageVersion = "1.3.0"
24+
}
25+
26+
ext.libraries = [
27+
findbugs : "com.google.code.findbugs:jsr305:$findBugsVersion",
28+
mockitoInline : "org.mockito:mockito-inline:$mockitoVersion",
29+
pegdown : "org.pegdown:pegdown:$pegdownVersion",
30+
reactorCore : "io.projectreactor:reactor-core:$reactorVersion",
31+
reactorTest : "io.projectreactor:reactor-test:$reactorVersion",
32+
scalaLibrary : "org.scala-lang:scala-library:$scalaVersion",
33+
scalaLogging : "com.typesafe.scala-logging:scala-logging_$baseScalaVersion:$scalaLoggingVersion",
34+
scalatest : "org.scalatest:scalatest_$baseScalaVersion:$scalatestVersion",
35+
scoveragePlugin : "org.scoverage:scalac-scoverage-plugin_$baseScalaVersion:$scoverageVersion",
36+
scoverageRuntime : "org.scoverage:scalac-scoverage-runtime_$baseScalaVersion:$scoverageVersion"
37+
]

0 commit comments

Comments
 (0)