Skip to content

Commit

Permalink
Upgrade to Gradle 6
Browse files Browse the repository at this point in the history
This included a couple of breaking changes:
- The build plugin is now part of the Gradle Enterprise plugin
- The osgi plugin was removed, for which we have to use the bndtools
plugin instead
- Kotlin version has to be updated, including their coroutine
library versions

Gradle 6 is required for us to build on Java 14.

Supersedes and closes #1923
  • Loading branch information
TimvdLippe committed Jun 15, 2020
1 parent b0e814b commit 60952f8
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 69 deletions.
8 changes: 1 addition & 7 deletions build.gradle
Expand Up @@ -15,10 +15,10 @@ buildscript {
}

plugins {
id 'com.gradle.build-scan' version '2.2.1'
id "com.diffplug.gradle.spotless" version "3.24.3"
id 'eclipse'
id 'com.github.ben-manes.versions' version '0.28.0'
id 'biz.aQute.bnd.builder' version '5.1.0'
}

description = 'Mockito mock objects library core API and implementation'
Expand Down Expand Up @@ -104,12 +104,6 @@ wrapper {
distributionSha256Sum = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
}

//Posting Build scans to https://scans.gradle.com
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}

spotless {
java {
licenseHeaderFile rootProject.file('config/spotless/spotless.header')
Expand Down
9 changes: 2 additions & 7 deletions gradle/dependencies.gradle
Expand Up @@ -34,15 +34,10 @@ libraries.osgi = 'org.osgi:osgi.core:7.0.0'
libraries.equinox = 'org.eclipse.platform:org.eclipse.osgi:3.15.0'
libraries.bndGradle = 'biz.aQute.bnd:biz.aQute.bnd.gradle:4.3.1'

def kotlinVersion = '1.2.10'
def kotlinVersion_1_3 = '1.3.0-rc-57'
def kotlinVersion = '1.3.72'
libraries.kotlin = [
version: kotlinVersion,
version_1_3: kotlinVersion_1_3,

stdlib: "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}",
coroutines: 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.19.3',

stdlib_1_3: "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion_1_3",
releaseCoroutines: "org.jetbrains.kotlinx:kotlinx-coroutines-core:0.26.1-eap13"
coroutines: 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7',
]
69 changes: 28 additions & 41 deletions gradle/mockito-core/osgi.gradle
Expand Up @@ -7,49 +7,36 @@ import java.util.jar.Manifest

import static java.util.Calendar.FEBRUARY

apply plugin: 'osgi'

afterEvaluate {
tasks.matching { it.name == 'jar' }.all { jar ->
jar.manifest {
classpath = project.configurations.runtime

instruction '-versionpolicy', '[${version;==;${@}},${version;+;${@}})'

name = 'Mockito Mock Library for Java. Core bundle requires Byte Buddy and Objenesis.'
symbolicName = 'org.mockito.mockito-core'
version = project.version.replace('-', '.')

instruction 'Export-Package',
'!org.mockito.internal.*',
"org.mockito.*;version=${version}"

instruction 'Import-Package',
'net.bytebuddy.*;version="[1.6.0,2.0)"',
'junit.*;resolution:=optional',
'org.junit.*;resolution:=optional',
'org.hamcrest;resolution:=optional',
'org.objenesis;version="[2.5,3.0)"',
'org.opentest4j.*;resolution:=optional',
'org.mockito.*'

instruction 'Private-Package',
'org.mockito.*'

instruction '-removeheaders', 'Private-Package'

attributes 'Automatic-Module-Name': 'org.mockito'
}

jar.doLast {
JarFile originalJar = new JarFile(jar.archivePath)
apply plugin: 'biz.aQute.bnd.builder'

jar {
classpath = project.configurations.runtime
bnd(
'Bundle-Name': 'Mockito Mock Library for Java. Core bundle requires Byte Buddy and Objenesis.',
'Bundle-SymbolicName': 'org.mockito.mockito-core',
'Bundl-version': project.version.replace('-', '.'),
'-versionpolicy': '[${version;==;${@}},${version;+;${@}})',
'Export-Package': "!org.mockito.internal.*,org.mockito.*;version=${version}",
'Import-Package': [
'net.bytebuddy.*;version="[1.6.0,2.0)"',
'junit.*;resolution:=optional',
'org.junit.*;resolution:=optional',
'org.hamcrest;resolution:=optional',
'org.objenesis;version="[2.5,3.0)"',
'org.opentest4j.*;resolution:=optional',
'org.mockito.*'
].join(','),
'-removeheaders': 'Private-Package',
'Automatic-Module-Name': 'org.mockito'
)
}

new RemoveOsgiLastModifiedHeader(originalJar)
.transform()
.renameTo jar.archivePath
}
jar.doLast {
JarFile originalJar = new JarFile(jar.archivePath)

}
new RemoveOsgiLastModifiedHeader(originalJar)
.transform()
.renameTo jar.archivePath
}


Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-bin.zip
distributionSha256Sum=e58cdff0cee6d9b422dcd08ebeb3177bc44eaa09bd9a2e838ff74c408fe1cbcd
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 17 additions & 1 deletion gradlew
@@ -1,5 +1,21 @@
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
##
## Gradle start up script for UN*X
Expand Down Expand Up @@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down
18 changes: 17 additions & 1 deletion gradlew.bat
@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
Expand All @@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down
13 changes: 13 additions & 0 deletions settings.gradle.kts
Expand Up @@ -34,6 +34,19 @@ rootProject.children.forEach { project ->
}
}

plugins {
id("com.gradle.enterprise").version("3.3.4")
//id("biz.aQute.bnd.builder").version("5.1.0")
}

//Posting Build scans to https://scans.gradle.com
gradleEnterprise {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
}
}

buildCache {
local {
isEnabled = !System.getenv().containsKey("CI")
Expand Down
Expand Up @@ -4,7 +4,7 @@ buildscript {
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${libraries.kotlin.version_1_3}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${libraries.kotlin.version}"
}
}

Expand All @@ -21,6 +21,6 @@ dependencies {
testCompile project(":")
testCompile libraries.junit4

testCompile libraries.kotlin.stdlib_1_3
testCompile libraries.kotlin.releaseCoroutines
testCompile libraries.kotlin.stdlib
testCompile libraries.kotlin.coroutines
}
8 changes: 1 addition & 7 deletions subprojects/kotlinTest/kotlinTest.gradle
@@ -1,17 +1,11 @@
plugins {
// Can not use libraries.kotlin.version here per https://stackoverflow.com/questions/37555196/in-gradle-how-to-use-a-variable-for-a-plugin-version
id 'org.jetbrains.kotlin.jvm' version '1.2.31'
id 'org.jetbrains.kotlin.jvm' version '1.3.72'
id 'java'
}

description = "Kotlin tests for Mockito."

kotlin {
experimental {
coroutines "enable"
}
}

apply from: "$rootDir/gradle/dependencies.gradle"

dependencies {
Expand Down
Expand Up @@ -4,7 +4,7 @@
*/
package org.mockito.kotlin

import kotlinx.coroutines.experimental.runBlocking
import kotlinx.coroutines.runBlocking
import org.hamcrest.core.IsEqual
import org.junit.Assert.assertThat
import org.junit.Test
Expand Down

0 comments on commit 60952f8

Please sign in to comment.