Rework spring-boot-docs to be a full-blown java project
Previously, spring-boot-docs used the java-base-plugin and then added configuration on top. This has proven to be error prone, with the most recent problem being that the tests were not being compiled and run. This commit changes approach and applies the java plugin to the project instead of the java-base plugin. Now, rather than adding the necessary configuration to the base, the unwanted pieces of the java plugin's configuration – specifically the jar and javadoc tasks – are disabled instead. The DeployedPlugin has also been updated so that it does not create a publication from the java component for projects that have a disabled jar task. Closes gh-22284
This commit is contained in:
parent
c765df6e5d
commit
b24f17b35c
|
|
@ -23,6 +23,7 @@ import org.gradle.api.plugins.JavaPlugin;
|
||||||
import org.gradle.api.publish.PublishingExtension;
|
import org.gradle.api.publish.PublishingExtension;
|
||||||
import org.gradle.api.publish.maven.MavenPublication;
|
import org.gradle.api.publish.maven.MavenPublication;
|
||||||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
|
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
|
||||||
|
import org.gradle.api.tasks.bundling.Jar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A plugin applied to a project that should be deployed.
|
* A plugin applied to a project that should be deployed.
|
||||||
|
|
@ -42,9 +43,14 @@ public class DeployedPlugin implements Plugin<Project> {
|
||||||
project.getPlugins().apply(MavenRepositoryPlugin.class);
|
project.getPlugins().apply(MavenRepositoryPlugin.class);
|
||||||
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
|
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
|
||||||
MavenPublication mavenPublication = publishing.getPublications().create("maven", MavenPublication.class);
|
MavenPublication mavenPublication = publishing.getPublications().create("maven", MavenPublication.class);
|
||||||
project.getPlugins().withType(JavaPlugin.class)
|
project.afterEvaluate((evaluated) -> {
|
||||||
.all((javaPlugin) -> project.getComponents().matching((component) -> component.getName().equals("java"))
|
project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> {
|
||||||
.all((javaComponent) -> mavenPublication.from(javaComponent)));
|
if (((Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME)).isEnabled()) {
|
||||||
|
project.getComponents().matching((component) -> component.getName().equals("java"))
|
||||||
|
.all((javaComponent) -> mavenPublication.from(javaComponent));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
project.getPlugins().withType(JavaPlatformPlugin.class)
|
project.getPlugins().withType(JavaPlatformPlugin.class)
|
||||||
.all((javaPlugin) -> project.getComponents()
|
.all((javaPlugin) -> project.getComponents()
|
||||||
.matching((component) -> component.getName().equals("javaPlatform"))
|
.matching((component) -> component.getName().equals("javaPlatform"))
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
plugins {
|
plugins {
|
||||||
id "java-base"
|
id "java"
|
||||||
id "org.asciidoctor.jvm.convert"
|
id "org.asciidoctor.jvm.convert"
|
||||||
id "org.asciidoctor.jvm.pdf"
|
id "org.asciidoctor.jvm.pdf"
|
||||||
id "org.springframework.boot.conventions"
|
id "org.springframework.boot.conventions"
|
||||||
|
|
@ -29,8 +29,12 @@ repositories {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
jar {
|
||||||
main
|
enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
javadoc {
|
||||||
|
enabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins.withType(EclipsePlugin) {
|
plugins.withType(EclipsePlugin) {
|
||||||
|
|
@ -87,6 +91,15 @@ dependencies {
|
||||||
|
|
||||||
mavenPluginDocumentation(project(path: ":spring-boot-project:spring-boot-tools:spring-boot-maven-plugin", configuration: "documentation"))
|
mavenPluginDocumentation(project(path: ":spring-boot-project:spring-boot-tools:spring-boot-maven-plugin", configuration: "documentation"))
|
||||||
|
|
||||||
|
testImplementation(project(":spring-boot-project:spring-boot-actuator-autoconfigure"))
|
||||||
|
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
|
||||||
|
testImplementation("org.assertj:assertj-core")
|
||||||
|
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||||
|
|
||||||
|
testRuntimeOnly(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web"))
|
||||||
|
testRuntimeOnly("com.h2database:h2")
|
||||||
|
testRuntimeOnly("org.springframework:spring-jdbc")
|
||||||
|
|
||||||
testSlices(project(path: ":spring-boot-project:spring-boot-test-autoconfigure", configuration: "testSliceMetadata"))
|
testSlices(project(path: ":spring-boot-project:spring-boot-test-autoconfigure", configuration: "testSliceMetadata"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,7 +107,7 @@ task dependencyVersions(type: org.springframework.boot.build.constraints.Extract
|
||||||
enforcedPlatform(":spring-boot-project:spring-boot-dependencies")
|
enforcedPlatform(":spring-boot-project:spring-boot-dependencies")
|
||||||
}
|
}
|
||||||
|
|
||||||
task javadoc(type: Javadoc) {
|
task aggregatedJavadoc(type: Javadoc) {
|
||||||
dependsOn dependencyVersions
|
dependsOn dependencyVersions
|
||||||
project.rootProject.gradle.projectsEvaluated {
|
project.rootProject.gradle.projectsEvaluated {
|
||||||
Set<String> excludedProjects = ['spring-boot-antlib', 'spring-boot-configuration-metadata', 'spring-boot-configuration-processor',
|
Set<String> excludedProjects = ['spring-boot-antlib', 'spring-boot-configuration-metadata', 'spring-boot-configuration-processor',
|
||||||
|
|
@ -288,7 +301,7 @@ task zip(type: Zip) {
|
||||||
from(asciidoctorMultipage.outputDir) {
|
from(asciidoctorMultipage.outputDir) {
|
||||||
into "reference/html"
|
into "reference/html"
|
||||||
}
|
}
|
||||||
from(javadoc) {
|
from(aggregatedJavadoc) {
|
||||||
into "api"
|
into "api"
|
||||||
}
|
}
|
||||||
into("gradle-plugin") {
|
into("gradle-plugin") {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue