Skip SCM and IssueManagement POM configuration for non OSS builds

See gh-42333
This commit is contained in:
Phillip Webb
2024-09-30 11:30:56 -07:00
parent ab968494e6
commit 89ce26bf26

View File

@@ -31,6 +31,11 @@ import org.gradle.api.publish.maven.MavenPomOrganization;
import org.gradle.api.publish.maven.MavenPomScm;
import org.gradle.api.publish.maven.MavenPublication;
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.build.properties.BuildProperties;
import org.springframework.boot.build.properties.BuildType;
/**
* Conventions that are applied in the presence of the {@link MavenPublishPlugin}. When
@@ -56,6 +61,8 @@ import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
*/
class MavenPublishingConventions {
private static final Logger logger = LoggerFactory.getLogger(MavenPublishingConventions.class);
void apply(Project project) {
project.getPlugins().withType(MavenPublishPlugin.class).all((mavenPublish) -> {
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
@@ -93,9 +100,7 @@ class MavenPublishingConventions {
pom.licenses(this::customizeLicences);
pom.developers(this::customizeDevelopers);
pom.scm((scm) -> customizeScm(scm, project));
if (!isUserInherited(project)) {
pom.issueManagement(this::customizeIssueManagement);
}
pom.issueManagement((issueManagement) -> customizeIssueManagement(issueManagement, project));
}
private void customizeJavaMavenPublication(MavenPublication publication, Project project) {
@@ -130,16 +135,26 @@ class MavenPublishingConventions {
}
private void customizeScm(MavenPomScm scm, Project project) {
if (BuildProperties.get(project).buildType() != BuildType.OPEN_SOURCE) {
logger.debug("Skipping Maven POM SCM for non open source build type");
return;
}
scm.getUrl().set("https://github.com/spring-projects/spring-boot");
if (!isUserInherited(project)) {
scm.getConnection().set("scm:git:git://github.com/spring-projects/spring-boot.git");
scm.getDeveloperConnection().set("scm:git:ssh://git@github.com/spring-projects/spring-boot.git");
}
scm.getUrl().set("https://github.com/spring-projects/spring-boot");
}
private void customizeIssueManagement(MavenPomIssueManagement issueManagement) {
issueManagement.getSystem().set("GitHub");
issueManagement.getUrl().set("https://github.com/spring-projects/spring-boot/issues");
private void customizeIssueManagement(MavenPomIssueManagement issueManagement, Project project) {
if (BuildProperties.get(project).buildType() != BuildType.OPEN_SOURCE) {
logger.debug("Skipping Maven POM SCM for non open source build type");
return;
}
if (!isUserInherited(project)) {
issueManagement.getSystem().set("GitHub");
issueManagement.getUrl().set("https://github.com/spring-projects/spring-boot/issues");
}
}
private boolean isUserInherited(Project project) {