196 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			Groovy
		
	
	
	
			
		
		
	
	
			196 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			Groovy
		
	
	
	
plugins {
 | 
						|
	id "java-gradle-plugin"
 | 
						|
	id "maven-publish"
 | 
						|
	id "org.antora"
 | 
						|
	id "org.springframework.boot.conventions"
 | 
						|
	id "org.springframework.boot.maven-repository"
 | 
						|
	id "org.springframework.boot.optional-dependencies"
 | 
						|
}
 | 
						|
 | 
						|
description = "Spring Boot Gradle Plugins"
 | 
						|
 | 
						|
configurations {
 | 
						|
	antoraContent
 | 
						|
	"testCompileClasspath" {
 | 
						|
		// Downgrade SLF4J is required for tests to run in Eclipse
 | 
						|
		resolutionStrategy.force("org.slf4j:slf4j-api:1.7.36")
 | 
						|
	}
 | 
						|
	modernGradleRuntimeClasspath {
 | 
						|
		extendsFrom runtimeClasspath
 | 
						|
		canBeConsumed = false
 | 
						|
		canBeResolved = true
 | 
						|
	}
 | 
						|
	modernGradleRuntimeElements {
 | 
						|
		extendsFrom configurations.implementation, configurations.runtimeOnly
 | 
						|
		canBeConsumed = true
 | 
						|
		canBeResolved = false
 | 
						|
		attributes {
 | 
						|
			attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category, Category.LIBRARY))
 | 
						|
			attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling, Bundling.EXTERNAL))
 | 
						|
			attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
 | 
						|
			attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
 | 
						|
			attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage, Usage.JAVA_RUNTIME))
 | 
						|
			attribute(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, project.objects.named(GradlePluginApiVersion, "8.7"))
 | 
						|
		}
 | 
						|
		outgoing.artifacts.addAll(configurations.runtimeElements.outgoing.artifacts)
 | 
						|
	}
 | 
						|
	runtimeElements {
 | 
						|
		attributes {
 | 
						|
			attribute(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, project.objects.named(GradlePluginApiVersion, "7.5"))
 | 
						|
		}
 | 
						|
	}
 | 
						|
	all { configuration ->
 | 
						|
		if (configuration.name == 'modernGradleRuntimeClasspath') {
 | 
						|
			return
 | 
						|
		}
 | 
						|
		resolutionStrategy {
 | 
						|
			eachDependency { dependency ->
 | 
						|
				// Downgrade Jackson as Gradle cannot cope with 2.15.0's multi-version
 | 
						|
				// jar files with bytecode in META-INF/versions/19
 | 
						|
				if (dependency.requested.group.startsWith("com.fasterxml.jackson")) {
 | 
						|
					dependency.useVersion("2.14.2")
 | 
						|
				}
 | 
						|
				// Downgrade Spring Framework as Gradle cannot cope with 6.1.0-M1's
 | 
						|
				// multi-version jar files with bytecode in META-INF/versions/21
 | 
						|
				if (dependency.requested.group.equals("org.springframework")) {
 | 
						|
					dependency.useVersion("$springFramework60xVersion")
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
components.java.addVariantsFromConfiguration(configurations.modernGradleRuntimeElements) {
 | 
						|
	mapToMavenScope("runtime")
 | 
						|
}
 | 
						|
 | 
						|
dependencies {
 | 
						|
	implementation(project(":spring-boot-project:spring-boot-tools:spring-boot-buildpack-platform"))
 | 
						|
	implementation(project(":spring-boot-project:spring-boot-tools:spring-boot-loader-tools"))
 | 
						|
	implementation("io.spring.gradle:dependency-management-plugin")
 | 
						|
	implementation("org.apache.commons:commons-compress")
 | 
						|
	implementation("org.springframework:spring-core")
 | 
						|
 | 
						|
	optional("org.graalvm.buildtools:native-gradle-plugin")
 | 
						|
	optional("org.cyclonedx:cyclonedx-gradle-plugin") {
 | 
						|
		exclude(group: "org.apache.maven", module: "maven-core")
 | 
						|
	}
 | 
						|
	optional("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") {
 | 
						|
		exclude(group: "commons-logging", module: "commons-logging")
 | 
						|
	}
 | 
						|
 | 
						|
	testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
 | 
						|
	testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-gradle-test-support"))
 | 
						|
	testImplementation("com.tngtech.archunit:archunit-junit5:0.22.0")
 | 
						|
	testImplementation("org.assertj:assertj-core")
 | 
						|
	testImplementation("org.junit.jupiter:junit-jupiter")
 | 
						|
	testImplementation("org.mockito:mockito-core")
 | 
						|
	testImplementation("org.testcontainers:junit-jupiter")
 | 
						|
	testImplementation("org.testcontainers:testcontainers")
 | 
						|
}
 | 
						|
 | 
						|
repositories {
 | 
						|
	gradlePluginPortal() {
 | 
						|
		content {
 | 
						|
			includeGroup("org.cyclonedx")
 | 
						|
		}
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
gradlePlugin {
 | 
						|
	plugins {
 | 
						|
		springBootPlugin {
 | 
						|
			id = "org.springframework.boot"
 | 
						|
			displayName = "Spring Boot Gradle Plugin"
 | 
						|
			description = "Spring Boot Gradle Plugin"
 | 
						|
			implementationClass = "org.springframework.boot.gradle.plugin.SpringBootPlugin"
 | 
						|
		}
 | 
						|
		springBootAotPlugin {
 | 
						|
			id = "org.springframework.boot.aot"
 | 
						|
			displayName = "Spring Boot AOT Gradle Plugin"
 | 
						|
			description = "Spring Boot AOT Gradle Plugin"
 | 
						|
			implementationClass = "org.springframework.boot.gradle.plugin.SpringBootAotPlugin"
 | 
						|
		}
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
task preparePluginValidationClasses(type: Copy) {
 | 
						|
	destinationDir = layout.buildDirectory.dir("classes/java/pluginValidation").get().asFile
 | 
						|
	from(sourceSets.main.output.classesDirs) {
 | 
						|
		exclude "**/CreateBootStartScripts.class"
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
validatePlugins {
 | 
						|
	classes.setFrom preparePluginValidationClasses
 | 
						|
	enableStricterValidation = true
 | 
						|
}
 | 
						|
 | 
						|
tasks.named('test') {
 | 
						|
	inputs.dir('src/docs/antora/modules/gradle-plugin/examples').withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName('buildScripts')
 | 
						|
}
 | 
						|
 | 
						|
javadoc {
 | 
						|
	options {
 | 
						|
		author = true
 | 
						|
		docTitle = "Spring Boot Gradle Plugin ${project.version} API"
 | 
						|
		encoding = "UTF-8"
 | 
						|
		memberLevel = "protected"
 | 
						|
		outputLevel = "quiet"
 | 
						|
		splitIndex = true
 | 
						|
		use = true
 | 
						|
		windowTitle = "Spring Boot Gradle Plugin ${project.version} API"
 | 
						|
		links "https://docs.gradle.org/$gradle.gradleVersion/javadoc/"
 | 
						|
		links "https://docs.oracle.com/en/java/javase/17/docs/api/"
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
def antoraGradlePluginLocalAggregateContent  = tasks.register("antoraGradlePluginLocalAggregateContent", Zip) {
 | 
						|
	destinationDirectory = layout.buildDirectory.dir('generated/docs/antora-content')
 | 
						|
	archiveClassifier = "gradle-plugin-local-aggregate-content"
 | 
						|
	from(tasks.getByName("generateAntoraYml")) {
 | 
						|
		into "modules"
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
def antoraGradlePluginCatalogContent = tasks.register("antoraGradlePluginCatalogContent", Zip) {
 | 
						|
	destinationDirectory = layout.buildDirectory.dir('generated/docs/antora-content')
 | 
						|
	archiveClassifier = "gradle-plugin-catalog-content"
 | 
						|
	from(javadoc) {
 | 
						|
		into "api/java"
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
tasks.named("generateAntoraPlaybook") {
 | 
						|
	xrefStubs = ["appendix:.*", "api:.*", "reference:.*"]
 | 
						|
	alwaysInclude = [name: "gradle-plugin", classifier: "local-aggregate-content"]
 | 
						|
	dependsOn antoraGradlePluginLocalAggregateContent
 | 
						|
}
 | 
						|
 | 
						|
tasks.named("antora") {
 | 
						|
	inputs.files(antoraGradlePluginLocalAggregateContent, antoraGradlePluginCatalogContent)
 | 
						|
}
 | 
						|
 | 
						|
artifacts {
 | 
						|
	antoraContent antoraGradlePluginCatalogContent
 | 
						|
}
 | 
						|
 | 
						|
toolchain {
 | 
						|
	maximumCompatibleJavaVersion = JavaLanguageVersion.of(20)
 | 
						|
}
 | 
						|
 | 
						|
publishing {
 | 
						|
	publications.matching { it.name == 'pluginMaven' }.configureEach {
 | 
						|
		versionMapping {
 | 
						|
			allVariants {
 | 
						|
				fromResolutionOf(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)
 | 
						|
			}
 | 
						|
		}
 | 
						|
		versionMapping {
 | 
						|
			variant(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, project.objects.named(GradlePluginApiVersion, "8.7")) {
 | 
						|
				fromResolutionOf("modernGradleRuntimeClasspath")
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
}
 |