• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1buildscript {
2    repositories {
3        mavenLocal() //for local testing of mockito-release-tools
4        google()
5        maven { url 'https://plugins.gradle.org/m2/' }
6    }
7
8    dependencies {
9        classpath 'gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:0.16.1'
10        classpath 'net.ltgt.gradle:gradle-errorprone-plugin:2.0.2'
11
12        classpath "io.github.gradle-nexus:publish-plugin:1.1.0"
13        classpath 'org.shipkit:shipkit-changelog:1.1.15'
14        classpath 'org.shipkit:shipkit-auto-version:1.1.19'
15
16        classpath 'com.google.googlejavaformat:google-java-format:1.13.0'
17        classpath 'com.android.tools.build:gradle:4.2.0'
18        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
19    }
20}
21
22plugins {
23    id 'com.diffplug.spotless' version '6.2.0'
24    id 'eclipse'
25    id 'com.github.ben-manes.versions' version '0.41.0'
26    id 'biz.aQute.bnd.builder' version '6.1.0'
27    id 'ru.vyarus.animalsniffer' version '1.5.2'
28}
29
30description = 'Mockito mock objects library core API and implementation'
31
32apply plugin: 'base'
33archivesBaseName = 'mockito-core'
34
35apply from: 'gradle/shipkit.gradle'
36
37apply from: 'gradle/root/ide.gradle'
38apply from: 'gradle/root/gradle-fix.gradle'
39apply from: 'gradle/java-library.gradle'
40apply from: 'gradle/license.gradle'
41apply from: 'gradle/root/coverage.gradle'
42
43apply from: 'gradle/mockito-core/inline-mock.gradle'
44apply from: 'gradle/mockito-core/osgi.gradle'
45apply from: 'gradle/mockito-core/javadoc.gradle'
46apply from: 'gradle/mockito-core/testing.gradle'
47
48apply from: 'gradle/dependencies.gradle'
49
50allprojects { proj ->
51    repositories {
52        mavenCentral()
53        google()
54    }
55    plugins.withId('java') {
56        proj.apply from: "$rootDir/gradle/errorprone.gradle"
57    }
58    tasks.withType(JavaCompile) {
59        //I don't believe those warnings add value given modern IDEs
60        options.warnings = false
61        options.encoding = 'UTF-8'
62    }
63    tasks.withType(Javadoc) {
64        options.addStringOption('Xdoclint:none', '-quiet')
65        options.addStringOption('encoding', 'UTF-8')
66        options.addStringOption('charSet', 'UTF-8')
67        options.setSource('8')
68    }
69
70    tasks.withType(AbstractArchiveTask) {
71        preserveFileTimestamps = false
72        reproducibleFileOrder = true
73    }
74
75    apply plugin: 'checkstyle'
76    checkstyle {
77       configFile = rootProject.file('config/checkstyle/checkstyle.xml')
78    }
79}
80
81configurations {
82    testUtil //TODO move to separate project
83}
84
85dependencies {
86    api libraries.bytebuddy, libraries.bytebuddyagent
87
88    compileOnly libraries.junit4, libraries.hamcrest, libraries.opentest4j
89    implementation libraries.objenesis
90
91    testImplementation libraries.assertj
92
93    //putting 'provided' dependencies on test compile and runtime classpath
94    testCompileOnly configurations.compileOnly
95    testRuntimeOnly configurations.compileOnly
96
97    testUtil sourceSets.test.output
98
99    signature 'org.codehaus.mojo.signature:java18:1.0@signature'
100    signature 'net.sf.androidscents.signature:android-api-level-24:7.0_r2@signature'
101}
102
103animalsniffer {
104    sourceSets = [sourceSets.main]
105    annotation = 'org.mockito.internal.SuppressSignatureCheck'
106}
107
108spotless {
109    // We run the check separately on CI, so don't run this by default
110    enforceCheck = false
111
112    java {
113        licenseHeaderFile rootProject.file('config/spotless/spotless.header')
114
115        custom 'google-java-format', { source ->
116            com.google.googlejavaformat.java.JavaFormatterOptions options = new com.google.googlejavaformat.java.JavaFormatterOptions.Builder()
117                    .style(com.google.googlejavaformat.java.JavaFormatterOptions.Style.AOSP)
118                    .formatJavadoc(false)
119                    .build()
120            com.google.googlejavaformat.java.Formatter formatter = new com.google.googlejavaformat.java.Formatter(options)
121            return formatter.formatSource(source)
122        }
123
124        // This test contains emulation of same-line stubbings. The formatter would put them on a separate line.
125        targetExclude 'src/test/java/org/mockitousage/internal/junit/UnusedStubbingsFinderTest.java'
126    }
127}
128
129
130//workaround for #1444, delete when Shipkit bug is fixed
131subprojects {
132	eclipse {
133		project {
134			name = rootProject.name + '-' + project.name
135		}
136	}
137
138    afterEvaluate {
139        def lib = publishing.publications.javaLibrary
140        if(lib && !lib.artifactId.startsWith("mockito-")) {
141            lib.artifactId = "mockito-" + lib.artifactId
142        }
143    }
144}
145//end workaround
146