-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Move to Gradle conventions plugins #3464
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e9488e6
Bump to Gradle 8.10.2
bric3 0d43cfd
GHA Gradle actions was deprecated
bric3 f575639
Move animal sniffer to a convention plugin
bric3 145aea1
Extract an empty OSGI convention
bric3 9492a64
Extract most of java-library.gradle to java-library-conventions.gradl…
bric3 9d1387e
Replace test-launcher.gradle by mockito-test-conventions plugin in an…
bric3 a9c31f5
Configure test task config only for java projects
bric3 d74c32b
Use test-logger plugin to simplify logging config
bric3 9d94699
Port retry-test to a convention plugin
bric3 065cc74
Port java-publication to mockito.publication-conventions.gradle.kts
bric3 5f06c53
Complete the replacement of java-test.gradle and test-launcher.gradle
bric3 bd76b11
Move most of root gradle subprojects to convention plugins
bric3 e3f37f4
Unify javadoc as Mockito Javadoc plugin
bric3 1a8ca0d
Remove root/ide.gradle
bric3 0e9433c
Move mockito-core specific config script to mockito-core
bric3 f4b5258
Tweak project naming validation
bric3 4888857
Fix some issues in the publication conventions
bric3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
plugins { | ||
// doc: https://docs.gradle.org/current/userguide/kotlin_dsl.html | ||
`kotlin-dsl` | ||
} | ||
|
||
dependencies { | ||
implementation(libs.gradleplugin.testLogger) | ||
implementation(libs.gradleplugin.animalSniffer) | ||
implementation(libs.gradleplugin.bnd) | ||
implementation(libs.gradleplugin.errorprone) | ||
|
||
// https://github.com/gradle/gradle/issues/15383 | ||
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
dependencyResolutionManagement { | ||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import org.gradle.accessors.dm.LibrariesForLibs | ||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.SourceSetContainer | ||
import org.gradle.kotlin.dsl.the | ||
|
||
val Project.libs | ||
get() = the<LibrariesForLibs>() | ||
|
||
val Project.sourceSets | ||
get() = the<SourceSetContainer>() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import org.gradle.api.provider.Property | ||
|
||
interface MockitoJavadocExtension { | ||
val title: Property<String> | ||
val docTitle: Property<String> | ||
} |
19 changes: 19 additions & 0 deletions
19
buildSrc/src/main/kotlin/mockito.checkstyle-conventions.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import org.gradle.api.plugins.quality.Checkstyle | ||
import org.gradle.kotlin.dsl.checkstyle | ||
import org.gradle.kotlin.dsl.withType | ||
|
||
plugins { | ||
checkstyle | ||
} | ||
|
||
checkstyle { | ||
configFile = rootProject.file("config/checkstyle/checkstyle.xml") | ||
} | ||
|
||
tasks.withType<Checkstyle>().configureEach { | ||
reports { | ||
xml.required.set(false) | ||
html.required.set(true) | ||
html.stylesheet = resources.text.fromFile("$rootDir/config/checkstyle/checkstyle.xsl") | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
buildSrc/src/main/kotlin/mockito.java-backward-compatibility-checks-conventions.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import ru.vyarus.gradle.plugin.animalsniffer.AnimalSnifferExtension | ||
|
||
plugins { | ||
java // for sourceSets | ||
id("ru.vyarus.animalsniffer") | ||
} | ||
|
||
|
||
val main: SourceSet by sourceSets.getting | ||
configure<AnimalSnifferExtension> { | ||
sourceSets = listOf(main) | ||
annotation = "org.mockito.internal.SuppressSignatureCheck" | ||
|
||
// See please https://github.com/mojohaus/animal-sniffer/issues/172 | ||
ignore( | ||
"java.lang.instrument.Instrumentation", | ||
"java.lang.invoke.MethodHandle", | ||
"java.lang.invoke.MethodHandles\$Lookup", | ||
"java.lang.StackWalker", | ||
"java.lang.StackWalker\$StackFrame", | ||
"java.lang.StackWalker\$Option", | ||
) | ||
} | ||
|
||
dependencies { | ||
// Equivalent to "net.sf.androidscents.signature:android-api-level-26:8.0.0_r2@signature" | ||
signature(variantOf(libs.animalSniffer.android.apiLevel26) { artifactType("signature") }) | ||
signature(variantOf(libs.animalSniffer.java) { artifactType("signature") }) | ||
} | ||
|
34 changes: 34 additions & 0 deletions
34
buildSrc/src/main/kotlin/mockito.java-conventions.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import org.gradle.api.plugins.JavaPlugin | ||
import org.gradle.api.plugins.JavaPluginExtension | ||
|
||
// only apply to Java projects | ||
// i.e., do nothing when applied to Android projects | ||
plugins.withType(JavaPlugin::class) { | ||
val javaReleaseVersion = 11 | ||
|
||
configure<JavaPluginExtension> { | ||
sourceCompatibility = JavaVersion.toVersion(javaReleaseVersion) | ||
targetCompatibility = JavaVersion.toVersion(javaReleaseVersion) | ||
} | ||
|
||
tasks { | ||
withType<JavaCompile>().configureEach { | ||
// I don't believe those warnings add value given modern IDEs | ||
options.isWarnings = false | ||
options.encoding = "UTF-8" | ||
} | ||
|
||
withType<Javadoc>().configureEach { | ||
options { | ||
encoding = "UTF-8" | ||
source = javaReleaseVersion.toString() | ||
|
||
if (this is StandardJavadocDocletOptions) { | ||
addStringOption("Xdoclint:none", "-quiet") | ||
addStringOption("charSet", "UTF-8") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
36 changes: 36 additions & 0 deletions
36
buildSrc/src/main/kotlin/mockito.java-library-conventions.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
plugins { | ||
`java-library` | ||
id("mockito.java-conventions") | ||
id("mockito.test-conventions") | ||
id("mockito.test-retry-conventions") | ||
id("mockito.test-launcher-conventions") | ||
id("net.ltgt.errorprone") | ||
} | ||
|
||
if (!project.name.startsWith("mockito-")) { | ||
throw GradleException("Published project module should be prefixed with `mockito-` : ${project.projectDir})") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
google() | ||
} | ||
|
||
dependencies { | ||
errorprone(libs.errorprone) | ||
} | ||
|
||
tasks { | ||
withType<AbstractArchiveTask>().configureEach { | ||
isPreserveFileTimestamps = false | ||
isReproducibleFileOrder = true | ||
// dirMode = Integer.parseInt("0755", 8) | ||
dirPermissions { | ||
unix("rwxr-xr-x") // 0755 | ||
} | ||
// fileMode = Integer.parseInt("0644", 8) | ||
filePermissions { | ||
unix("rw-r--r--") // 0644 | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
buildSrc/src/main/kotlin/mockito.javadoc-conventions.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import org.gradle.api.tasks.javadoc.Javadoc | ||
|
||
plugins { | ||
java | ||
} | ||
|
||
val mockitoJavadocExtension = project.extensions.create<MockitoJavadocExtension>("mockitoJavadoc").apply { | ||
title.convention(project.name) | ||
docTitle.convention("<h1>${project.name}</h1>") | ||
} | ||
|
||
val javadocConfigDir = "$rootDir/config/javadoc" | ||
|
||
tasks.named<Javadoc>("javadoc") { | ||
inputs.dir(javadocConfigDir) | ||
description = "Creates javadoc html for ${project.name}." | ||
|
||
// For more details on the format | ||
// see https://docs.oracle.com/en/java/javase/21/javadoc/javadoc.html | ||
|
||
source = project.sourceSets["main"].allJava | ||
|
||
options { | ||
title = mockitoJavadocExtension.title.get() | ||
destinationDirectory = project.layout.buildDirectory.dir("javadoc").get().asFile | ||
encoding = "UTF-8" | ||
|
||
if (this is StandardJavadocDocletOptions) { | ||
addBooleanOption("-allow-script-in-comments", true) | ||
addFileOption("-add-stylesheet", file("$javadocConfigDir/resources/mockito-theme.css")) | ||
addStringOption("Xwerror", "-quiet") | ||
charSet = "UTF-8" | ||
docEncoding = "UTF-8" | ||
docTitle = mockitoJavadocExtension.docTitle.get() | ||
|
||
bottom( | ||
""" | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/obsidian.min.css"> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script> | ||
<script>hljs.highlightAll();</script> | ||
""".trimIndent().replace("\r|\n|[ ]{8}".toRegex(), "") | ||
) | ||
|
||
group("Main package", "org.mockito") | ||
links("https://junit.org/junit4/javadoc/${project.libs.versions.junit4.get()}/") | ||
linksOffline( | ||
"https://docs.oracle.com/en/java/javase/11/docs/api/", | ||
"$javadocConfigDir/jdk-package-list" | ||
) | ||
|
||
isSplitIndex = true | ||
isUse = true | ||
windowTitle = mockitoJavadocExtension.title.get() | ||
|
||
addBooleanOption("html5", true) | ||
} | ||
memberLevel = JavadocMemberLevel.PROTECTED | ||
outputLevel = JavadocOutputLevel.QUIET | ||
|
||
doLast { | ||
copy { | ||
from("$javadocConfigDir/resources") | ||
into(project.layout.buildDirectory.dir("javadoc")) | ||
} | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
buildSrc/src/main/kotlin/mockito.library-conventions.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
plugins { | ||
base | ||
id("mockito.java-library-conventions") | ||
id("mockito.osgi-conventions") | ||
id("mockito.publication-conventions") | ||
id("mockito.checkstyle-conventions") | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
plugins { | ||
id("biz.aQute.bnd.builder") | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.