1 Star 0 Fork 1

sister-hua/micrometer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
build.gradle 15.69 KB
一键复制 编辑 原始数据 按行查看 历史
Tommy Ludwig 提交于 2023-11-30 17:59 . Merge branch '1.11.x' into 1.12.x
buildscript {
ext.javaLanguageVersion = JavaLanguageVersion.of(JavaVersion.current().isJava11Compatible() ? JavaVersion.current().getMajorVersion() : 17)
ext.javaTargetVersion = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath libs.plugin.license
classpath libs.plugin.nebulaRelease
classpath libs.plugin.nebulaPublishing
classpath libs.plugin.nebulaProject
classpath libs.plugin.nebulaInfo
classpath libs.plugin.noHttp
classpath libs.plugin.nexusPublish
classpath libs.plugin.javaformat
classpath libs.plugin.japicmp
classpath libs.plugin.downloadTask
classpath libs.plugin.spotless
classpath libs.plugin.bnd
constraints {
classpath(libs.asmForPlugins) {
because 'Supports modern JDKs'
}
}
}
configurations.classpath.resolutionStrategy.cacheDynamicVersionsFor 0, 'minutes'
}
// Hacks because of Antora's clone/checkout/worktrees behavior
// Antora uses shallow-clone and worktrees to check out branches/tags.
if (project.hasProperty('antora')) {
'git fetch --unshallow --all --tags'.execute().text // Antora shallow-clones so there is no history (we need commit history to find the last tag in the tree)
String ref = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
if (ref == 'HEAD') { // if Antora checks out a tag instead of a branch
String tag = 'git tag --points-at HEAD'.execute().text.trim() // jgit is not able to figure out tags in Antora's worktree
if (tag) {
println "Found release tag: $tag, using it as release.version"
ext['release.version'] = tag.substring(1)
}
}
}
// TODO: remove this hack, see: https://github.com/nebula-plugins/nebula-release-plugin/issues/213
def releaseStage = findProperty('release.stage')
apply plugin: 'com.netflix.nebula.release'
release.defaultVersionStrategy = nebula.plugin.release.git.opinion.Strategies.SNAPSHOT
apply plugin: 'io.github.gradle-nexus.publish-plugin'
apply from: 'dependencies.gradle'
allprojects {
group = 'io.micrometer'
ext.'release.stage' = releaseStage ?: 'SNAPSHOT'
afterEvaluate { project -> println "I'm configuring $project.name with version $project.version" }
}
subprojects {
apply plugin: 'signing'
apply plugin: 'io.spring.javaformat'
apply plugin: 'com.diffplug.spotless'
if (project.name != 'micrometer-bom') {
if (project.name.contains('samples') || project.name.contains('benchmarks')) {
apply plugin: 'java'
} else {
apply plugin: 'java-library'
}
apply plugin: 'com.github.hierynomus.license'
apply plugin: 'checkstyle'
apply plugin: 'io.spring.nohttp'
java {
// It is more idiomatic to define different features for different sets of optional
// dependencies, e.g., 'dropwizard' and 'reactor'. If this library published Gradle
// metadata, Gradle users would be able to use these feature names in their dependency
// declarations instead of understanding the actual required optional dependencies.
// But we don't publish Gradle metadata yet and this may be overkill so just have a
// single feature for now to correspond to any optional dependency.
registerFeature('optional') {
usingSourceSet(sourceSets.main)
}
toolchain {
languageVersion = javaLanguageVersion
}
}
// All projects use optional annotations, but since we don't expose them downstream we would
// have to add the dependency in every project, which is tedious so just do it here.
dependencies {
// JSR-305 only used for non-required meta-annotations
optionalApi libs.jsr305
checkstyle libs.spring.javaformatCheckstyle
}
tasks {
compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
sourceCompatibility = javaTargetVersion
targetCompatibility = javaTargetVersion
// ensure Java 8 baseline is enforced for main source
options.release = 8
doLast {
task -> logger.info("Compiling with " + task.javaCompiler.get().executablePath)
}
}
compileTestJava {
options.encoding = 'UTF-8'
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
}
javadoc {
if (project.name.contains('samples')) {
enabled = false
} else {
configure(options) {
tags(
'apiNote:a:API Note:',
'implSpec:a:Implementation Requirements:',
'implNote:a:Implementation Note:'
)
options.addBooleanOption('Xdoclint:all,-missing', true)
}
}
}
}
normalization {
runtimeClasspath {
metaInf {
[
'Bnd-LastModified',
'Build-Date',
'Build-Date-UTC',
'Built-By',
'Built-OS',
'Build-Host',
'Build-Job',
'Build-Number',
'Build-Id',
'Change',
'Full-Change',
'Branch',
'Module-Origin',
'Created-By',
'Build-Java-Version'
].each {
ignoreAttribute it
ignoreProperty it
}
}
}
}
//noinspection GroovyAssignabilityCheck
test {
// set heap size for the test JVM(s)
maxHeapSize = "1500m"
useJUnitPlatform {
excludeTags 'docker'
}
retry {
maxFailures = 5
maxRetries = 3
}
}
task dockerTest(type: Test) {
// set heap size for the test JVM(s)
maxHeapSize = "1500m"
useJUnitPlatform {
includeTags 'docker'
}
}
project.tasks.withType(Test) { Test testTask ->
testTask.testLogging.exceptionFormat = 'full'
}
license {
header rootProject.file('gradle/licenseHeader.txt')
strictCheck true
mapping {
java = 'SLASHSTAR_STYLE'
}
sourceSets = project.sourceSets
ext.year = Calendar.getInstance().get(Calendar.YEAR)
skipExistingHeaders = true
exclude '**/*.json' // comments not supported
}
spotless {
kotlin {
ktlint().editorConfigOverride(['ktlint_standard_no-wildcard-imports': 'disabled'])
}
}
// Publish resolved versions.
plugins.withId('maven-publish') {
publishing {
publications {
nebula(MavenPublication) {
versionMapping {
allVariants {
fromResolutionResult()
}
}
// We publish resolved versions so don't need to publish our dependencyManagement
// too. This is different from many Maven projects, where published artifacts often
// don't include resolved versions and have a parent POM including dependencyManagement.
pom.withXml {
def dependencyManagement = asNode().get('dependencyManagement')
if (dependencyManagement != null) {
asNode().remove(dependencyManagement)
}
}
}
}
}
}
}
plugins.withId('maven-publish') {
publishing {
publications {
nebula(MavenPublication) {
// Nebula converts dynamic versions to static ones so it's ok.
suppressAllPomMetadataWarnings()
}
}
repositories {
maven {
name = 'Snapshot'
url = 'https://repo.spring.io/snapshot'
credentials {
username findProperty('SNAPSHOT_REPO_USER')
password findProperty('SNAPSHOT_REPO_PASSWORD')
}
}
maven {
name = 'Milestone'
url = 'https://repo.spring.io/milestone'
credentials {
username findProperty('MILESTONE_REPO_USER')
password findProperty('MILESTONE_REPO_PASSWORD')
}
}
}
}
signing {
required = System.env.CIRCLE_STAGE == 'deploy'
useInMemoryPgpKeys(findProperty('SIGNING_KEY'), findProperty('SIGNING_PASSWORD'))
sign publishing.publications.nebula
}
// Nebula doesn't interface with Gradle's module format so just disable it for now.
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
}
tasks.register('downloadDependencies') {
outputs.upToDateWhen { false }
doLast {
project.configurations.findAll { it.canBeResolved }*.files
}
}
// Do not publish some modules
if (!['samples', 'benchmarks', 'micrometer-osgi-test'].find { project.name.contains(it) }) {
apply plugin: 'com.netflix.nebula.maven-publish'
apply plugin: 'com.netflix.nebula.maven-manifest'
apply plugin: 'com.netflix.nebula.maven-developer'
apply plugin: 'com.netflix.nebula.javadoc-jar'
apply plugin: 'com.netflix.nebula.source-jar'
apply plugin: 'com.netflix.nebula.maven-apache-license'
apply plugin: 'com.netflix.nebula.publish-verification'
apply plugin: 'com.netflix.nebula.contacts'
apply plugin: 'com.netflix.nebula.info'
apply plugin: 'com.netflix.nebula.project'
if (project.name != 'micrometer-bom') {
apply plugin: 'biz.aQute.bnd.builder'
jar {
manifest.attributes.put('Automatic-Module-Name', project.name.replace('-', '.'))
metaInf {
from "$rootDir/LICENSE"
from "$rootDir/NOTICE"
}
bundle {
// workaround for multi-version JARs
// see https://github.com/bndtools/bnd/issues/2227
bnd '''\
-fixupmessages: '^Classes found in the wrong directory: .*'
-exportcontents: io.micrometer.*
'''.stripIndent()
}
}
task testModules(type: Exec) {
dependsOn jar
String executablePath = javaToolchains.launcherFor { languageVersion = javaLanguageVersion }.get().executablePath
commandLine "$executablePath", '-p', "$jar.archivePath", '--list-modules'
standardOutput = new ByteArrayOutputStream()
ignoreExitValue = true
doLast {
if (executionResult.get().getExitValue() != 0) {
throw new GradleException("Command finished with non-zero exit value ${executionResult.get().getExitValue()}:\n$standardOutput")
}
}
}
check.dependsOn("testModules")
if (!(project.name in ['micrometer-jakarta9'])) { // add projects here that do not exist in the previous minor so should be excluded from japicmp
apply plugin: 'me.champeau.gradle.japicmp'
apply plugin: 'de.undercouch.download'
task downloadBaseline(type: Download) {
onlyIf {
if (project.gradle.startParameter.isOffline()) {
println 'Offline: skipping downloading of baseline and JAPICMP'
return false
} else if (compatibleVersion == 'SKIP') {
println 'SKIP: Instructed to skip the baseline comparison'
return false
} else {
println "Will download and perform baseline comparison with ${compatibleVersion}"
return true
}
}
onlyIfNewer true
compress true
String rootUrl
if (compatibleVersion.contains('-M') || compatibleVersion.contains('-RC')) {
rootUrl = 'https://repo.spring.io/milestone/'
} else if (compatibleVersion.contains('-SNAPSHOT') ) {
rootUrl = 'https://repo.spring.io/snapshot/'
} else {
rootUrl = repositories.mavenCentral().url
}
src "${rootUrl}io/micrometer/${project.name}/${compatibleVersion}/${project.name}-${compatibleVersion}.jar"
dest "${buildDir}/baselineLibs/${project.name}-${compatibleVersion}.jar"
}
task japicmp(type: me.champeau.gradle.japicmp.JapicmpTask) {
oldClasspath.from(files("${buildDir}/baselineLibs/${project.name}-${compatibleVersion}.jar"))
newClasspath.from(files(jar.archiveFile, project(":${project.name}").jar))
onlyBinaryIncompatibleModified = true
failOnModification = true
failOnSourceIncompatibility = true
txtOutputFile = file("${project.buildDir}/reports/japi.txt")
ignoreMissingClasses = true
includeSynthetic = true
compatibilityChangeExcludes = [ "METHOD_NEW_DEFAULT" ]
packageExcludes = ['io.micrometer.shaded.*', 'io.micrometer.statsd.internal']
onlyIf { compatibleVersion != 'SKIP' }
}
tasks.japicmp.dependsOn(downloadBaseline)
tasks.japicmp.dependsOn(jar)
tasks.check.dependsOn(japicmp)
}
}
contacts {
'tludwig@vmware.com' {
moniker 'Tommy Ludwig'
github 'shakuzen'
}
}
}
description = 'Application monitoring instrumentation facade'
repositories {
mavenCentral()
}
def check = tasks.findByName('check')
if (check) project.rootProject.tasks.releaseCheck.dependsOn check
}
nexusPublishing {
repositories {
mavenCentral {
nexusUrl.set(uri('https://s01.oss.sonatype.org/service/local/'))
snapshotRepositoryUrl.set(uri('https://repo.spring.io/snapshot/')) // not used but necessary for the plugin
username = findProperty('MAVEN_CENTRAL_USER')
password = findProperty('MAVEN_CENTRAL_PASSWORD')
}
}
}
wrapper {
gradleVersion = '8.5'
}
defaultTasks 'build'
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/sister-hua/micrometer.git
git@gitee.com:sister-hua/micrometer.git
sister-hua
micrometer
micrometer
main

搜索帮助