Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gradle 6 #1948

Merged
merged 8 commits into from Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion .travis.yml
Expand Up @@ -34,6 +34,9 @@ matrix:
env: SKIP_RELEASE=true
- jdk: openjdk11
env: SKIP_RELEASE=true MOCK_MAKER=mock-maker-inline
- jdk: openjdk8
script: ./check_reproducibility.sh
Comment on lines +37 to +38
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- jdk: openjdk8
script: ./check_reproducibility.sh
- name: "Check reproducibility"
jdk: openjdk8
script: ./check_reproducibility.sh

Taking a look in Travis right now, it looks like "just" another Jdk 8 build and this would allow people to identify this particular job at a glance if it starts failing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to do this in a follow-up, as we can do some more cleanup of the Travis tasks. Thanks for the suggestion 😄

after_success: true

branches:
#Don't build tags
Expand All @@ -50,7 +53,7 @@ script:
# We are using && below on purpose
# ciPerformRelease must run only when the entire build has completed
# This guarantees that no release steps are executed when the build or tests fail
- ./gradlew spotlessCheck && ./gradlew build idea -s && ./gradlew checkReproducibility && ./gradlew ciPerformRelease
- ./gradlew spotlessCheck && ./gradlew build idea -s && ./gradlew ciPerformRelease

after_success:
#Generates coverage report:
Expand Down
9 changes: 1 addition & 8 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 All @@ -43,7 +43,6 @@ apply from: 'gradle/root/coverage.gradle'
apply from: 'gradle/mockito-core/inline-mock.gradle'
apply from: 'gradle/mockito-core/osgi.gradle'
apply from: 'gradle/mockito-core/javadoc.gradle'
apply from: 'gradle/mockito-core/reproducible-build.gradle'
apply from: 'gradle/mockito-core/testing.gradle'

apply from: 'gradle/dependencies.gradle'
Expand Down Expand Up @@ -104,12 +103,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
26 changes: 26 additions & 0 deletions check_reproducibility.sh
@@ -0,0 +1,26 @@
#!/bin/bash -e

# This script is taken from https://github.com/junit-team/junit5/pull/2217

rm -rf checksums/
mkdir checksums/

export SOURCE_DATE_EPOCH=$(date +%s)

function calculate_checksums() {
OUTPUT=checksums/$1

./gradlew --no-build-cache clean assemble --parallel

find ./build -name '*.jar' \
| grep '/build/libs/' \
| grep --invert-match 'javadoc' \
| sort \
| xargs sha256sum > ${OUTPUT}
}


calculate_checksums checksums-1.txt
calculate_checksums checksums-2.txt

diff checksums/checksums-1.txt checksums/checksums-2.txt
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
69 changes: 0 additions & 69 deletions gradle/mockito-core/reproducible-build.gradle

This file was deleted.

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
12 changes: 12 additions & 0 deletions settings.gradle.kts
Expand Up @@ -34,6 +34,18 @@ rootProject.children.forEach { project ->
}
}

plugins {
id("com.gradle.enterprise").version("3.3.4")
}

//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