|
31 | 31 | import org.gradle.api.publish.maven.MavenPomScm;
|
32 | 32 | import org.gradle.api.publish.maven.MavenPublication;
|
33 | 33 | import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
|
| 34 | +import org.slf4j.Logger; |
| 35 | +import org.slf4j.LoggerFactory; |
| 36 | + |
| 37 | +import org.springframework.boot.build.properties.BuildProperties; |
| 38 | +import org.springframework.boot.build.properties.BuildType; |
34 | 39 |
|
35 | 40 | /**
|
36 | 41 | * Conventions that are applied in the presence of the {@link MavenPublishPlugin}. When
|
|
56 | 61 | */
|
57 | 62 | class MavenPublishingConventions {
|
58 | 63 |
|
| 64 | + private static final Logger logger = LoggerFactory.getLogger(MavenPublishingConventions.class); |
| 65 | + |
59 | 66 | void apply(Project project) {
|
60 | 67 | project.getPlugins().withType(MavenPublishPlugin.class).all((mavenPublish) -> {
|
61 | 68 | PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
|
@@ -93,9 +100,7 @@ private void customizePom(MavenPom pom, Project project) {
|
93 | 100 | pom.licenses(this::customizeLicences);
|
94 | 101 | pom.developers(this::customizeDevelopers);
|
95 | 102 | pom.scm((scm) -> customizeScm(scm, project));
|
96 |
| - if (!isUserInherited(project)) { |
97 |
| - pom.issueManagement(this::customizeIssueManagement); |
98 |
| - } |
| 103 | + pom.issueManagement((issueManagement) -> customizeIssueManagement(issueManagement, project)); |
99 | 104 | }
|
100 | 105 |
|
101 | 106 | private void customizeJavaMavenPublication(MavenPublication publication, Project project) {
|
@@ -130,16 +135,26 @@ private void customizeDevelopers(MavenPomDeveloperSpec developers) {
|
130 | 135 | }
|
131 | 136 |
|
132 | 137 | private void customizeScm(MavenPomScm scm, Project project) {
|
| 138 | + if (BuildProperties.get(project).buildType() != BuildType.OPEN_SOURCE) { |
| 139 | + logger.debug("Skipping Maven POM SCM for non open source build type"); |
| 140 | + return; |
| 141 | + } |
| 142 | + scm.getUrl().set("https://github.com/spring-projects/spring-boot"); |
133 | 143 | if (!isUserInherited(project)) {
|
134 | 144 | scm.getConnection().set("scm:git:git://github.com/spring-projects/spring-boot.git");
|
135 | 145 | scm. getDeveloperConnection(). set( "scm:git:ssh://[email protected]/spring-projects/spring-boot.git");
|
136 | 146 | }
|
137 |
| - scm.getUrl().set("https://github.com/spring-projects/spring-boot"); |
138 | 147 | }
|
139 | 148 |
|
140 |
| - private void customizeIssueManagement(MavenPomIssueManagement issueManagement) { |
141 |
| - issueManagement.getSystem().set("GitHub"); |
142 |
| - issueManagement.getUrl().set("https://github.com/spring-projects/spring-boot/issues"); |
| 149 | + private void customizeIssueManagement(MavenPomIssueManagement issueManagement, Project project) { |
| 150 | + if (BuildProperties.get(project).buildType() != BuildType.OPEN_SOURCE) { |
| 151 | + logger.debug("Skipping Maven POM SCM for non open source build type"); |
| 152 | + return; |
| 153 | + } |
| 154 | + if (!isUserInherited(project)) { |
| 155 | + issueManagement.getSystem().set("GitHub"); |
| 156 | + issueManagement.getUrl().set("https://github.com/spring-projects/spring-boot/issues"); |
| 157 | + } |
143 | 158 | }
|
144 | 159 |
|
145 | 160 | private boolean isUserInherited(Project project) {
|
|
0 commit comments