Skip to content

Commit 415e340

Browse files
committed
Refactor how the Maven BOM for the SBDG project is created.
1 parent 6ab5740 commit 415e340

File tree

4 files changed

+23
-109
lines changed

4 files changed

+23
-109
lines changed

buildSrc/src/main/groovy/io/spring/gradle/convention/ArtifactoryPlugin.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class ArtifactoryPlugin implements Plugin<Project> {
4646
}
4747
defaults {
4848
publications('mavenJava')
49-
publishConfigs('archives')
5049
}
5150
}
5251
}

buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomPlugin.groovy

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,51 +17,29 @@ package io.spring.gradle.convention
1717

1818
import org.gradle.api.Plugin
1919
import org.gradle.api.Project
20+
import org.gradle.api.plugins.JavaPlatformPlugin
21+
import org.gradle.api.plugins.PluginManager
22+
import org.springframework.gradle.CopyPropertiesPlugin
2023
import org.springframework.gradle.maven.SpringMavenPlugin
2124

2225
/**
26+
* Gradle {@link Plugin} used to generate a Maven BOM for the Gradle {@link Project}.
27+
*
2328
* @author Rob Winch
2429
* @author John Blum
30+
* @see org.gradle.api.Plugin
31+
* @see org.gradle.api.Project
2532
*/
2633
class MavenBomPlugin implements Plugin<Project> {
2734

28-
static String MAVEN_BOM_TASK_NAME = "mavenBom"
29-
3035
@Override
3136
void apply(Project project) {
3237

33-
// Declares a new configuration that will be used to associate with Project artifacts
34-
// (namely, the Maven BOM file).
35-
project.configurations {
36-
archives
37-
}
38-
39-
project.group = project.rootProject.group
40-
project.plugins.apply(SpringMavenPlugin)
41-
42-
Utils.skipProjectWithSonarQubePlugin(project)
43-
44-
project.task(MAVEN_BOM_TASK_NAME, type: MavenBomTask, group: 'Generate',
45-
description: 'Configures the Maven POM as a Maven BOM (Bill of Materials)')
46-
47-
project.tasks.artifactoryPublish.dependsOn project.mavenBom
48-
project.tasks.publishToMavenLocal.dependsOn project.mavenBom
49-
project.tasks.publishToOssrh.dependsOn project.mavenBom
38+
PluginManager pluginManager = project.getPluginManager();
5039

51-
project.rootProject.allprojects.each { p ->
52-
p.plugins.withType(SpringMavenPlugin) {
53-
if (!project.name.equals(p.name)) {
54-
//println("Maven BOM Project [${p.name}]")
55-
project.mavenBom.projects.add(p)
56-
}
57-
}
58-
}
40+
pluginManager.apply(JavaPlatformPlugin)
41+
pluginManager.apply(SpringMavenPlugin)
42+
pluginManager.apply(CopyPropertiesPlugin)
5943

60-
// TODO: Shouldn't this be { archives project.mavenBom } according to:
61-
// https://docs.gradle.org/current/javadoc/org/gradle/api/Project.html#getArtifacts--
62-
// TODO: Is this even necessary since this block is defined in MavenBomTask?
63-
project.artifacts {
64-
archives project.mavenBom.bomFile
65-
}
6644
}
6745
}

buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomTask.groovy

Lines changed: 0 additions & 75 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
1+
import io.spring.gradle.convention.SpringModulePlugin
2+
13
apply plugin: 'io.spring.convention.maven-bom'
4+
5+
dependencies {
6+
constraints {
7+
project.rootProject.allprojects { p ->
8+
p.plugins.withType(SpringModulePlugin) {
9+
api p
10+
}
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)