Skip to content

Commit

Permalink
Skip SCM and IssueManagement POM configuration for non OSS builds
Browse files Browse the repository at this point in the history
  • Loading branch information
philwebb committed Sep 30, 2024
1 parent ab96849 commit 89ce26b
Showing 1 changed file with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
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
Expand All @@ -56,6 +61,8 @@
*/
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);
Expand Down Expand Up @@ -93,9 +100,7 @@ private void customizePom(MavenPom pom, Project project) {
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) {
Expand Down Expand Up @@ -130,16 +135,26 @@ private void customizeDevelopers(MavenPomDeveloperSpec developers) {
}

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://[email protected]/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) {
Expand Down

0 comments on commit 89ce26b

Please sign in to comment.